Webpage Editor functionality
This commit is contained in:
0
src/components/CMyPageElem/CMyPageElem.scss
Executable file
0
src/components/CMyPageElem/CMyPageElem.scss
Executable file
98
src/components/CMyPageElem/CMyPageElem.ts
Executable file
98
src/components/CMyPageElem/CMyPageElem.ts
Executable file
@@ -0,0 +1,98 @@
|
||||
import {
|
||||
computed,
|
||||
defineComponent, onMounted, ref, toRef, watch,
|
||||
} from 'vue'
|
||||
|
||||
import { IMyElem, IMyPage } from '@src/model'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { LandingFooter } from '@/components/LandingFooter'
|
||||
import { CMyElem } from '@/components/CMyElem'
|
||||
|
||||
import { CImgTitle } from '../CImgTitle/index'
|
||||
import { CTitle } from '../CTitle/index'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useI18n } from '@/boot/i18n'
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyPageElem',
|
||||
components: { LandingFooter, CImgTitle, CTitle, CMyElem },
|
||||
props: {
|
||||
title: String,
|
||||
mypath: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
imgbackground: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
sizes: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
styleadd: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
nofooter: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
const rec = ref<IMyPage | null>(null)
|
||||
const mypathin = toRef(props, 'mypath')
|
||||
|
||||
const $q = useQuasar()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const editOn = ref(false)
|
||||
const addOn = ref(false)
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
const myelems = computed(() => {
|
||||
if (mypathin.value)
|
||||
return globalStore.getMyElems(mypathin.value)
|
||||
else
|
||||
return null
|
||||
})
|
||||
|
||||
|
||||
const load = async (): Promise<void> => {
|
||||
// console.log('load', mypathin.value)
|
||||
if (mypathin.value !== '') rec.value = await globalStore.loadPage('/' + mypathin.value)
|
||||
}
|
||||
|
||||
watch(() => props.mypath, async (to: string, from: string) => {
|
||||
console.log('... load', mypathin.value, props.mypath)
|
||||
await load()
|
||||
})
|
||||
|
||||
|
||||
onMounted(load)
|
||||
|
||||
return {
|
||||
rec, myelems,
|
||||
mypathin,
|
||||
editOn,
|
||||
addOn,
|
||||
tools,
|
||||
shared_consts,
|
||||
}
|
||||
},
|
||||
|
||||
})
|
||||
75
src/components/CMyPageElem/CMyPageElem.vue
Executable file
75
src/components/CMyPageElem/CMyPageElem.vue
Executable file
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="mypathin && !!rec">
|
||||
<q-toolbar>
|
||||
<q-toggle v-if="tools.isManager()"
|
||||
v-model="editOn"
|
||||
icon="fas fa-pencil-alt"
|
||||
>
|
||||
|
||||
</q-toggle>
|
||||
<q-toggle v-if="tools.isManager()"
|
||||
v-model="addOn"
|
||||
icon="fas fa-plus"
|
||||
>
|
||||
|
||||
</q-toggle>
|
||||
|
||||
|
||||
</q-toolbar>
|
||||
|
||||
<div class="q-ma-sm q-gutter-sm q-pa-xs">
|
||||
<div v-if="!!rec.img1" class="text-center">
|
||||
<q-img :src="``+ rec.img1" class="img"></q-img>
|
||||
</div>
|
||||
|
||||
<div v-if="!!rec.content" v-html="rec.content"></div>
|
||||
<q-video v-if="!!rec.video1" :src="rec.video1" :ratio="rec.ratio1">
|
||||
</q-video>
|
||||
|
||||
<div v-if="!!rec.img2" class="text-center">
|
||||
<q-img :src="``+ rec.img2" class="img"></q-img>
|
||||
</div>
|
||||
|
||||
<div v-if="!!rec.content2" v-html="rec.content2"></div>
|
||||
<q-video v-if="!!rec.video2" :src="rec.video2" :ratio="rec.ratio2"></q-video>
|
||||
|
||||
<div v-if="!!rec.img3" class="text-center">
|
||||
<q-img :src="``+ rec.img2" class="img"></q-img>
|
||||
</div>
|
||||
|
||||
<div v-if="!!rec.content3" v-html="rec.content3"></div>
|
||||
<q-video v-if="!!rec.video3" :src="rec.video3" :ratio="rec.ratio3"></q-video>
|
||||
<div v-if="!!rec.content4" v-html="rec.content4"></div>
|
||||
|
||||
<span v-for="(myelem, ind) in myelems" :key="ind">
|
||||
<CMyElem v-if="myelem.active" :myelem="myelem" :editOn="editOn" :addOn="addOn">
|
||||
|
||||
</CMyElem>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
|
||||
<div v-if="!!title">
|
||||
<CTitle
|
||||
v-if="imgbackground" :imgbackground="imgbackground"
|
||||
:headtitle="title" :sizes="sizes" :styleadd="styleadd"></CTitle>
|
||||
<div v-if="!imgbackground">
|
||||
<CImgTitle v-if="img" :src="img" :title="title">
|
||||
</CImgTitle>
|
||||
</div>
|
||||
<slot></slot>
|
||||
<div v-if="!nofooter">
|
||||
<LandingFooter></LandingFooter>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./CMyPageElem.ts">
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './CMyPageElem.scss';
|
||||
</style>
|
||||
1
src/components/CMyPageElem/index.ts
Executable file
1
src/components/CMyPageElem/index.ts
Executable file
@@ -0,0 +1 @@
|
||||
export { default as CMyPageElem } from './CMyPageElem.vue'
|
||||
Reference in New Issue
Block a user