- generato lista libri, con possibilità di cambiare l'ordinamento dei libri o di cancellare libri.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
.maximized-dialog-card {
|
||||
max-width: 90%;
|
||||
/* Larghezza massima del dialog */
|
||||
max-height: 90%;
|
||||
/* Altezza massima del dialog */
|
||||
margin: auto;
|
||||
/* Centra il dialog nello schermo */
|
||||
border-radius: 16px;
|
||||
/* Angoli arrotondati opzionali */
|
||||
}
|
||||
@@ -20,6 +20,11 @@ export default defineComponent({
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
class: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
<template>
|
||||
<q-dialog v-model="internalModel" maximized
|
||||
<div :class="class">
|
||||
<q-dialog
|
||||
v-model="internalModel"
|
||||
maximized
|
||||
transition-show="slide-up"
|
||||
transition-hide="slide-down"
|
||||
>
|
||||
<q-card class="dialog_card">
|
||||
>
|
||||
<q-card class="dialog_card maximized-dialog-card">
|
||||
<q-toolbar class="bg-primary text-white">
|
||||
<q-toolbar-title>
|
||||
{{ title }}
|
||||
</q-toolbar-title>
|
||||
<q-btn flat round color="white" icon="close" v-close-popup></q-btn>
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
color="white"
|
||||
icon="close"
|
||||
v-close-popup
|
||||
></q-btn>
|
||||
</q-toolbar>
|
||||
|
||||
<q-card-section class="inset-shadow">
|
||||
@@ -16,10 +25,10 @@
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./CMyDialog.ts">
|
||||
</script>
|
||||
<script lang="ts" src="./CMyDialog.ts"></script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './CMyDialog';
|
||||
|
||||
@@ -368,174 +368,7 @@ export default defineComponent({
|
||||
}
|
||||
function addNewScheda() {
|
||||
|
||||
let maxorder = 0
|
||||
myel.value.catalogo!.arrSchede?.forEach(scheda => {
|
||||
if (scheda?.order > maxorder) {
|
||||
maxorder = scheda.order
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
let testodef: IText = {}
|
||||
testodef = tools.resetIText(testodef)
|
||||
|
||||
const defaultDimensioniPag = tools.resetRecIDimensioni(null)
|
||||
defaultDimensioniPag.size = {
|
||||
width: '800px',
|
||||
height: '600px',
|
||||
}
|
||||
defaultDimensioniPag.margini = {
|
||||
top: '12px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
defaultDimensioniPag.padding = {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
|
||||
const defaultDimensioniRiga = tools.resetRecIDimensioni(null)
|
||||
|
||||
defaultDimensioniRiga.size = {
|
||||
width: '800px',
|
||||
height: '300px',
|
||||
}
|
||||
defaultDimensioniRiga.margini = {
|
||||
top: '40px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
defaultDimensioniRiga.padding = {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
|
||||
const defaultSchedaProdotto = tools.resetRecIDimensioni(null)
|
||||
|
||||
defaultSchedaProdotto.size = {
|
||||
width: '360px',
|
||||
height: '230px',
|
||||
}
|
||||
|
||||
defaultSchedaProdotto.margini = {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
|
||||
defaultSchedaProdotto.padding = {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
|
||||
const dimensioni: IElementiScheda = {
|
||||
pagina: { dimensioni: defaultDimensioniPag, testo_down: testodef, testo_up: testodef, testo_title: testodef },
|
||||
riga: defaultDimensioniRiga,
|
||||
scheda_prodotto: defaultSchedaProdotto,
|
||||
immagine_prodotto: {
|
||||
size: {
|
||||
width: '150px',
|
||||
height: '235px',
|
||||
},
|
||||
margini: {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
},
|
||||
padding: {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const newscheda: IMyScheda = {
|
||||
_id: objectId(),
|
||||
idapp: tools.appid()!,
|
||||
isTemplate: false,
|
||||
isPagIntro: false,
|
||||
show_separatore: true,
|
||||
name: 'Scheda Nuova',
|
||||
dimensioni,
|
||||
numschede_perRiga: 2,
|
||||
numschede_perCol: 2,
|
||||
testo_right_attaccato: {
|
||||
contenuto: '',
|
||||
maxlength: 0,
|
||||
font: {
|
||||
posiz_text: costanti.POSIZ_TESTO.A_DESTRA,
|
||||
},
|
||||
},
|
||||
testo_right: {
|
||||
contenuto: '',
|
||||
maxlength: 0,
|
||||
font: {
|
||||
posiz_text: costanti.POSIZ_TESTO.A_DESTRA,
|
||||
},
|
||||
},
|
||||
testo_bottom: {
|
||||
contenuto: '',
|
||||
maxlength: 0,
|
||||
font: {
|
||||
posiz_text: costanti.POSIZ_TESTO.IN_BASSO,
|
||||
}
|
||||
},
|
||||
barcode: {
|
||||
show: false,
|
||||
format: '',
|
||||
size: {
|
||||
width: '2',
|
||||
height: '100',
|
||||
},
|
||||
font: {
|
||||
name: 'monospace',
|
||||
size: '16px',
|
||||
}
|
||||
},
|
||||
productTypes: [],
|
||||
excludeproductTypes: [],
|
||||
editore: [],
|
||||
argomenti: [],
|
||||
author: '',
|
||||
sort_field: '',
|
||||
sort_dir: 0,
|
||||
arrProdottiSpeciali: [],
|
||||
etichette: {
|
||||
novita: {
|
||||
show: false,
|
||||
months: 6,
|
||||
},
|
||||
bestseller: {
|
||||
show: false,
|
||||
primiNInClassifica: 20
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!myel.value.catalogo!.arrSchede)
|
||||
myel.value.catalogo!.arrSchede = []
|
||||
|
||||
myel.value.catalogo!.arrSchede.push(
|
||||
{
|
||||
_id: objectId(),
|
||||
scheda: newscheda,
|
||||
order: maxorder + 10,
|
||||
numPagineMax: 0,
|
||||
}
|
||||
)
|
||||
// console.log('arrschede', myel.value.catalogo!.arrSchede)
|
||||
Products.addNewScheda(myel.value.catalogo)
|
||||
|
||||
modifElem()
|
||||
|
||||
|
||||
@@ -1463,6 +1463,7 @@
|
||||
@click="addNewScheda"
|
||||
>
|
||||
</q-btn>
|
||||
|
||||
<div
|
||||
v-for="(recscheda, ind) in myel.catalogo.arrSchede"
|
||||
:key="recscheda._id"
|
||||
@@ -1470,6 +1471,41 @@
|
||||
dense
|
||||
:label="`${ind}. ` + recscheda.scheda.name ? recscheda.scheda.name : `Scheda ` + (ind + 1)"
|
||||
>
|
||||
<div class="row">
|
||||
<q-select
|
||||
:behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
|
||||
v-if="enableEdit"
|
||||
rounded
|
||||
outlined
|
||||
v-model="recscheda.scheda.linkIdTemplate"
|
||||
:options="globalStore.getSchedeOpt('SEARCH_')"
|
||||
@update:model-value="modifElem"
|
||||
label="Scheda collegata:"
|
||||
style="width: 250px"
|
||||
emit-value
|
||||
map-options
|
||||
>
|
||||
</q-select>
|
||||
|
||||
<q-toggle
|
||||
v-model="recscheda.scheda.isTemplate"
|
||||
color="positive"
|
||||
icon="fas fa-file-pdf"
|
||||
label="E' un template"
|
||||
@update:model-value="modifElem"
|
||||
>
|
||||
</q-toggle>
|
||||
<q-input
|
||||
label="Nome Template"
|
||||
@update:model-value="modifElem"
|
||||
v-model="recscheda.scheda.name"
|
||||
filled
|
||||
debounce="1000"
|
||||
v-on:keyup.enter="saveElem"
|
||||
>
|
||||
</q-input>
|
||||
</div>
|
||||
|
||||
<q-expansion-item
|
||||
dense
|
||||
dense-toggle
|
||||
|
||||
@@ -21,6 +21,11 @@ export default defineComponent({
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
showvalue: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
min: {
|
||||
type: Number,
|
||||
required: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<q-badge color="primary"> {{ label }} <span v-if="modelValue">{{ modelValue }}</span> </q-badge>
|
||||
<q-badge class="q-mx-sm" color="primary"> {{ label }} <span v-if="modelValue && showvalue"> ({{ modelValue }})</span> </q-badge>
|
||||
<div class="q-pa-xs row no-wrap">
|
||||
<q-btn
|
||||
icon="fas fa-minus"
|
||||
|
||||
@@ -5,13 +5,21 @@ import { tools } from '@tools'
|
||||
|
||||
import { useGlobalStore } from '@src/store/globalStore'
|
||||
|
||||
import { CSearchProduct } from '@src/components/CSearchProduct'
|
||||
import { CMyDialog } from '@src/components/CMyDialog'
|
||||
|
||||
import { costanti } from '@costanti'
|
||||
import { IAuthor, ICatProd } from "app/src/model";
|
||||
|
||||
import type {
|
||||
IProduct
|
||||
} from '@src/model';
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: "CProductTable",
|
||||
components: {
|
||||
draggable,
|
||||
draggable, CSearchProduct, CMyDialog,
|
||||
},
|
||||
props: {
|
||||
lista_prodotti: {
|
||||
@@ -26,6 +34,9 @@ export default defineComponent({
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
const showProd = ref(false)
|
||||
const selProd = ref(<IProduct>{})
|
||||
|
||||
async function mounted() {
|
||||
|
||||
}
|
||||
@@ -40,20 +51,28 @@ export default defineComponent({
|
||||
|
||||
// Colonne della tabella
|
||||
const allColumns = [
|
||||
{ name: "drag", label: "", field: "", align: "left", style: "width: 50px" },
|
||||
{ name: "image", label: "Immagine", field: "image", align: "center" },
|
||||
{ name: "title", label: "Titolo", field: "title", align: "left" },
|
||||
{ name: "author", label: "Autore", field: "author", align: "left" },
|
||||
{ name: "topic", label: "Argomento", field: "topic", align: "left" },
|
||||
{ name: "drag", label: "Ordinamento", field: "", align: "left", style: "width: 50px" },
|
||||
{ name: "image", label: "Copertina", field: "image", align: "center" },
|
||||
{ name: "name", label: "Titolo", field: "name", align: "left" },
|
||||
{ name: "authors", label: "Autore", field: "authors", align: "left" },
|
||||
{ name: "catprods", label: "Argomento", field: "catprods", align: "left" },
|
||||
{ name: "quantity", label: "Disponibilità", field: "quantity", align: "left" },
|
||||
{ name: "isbn", label: "ISBN", field: "isbn", align: "left" },
|
||||
{ name: "actions", label: "Azioni", field: "", align: "center" },
|
||||
];
|
||||
|
||||
const selectedColumns = ref(
|
||||
tools.getCookie("selColCat")
|
||||
? JSON.parse(tools.getCookie("selColCat"))
|
||||
: ["drag", "image", "name", "authors", "catprods", "isbn", "actions"] // Valori di default
|
||||
)
|
||||
let cookieValue: string | null = null;
|
||||
try {
|
||||
cookieValue = tools.getCookie("selColCat");
|
||||
// Se il cookie esiste e contiene una stringa JSON valida
|
||||
cookieValue = cookieValue ? cookieValue : [];
|
||||
} catch (error) {
|
||||
console.error("Errore durante la lettura del cookie 'selColCat'", error);
|
||||
cookieValue = []; // In caso di errore, inizializza come array vuoto
|
||||
}
|
||||
|
||||
const selectedColumns = ref(cookieValue.length > 0 ? cookieValue : ["drag", "image", "name", "authors", "catprods", "isbn", "actions"]);
|
||||
|
||||
|
||||
// 3. Funzione per verificare se una colonna è visibile (isColumnVisible)
|
||||
const isColumnVisible = (column) => {
|
||||
@@ -110,10 +129,16 @@ export default defineComponent({
|
||||
onMounted(() => {
|
||||
const savedColumns = tools.getCookie("selColCat");
|
||||
if (savedColumns) {
|
||||
selectedColumns.value = JSON.parse(savedColumns);
|
||||
selectedColumns.value = savedColumns;
|
||||
}
|
||||
});
|
||||
|
||||
function showProduct(element: any) {
|
||||
selProd.value = element
|
||||
|
||||
showProd.value = true
|
||||
}
|
||||
|
||||
return {
|
||||
allColumns,
|
||||
selectedColumns,
|
||||
@@ -126,6 +151,9 @@ export default defineComponent({
|
||||
globalStore,
|
||||
costanti,
|
||||
onDragEnd,
|
||||
showProduct,
|
||||
showProd,
|
||||
selProd,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
multiple
|
||||
emit-value
|
||||
map-options
|
||||
option-value="name"
|
||||
option-label="label"
|
||||
filled
|
||||
style="max-width: 400px"
|
||||
/>
|
||||
@@ -19,13 +21,14 @@
|
||||
<!-- Intestazioni (Thead) -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th v-if="isColumnVisible('drag')">Drag</th>
|
||||
<th v-if="isColumnVisible('image')">Immagine</th>
|
||||
<th v-if="isColumnVisible('name')">Nome</th>
|
||||
<th v-if="isColumnVisible('authors')">Autore</th>
|
||||
<th v-if="isColumnVisible('catprods')">Argomento</th>
|
||||
<th v-if="isColumnVisible('isbn')">ISBN</th>
|
||||
<th v-if="isColumnVisible('actions')">Azioni</th>
|
||||
<template v-for="col in allColumns">
|
||||
<th
|
||||
v-if="isColumnVisible(col.name)"
|
||||
:key="col.name"
|
||||
>
|
||||
{{ col.label }}
|
||||
</th>
|
||||
</template>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- Corpo della Tabella (Tbody) -->
|
||||
@@ -39,8 +42,15 @@
|
||||
<template #item="{ element }">
|
||||
<tr :key="element._id">
|
||||
<!-- Icona Drag Handle -->
|
||||
<td v-if="isColumnVisible('drag')" class="drag-handle">
|
||||
<q-icon name="drag_handle" size="32px" color="primary" />
|
||||
<td
|
||||
v-if="isColumnVisible('drag')"
|
||||
class="drag-handle"
|
||||
>
|
||||
<q-icon
|
||||
name="drag_handle"
|
||||
size="32px"
|
||||
color="primary"
|
||||
/>
|
||||
</td>
|
||||
|
||||
<!-- Immagine Piccola -->
|
||||
@@ -52,7 +62,8 @@
|
||||
: element.productInfo?.image_link
|
||||
"
|
||||
style="width: 50px; height: 50px"
|
||||
class="rounded-borders"
|
||||
class="rounded-borders cursor-pointer"
|
||||
@click="showProduct(element)"
|
||||
/>
|
||||
</td>
|
||||
|
||||
@@ -65,14 +76,25 @@
|
||||
<!-- Argomento -->
|
||||
<td v-if="isColumnVisible('catprods')">{{ formatCatProds(element.productInfo?.catprods) }}</td>
|
||||
|
||||
<!-- Quantità -->
|
||||
<td v-if="isColumnVisible('quantity')">{{ element.arrvariazioni[0].quantita }}</td>
|
||||
|
||||
<!-- ISBN -->
|
||||
<td v-if="isColumnVisible('isbn')">{{ element.isbn }}</td>
|
||||
|
||||
<!-- Azioni -->
|
||||
<td v-if="isColumnVisible('actions')">
|
||||
<q-btn-dropdown label="Azioni" color="primary" flat>
|
||||
<q-btn-dropdown
|
||||
label="Azioni"
|
||||
color="primary"
|
||||
flat
|
||||
>
|
||||
<q-list>
|
||||
<q-item clickable v-close-popup @click="removeProduct(element)">
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="removeProduct(element)"
|
||||
>
|
||||
<q-item-section>
|
||||
<q-item-label>Elimina</q-item-label>
|
||||
</q-item-section>
|
||||
@@ -85,9 +107,15 @@
|
||||
</draggable>
|
||||
</table>
|
||||
</div>
|
||||
<CMyDialog
|
||||
v-model="showProd"
|
||||
title="Prodotto"
|
||||
class="q-ma-md"
|
||||
>
|
||||
<CSearchProduct v-if="selProd" :idprodtoshow="selProd._id" nameLinkTemplate="SEARCH_Prima"> </CSearchProduct>
|
||||
</CMyDialog>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts" src="./CProductTable.ts"></script>
|
||||
<style lang="scss" scoped>
|
||||
@import './CProductTable.scss';
|
||||
|
||||
@@ -32,7 +32,18 @@ export default defineComponent({
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object as PropType<IOptCatalogo>,
|
||||
required: true,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
idprodtoshow: {
|
||||
type: String,
|
||||
required: false,
|
||||
default : '',
|
||||
},
|
||||
nameLinkTemplate: {
|
||||
type: String,
|
||||
required: false,
|
||||
default : '',
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
@@ -101,11 +112,13 @@ export default defineComponent({
|
||||
|
||||
console.log('myproduct.value', myproduct.value)
|
||||
|
||||
if (!props.idprodtoshow) {
|
||||
if (myproduct.value) {
|
||||
tools.setCookie(tools.COOK_LAST_PROD_SEARCH, myproduct.value._id.toString())
|
||||
} else {
|
||||
tools.setCookie(tools.COOK_LAST_PROD_SEARCH, '')
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -123,18 +136,57 @@ export default defineComponent({
|
||||
return lista && lista.value && lista.value._id ? lista.value._id : ''
|
||||
}
|
||||
|
||||
function populateDataWithlinkIdTemplate() {
|
||||
console.log('populateDataWithlinkIdTemplate')
|
||||
|
||||
if (optcatalogo.value) {
|
||||
|
||||
for (const recscheda of optcatalogo.value.arrSchede!) {
|
||||
if (recscheda.scheda?.linkIdTemplate) {
|
||||
// ricopia da Template:
|
||||
const myscheda = globalStore.sovrascriviSchedaFromTemplate(recscheda.scheda?.linkIdTemplate, recscheda)
|
||||
if (myscheda) {
|
||||
recscheda.scheda = { ...myscheda }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(' FINE - populateDataWithlinkIdTemplate')
|
||||
}
|
||||
|
||||
|
||||
async function mounted() {
|
||||
// console.log('mounted Catalogo')
|
||||
|
||||
if (props.modelValue) {
|
||||
optcatalogo.value = props.modelValue
|
||||
loadpage.value = false
|
||||
} else {
|
||||
optcatalogo.value = globalStore.createCatalogoVuoto()
|
||||
productStore.addNewScheda(optcatalogo.value)
|
||||
|
||||
const id = tools.getCookie(tools.COOK_LAST_PROD_SEARCH, '')
|
||||
if (props.nameLinkTemplate) {
|
||||
const linkIdTemplate = globalStore.getLinkIdTemplateByName(props.nameLinkTemplate)
|
||||
optcatalogo.value.arrSchede[0].scheda.linkIdTemplate = linkIdTemplate
|
||||
} else {
|
||||
optcatalogo.value.arrSchede[0].scheda.name = 'SEARCH_NEW'
|
||||
}
|
||||
}
|
||||
|
||||
const id = props.idprodtoshow || tools.getCookie(tools.COOK_LAST_PROD_SEARCH, '')
|
||||
|
||||
if (props.nameLinkTemplate) {
|
||||
populateDataWithlinkIdTemplate()
|
||||
}
|
||||
|
||||
loadpage.value = false
|
||||
|
||||
if (id) {
|
||||
await loadProduct(id)
|
||||
}
|
||||
|
||||
|
||||
mycolumns.value = fieldsTable.getArrColsByTable('products')
|
||||
|
||||
searchList.value = [
|
||||
|
||||
@@ -493,7 +493,7 @@ export interface IGlobalState {
|
||||
gallery: IGallery[],
|
||||
mypage: IMyPage[],
|
||||
myelems: IMyElem[],
|
||||
myschedas: IMyScheda[],
|
||||
myschedas: ISchedaSingola[],
|
||||
templemail: ITemplEmail[],
|
||||
opzemail: ISettings[],
|
||||
mailinglist: IMailinglist[],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali, ISingleProductOrdered, ISchedaSingola, IMyScheda } from 'model'
|
||||
import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali, ISingleProductOrdered, ISchedaSingola, IMyScheda, IElementiScheda } from 'model'
|
||||
|
||||
import { Api } from '@api'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
@@ -12,6 +12,9 @@ import { toolsext } from '@store/Modules/toolsext'
|
||||
import { useGlobalStore } from './globalStore'
|
||||
import { ref } from 'vue'
|
||||
|
||||
import objectId from '@src/js/objectId'
|
||||
import { costanti } from '@costanti'
|
||||
|
||||
import translate from '@src/globalroutines/util'
|
||||
import { useCatalogStore } from './CatalogStore'
|
||||
|
||||
@@ -1529,7 +1532,7 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
},
|
||||
|
||||
getSchedeOpt(arrschede: IMyScheda[]): any[] {
|
||||
getSchedeOpt(arrschede: ISchedaSingola[], tag?: string): any[] {
|
||||
|
||||
let arr: any = []
|
||||
|
||||
@@ -1547,8 +1550,10 @@ export const useProducts = defineStore('Products', {
|
||||
pagename = '[Pag: ' + pagename + '] '
|
||||
|
||||
const mylabel = pagename + (recscheda.scheda ? recscheda.scheda!.name : '')
|
||||
if (!tag || mylabel.startsWith(tag)) {
|
||||
arr.push({ label: mylabel, value: recscheda.scheda!._id })
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1556,6 +1561,178 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
},
|
||||
|
||||
addNewScheda(catalogo: IOptCatalogo) {
|
||||
|
||||
let maxorder = 0
|
||||
catalogo!.arrSchede?.forEach(scheda => {
|
||||
if (scheda?.order > maxorder) {
|
||||
maxorder = scheda.order
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
let testodef: IText = {}
|
||||
testodef = tools.resetIText(testodef)
|
||||
|
||||
const defaultDimensioniPag = tools.resetRecIDimensioni(null)
|
||||
defaultDimensioniPag.size = {
|
||||
width: '800px',
|
||||
height: '600px',
|
||||
}
|
||||
defaultDimensioniPag.margini = {
|
||||
top: '12px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
defaultDimensioniPag.padding = {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
|
||||
const defaultDimensioniRiga = tools.resetRecIDimensioni(null)
|
||||
|
||||
defaultDimensioniRiga.size = {
|
||||
width: '800px',
|
||||
height: '300px',
|
||||
}
|
||||
defaultDimensioniRiga.margini = {
|
||||
top: '40px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
defaultDimensioniRiga.padding = {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
|
||||
const defaultSchedaProdotto = tools.resetRecIDimensioni(null)
|
||||
|
||||
defaultSchedaProdotto.size = {
|
||||
width: '360px',
|
||||
height: '230px',
|
||||
}
|
||||
|
||||
defaultSchedaProdotto.margini = {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
|
||||
defaultSchedaProdotto.padding = {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
}
|
||||
|
||||
const dimensioni: IElementiScheda = {
|
||||
pagina: { dimensioni: defaultDimensioniPag, testo_down: testodef, testo_up: testodef, testo_title: testodef },
|
||||
riga: defaultDimensioniRiga,
|
||||
scheda_prodotto: defaultSchedaProdotto,
|
||||
immagine_prodotto: {
|
||||
size: {
|
||||
width: '150px',
|
||||
height: '235px',
|
||||
},
|
||||
margini: {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
},
|
||||
padding: {
|
||||
top: '0px',
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const newscheda: IMyScheda = {
|
||||
_id: objectId(),
|
||||
idapp: tools.appid()!,
|
||||
isTemplate: false,
|
||||
isPagIntro: false,
|
||||
show_separatore: true,
|
||||
name: 'Scheda Nuova',
|
||||
dimensioni,
|
||||
numschede_perRiga: 2,
|
||||
numschede_perCol: 2,
|
||||
testo_right_attaccato: {
|
||||
contenuto: '',
|
||||
maxlength: 0,
|
||||
font: {
|
||||
posiz_text: costanti.POSIZ_TESTO.A_DESTRA,
|
||||
},
|
||||
},
|
||||
testo_right: {
|
||||
contenuto: '',
|
||||
maxlength: 0,
|
||||
font: {
|
||||
posiz_text: costanti.POSIZ_TESTO.A_DESTRA,
|
||||
},
|
||||
},
|
||||
testo_bottom: {
|
||||
contenuto: '',
|
||||
maxlength: 0,
|
||||
font: {
|
||||
posiz_text: costanti.POSIZ_TESTO.IN_BASSO,
|
||||
}
|
||||
},
|
||||
barcode: {
|
||||
show: false,
|
||||
format: '',
|
||||
size: {
|
||||
width: '2',
|
||||
height: '100',
|
||||
},
|
||||
font: {
|
||||
name: 'monospace',
|
||||
size: '16px',
|
||||
}
|
||||
},
|
||||
productTypes: [],
|
||||
excludeproductTypes: [],
|
||||
editore: [],
|
||||
argomenti: [],
|
||||
author: '',
|
||||
sort_field: '',
|
||||
sort_dir: 0,
|
||||
arrProdottiSpeciali: [],
|
||||
etichette: {
|
||||
novita: {
|
||||
show: false,
|
||||
months: 6,
|
||||
},
|
||||
bestseller: {
|
||||
show: false,
|
||||
primiNInClassifica: 20
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!catalogo!.arrSchede)
|
||||
catalogo!.arrSchede = []
|
||||
|
||||
catalogo!.arrSchede.push(
|
||||
{
|
||||
_id: objectId(),
|
||||
scheda: newscheda,
|
||||
order: maxorder + 10,
|
||||
numPagineMax: 0,
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ import type {
|
||||
IStatusSkill,
|
||||
StateConnection,
|
||||
ISchedaSingola,
|
||||
IOptQueryGM
|
||||
IOptQueryGM,
|
||||
IOptCatalogo
|
||||
} from '@model';
|
||||
import {
|
||||
ICity, IMySkill,
|
||||
@@ -211,6 +212,31 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
}),
|
||||
|
||||
getters: {
|
||||
|
||||
sovrascriviSchedaFromTemplate: (state: IGlobalState) => (idTemplate: string, origScheda: ISchedaSingola) => {
|
||||
|
||||
const arrschede: ISchedaSingola[] = state.myschedas
|
||||
const myfindscheda = arrschede.find((recscheda: ISchedaSingola) => recscheda.scheda?._id === idTemplate)
|
||||
|
||||
const linkIdTemplate = origScheda.scheda?.linkIdTemplate
|
||||
const precname = origScheda.scheda?.name
|
||||
|
||||
if (myfindscheda) {
|
||||
const myschedatocopy = tools.jsonCopy(myfindscheda)
|
||||
|
||||
if (myschedatocopy) {
|
||||
myschedatocopy.scheda._id = origScheda.scheda?._id
|
||||
myschedatocopy.scheda.isTemplate = false
|
||||
myschedatocopy.scheda.name = precname
|
||||
myschedatocopy.scheda.linkIdTemplate = linkIdTemplate
|
||||
|
||||
return myschedatocopy.scheda
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
},
|
||||
|
||||
// conta: (state: IGlobalState) => { state.conta },
|
||||
// listatodo: (state: IGlobalState) => { state.listatodo },
|
||||
// category: (state: IGlobalState) => { state.category },
|
||||
@@ -258,10 +284,22 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
return false
|
||||
},
|
||||
|
||||
getSchedeOpt: (state: IGlobalState) => {
|
||||
getSchedeOpt: (state: IGlobalState) => (tag?: string) => {
|
||||
const Products = useProducts()
|
||||
|
||||
return Products.getSchedeOpt(state.myschedas)
|
||||
return Products.getSchedeOpt(state.myschedas, tag)
|
||||
},
|
||||
|
||||
getLinkIdTemplateByName: (state: IGlobalState) => (name: string) => {
|
||||
|
||||
try {
|
||||
const myrecscheda = state.myschedas.find((recscheda: ISchedaSingola) => recscheda.scheda.name === name)
|
||||
|
||||
return myrecscheda.scheda._id
|
||||
} catch (error) {
|
||||
return ''
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
isMyLang: (state: IGlobalState) => (rec: any) => {
|
||||
@@ -2393,6 +2431,21 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
})
|
||||
},
|
||||
|
||||
createCatalogoVuoto(): IOptCatalogo {
|
||||
return {
|
||||
productTypes: [0],
|
||||
excludeproductTypes: [],
|
||||
formato: [],
|
||||
Categoria: [],
|
||||
editore: [],
|
||||
pdf: false,
|
||||
dimensioni_def: {
|
||||
pagina: tools.resetRecIDimensioni(null)
|
||||
},
|
||||
areadistampa: tools.resetRecIAreaDiStampa(null),
|
||||
}
|
||||
},
|
||||
|
||||
async prepareAddNewElem(order: any, $q: any, t: any, myelem: any, newtype: any) {
|
||||
|
||||
const newrec: IMyElem = {
|
||||
@@ -2411,30 +2464,11 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
} else if (newrec.type === shared_consts.ELEMTYPE.CARD) {
|
||||
newrec.class2 = 'row justify-center'
|
||||
} else if (newrec.type === shared_consts.ELEMTYPE.SEARCHPRODUCT) {
|
||||
newrec.catalogo = {
|
||||
productTypes: [0],
|
||||
excludeproductTypes: [],
|
||||
formato: [],
|
||||
Categoria: [],
|
||||
editore: [],
|
||||
pdf: false,
|
||||
dimensioni_def: {
|
||||
pagina: tools.resetRecIDimensioni(null)
|
||||
},
|
||||
}
|
||||
|
||||
newrec.catalogo = this.createCatalogoVuoto()
|
||||
|
||||
} else if (newrec.type === shared_consts.ELEMTYPE.CATALOGO) {
|
||||
newrec.catalogo = {
|
||||
//++AddCATALOGO_FIELDS
|
||||
productTypes: [0],
|
||||
excludeproductTypes: [],
|
||||
formato: [],
|
||||
Categoria: [],
|
||||
editore: [],
|
||||
pdf: false,
|
||||
dimensioni_def: {
|
||||
pagina: tools.resetRecIDimensioni(null)
|
||||
},
|
||||
}
|
||||
newrec.catalogo = this.createCatalogoVuoto()
|
||||
}
|
||||
|
||||
const mynewrec = await this.addNewElem($q, t, newrec)
|
||||
|
||||
@@ -410,33 +410,6 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
|
||||
function sovrascriviSchedaFromTemplate(idTemplate: string, origScheda: ISchedaSingola) {
|
||||
if (!optcatalogo.value)
|
||||
return
|
||||
|
||||
const arrschede: ISchedaSingola[] = globalStore.getMySchede()
|
||||
const myfindscheda = arrschede.find((recscheda: ISchedaSingola) => recscheda.scheda?._id === idTemplate)
|
||||
|
||||
const mynewscheda = tools.jsonCopy(origScheda)
|
||||
|
||||
const linkIdTemplate = origScheda.scheda?.linkIdTemplate
|
||||
const precname = origScheda.scheda?.name
|
||||
|
||||
if (myfindscheda) {
|
||||
const myschedatocopy = tools.jsonCopy(myfindscheda)
|
||||
|
||||
if (myschedatocopy) {
|
||||
myschedatocopy.scheda._id = origScheda.scheda?._id
|
||||
myschedatocopy.scheda.isTemplate = false
|
||||
myschedatocopy.scheda.name = precname
|
||||
myschedatocopy.scheda.linkIdTemplate = linkIdTemplate
|
||||
|
||||
return myschedatocopy.scheda
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function populateDataWithlinkIdTemplate() {
|
||||
// console.log('populateDataWithlinkIdTemplate')
|
||||
@@ -446,15 +419,14 @@ export default defineComponent({
|
||||
for (const recscheda of optcatalogo.value.arrSchede!) {
|
||||
if (recscheda.scheda?.linkIdTemplate) {
|
||||
// ricopia da Template:
|
||||
const myscheda = sovrascriviSchedaFromTemplate(recscheda.scheda?.linkIdTemplate, recscheda)
|
||||
const myscheda = globalStore.sovrascriviSchedaFromTemplate(recscheda.scheda?.linkIdTemplate, recscheda)
|
||||
if (myscheda) {
|
||||
recscheda.scheda = myscheda
|
||||
recscheda.scheda = { ...myscheda }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(' FINE - populateDataWithlinkIdTemplate')
|
||||
}
|
||||
|
||||
@@ -586,12 +558,12 @@ export default defineComponent({
|
||||
// Se nel catalogo è stato già generato, allora gli passo quello.
|
||||
const trovatocatalogo = getCatalogoByMyPage.value
|
||||
|
||||
if (trovatocatalogo.lista_prodotti.length === 0) {
|
||||
if (trovatocatalogo?.lista_prodotti.length === 0) {
|
||||
generalista = true
|
||||
}
|
||||
|
||||
if (!generalista && (trovatocatalogo.lista_prodotti.length > 0)) {
|
||||
arrprod = trovatocatalogo.lista_prodotti
|
||||
if (!generalista && (trovatocatalogo?.lista_prodotti.length > 0)) {
|
||||
arrprod = trovatocatalogo?.lista_prodotti
|
||||
} else {
|
||||
arrprod = productStore.getProducts(cosa.value)
|
||||
arrprod = filterProducts(
|
||||
@@ -615,7 +587,7 @@ export default defineComponent({
|
||||
|
||||
arrProducts.value = arrprod;
|
||||
|
||||
console.log('arrprod', arrprod)
|
||||
// console.log('arrprod', arrprod)
|
||||
|
||||
populateDataWithlinkIdTemplate();
|
||||
generatearrProdToViewSorted(!generalista, salva);
|
||||
@@ -625,7 +597,17 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function generaListaLibri() {
|
||||
// chiedi prima "Sei sicuro di rigenerare il catalogo?"
|
||||
let risposta_si = false
|
||||
|
||||
$q.dialog({
|
||||
title: 'Genera catalogo',
|
||||
message: 'Sei sicuro di rigenerare il catalogo?',
|
||||
cancel: true,
|
||||
persistent: true
|
||||
}).onOk(() => {
|
||||
calcArrProducts(true)
|
||||
})
|
||||
}
|
||||
|
||||
function getProductsFilteredByScheda(scheda: IMyScheda): IProduct[] {
|
||||
@@ -644,8 +626,8 @@ export default defineComponent({
|
||||
const gasselstr = cosa.value === shared_consts.PROD.GAS ? idGasSel.value || '' : '';
|
||||
|
||||
const trovatocatalogo = getCatalogoByMyPage.value
|
||||
if (trovatocatalogo.lista_prodotti.length > 0) {
|
||||
arrprod = trovatocatalogo.lista_prodotti
|
||||
if (trovatocatalogo?.lista_prodotti.length > 0) {
|
||||
arrprod = trovatocatalogo?.lista_prodotti
|
||||
} else {
|
||||
|
||||
arrprod = filterProducts(
|
||||
@@ -754,7 +736,7 @@ export default defineComponent({
|
||||
|
||||
let arrGeneraleProdotti = []
|
||||
|
||||
if (usaprodottiSalvati) {
|
||||
if (usaprodottiSalvati && trovatocatalogo?.lista_prodotti.length > 0) {
|
||||
|
||||
} else {
|
||||
arrGeneraleProdotti = arrProducts.value;
|
||||
@@ -775,8 +757,8 @@ export default defineComponent({
|
||||
|
||||
let arrProdFiltrati: IProduct[] = []
|
||||
|
||||
if (usaprodottiSalvati && trovatocatalogo.lista_prodotti.length > 0) {
|
||||
arrProdFiltrati = trovatocatalogo.lista_prodotti
|
||||
if (usaprodottiSalvati && trovatocatalogo?.lista_prodotti.length > 0) {
|
||||
arrProdFiltrati = trovatocatalogo?.lista_prodotti
|
||||
} else {
|
||||
if (recscheda.scheda.productTypes!.length > 0) {
|
||||
// Filtra i prodotti in base ai filtri impostati !
|
||||
@@ -860,10 +842,12 @@ export default defineComponent({
|
||||
|
||||
|
||||
if (!usaprodottiSalvati && salva) {
|
||||
if (trovatocatalogo) {
|
||||
trovatocatalogo.lista_prodotti = arrprod
|
||||
|
||||
salvaListaProdotti(false)
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e)
|
||||
@@ -1234,10 +1218,12 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function updateProducts(arr: any) {
|
||||
if (getCatalogoByMyPage.value) {
|
||||
getCatalogoByMyPage.value.lista_prodotti = [...arr]
|
||||
|
||||
salvaListaProdotti(true)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
>
|
||||
</q-tab>
|
||||
<q-tab
|
||||
v-if="lista_prodotti"
|
||||
name="lista"
|
||||
icon="fas fa-list"
|
||||
label="Lista"
|
||||
@@ -61,6 +62,13 @@
|
||||
name="lista"
|
||||
v-if="optcatalogo"
|
||||
>
|
||||
<q-btn
|
||||
rounded
|
||||
label="Rigenera Lista Libri"
|
||||
color="primary"
|
||||
@click="generaListaLibri()"
|
||||
></q-btn>
|
||||
|
||||
<CProductTable
|
||||
:lista_prodotti="lista_prodotti"
|
||||
@update:lista_prodotti="updateProducts"
|
||||
@@ -554,12 +562,6 @@
|
||||
</div>
|
||||
</q-tab-panel>
|
||||
<q-tab-panel name="opzioni">
|
||||
<q-btn
|
||||
rounded
|
||||
label="Genera Lista Libri"
|
||||
color="primary"
|
||||
@click="generaListaLibri()"
|
||||
></q-btn>
|
||||
<pre>
|
||||
<strong>PASSI DA COMPIERE PER FARE AGGIORNAMENTI :</strong>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user