Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/assets/vue/views/page/Show.vue

123 lines
2.9 KiB

4 years ago
<template>
<div v-if="item">
<p
class="text-body-1 font-semibold"
v-text="item.title"
/>
<div class="flex flex-row gap-4">
<div class="w-2/3 flex justify-center">
<div class="w-4/5">
<div v-html="item.content" />
</div>
</div>
4 years ago
<div class="w-1/3">
<dl class="grid grid-cols-2">
<dt
v-t="'Author'"
class="font-semibold"
/>
<dl v-text="item.creator.username" />
<dt
v-t="'Locale'"
class="font-semibold"
/>
<dl v-text="item.locale" />
<dt
v-t="'Enabled'"
class="font-semibold"
/>
<dl v-t="item.enabled ? 'Yes' : 'No'" />
<dt
v-t="'Category'"
class="font-semibold"
/>
<dl v-text="item.category.title" />
4 years ago
<dt
v-t="'Created at'"
class="font-semibold"
/>
<dl v-text="item.createdAt ? relativeDatetime(item.createdAt) : ''" />
<dt
v-t="'Updated at'"
class="font-semibold"
/>
<dl v-text="item.updatedAt ? relativeDatetime(item.updatedAt) : ''" />
</dl>
</div>
</div>
4 years ago
</div>
<Loading :visible="isLoading" />
4 years ago
</template>
<script setup>
import Loading from "../../components/Loading.vue"
import { useFormatDate } from "../../composables/formatDate"
import { useConfirm } from "primevue/useconfirm"
import { useRoute, useRouter } from "vue-router"
import { inject, ref, watch } from "vue"
import { useSecurityStore } from "../../store/securityStore"
import { storeToRefs } from "pinia"
import pageService from "../../services/page"
import { useNotification } from "../../composables/notification"
4 years ago
const { relativeDatetime } = useFormatDate()
const securityStore = useSecurityStore()
const { isAdmin } = storeToRefs(securityStore)
const route = useRoute()
const router = useRouter()
const confirm = useConfirm()
const notification = useNotification()
const isLoading = ref(true)
const item = ref()
const layoutMenuItems = inject("layoutMenuItems")
watch(item, () => {
if (!isAdmin.value) {
return
}
layoutMenuItems.value = [
{
label: "Edit page",
to: {
name: "PageUpdate",
query: { id: item.value["@id"] },
},
},
{
label: "Delete page",
command() {
confirm.require({
header: "Confirmation",
message: "Are you sure you want to delete it?",
async accept() {
await pageService.del(item.value)
await router.push({ name: "PageList" })
},
})
},
},
]
})
pageService
.find(route.query.id)
.then((response) => response.json())
.then((json) => (item.value = json))
.catch((e) => notification.showErrorNotification(e))
.finally(() => (isLoading.value = false))
</script>