199 lines
4.5 KiB
TypeScript
Executable File
199 lines
4.5 KiB
TypeScript
Executable File
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 { CTitleBanner } from '@/components/CTitleBanner'
|
|
import { CMyEditElem } from '@/components/CMyEditElem'
|
|
import { CMyPageElem2 } from '@/components/CMyPageElem2'
|
|
|
|
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'
|
|
import objectId from '@src/js/objectId'
|
|
import { useRouter } from 'vue-router'
|
|
|
|
export default defineComponent({
|
|
name: 'CMyPageElem',
|
|
components: {
|
|
LandingFooter, CImgTitle, CTitle, CMyElem,
|
|
CMyEditElem, CMyPageElem2, CTitleBanner,
|
|
},
|
|
props: {
|
|
title: String,
|
|
mypath: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
myidPage: {
|
|
type: String,
|
|
required: false,
|
|
default: ''
|
|
},
|
|
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 myidPage = toRef(props, 'idPage')
|
|
|
|
const $q = useQuasar()
|
|
|
|
const { t } = useI18n()
|
|
const globalStore = useGlobalStore()
|
|
const $router = useRouter()
|
|
|
|
const mywidthEditor = ref(400)
|
|
|
|
const editOn = computed({
|
|
get(): boolean {
|
|
return !!globalStore.editOn ? globalStore.editOn : false
|
|
},
|
|
|
|
set(value: boolean) {
|
|
return tools.updateEditOn(value)
|
|
}
|
|
})
|
|
const visuEditor = ref(false)
|
|
const addOn = ref(false)
|
|
const myelemVoid = ref({ _id: objectId(), active: true, type: shared_consts.ELEMTYPE.TEXT, container: '...', path: mypathin.value } as IMyElem)
|
|
|
|
|
|
const selElem = ref(globalStore.selElem)
|
|
const site = ref(globalStore.site)
|
|
|
|
const onloading = ref(false)
|
|
|
|
const myelems = computed(() => {
|
|
if (myidPage.value)
|
|
return globalStore.getMyElemsByIdPage(myidPage.value)
|
|
else if (mypathin.value)
|
|
return globalStore.getMyElems(mypathin.value)
|
|
else
|
|
return null
|
|
})
|
|
|
|
async function load() {
|
|
// console.log('load', mypathin.value)
|
|
|
|
if (mypathin.value !== '') {
|
|
await globalStore.loadPage('/' + mypathin.value, 'cmypageelem').then(ris => {
|
|
rec.value = ris
|
|
// console.log('LoadPage', ris)
|
|
})
|
|
}
|
|
|
|
if (mypathin.value === 'home_logout' && globalStore.site.name === 'local' && !rec.value) {
|
|
$router.replace('/install_site')
|
|
}
|
|
|
|
if (tools.isManager()) {
|
|
// console.log('getcookie: ', editOn.value, mypathin.value)
|
|
}
|
|
}
|
|
|
|
watch(() => props.mypath, (to: string, from: string) => {
|
|
// console.log('... load', mypathin.value, props.mypath)
|
|
selElem.value = {}
|
|
load()
|
|
})
|
|
|
|
watch(
|
|
() => editOn.value,
|
|
() => {
|
|
if (!editOn.value) {
|
|
selElem.value = {}
|
|
}
|
|
})
|
|
|
|
async function mounted() {
|
|
await load()
|
|
}
|
|
|
|
function saveElem(myelem: IMyElem) {
|
|
//
|
|
}
|
|
|
|
function changeVisuDrawer(path: string, edit: boolean) {
|
|
globalStore.changeVisuDrawer(path, edit)
|
|
}
|
|
|
|
function toggleSize() {
|
|
mywidthEditor.value = mywidthEditor.value === 400 ? 1050 : 400
|
|
}
|
|
|
|
function deleteElem() {
|
|
selElem.value = {}
|
|
visuEditor.value = false
|
|
}
|
|
function selElemClick(myelem: IMyElem) {
|
|
// console.log('mypageelem selElemClick', myelem)
|
|
|
|
selElem.value = {}
|
|
selElem.value = myelem
|
|
visuEditor.value = !!myelem
|
|
|
|
}
|
|
|
|
async function duplicatePage() {
|
|
await globalStore.duplicatePage(mypathin.value, $q, t)
|
|
}
|
|
|
|
|
|
onMounted(mounted)
|
|
|
|
return {
|
|
rec, myelems,
|
|
mypathin,
|
|
editOn,
|
|
visuEditor,
|
|
addOn,
|
|
tools,
|
|
shared_consts,
|
|
myelemVoid,
|
|
selElemClick,
|
|
selElem,
|
|
saveElem,
|
|
changeVisuDrawer,
|
|
mywidthEditor,
|
|
toggleSize,
|
|
onloading,
|
|
deleteElem,
|
|
duplicatePage,
|
|
}
|
|
},
|
|
|
|
})
|