- creato editor di Pagine (iniziato)

- fix: mancano i "t," su alcuni componenti...
This commit is contained in:
Surya Paolo
2025-09-02 16:22:13 +02:00
parent 4f4297ca21
commit 574f389200
324 changed files with 5838 additions and 759 deletions

View File

@@ -0,0 +1,114 @@
import { defineComponent, ref, watch, onMounted } from 'vue'
import { useQuasar } from 'quasar'
import { storeToRefs } from 'pinia'
import { IMyPage } from 'app/src/model'
import { useGlobalStore } from 'app/src/store'
import { PagesConfigurator } from '@src/components/PagesConfigurator'
import { useI18n } from 'vue-i18n'
export default defineComponent({
name: 'PagesAdmin',
components: { PagesConfigurator },
setup () {
const $q = useQuasar()
const { t } = useI18n()
const globalStore = useGlobalStore()
const { mypage } = storeToRefs(globalStore)
// Copia locale per lediting tramite v-model
const pagesLocal = ref<IMyPage[]>([])
const savingAll = ref(false)
// Mantieni pagesLocal <-> store allineati
const syncFromStore = () => {
pagesLocal.value = (mypage.value || []).map(p => ({ ...p }))
}
watch(mypage, syncFromStore, { deep: true })
onMounted(async () => {
// Se hai una funzione per caricare tutte le pagine, chiamala qui
// es. await globalStore.loadAllPages()
syncFromStore()
})
// Salva singola pagina (chiamato da PagesConfigurator @save)
async function saveOne (page: IMyPage) {
try {
const saved = await globalStore.savePage({ ...page })
if (saved && typeof saved === 'object') {
// rimpiazza nel local e nello store (lo store viene aggiornato da savePage)
const idx = pagesLocal.value.findIndex(p =>
(p._id && p._id === saved._id) || (p.path && p.path === saved.path)
)
if (idx >= 0) pagesLocal.value[idx] = { ...saved }
$q.notify({ type: 'positive', message: `Salvata: ${saved.title || saved.path}` })
} else {
$q.notify({ type: 'positive', message: 'Salvataggio completato' })
}
} catch (err) {
console.error(err)
$q.notify({ type: 'negative', message: 'Errore nel salvataggio della pagina' })
}
}
// Salva lordinamento (fallback: batch di savePage per aggiornare order)
async function saveOrder (orders: { id?: string; order: number }[]) {
try {
// Applica l'order nella copia locale
for (const { id, order } of orders) {
const p = pagesLocal.value.find(x => x._id === id) ||
pagesLocal.value.find(x => !id && typeof x.order === 'number' && x.order === order)
if (p) p.order = order
}
// Fallback: se non hai un endpoint /reorder, salvi singolarmente
await Promise.all(
pagesLocal.value.map(p => globalStore.savePage({ ...p }))
)
$q.notify({ type: 'positive', message: 'Ordinamento salvato' })
} catch (err) {
console.error(err)
$q.notify({ type: 'negative', message: 'Errore nel salvataggio dellordinamento' })
}
}
// Ricarica lelenco (se disponibile una API globale; altrimenti rilegge dallo store)
async function reloadAll () {
try {
// Se esiste: await globalStore.loadAllPages()
syncFromStore()
$q.notify({ type: 'info', message: 'Elenco ricaricato' })
} catch (err) {
console.error(err)
$q.notify({ type: 'negative', message: 'Errore nel ricaricare lelenco' })
}
}
// Salva tutto (batch)
async function saveAll () {
try {
savingAll.value = true
await Promise.all(
pagesLocal.value.map(p => globalStore.savePage({ ...p }))
)
$q.notify({ type: 'positive', message: 'Tutte le pagine salvate' })
} catch (err) {
console.error(err)
$q.notify({ type: 'negative', message: 'Errore nel salvataggio massivo' })
} finally {
savingAll.value = false
}
}
return {
pagesLocal,
saveOne,
saveOrder,
reloadAll,
saveAll,
savingAll,
t,
}
}
})

View File

@@ -0,0 +1,34 @@
<template>
<q-page class="q-pa-md">
<q-toolbar class="q-mb-md">
<q-toolbar-title>Configuratore Pagine</q-toolbar-title>
<q-space />
<q-btn
flat
dense
icon="fas fa-rotate"
label="Ricarica elenco"
@click="reloadAll"
/>
<q-btn
color="primary"
dense
class="q-ml-sm"
icon="fas fa-floppy-disk"
label="Salva tutto"
:loading="savingAll"
@click="saveAll"
/>
</q-toolbar>
<PagesConfigurator
v-model="pagesLocal"
@save="saveOne"
@change-order="saveOrder"
/>
</q-page>
</template>
<script lang="ts" src="./editpages.ts">
</script>

View File

@@ -170,6 +170,7 @@ export default defineComponent({
gettitle,
change_rec,
showPrev,
t,
}
}
})

View File

