parent
c10ef97e85
commit
792982606d
@ -1,54 +1,44 @@ |
|||||||
<template> |
<template> |
||||||
<q-card |
<BaseCard plain> |
||||||
v-if="page" |
<template #header> |
||||||
elevation="4" |
<div class="-mb-2 flex items-center justify-between gap-2 bg-gray-15 px-4 py-2"> |
||||||
> |
<h6 v-text="page.title" /> |
||||||
<q-card-section> |
<BaseButton |
||||||
<div class="text-h6"> |
v-if="isAdmin" |
||||||
{{ page.title }} |
icon="edit" |
||||||
|
label="Edit" |
||||||
|
type="black" |
||||||
|
@click="handleClick(page)" |
||||||
|
/> |
||||||
</div> |
</div> |
||||||
</q-card-section> |
</template> |
||||||
|
|
||||||
<q-card-section> |
<div v-html="page.content" /> |
||||||
<p v-html="page.content" /> |
</BaseCard> |
||||||
</q-card-section> |
|
||||||
|
|
||||||
<q-card-actions v-if="isAdmin"> |
|
||||||
<q-btn |
|
||||||
v-close-popup |
|
||||||
flat |
|
||||||
label="Edit" |
|
||||||
color="primary" |
|
||||||
@click="handleClick(page)" |
|
||||||
/> |
|
||||||
</q-card-actions> |
|
||||||
</q-card> |
|
||||||
</template> |
</template> |
||||||
|
|
||||||
<script> |
<script setup> |
||||||
|
import { useRouter } from "vue-router" |
||||||
|
import { useSecurityStore } from "../../store/securityStore" |
||||||
|
import { storeToRefs } from "pinia" |
||||||
|
import BaseCard from "../basecomponents/BaseCard.vue" |
||||||
|
import BaseButton from "../basecomponents/BaseButton.vue" |
||||||
|
|
||||||
import {mapGetters} from "vuex"; |
const router = useRouter() |
||||||
import {useRouter} from "vue-router"; |
const securityStore = useSecurityStore() |
||||||
import {reactive, toRefs} from "vue"; |
const { isAdmin } = storeToRefs(securityStore) |
||||||
|
|
||||||
export default { |
defineProps({ |
||||||
name: 'PageCard', |
page: { |
||||||
props: { |
type: Object, |
||||||
page: Object, |
required: true, |
||||||
}, |
|
||||||
setup() { |
|
||||||
const router = useRouter(); |
|
||||||
const state = reactive({ |
|
||||||
handleClick: function (page) { |
|
||||||
router.push({name: 'PageUpdate', query: {id: page['@id']}}); |
|
||||||
}, |
|
||||||
}); |
|
||||||
return toRefs(state); |
|
||||||
}, |
}, |
||||||
computed: { |
}) |
||||||
...mapGetters({ |
|
||||||
'isAdmin': 'security/isAdmin', |
const handleClick = (page) => { |
||||||
}), |
router.push({ |
||||||
} |
name: "PageUpdate", |
||||||
}; |
query: { id: page["@id"] }, |
||||||
|
}) |
||||||
|
} |
||||||
</script> |
</script> |
||||||
@ -1,23 +1,34 @@ |
|||||||
<template> |
<template> |
||||||
<div |
<div |
||||||
v-for="page in pages" |
v-if="pages.length" |
||||||
:key="page.id" |
class="grid gap-4 grid-cols-1 lg:grid-cols-2 xl:grid-cols-2" |
||||||
> |
> |
||||||
<PageCard |
<PageCard |
||||||
|
v-for="page in pages" |
||||||
|
:key="page.id" |
||||||
:page="page" |
:page="page" |
||||||
/> |
/> |
||||||
</div> |
</div> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script setup> |
<script setup> |
||||||
import PageCard from './PageCard.vue'; |
import PageCard from "./PageCard.vue" |
||||||
|
import pageService from "../../services/page" |
||||||
|
import { useI18n } from "vue-i18n" |
||||||
|
import { ref } from "vue" |
||||||
|
|
||||||
defineProps({ |
const { locale } = useI18n() |
||||||
pages: { |
|
||||||
type: Array, |
const pages = ref([]) |
||||||
default () { |
|
||||||
return []; |
pageService |
||||||
} |
.findAll({ |
||||||
}, |
params : { |
||||||
}); |
"category.title": "home", |
||||||
|
enabled: "1", |
||||||
|
locale: locale.value, |
||||||
|
}, |
||||||
|
}) |
||||||
|
.then(response => response.json()) |
||||||
|
.then(json => pages.value = json["hydra:member"]) |
||||||
</script> |
</script> |
||||||
Loading…
Reference in new issue