- generato lista libri, con possibilità di cambiare l'ordinamento dei libri o di cancellare libri.

This commit is contained in:
Surya Paolo
2025-04-01 18:36:45 +02:00
parent 61c1dc3d0d
commit 79d1c5fe1d
15 changed files with 507 additions and 302 deletions

View File

@@ -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'
@@ -163,7 +166,7 @@ export const useProducts = defineStore('Products', {
mystr = ' - '
mystr += myarrcat.name
}
}
}
return mystr
},
@@ -1529,7 +1532,7 @@ export const useProducts = defineStore('Products', {
},
getSchedeOpt(arrschede: IMyScheda[]): any[] {
getSchedeOpt(arrschede: ISchedaSingola[], tag?: string): any[] {
let arr: any = []
@@ -1547,7 +1550,9 @@ export const useProducts = defineStore('Products', {
pagename = '[Pag: ' + pagename + '] '
const mylabel = pagename + (recscheda.scheda ? recscheda.scheda!.name : '')
arr.push({ label: mylabel, value: recscheda.scheda!._id })
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,
}
)
}
},

View File

@@ -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)