@@ -16,23 +16,23 @@
<q-markup-table wrap-cells bordered separator="horizontal" class="listaev__table">
<thead>
<tr>
<th>{{ $t('cal.data') }}</th>
<th>{{ $t('cal.event') }}</th>
<th v-if="!tools.isMobile()">{{ $t('cal.teachertitle') }}</th>
<th>{{ t('cal.data') }}</th>
<th>{{ t('cal.event') }}</th>
<th v-if="!tools.isMobile()">{{ t('cal.teachertitle') }}</th>
<th v-if="showall()">
<span v-if="!tools.isMobile()">{{ $t('cal.selnumpeople') }}</span>
<span v-else>{{ $t('cal.selnumpeople_short') }}</span>
<span v-if="!tools.isMobile()">{{ t('cal.selnumpeople') }}</span>
<span v-else>{{ t('cal.selnumpeople_short') }}</span>
</th>
<th v-if="showall()">
{{ $t('cal.selnumpeopleLunch') }}
{{ t('cal.selnumpeopleLunch') }}
</th>
<th v-if="showall()">
{{ $t('cal.selnumpeopleDinner') }}
{{ t('cal.selnumpeopleDinner') }}
</th>
<th v-if="showall()">
{{ $t('cal.selnumpeopleDinnerShared') }}
{{ t('cal.selnumpeopleDinnerShared') }}
</th>
<th>{{ $t('cal.peoplebooked') }}</th>
<th>{{ t('cal.peoplebooked') }}</th>
</tr>
</thead>
@@ -172,7 +172,7 @@ eventbook, index
userStore.getNameSurnameByUserId(eventbook.userId)
}}</strong>
<span v-if="eventbook.msgbooking">
{{ $t('sendmsg.write') }}: </span><br />
{{ t('sendmsg.write') }}: </span><br />
{{ eventbook.msgbooking }}
</td>
<td class="text-center">

View File

@@ -1,24 +0,0 @@
import { defineComponent } from 'vue'
import { CImgText } from '../../../components/CImgText/index'
import { CCard } from '@src/components/CCard'
import { CMyPage } from '@src/components/CMyPage'
import { CTitleBanner } from '@src/components/CTitleBanner'
import { CGridTableRec } from '@src/components/CGridTableRec'
import { colTableProductInfosShort } from '@src/store/Modules/fieldsTable'
import MixinMetaTags from '@src/mixins/mixin-metatags'
export default defineComponent({
name: 'ProductInfosPage',
components: { CImgText, CCard, CMyPage, CTitleBanner, CGridTableRec },
setup() {
const { setmeta } = MixinMetaTags()
return {
colTableProductInfosShort,
setmeta,
}
}
})

View File

@@ -1,28 +0,0 @@
<template>
<CMyPage title="Info Prodotti" imgbackground="/images/prodotti.jpg" sizes="max-height: 120px">
<span>{{
setmeta({
title: 'Info Prodotti',
description: '',
keywords: '',
})
}}
</span>
<div class="q-ma-sm q-gutter-sm q-pa-xs">
<CTitleBanner title="Info Prodotti"></CTitleBanner>
<CGridTableRec prop_mytable="productinfos" prop_mytitle="Lista Info Prodotti"
:prop_mycolumns="colTableProductInfosShort" prop_colkey="name" nodataLabel="Nessun Info Prodotto"
noresultLabel="Il filtro selezionato non ha trovato nessun risultato">
</CGridTableRec>
</div>
</CMyPage>
</template>
<script lang="ts" src="./productInfos.ts">
</script>
<style lang="scss" scoped>
@import 'productInfos.scss';
</style>

View File

@@ -1,24 +0,0 @@
import { defineComponent } from 'vue'
import { CImgText } from '../../../components/CImgText/index'
import { CCard } from '@src/components/CCard'
import { CMyPage } from '@src/components/CMyPage'
import { CTitleBanner } from '@src/components/CTitleBanner'
import { CGridTableRec } from '@src/components/CGridTableRec'
import { colTableProductInfos } from '@src/store/Modules/fieldsTable'
import MixinMetaTags from '@src/mixins/mixin-metatags'
export default defineComponent({
name: 'productInfosComplete',
components: { CImgText, CCard, CMyPage, CTitleBanner, CGridTableRec },
setup() {
const { setmeta } = MixinMetaTags()
return {
colTableProductInfos,
setmeta,
}
}
})

View File

@@ -1,28 +0,0 @@
<template>
<CMyPage title="Info Prodotti" imgbackground="/images/prodotti.jpg" sizes="max-height: 120px">
<span>{{
setmeta({
title: 'Info Prodotti',
description: '',
keywords: '',
})
}}
</span>
<div class="q-ma-sm q-gutter-sm q-pa-xs">
<CTitleBanner title="Info Prodotti"></CTitleBanner>
<CGridTableRec prop_mytable="productinfos" prop_mytitle="Lista Info Prodotti"
:prop_mycolumns="colTableProductInfos" prop_colkey="name" nodataLabel="Nessun Info Prodotto"
noresultLabel="Il filtro selezionato non ha trovato nessun risultato">
</CGridTableRec>
</div>
</CMyPage>
</template>
<script lang="ts" src="./productInfosComplete.ts">
</script>
<style lang="scss" scoped>
@import 'productInfosComplete.scss';
</style>

View File

@@ -188,6 +188,7 @@ export default defineComponent({
listnotifid,
listnotifidTest,
getMyUsername,
t,
}
}
})

View File

@@ -130,7 +130,7 @@
class="bg-red text-white"
style="text-align: center;"
>
<em style="font-weight: bold">{{ $t('db.reporteduser', {date_report: tools.getstrDateTimeShort(myuser.date_report)}) }}<br>
<em style="font-weight: bold">{{ t('db.reporteduser', {date_report: tools.getstrDateTimeShort(myuser.date_report)}) }}<br>
da: {{ myuser.username_who_report }}<br>
</em>
</q-banner>