- catalogo

- corretto logica del RefreshToken che non richiedeva il nuovo token, quindi scadeva tutte le volte, richiedendo sempre l'accesso !
This commit is contained in:
Surya Paolo
2025-01-07 17:17:08 +01:00
parent ce86dd51a8
commit 3734762a8b
72 changed files with 2112 additions and 3592650 deletions

View File

@@ -129,6 +129,37 @@ export const Api = {
throw error
}
},
async checkTokenScaduto(status: number, evitaloop: boolean, resolve: any, reject: any, url: string, method: string, mydata: any, setAuthToken = false) {
const userStore = useUserStore()
const $router = useRouter()
if (status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED) {
try {
console.log('Token Scaduto.')
const newAccessToken = await this.refreshToken();
if (newAccessToken) {
userStore.setAuth(newAccessToken, userStore.refreshToken);
if (!evitaloop) {
console.log('uso il RefreshToken...')
return resolve(this.SendReq(url, method, mydata, setAuthToken, true));
}
} else {
$router.push('/signin')
}
} catch (err2: any) {
console.error('err2, Token Invalido', err2)
if (err2?.code === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
userStore.setServerCode(toolsext.ERR_AUTHENTICATION)
userStore.setAuth('', '')
return reject({ code: toolsext.ERR_AUTHENTICATION })
}
}
return null
}
},
async SendReqBase(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false, myformdata?: any, responsedata?: any): Promise<Types.AxiosSuccess | Types.AxiosError> {
@@ -146,8 +177,8 @@ export const Api = {
userStore.setResStatus(0)
return new Promise((resolve, reject) => sendRequest(url, method, mydataout, myformdata, responsedata)
.then((res) => {
setTimeout(() => {
.then(async (res) => {
setTimeout( () => {
if (method === 'get') {
globalStore.connData.downloading_server = 0
} else {
@@ -164,6 +195,12 @@ export const Api = {
return reject({ code: toolsext.ERR_AUTHENTICATION })
}
}
const ret = await this.checkTokenScaduto(res.status, evitaloop, resolve, reject, url, method, mydataout, setAuthToken)
if (ret) {
return ret
}
if (tools.isDebug())
console.log(' ----> ', res)
return resolve(res)
@@ -178,27 +215,9 @@ export const Api = {
}
}, 1000)
if (error.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED) {
try {
console.log('Token Scaduto.')
const newAccessToken = await this.refreshToken();
if (newAccessToken) {
userStore.setAuth(newAccessToken, userStore.refreshToken);
if (!evitaloop) {
console.log('uso il RefreshToken...')
return resolve(this.SendReq(url, method, mydata, setAuthToken, true));
}
} else {
$router.push('/signin')
}
} catch (err2: any) {
console.error('err2, Token Invalido', err2)
if (err2?.code === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
userStore.setServerCode(toolsext.ERR_AUTHENTICATION)
userStore.setAuth('', '')
return reject({ code: toolsext.ERR_AUTHENTICATION })
}
}
const ret = await this.checkTokenScaduto(error.status, evitaloop, resolve, reject, url, method, mydataout, setAuthToken)
if (ret) {
return ret
}
console.log('ERROR', error)
@@ -206,6 +225,7 @@ export const Api = {
}))
},
/**
* Creates a Promise that resolves after a specified number of milliseconds.
* Useful for creating delayed operations or pause in async functions.
@@ -229,7 +249,7 @@ export const Api = {
* // Usage with Promise chaining
* delay(1000).then(() => console.log('1 second passed'));
*/
async delay (ms: number): Promise<void> {
async delay(ms: number): Promise<void> {
// Input validation
if (ms < 0) {
throw new Error('Delay time cannot be negative');
@@ -253,7 +273,13 @@ export const Api = {
const response = await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop, myformdata, responsedata);
return response;
} catch (error: any) {
if (retryCount > 0) {
let riprova = true
try {
riprova = (error.status !== 403);
} catch (e) {
}
if (retryCount > 0 && riprova) {
// (!error.hasOwnProperty('data') || (error.hasOwnProperty('data') && !error.data.error.hasOwnProperty('code')) && (!error.hasOwnProperty('msgerr')))
console.log(`❌❌❌ Retrying request. Attempts remaining: ${retryCount}`);
await this.delay(retryDelay);

View File

@@ -29,7 +29,7 @@ export const costanti = {
'excludeproductTypes',
'misure',
'Categoria',
'Editore',
'editore',
'pdf',
'Printable',
'numschede_perCol',
@@ -473,7 +473,7 @@ export const costanti = {
Nessuno: 0,
Entrata: 1,
Uscita: -1,
},
},
FieldTypeArr: [
{ label: 'Boolean', value: 1 },
@@ -500,8 +500,4 @@ export const costanti = {
TESTO_BORDATO: 5,
},
SORT_DEFAULT: 0,
SORT_PUBDATE: 1,
SORT_BESTSELLER: 2,
}

View File

@@ -103,6 +103,7 @@ function AddCol(params: IColGridTable) {
filter_field: (params.filter_field === undefined) ? '' : params.filter_field,
isadvanced_field: (params.isadvanced_field === undefined) ? false : params.isadvanced_field,
path: (params.path === undefined) ? '' : params.path,
onlyforAdmin: (params.onlyforAdmin === undefined) ? false : params.onlyforAdmin,
}
}
@@ -188,10 +189,13 @@ export const colmyScheda = [
AddCol({ name: 'productTypes', label_trans: 'productTypes', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'excludeproductTypes', label_trans: 'excludeproductTypes', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'Editore', label_trans: 'Editore' }),
AddCol({ name: 'author', label_trans: 'author' }),
AddCol({ name: 'sort', label_trans: 'catalogo.sort', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'arrProdottiSpeciali', label_trans: 'Editore' }),
AddCol({ name: 'editore', label_trans: 'editore' }),
AddCol({ name: 'author', label_trans: 'scheda.author' }),
AddCol({ name: 'argomenti', label_trans: 'scheda.argomenti' }),
AddCol({ name: 'idCollana', label_trans: 'scheda.idCollana' }),
AddCol({ name: 'sort_field', label_trans: 'catalogo.sort_field', fieldtype: costanti.FieldType.string }),
AddCol({ name: 'sort_dir', label_trans: 'catalogo.sort_dir', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'arrProdottiSpeciali', label_trans: 'editore' }),
]
export const colmyelCatalogo = [
@@ -199,7 +203,9 @@ export const colmyelCatalogo = [
AddCol({ name: 'excludeproductTypes', label_trans: 'excludeproductTypes', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'pdf', label_trans: 'pdf' }),
AddCol({ name: 'pdf_filename', label_trans: 'pdf_filename' }),
AddCol({ name: 'Editore', label_trans: 'Editore' }),
AddCol({ name: 'editore', label_trans: 'editore' }),
AddCol({ name: 'argomenti', label_trans: 'scheda.argomenti' }),
AddCol({ name: 'idCollana', label_trans: 'scheda.idCollana' }),
AddCol({ name: 'width', label_trans: 'width', fieldtype: costanti.FieldType.string }),
AddCol({ name: 'height', label_trans: 'height', fieldtype: costanti.FieldType.string }),
AddCol({ name: 'optcatalogo.', label_trans: 'catalogo.optcatalogo.', fieldtype: costanti.FieldType.number }),
@@ -280,6 +286,7 @@ export const colmsg_templates = [
]
export const colmypage = [
AddCol({ name: '_id', label_trans: 'index', fieldtype: costanti.FieldType.string }),
AddCol({ name: 'path', label_trans: 'pages.path' }),
AddCol({ name: 'icon', label_trans: 'pages.icon' }),
AddCol({ name: 'order', label_trans: 'pages.order', fieldtype: costanti.FieldType.number }),
@@ -497,12 +504,20 @@ export const colTablecategories = [
export const colTableCatProd = [
AddCol({ name: 'name', label_trans: 'categories.name' }),
AddCol({ name: 'descr_estesa', label_trans: 'categories.descr_estesa' }),
AddCol({ name: 'img', label_trans: 'categories.img' }),
AddCol({ name: 'icon', label_trans: 'categories.icon' }),
AddCol({ name: 'color', label_trans: 'categories.color' }),
AddCol(DeleteRec),
AddCol(DuplicateRec),
]
export const colTableCollane = [
AddCol({ name: 'idCollana', label_trans: 'collane.idCollana', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'descrizione', label_trans: 'collane.descrizione' }),
AddCol({ name: 'descrizione_estesa', label_trans: 'collane.descrizione_estesa' }),
AddCol(DeleteRec),
AddCol(DuplicateRec),
]
export const colTableCatAI = [
AddCol({ name: 'name', label_trans: 'categories.name' }),
@@ -2317,6 +2332,12 @@ export const colTableProductInfos = [
fieldtype: costanti.FieldType.multiselect,
jointable: 'catprods',
}),
AddCol({
name: 'idCollana',
label_trans: 'products.category',
fieldtype: costanti.FieldType.select,
jointable: 'collanas',
}),
AddCol({ name: 'color', label_trans: 'products.color' }),
AddCol({ name: 'size', label_trans: 'products.size' }),
AddCol({ name: 'weight', label_trans: 'products.weight', fieldtype: costanti.FieldType.number }),
@@ -3600,11 +3621,17 @@ export const colTableCircuitComplete = [
AddCol({ name: 'qta_max_default', label_trans: 'circuit.qta_max_default', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'fido_scoperto_default_grp', label_trans: 'circuit.fido_scoperto_default_grp', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'qta_max_default_grp', label_trans: 'circuit.qta_max_default_grp', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'fido_scoperto_default_contocom', label_trans: 'circuit.fido_scoperto_default_contocom', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'qta_max_default_contocom', label_trans: 'circuit.qta_max_default_contocom', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'data_costituz', label_trans: 'circuit.data_costituz', fieldtype: costanti.FieldType.date }),
AddCol({ name: 'deperimento', label_trans: 'circuit.deperimento', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'showAlways', label_trans: 'circuit.showAlways', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'ignoreLimits', label_trans: 'circuit.ignoreLimits', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'transactionsEnabled', label_trans: 'circuit.transactionsEnabled', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'showAlways', label_trans: 'circuit.showAlways', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'ignoreLimits', label_trans: 'circuit.ignoreLimits', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'transactionsEnabled', label_trans: 'circuit.transactionsEnabled', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'askManagerToEnter', label_trans: 'circuit.askManagerToEnter', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'sendEmailAfterAskingToEnter', label_trans: 'circuit.sendEmailAfterAskingToEnter', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'circuitoIndipendente', label_trans: 'circuit.circuitoIndipendente', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'creditodiPartenza', label_trans: 'circuit.creditodiPartenza', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'freq_deper', label_trans: 'circuit.freq_deper' }),
AddCol({ name: 'minuto_deper', label_trans: 'circuit.minuto_deper', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'ora_deper', label_trans: 'circuit.ora_deper', fieldtype: costanti.FieldType.number }),
@@ -3641,6 +3668,9 @@ export const colTableCircuitComplete = [
sortable: true,
showWhen: 0
}),
AddCol({ name: 'circuitoIndipendente', label_trans: 'circuit.circuitoIndipendente', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'askManagerToEnter', label_trans: 'circuit.askManagerToEnter', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'sendEmailAfterAskingToEnter', label_trans: 'circuit.sendEmailAfterAskingToEnter', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol(ModifRec),
AddCol(DeleteRec),
AddCol(DuplicateRec),
@@ -3693,10 +3723,12 @@ export const colTableCircuit = [
fieldtype: costanti.FieldType.multiselect,
jointable: 'visibilGroup',
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
onlyforAdmin: true,
}),
AddCol({
name: 'systemUserId', label_trans: 'circuit.systemUserId', fieldtype: costanti.FieldType.select, jointable: 'users',
showWhen: costanti.showWhen.InEdit + costanti.showWhen.InView,
onlyforAdmin: true
}),
AddCol({
name: 'createdBy', label_trans: 'circuit.founder', fieldtype: costanti.FieldType.select, jointable: 'users',
@@ -3730,6 +3762,8 @@ export const colTableCircuit = [
}),
AddCol({ name: 'fido_scoperto_default_grp', label_trans: 'circuit.fido_scoperto_default_grp', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'qta_max_default_grp', label_trans: 'circuit.qta_max_default_grp', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'fido_scoperto_default_contocom', label_trans: 'circuit.fido_scoperto_default_contocom', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'qta_max_default_contocom', label_trans: 'circuit.qta_max_default_contocom', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'valuta_per_euro', label_trans: 'circuit.valuta_per_euro', fieldtype: costanti.FieldType.number }),
AddCol({
name: 'totCircolante', label_trans: 'circuit.totCircolante',
@@ -3743,14 +3777,19 @@ export const colTableCircuit = [
}),
AddCol({ name: 'regulation', label_trans: 'circuit.regulation', fieldtype: costanti.FieldType.html, required: false }),
AddCol({ name: 'deperimento', label_trans: 'circuit.deperimento', fieldtype: costanti.FieldType.boolean, disable: true }),
AddCol({ name: 'showAlways', label_trans: 'circuit.showAlways', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'ignoreLimits', label_trans: 'circuit.ignoreLimits', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'transactionsEnabled', label_trans: 'circuit.transactionsEnabled', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'showAlways', label_trans: 'circuit.showAlways', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'ignoreLimits', label_trans: 'circuit.ignoreLimits', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'transactionsEnabled', label_trans: 'circuit.transactionsEnabled', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'askManagerToEnter', label_trans: 'circuit.askManagerToEnter', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'sendEmailAfterAskingToEnter', label_trans: 'circuit.sendEmailAfterAskingToEnter', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'circuitoIndipendente', label_trans: 'circuit.circuitoIndipendente', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true }),
AddCol({ name: 'creditodiPartenza', label_trans: 'circuit.creditodiPartenza', fieldtype: costanti.FieldType.number }),
AddCol({
name: 'status', label_trans: 'circuit.status',
fieldtype: costanti.FieldType.select,
jointable: 'statuscircuit',
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
onlyforAdmin: true
}
),
AddCol({ name: 'data_costituz', label_trans: 'circuit.data_costituz', fieldtype: costanti.FieldType.date }),
@@ -4110,6 +4149,13 @@ export const fieldsTable = {
colkey: '_id',
collabel: 'name',
},
{
value: 'collanas',
label: 'Collane',
columns: colTableCollane,
colkey: 'idCollana',
collabel: 'descrizione',
},
{
value: 'catais',
label: 'Categorie AI',

View File

@@ -6616,6 +6616,10 @@ export const tools = {
check = check && tools.isBitActive(col.showWhen, costanti.showWhen.InPage)
}
if (col.onlyforAdmin) {
check = check && tools.isAdmin()
}
return check
@@ -6648,14 +6652,23 @@ export const tools = {
setRequestCircuit($q: any, username: string, circuitname: string, value: boolean, groupname?: string) {
const userStore = useUserStore()
const circuitStore = useCircuitStore()
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REQ, value, { groupname })
.then((res: any) => {
if (res) {
if (value) {
const mycircuit = circuitStore.getCircuitByName(circuitname)
let msg = t('circuit.already_entered', { circuitname })
if (mycircuit?.askManagerToEnter) {
msg = t('circuit.askedto', { circuitname })
}
// ADD to req
userStore.my.profile.asked_circuits.push(res.circuit)
tools.showPositiveNotif($q, t('circuit.askedto', { circuitname }))
tools.showPositiveNotif($q, msg)
} else {
// REMOVE to req
userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname)
@@ -6744,7 +6757,7 @@ export const tools = {
userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname)
}
this.updateMyData(res)
tools.showPositiveNotif($q, t('circuit.cancel_req'))
tools.showPositiveNotif($q, t('circuit.cancel_req', { circuitname }))
}
})
})
@@ -7384,6 +7397,8 @@ export const tools = {
qta_max_default: 200,
fido_scoperto_default_grp: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP,
qta_max_default_grp: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_GRP,
fido_scoperto_default_contocom: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO,
qta_max_default_contocom: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO,
valuta_per_euro: 1,
totTransato: 0,
totCircolante: 0,

View File

@@ -13,7 +13,6 @@ import { useGlobalStore } from './globalStore'
import { ref } from 'vue'
import translate from '@src/globalroutines/util'
import products from '@src/rootgen/admin/products/products'
function getRecordOrdersCartEmpty(): IOrderCart {
return {
@@ -149,6 +148,27 @@ export const useProducts = defineStore('Products', {
return arrcat
},
getCatProdsStrByCatProds: (state: IProductsState) => (catProds: ICatProd[]): string => {
let mystr = ''
for (const catprod of catProds) {
const myarrcat = state.catprods.find((rec: ICatProd) => rec._id === catprod)
if (myarrcat) {
if (mystr)
mystr = ' - '
mystr += myarrcat.name
}
}
return mystr
},
getCatProdDescrStrByIdCatProd: (state: IProductsState) => (idCatProd: string): string => {
const myfirstcat = state.catprods.find((rec: ICatProd) => rec._id === idCatProd)
if (myfirstcat) {
return myfirstcat.descr_estesa!
}
return ''
},
getSubCatProdsByGas: (state: IProductsState) => (idGasOrdine: string, idCatProd: string): ISubCatProd[] => {
let arrcat = state.subcatprods
@@ -1267,6 +1287,14 @@ export const useProducts = defineStore('Products', {
return authorString
},
getkeyValStr(chiave: string, valore: any) {
try {
return ` ${chiave} = ${valore} `
} catch (e) {
return ` ${chiave}`
}
},
replaceKeyWordsByProduct(optcatalogo: ICatalogo, myproduct: IProduct, testo: IText) {
if (!myproduct || !testo.contenuto) {
return testo.contenuto;
@@ -1279,23 +1307,33 @@ export const useProducts = defineStore('Products', {
const description = myproduct.productInfo.short_descr || '';
const long_descr = myproduct.productInfo.description || '';
const date_pub = tools.getstrDateShort(myproduct.productInfo.date_pub) || '';
const fatLast3M = myproduct.productInfo.fatLast3M! || 0;
const vLast3M = myproduct.productInfo.vLast3M! || 0;
const vLast6M = myproduct.productInfo.vLast6M! || 0;
const ranking_globale = myproduct.productInfo.rank3M! || 0;
const ranking = myproduct.indiceRanking! || 0;
const venduti = myproduct.productInfo.totVen! || 0;
const fatturati = myproduct.productInfo.totFat! || 0;
const linkvenduti = '<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-ordini-by-idarticolo/' + myproduct.productInfo.sku + '" target="_blank">'+venduti+'</a>'
const debugstr = " Rank=" + ranking + "<br> Rank3M=" + (myproduct.productInfo.rank3M! || '') + '<br> Venduti=' + linkvenduti + '<br>vLast3M= ' + vLast3M + '<br>vLast6M= ' + vLast6M + ' <br> Data Pubb=' + date_pub
const linkvenduti = '<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-ordini-by-idarticolo/' + myproduct.productInfo.sku + '" target="_blank">' + venduti + '</a>'
const linkfatturati = '<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-fatturati-by-idarticolo/' + myproduct.productInfo.sku + '" target="_blank">' + fatturati + '</a>'
const debugstr = this.getkeyValStr('Pubblicato il', date_pub) +
this.getkeyValStr('Rank', ranking) +
this.getkeyValStr('Rank3M', myproduct.productInfo.rank3M) +
this.getkeyValStr('Venduti', linkvenduti) +
this.getkeyValStr('vLast3M', vLast3M) +
this.getkeyValStr('vLast6M', vLast6M) +
this.getkeyValStr('Fatturati', linkfatturati) +
this.getkeyValStr('fatLast3M', fatLast3M)
const truncatedDescription = description.length > maxDescriptionLength
? description.substring(0, description.lastIndexOf(' ', maxDescriptionLength)) + '...'
: description;
const truncatedlongDescription = long_descr.length > maxDescriptionLength
? long_descr.substring(0, long_descr.lastIndexOf(' ', maxDescriptionLength)) + '...'
: long_descr;
let addtesto = false
const long_descr_macro = myproduct.productInfo.descrizione_completa_macro || '';
@@ -1316,17 +1354,20 @@ export const useProducts = defineStore('Products', {
const descrizione_breve_macro = short_descr.length > maxDescriptionLength
? short_descr.substring(0, short_descr.lastIndexOf(' ', maxDescriptionLength)) + '...'
: short_descr;
const sottotitolo = myproduct.productInfo.sottotitolo || '';
const link_macro = myproduct.productInfo.link_macro || '';
const prezzo = tools.arrotonda2Dec(myproduct.arrvariazioni![0].price) || ''
const prezzo_scontato = tools.arrotonda2Dec(myproduct.arrvariazioni![0].sale_price) || ''
const misure = myproduct.arrvariazioni![0].misure || ''
const formato = myproduct.arrvariazioni![0].formato || ''
const pagine = myproduct.arrvariazioni![0].pagine || ''
const categoria = this.getCatProdsStrByCatProds(myproduct.productInfo.catprods!)
const sottocategoria = myproduct.productInfo.subcatprods && myproduct.productInfo.subcatprods.length > 0 ? myproduct.productInfo.subcatprods[0].name! : ''
const descr_categoria = myproduct.productInfo.catprods ? this.getCatProdDescrStrByIdCatProd(myproduct.productInfo.catprods![0]) : ''
const misure = myproduct.arrvariazioni![0].misure || ''
const formato = myproduct.arrvariazioni![0].formato || ''
const pagine = myproduct.arrvariazioni![0].pagine || ''
const scale = optcatalogo.printable ? optcatalogo.areadistampa?.scale : 1
// Crea una mappa di sostituzioni
const replacements = {
@@ -1337,7 +1378,10 @@ export const useProducts = defineStore('Products', {
'{descrizione_estesa_fdv}': truncatedlongDescription || '',
'{descrizione_estesa}': descrizione_completa_macro || '',
'{debug}': (debugstr) || '',
'{pagine}': (pagine ) || '',
'{categoria}': (categoria) || '',
'{sottocategoria}': (sottocategoria) || '',
'{descr_categoria}': (descr_categoria) || '',
'{pagine}': (pagine) || '',
'{misure}': misure || '',
'{date_pub}': date_pub || '',
'{ranking_globale}': ranking_globale || '',

View File

@@ -321,7 +321,7 @@ export const useUserStore = defineStore('UserStore', {
GroupsListWhereIAmAdminInTheCircuit(circuitname: string): any {
try {
const arr: any = this.my.profile.manage_mygroups.filter((group: IMyGroup) => (group.mycircuits!.findIndex((circ: IMyCircuit) => circ.circuitname === circuitname) >= 0))
console.log('arr', arr)
// console.log('arr', arr)
return arr
} catch (e) {
return []

View File

@@ -1019,7 +1019,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
await globalroutines('readall', 'config', null)
this.editOn = tools.getCookie('edn', '0') === '1'
if (tools.isLogged()) {
this.editOn = tools.getCookie('edn', '0') === '1'
}
return isok
},
@@ -1727,6 +1729,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
this.providers = (res.data.providers) ? [...res.data.providers] : []
Products.catprods = (res.data.catprods) ? [...res.data.catprods] : []
Products.collane = (res.data.collane) ? [...res.data.collane] : []
Products.subcatprods = (res.data.subcatprods) ? [...res.data.subcatprods] : []
Products.catprods_gas = (res.data.catprods_gas) ? [...res.data.catprods_gas] : []
Products.authors = (res.data.authors) ? [...res.data.authors] : []
@@ -2303,7 +2306,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
excludeproductTypes: [],
formato: [],
Categoria: [],
Editore: [],
editore: [],
pdf: false,
dimensioni_def: {
pagina: tools.resetRecIDimensioni(null)