Animations in the WebEditor

This commit is contained in:
Surya Paolo
2022-11-20 10:21:02 +01:00
parent a56ee80fbb
commit 358bdd5d1e
21 changed files with 704 additions and 88 deletions

View File

@@ -19,6 +19,7 @@ import { CEventsCalendar } from '@src/components/CEventsCalendar'
import { CMyEditor } from '@src/components/CMyEditor'
import { CMyFieldRec } from '@src/components/CMyFieldRec'
import { CSelectImage } from '@src/components/CSelectImage'
import { CSelectAnimation } from '@src/components/CSelectAnimation'
import { CSelectColor } from '@src/components/CSelectColor'
import { CSelectFontSize } from '@src/components/CSelectFontSize'
@@ -35,7 +36,7 @@ export default defineComponent({
components: {
CImgTitle, CTitle, LandingFooter, CEventsCalendar,
CCardCarousel, COpenStreetMap, CMyPage, CMyPageIntro, CMyEditor, CMyFieldRec,
CSelectColor, CSelectFontSize, CSelectImage, CImgPoster
CSelectColor, CSelectFontSize, CSelectImage, CImgPoster, CSelectAnimation
},
emits: ['saveElem'],
props: {
@@ -247,6 +248,7 @@ export default defineComponent({
return (myel.value.type === shared_consts.ELEMTYPE.IMAGE)
|| (myel.value.type === shared_consts.ELEMTYPE.IMGTITLE)
|| (myel.value.type === shared_consts.ELEMTYPE.TEXT)
|| (myel.value.type === shared_consts.ELEMTYPE.CARD)
|| (myel.value.type === shared_consts.ELEMTYPE.HTML)
|| (myel.value.type === shared_consts.ELEMTYPE.CAROUSEL_IMGS)
}

View File

@@ -182,22 +182,12 @@
>
</q-input>
</div>
<q-select
v-if="enableEdit && showAnimation"
rounded
style="min-width: 150px"
outlined
v-model="myel.class_anim"
:options="tools.SelectListAnimation"
@update:model-value="modifElem"
dense
label="Animazione"
emit-value
map-options
>
</q-select>
<CSelectAnimation
v-if="enableEdit && showAnimation"
v-model="myel.class_anim"
@update:model-value="modifElem"
>
</CSelectAnimation>
<div v-if="myel.type === shared_consts.ELEMTYPE.TEXT">
<div v-if="enableEdit">
<q-input
@@ -486,20 +476,6 @@
v-on:keyup.enter="saveElem"
>
</q-input>
<q-select
v-if="enableEdit"
rounded
style="min-width: 150px"
outlined
v-model="myel.class_anim"
:options="tools.SelectListAnimation"
@update:model-value="modifElem"
dense
label="Animazione Titolo"
emit-value
map-options
>
</q-select>
<CSelectColor
style="min-width: 100px"
v-model="myel.color"
@@ -524,20 +500,13 @@
>
</CSelectColor>
</div>
<q-select
v-if="enableEdit"
rounded
style="min-width: 150px"
outlined
v-model="myel.class_anim2"
:options="tools.SelectListAnimation"
@update:model-value="modifElem"
dense
label="Animaz SottoTitolo"
emit-value
map-options
>
</q-select>
<CSelectAnimation
v-if="enableEdit && showAnimation"
v-model="myel.class_anim2"
@update:model-value="modifElem"
label="Animaz SottoTitolo"
>
</CSelectAnimation>
<div class="row">
<q-input
label="Classe Title"

View File

@@ -32,7 +32,7 @@
<div :class="` ` + rec.size" :style="`color: ` + rec.color">
{{ rec.alt }}
</div>
<div :class="`q-mt-sm q-mb-xs `" v-html="rec.content"></div>
<div :class="`q-mt-sm q-mb-xs ` + myel.class_anim" v-html="rec.content"></div>
<div
v-if="rec.description"
class="text-caption"
@@ -196,20 +196,12 @@
</q-video>
</div>
</div>
<div v-else-if="myel.type === shared_consts.ELEMTYPE.FOOTER">
<div
:class="myel.class + (editOn ? ` clEdit` : ``) + getClass()"
@click="clickOnElem"
>
<LandingFooter></LandingFooter>
</div>
</div>
<div v-else-if="myel.type === shared_consts.ELEMTYPE.PAGE">
<div
:class="myel.class + (editOn ? ` clEdit` : ``) + getClass()"
@click="clickOnElem"
>
<CMyPage :mypath="myel.container">&nbsp;</CMyPage>
<div style="color: gray;">Pagina: {{myel.container}}</div>
</div>
</div>
<div v-else-if="myel.type === shared_consts.ELEMTYPE.PAGEINTRO">

View File

@@ -8,6 +8,7 @@ import { useGlobalStore } from '@store/globalStore'
import { LandingFooter } from '@/components/LandingFooter'
import { CMyElem } from '@/components/CMyElem'
import { CMyEditElem } from '@/components/CMyEditElem'
import { CMyPageElem2 } from '@/components/CMyPageElem2'
import { CImgTitle } from '../CImgTitle/index'
import { CTitle } from '../CTitle/index'
@@ -19,7 +20,7 @@ import objectId from '@src/js/objectId'
export default defineComponent({
name: 'CMyPageElem',
components: { LandingFooter, CImgTitle, CTitle, CMyElem, CMyEditElem },
components: { LandingFooter, CImgTitle, CTitle, CMyElem, CMyEditElem, CMyPageElem2 },
props: {
title: String,
mypath: {
@@ -79,6 +80,7 @@ export default defineComponent({
function load() {
// console.log('load', mypathin.value)
if (mypathin.value !== '') {
globalStore.loadPage('/' + mypathin.value, 'cmypageelem').then(ris => {
rec.value = ris

View File

@@ -34,16 +34,10 @@
round
color="white"
icon="close"
@click="
visuEditor = false;
"
@click="visuEditor = false"
></q-btn>
</q-bar>
<CMyEditElem
:myelem="selElem"
:editOn="true"
:path="rec.path"
>
<CMyEditElem :myelem="selElem" :editOn="true" :path="rec.path">
</CMyEditElem>
</q-scroll-area>
</q-drawer>
@@ -81,16 +75,21 @@
<div v-if="!!rec.content4" v-html="rec.content4"></div>
<div v-for="(myelem, ind) in myelems" :key="ind">
<CMyElem
v-if="myelem.active || editOn"
:myelem="myelem"
:editOn="editOn"
:addOn="addOn"
:path="rec.path"
:selElem="selElem"
@selElemClick="selElemClick"
>
</CMyElem>
<div>
<CMyElem
v-if="myelem.active || editOn"
:myelem="myelem"
:editOn="editOn"
:addOn="addOn"
:path="rec.path"
:selElem="selElem"
@selElemClick="selElemClick"
>
</CMyElem>
</div>
<div v-if="myelem.type === shared_consts.ELEMTYPE.PAGE">
<CMyPageElem2 :mypath="myelem.container">&nbsp;</CMyPageElem2>
</div>
</div>
<div v-if="myelems.length === 0">
<CMyElem
@@ -105,6 +104,7 @@
</CMyElem>
</div>
</div>
<LandingFooter v-if="rec.showFooter"></LandingFooter>
</div>
<div v-else>
<div v-if="!!title">

View File

View File

@@ -0,0 +1,145 @@
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 { CMyEditElem } from '@/components/CMyEditElem'
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'
export default defineComponent({
name: 'CMyPageElem2',
components: { LandingFooter, CImgTitle, CTitle, CMyElem, CMyEditElem },
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 globalStore = useGlobalStore()
const editOn = ref(false)
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 myelems = computed(() => {
if (mypathin.value)
return globalStore.getMyElems(mypathin.value)
else
return null
})
function load() {
// console.log('load', mypathin.value)
if (mypathin.value !== '') {
globalStore.loadPage('/' + mypathin.value, 'cmypageelem').then(ris => {
rec.value = ris
})
}
if (tools.isManager()) {
editOn.value = tools.getCookie('EDITPAGES', '0') === '-1' ? true : false
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 = {}
}
})
function selElemClick(myelem: IMyElem) {
console.log('mypageelem selElemClick', myelem)
selElem.value = myelem
visuEditor.value = !!myelem
}
function mounted() {
load()
}
function saveElem(myelem: IMyElem) {
//
}
function changeVisuDrawer(path: string, edit: boolean) {
globalStore.changeVisuDrawer(path, edit)
}
onMounted(mounted)
return {
rec, myelems,
mypathin,
editOn,
visuEditor,
addOn,
tools,
shared_consts,
myelemVoid,
selElemClick,
selElem,
saveElem,
changeVisuDrawer,
}
},
})

View File

@@ -0,0 +1,135 @@
<template>
<div>
<div v-if="mypathin && !!rec">
<q-toggle
v-if="tools.isManager()"
v-model="editOn"
color="green"
@update:model-value="changeVisuDrawer(mypathin, editOn)"
icon="fas fa-pencil-alt"
>
</q-toggle>
<q-toggle
v-if="tools.isManager()"
v-model="visuEditor"
color="green"
@update:model-value="changeVisuDrawer(mypathin, editOn)"
icon="fas fa-pencil-alt"
>
</q-toggle>
<q-drawer
v-model="visuEditor"
side="right"
:width="350"
:breakpoint="700"
elevated
>
<q-scroll-area class="fit">
<q-bar dense class="bg-primary text-white">
<q-toolbar-title> Editor </q-toolbar-title>
<q-btn
flat
round
color="white"
icon="close"
@click="
visuEditor = false;
"
></q-btn>
</q-bar>
<CMyEditElem
:myelem="selElem"
:editOn="true"
:path="rec.path"
>
</CMyEditElem>
</q-scroll-area>
</q-drawer>
<div class="q-ma-xs q-gutter-xs 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>
<div v-for="(myelem, ind) in myelems" :key="ind">
<CMyElem
v-if="myelem.active || editOn"
:myelem="myelem"
:editOn="editOn"
:addOn="addOn"
:path="rec.path"
:selElem="selElem"
@selElemClick="selElemClick"
>
</CMyElem>
</div>
<div v-if="myelems.length === 0">
<CMyElem
v-if="editOn"
:myelem="myelemVoid"
:editOn="editOn"
:addOn="addOn"
:selElem="selElem"
:path="rec.path"
@selElemClick="selElemClick"
>
</CMyElem>
</div>
</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="./CMyPageElem2.ts">
</script>
<style lang="scss" scoped>
@import './CMyPageElem2.scss';
</style>

View File

@@ -0,0 +1 @@
export { default as CMyPageElem2 } from './CMyPageElem2.vue'

View File

@@ -0,0 +1,60 @@
import { defineComponent, onMounted, ref } from 'vue'
import { tools } from '@src/store/Modules/tools'
import { shared_consts } from '@src/common/shared_vuejs'
import { emit } from 'process'
export default defineComponent({
name: 'CSelectAnimation',
emits: ['update:modelValue'],
props: {
modelValue: {
type: String,
required: true,
default: '',
},
label: {
type: String,
required: false,
default: '',
},
},
setup(props, { emit }) {
const myclass = ref('')
const animType = ref('')
const animSpeed = ref('')
const animDelay = ref('')
function updateClass() {
let mycl = ''
myclass.value = 'animate__animated ' + animType.value + ' ' + animSpeed.value + ' ' + animDelay.value
emit('update:modelValue', myclass.value)
}
function mounted() {
const myarr = props.modelValue.split(' ')
animType.value = tools.findFirstElemInCommon(tools.SelectListAnimation, myarr)
animSpeed.value = tools.findFirstElemInCommon(tools.SelectListSpeed, myarr)
animDelay.value = tools.findFirstElemInCommon(tools.SelectListDelay, myarr)
}
onMounted(mounted)
return {
tools,
updateClass,
animType,
animSpeed,
animDelay,
}
},
})

View File

@@ -0,0 +1,52 @@
<template>
<div>
{{label}}
<q-select
rounded
style="min-width: 150px"
outlined
v-model="animType"
:options="tools.SelectListAnimation"
@update:model-value="updateClass"
dense
label="Tipo:"
emit-value
map-options
>
</q-select>
<q-select
rounded
style="min-width: 150px"
outlined
v-model="animSpeed"
:options="tools.SelectListSpeed"
@update:model-value="updateClass"
dense
label="Speed:"
emit-value
map-options
>
</q-select>
<q-select
rounded
style="min-width: 150px"
outlined
v-model="animDelay"
:options="tools.SelectListDelay"
@update:model-value="updateClass"
dense
label="Ritardo:"
emit-value
map-options
>
</q-select>
</div>
</template>
<script lang="ts" src="./CSelectAnimation.ts">
</script>
<style lang="scss" scoped>
@import './CSelectAnimation.scss';
</style>

View File

@@ -0,0 +1 @@
export { default as CSelectAnimation } from './CSelectAnimation.vue'