- Catalogo: Aggiunta di Schede
This commit is contained in:
@@ -109,7 +109,7 @@ export const Api = {
|
||||
// Reset the refresh token if it was reset by the server
|
||||
if (response.data.refreshToken) {
|
||||
// console.log('salva refreshtoken', response.data.refreshToken)
|
||||
userStore.setRefreshToken(response.data.refreshToken)
|
||||
userStore.setRefreshToken(response.data.refreshToken)
|
||||
}
|
||||
|
||||
// Return the new access token
|
||||
@@ -131,27 +131,22 @@ export const Api = {
|
||||
|
||||
},
|
||||
|
||||
async SendReq(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
async SendReqBase(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
const mydataout = {
|
||||
...mydata,
|
||||
keyappid: process.env.PAO_APP_ID,
|
||||
idapp: process.env.APP_ID,
|
||||
}
|
||||
|
||||
// console.log('INIZIO - SendReq', url)
|
||||
// console.log('mydata', mydata)
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
const $router = useRouter()
|
||||
|
||||
userStore.setServerCode(tools.EMPTY)
|
||||
userStore.setResStatus(0)
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
|
||||
return new Promise((resolve, reject) => sendRequest(url, method, mydataout)
|
||||
.then((res) => {
|
||||
// console.log('status:', res.status)
|
||||
|
||||
setTimeout(() => {
|
||||
if (method === 'get') {
|
||||
globalStore.connData.downloading_server = 0
|
||||
@@ -164,11 +159,8 @@ export const Api = {
|
||||
if (res.status) {
|
||||
userStore.setResStatus(res.status)
|
||||
if (res.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
// Forbidden
|
||||
// You probably is connectiong with other page...
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION)
|
||||
userStore.setAuth('', '')
|
||||
// $router.push('/signin')
|
||||
return reject({ code: toolsext.ERR_AUTHENTICATION })
|
||||
}
|
||||
}
|
||||
@@ -187,41 +179,92 @@ export const Api = {
|
||||
}, 1000)
|
||||
|
||||
if (error.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
// console.log('Token Expired')
|
||||
// Prova ad ottenere un nuovo token di accesso
|
||||
try {
|
||||
// Se il token è scaduto, allora faccio la richiesta di un NUOVO TOKEN, passandogli refreshToken
|
||||
const newAccessToken = await this.refreshToken();
|
||||
if (newAccessToken) {
|
||||
userStore.setAuth(newAccessToken, userStore.refreshToken);
|
||||
|
||||
// Riprova l'originale SendReq con il nuovo token.
|
||||
// Assicurati di evitare un loop infinito in caso di errori continui
|
||||
if (!evitaloop)
|
||||
return resolve(this.SendReq(url, method, mydata, setAuthToken, true));
|
||||
} else {
|
||||
$router.push('/signin')
|
||||
}
|
||||
} catch (err2: any) {
|
||||
// Gestisci errore di refresh token (es. redirect a signin)
|
||||
console.error('err2', err2)
|
||||
if (err2 && err2.hasOwnProperty('code') && err2.code === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
// Forbidden
|
||||
// You probably is connectiong with other page...
|
||||
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 reject(err2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log('ERROR', error)
|
||||
return reject(error)
|
||||
}))
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a Promise that resolves after a specified number of milliseconds.
|
||||
* Useful for creating delayed operations or pause in async functions.
|
||||
*
|
||||
* @param ms - The number of milliseconds to delay
|
||||
* @returns A Promise that resolves after the specified delay
|
||||
*
|
||||
* @example
|
||||
* // Basic usage
|
||||
* await delay(1000); // waits for 1 second
|
||||
*
|
||||
* @example
|
||||
* // Usage in an async function
|
||||
* async function example() {
|
||||
* console.log('Start');
|
||||
* await delay(2000);
|
||||
* console.log('2 seconds later');
|
||||
* }
|
||||
*
|
||||
* @example
|
||||
* // Usage with Promise chaining
|
||||
* delay(1000).then(() => console.log('1 second passed'));
|
||||
*/
|
||||
async delay (ms: number): Promise<void> {
|
||||
// Input validation
|
||||
if (ms < 0) {
|
||||
throw new Error('Delay time cannot be negative');
|
||||
}
|
||||
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
},
|
||||
|
||||
async SendReq(
|
||||
url: string,
|
||||
method: string,
|
||||
mydata: any,
|
||||
setAuthToken = false,
|
||||
evitaloop = false,
|
||||
retryCount = 5,
|
||||
retryDelay = 3000
|
||||
): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
try {
|
||||
const response = await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop);
|
||||
return response;
|
||||
} catch (error) {
|
||||
if (retryCount > 0) {
|
||||
console.log(`❌❌❌ Retrying request. Attempts remaining: ${retryCount}`);
|
||||
await this.delay(retryDelay);
|
||||
return this.SendReq(
|
||||
url,
|
||||
method,
|
||||
mydata,
|
||||
setAuthToken,
|
||||
evitaloop,
|
||||
retryCount - 1,
|
||||
retryDelay
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
async syncAlternative(mystrparam: string) {
|
||||
console.log('[ALTERNATIVE Background syncing', mystrparam)
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@ export const costanti = {
|
||||
CERCO: 2,
|
||||
},
|
||||
|
||||
POSIZ_TESTO: {
|
||||
IN_BASSO: 0,
|
||||
A_DESTRA: 1,
|
||||
},
|
||||
|
||||
CATALOGO_FIELDS: [
|
||||
'productTypes',
|
||||
'excludeproductTypes',
|
||||
@@ -40,6 +45,13 @@ export const costanti = {
|
||||
'margine_riga',
|
||||
'margine_paginaPrintable',
|
||||
'margine_rigaPrintable',
|
||||
'first_page_img',
|
||||
'first_page_html',
|
||||
'first_page_height',
|
||||
'last_page_img?',
|
||||
'last_page_html',
|
||||
'last_page_height',
|
||||
'text',
|
||||
],
|
||||
|
||||
TIPOFAVBOOK: {
|
||||
|
||||
@@ -147,6 +147,30 @@ export const colmylistcards = [
|
||||
AddCol({ name: 'link', label_trans: 'link' }),
|
||||
]
|
||||
|
||||
export const colmyScheda = [
|
||||
AddCol({ name: 'name', label_trans: 'scheda.name', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'isTemplate', label_trans: 'scheda.isTemplate', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'widthscheda', label_trans: 'scheda.widthscheda', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'widthpag', label_trans: 'scheda.widthpag', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'width', label_trans: 'scheda.width', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'height', label_trans: 'scheda.height', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'numschede_perCol', label_trans: 'scheda,numschede_perCol', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'numschede_perRiga', label_trans: 'scheda.numschede_perRiga', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'margine_top', label_trans: 'scheda.margine_top', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_pagina', label_trans: 'scheda.margine_pagina', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_riga', label_trans: 'scheda.margine_riga', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'text', label_trans: 'catalogo.text', fieldtype: costanti.FieldType.html }),
|
||||
AddCol({ name: 'posiz_text', label_trans: 'catalogo.posiz_text', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'line_height', label_trans: 'catalogo.line_height', fieldtype: costanti.FieldType.number }),
|
||||
|
||||
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' }),
|
||||
]
|
||||
|
||||
export const colmyelCatalogo = [
|
||||
AddCol({ name: 'productTypes', label_trans: 'productTypes', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'excludeproductTypes', label_trans: 'excludeproductTypes', fieldtype: costanti.FieldType.number }),
|
||||
@@ -154,22 +178,25 @@ export const colmyelCatalogo = [
|
||||
AddCol({ name: 'Editore', label_trans: 'Editore' }),
|
||||
AddCol({ name: 'backgroundimage', label_trans: 'backgroundimage', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'backgroundimage_printable', label_trans: 'backgroundimage_printable', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'widthscheda', label_trans: 'widthscheda', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'widthpag', label_trans: 'widthpag', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'widthpagPrintable', label_trans: 'widthpagPrintable', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'width', label_trans: 'width', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'height', label_trans: 'height', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'numschede_perCol', label_trans: 'numschede_perCol', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'numschede_perRiga', label_trans: 'numschede_perRiga', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'margine_pagina', label_trans: 'margine_pagina', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_riga', label_trans: 'margine_riga', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'optcatalogo.', label_trans: 'catalogo.optcatalogo.', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'margine_paginaPrintable', label_trans: 'margine_paginaPrintable', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_rigaPrintable', label_trans: 'margine_rigaPrintable', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'first_page_img', label_trans: 'catalogo.first_page_img', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'last_page_img', label_trans: 'catalogo.last_page_img', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'first_page_html', label_trans: 'catalogo.first_page_html', fieldtype: costanti.FieldType.html }),
|
||||
AddCol({ name: 'first_page_height', label_trans: 'catalogo.first_page_height', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'last_page_height', label_trans: 'catalogo.last_page_html', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'last_page_html', label_trans: 'catalogo.last_page_html', fieldtype: costanti.FieldType.html }),
|
||||
]
|
||||
|
||||
export const colmyelems = [
|
||||
AddCol({ name: 'active', label_trans: 'myelems.active', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'path', label_trans: 'myelems.path' }),
|
||||
AddCol({ name: 'idPage', label_trans: 'myelems.idPage' }),
|
||||
AddCol({ name: 'order', label_trans: 'myelems.order', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'type', label_trans: 'myelems.type', fieldtype: costanti.FieldType.select, jointable: 'elemtypes' }),
|
||||
AddCol({ name: 'container', label_trans: 'myelems.container' }),
|
||||
@@ -4158,6 +4185,13 @@ export const fieldsTable = {
|
||||
colkey: '_id',
|
||||
collabel: 'title',
|
||||
},
|
||||
{
|
||||
value: 'scheda',
|
||||
label: 'Elementi SCheda',
|
||||
columns: colmyScheda,
|
||||
colkey: '_id',
|
||||
collabel: 'name',
|
||||
},
|
||||
{
|
||||
value: 'listcards',
|
||||
label: 'Elementi',
|
||||
|
||||
@@ -8904,7 +8904,7 @@ export const tools = {
|
||||
|
||||
getsrcimg(gallerylist: any, dir: string) {
|
||||
|
||||
console.log('getsrcimg', gallerylist)
|
||||
// console.log('getsrcimg', gallerylist)
|
||||
|
||||
let addtourl = ''
|
||||
if (!gallerylist) {
|
||||
@@ -9109,7 +9109,7 @@ export const tools = {
|
||||
|
||||
convertStringToUrl(str: string) {
|
||||
return encodeURIComponent(str); // Codifica la stringa per URL
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// FINE !
|
||||
|
||||
@@ -131,7 +131,7 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
// Ottieni le categorie solo per i "products" che hanno come idGasOrdine il valore passato
|
||||
if (idGasOrdine) {
|
||||
arrcat = state.catprods_gas.filter((rec: ICatProd) => {
|
||||
arrcat = state.catprods_gas.filter((rec: ICatProd) => {
|
||||
const arrprod = state.products.filter((prod: IProduct) => {
|
||||
if (prod.idGasordine === idGasOrdine && prod.productInfo.idCatProds?.includes(rec._id)) {
|
||||
return true
|
||||
@@ -140,12 +140,12 @@ export const useProducts = defineStore('Products', {
|
||||
})
|
||||
return arrprod.length > 0 ? true : false
|
||||
})
|
||||
|
||||
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
|
||||
|
||||
|
||||
return arrcat
|
||||
},
|
||||
|
||||
@@ -155,9 +155,9 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
// Ottieni le categorie solo per i "products" che hanno come idGasOrdine il valore passato
|
||||
if (idGasOrdine) {
|
||||
arrcat = state.subcatprods.filter((rec: ISubCatProd) => {
|
||||
arrcat = state.subcatprods.filter((rec: ISubCatProd) => {
|
||||
const arrprod = state.products.filter((prod: IProduct) => {
|
||||
if (prod.idGasordine === idGasOrdine
|
||||
if (prod.idGasordine === idGasOrdine
|
||||
&& prod.productInfo.idSubCatProds?.includes(rec._id)
|
||||
&& prod.productInfo.idCatProds?.includes(idCatProd)
|
||||
) {
|
||||
@@ -167,7 +167,7 @@ export const useProducts = defineStore('Products', {
|
||||
})
|
||||
return arrprod.length > 0 ? true : false
|
||||
})
|
||||
|
||||
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
@@ -473,7 +473,7 @@ export const useProducts = defineStore('Products', {
|
||||
this.products = [...arrprod]
|
||||
},*/
|
||||
|
||||
async getProductById (id: string): Promise<IProduct> {
|
||||
async getProductById(id: string): Promise<IProduct> {
|
||||
let prod = null
|
||||
if (!this.products) {
|
||||
// Se non lo carico all'avvio, allora fai la chiamata al server
|
||||
@@ -481,7 +481,7 @@ export const useProducts = defineStore('Products', {
|
||||
} else {
|
||||
prod = this.products.find((prod: IProduct) => prod._id === id)
|
||||
}
|
||||
|
||||
|
||||
return prod ? prod : getRecordProductEmpty()
|
||||
},
|
||||
|
||||
@@ -1244,6 +1244,62 @@ export const useProducts = defineStore('Products', {
|
||||
return globalStore.gasordines.filter((rec) => rec.active)
|
||||
},
|
||||
|
||||
getAutoriByArrayAuthors(authors: IAuthor[] | null) {
|
||||
// Gestione degli autori
|
||||
let authorString = '';
|
||||
if (authors && Array.isArray(authors)) {
|
||||
|
||||
// Crea un array di nomi completi
|
||||
const fullNames = authors.map(author =>
|
||||
`${author.name} ${author.surname}`.trim()
|
||||
);
|
||||
|
||||
// Formattazione degli autori
|
||||
if (fullNames.length === 1) {
|
||||
authorString = fullNames[0];
|
||||
} else if (fullNames.length === 2) {
|
||||
authorString = `${fullNames[0]} e ${fullNames[1]}`;
|
||||
} else if (fullNames.length > 2) {
|
||||
const lastAuthor = fullNames.pop();
|
||||
authorString = `${fullNames.join(', ')} e ${lastAuthor}`;
|
||||
}
|
||||
}
|
||||
return authorString
|
||||
},
|
||||
|
||||
replaceKeyWordsByProduct(myproduct: IProduct, text_html: string) {
|
||||
if (!myproduct || !text_html) {
|
||||
return text_html;
|
||||
}
|
||||
|
||||
const autori = this.getAutoriByArrayAuthors(myproduct.productInfo.authors)
|
||||
|
||||
const maxDescriptionLength = 100;
|
||||
const description = myproduct.productInfo.short_descr || '';
|
||||
|
||||
const truncatedDescription = description.length > maxDescriptionLength
|
||||
? description.substring(0, description.lastIndexOf(' ', maxDescriptionLength)) + '...'
|
||||
: description;
|
||||
|
||||
const prezzo = myproduct.arrvariazioni ? myproduct.arrvariazioni[0].price?.toFixed(2) : ''
|
||||
|
||||
// Crea una mappa di sostituzioni
|
||||
const replacements = {
|
||||
'{autore}': autori || '',
|
||||
'{titolo}': myproduct.productInfo.name || '',
|
||||
'{descrizione}': truncatedDescription || '',
|
||||
'{prezzo}': prezzo || '',
|
||||
};
|
||||
|
||||
// Esegue le sostituzioni
|
||||
let result = text_html;
|
||||
for (const [key, value] of Object.entries(replacements)) {
|
||||
result = result.replace(new RegExp(key, 'g'), value);
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
ISites,
|
||||
IStatusSkill,
|
||||
StateConnection,
|
||||
IMyScheda,
|
||||
} from '@model'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
@@ -115,6 +116,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
mailinglist: [],
|
||||
mypage: [],
|
||||
myelems: [],
|
||||
myscheda: [],
|
||||
calzoom: [],
|
||||
producers: [],
|
||||
groups: [],
|
||||
@@ -269,15 +271,20 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
},
|
||||
|
||||
getPage: (state: IGlobalState) => (path: string): IMyPage | undefined => state.mypage.find((page) => (`/${page.path}`) === path),
|
||||
getPageById: (state: IGlobalState) => (idpage: string): IMyPage | undefined => state.mypage.find((page) => (`/${page._id}`) === idpage),
|
||||
|
||||
getMyElems: (state: IGlobalState) => (path: string): IMyElem[] | [] => {
|
||||
return state.myelems.filter((page: IMyElem) => (page.path === path)).sort((a: any, b: any) => a.order - b.order)
|
||||
getMyElemsByIdPage: (state: IGlobalState) => (idPage?: string): IMyElem[] | [] => {
|
||||
return state.myelems.filter((page: IMyElem) => (page._id === idPage)).sort((a: any, b: any) => a.order - b.order)
|
||||
},
|
||||
|
||||
getMyElemPrecThisElemId: (state: IGlobalState) => (path: string, idelem: string): IMyElem => {
|
||||
getMySchede: (state: IGlobalState) => (): IMyScheda[] | [] => {
|
||||
return state.myschedas
|
||||
},
|
||||
|
||||
getMyElemPrecThisElemId: (state: IGlobalState) => (idPage: string, idelem: string): IMyElem => {
|
||||
// Ottieni tutti gli myelem con lo stesso path e ordinali per order
|
||||
const sortedElems = state.myelems
|
||||
.filter((elem: IMyElem) => elem.path === path)
|
||||
.filter((elem: IMyElem) => elem.idPage === idPage)
|
||||
.sort((a: any, b: any) => a.order - b.order);
|
||||
|
||||
// Trova l'indice dell'elemento con _id = idelem
|
||||
@@ -291,10 +298,10 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
}
|
||||
},
|
||||
|
||||
getMyElemNextThisElemId: (state: IGlobalState) => (path: string, idelem: string): IMyElem => {
|
||||
// Ottieni tutti gli myelem con lo stesso path e ordinali per order
|
||||
getMyElemNextThisElemId: (state: IGlobalState) => (idPage: string, idelem: string): IMyElem => {
|
||||
// Ottieni tutti gli myelem con lo stesso idpage e ordinali per order
|
||||
const sortedElems = state.myelems
|
||||
.filter((elem: IMyElem) => elem.path === path)
|
||||
.filter((elem: IMyElem) => elem.idPage === idPage)
|
||||
.sort((a: any, b: any) => a.order - b.order);
|
||||
|
||||
// Trova l'indice dell'elemento con _id = idelem
|
||||
@@ -462,6 +469,20 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
},
|
||||
|
||||
actions: {
|
||||
getMyElems(path: string): IMyElem[] | [] {
|
||||
const mypage = this.getPage(`/${path}`)
|
||||
if (mypage) {
|
||||
const idPage = mypage._id
|
||||
let arrelems = this.myelems.filter((myelem: IMyElem) => (myelem.idPage === idPage)).sort((a: any, b: any) => a.order - b.order)
|
||||
if (arrelems.length > 0)
|
||||
return arrelems
|
||||
// Se non lo trovo per ID allora lo cerco per path
|
||||
const arrelempath = this.myelems.filter((myelem: IMyElem) => (myelem.path === path)).sort((a: any, b: any) => a.order - b.order)
|
||||
return arrelempath
|
||||
}
|
||||
return [];
|
||||
},
|
||||
|
||||
setValueSettingsByKey({ key, value, serv }: { key: string, value: any, serv: boolean }): any {
|
||||
// Update the Server
|
||||
|
||||
@@ -1176,6 +1197,26 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
})
|
||||
},
|
||||
|
||||
async duplicatePage(path: string, $q: any, t: any) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
return Api.SendReq('/duppage', 'POST', { path })
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
tools.showPositiveNotif($q, t('mypages.duplicateok'))
|
||||
return true
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('mypages.duplicateerr'))
|
||||
return false
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error loadTable', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return null
|
||||
})
|
||||
},
|
||||
|
||||
async loadPageTest() {
|
||||
|
||||
console.log('loadPageTest')
|
||||
@@ -1670,6 +1711,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
}
|
||||
this.myelems = []
|
||||
this.myelems = (res.data.myelems) ? [...res.data.myelems] : []
|
||||
this.myschedas = []
|
||||
this.myschedas = (res.data.myschedas) ? [...res.data.myschedas] : []
|
||||
// console.log('this.mypage', this.mypage)
|
||||
|
||||
let isLogged = false
|
||||
@@ -2068,7 +2111,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
// console.log('getServerHost API', myserv)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// console.log('getServerHost', myserv)
|
||||
@@ -2076,7 +2119,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
return myserv
|
||||
} catch (e) {
|
||||
return process.env.MONGODB_HOST
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -2107,6 +2150,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
table: 'myelems',
|
||||
data: {}
|
||||
}
|
||||
console.log(' DA SALVARE', myelem)
|
||||
|
||||
mydata.data = myelem
|
||||
|
||||
@@ -2119,6 +2163,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
for (let i = 0; i < this.myelems.length; i++) {
|
||||
if (this.myelems[i]._id === newelem._id) {
|
||||
this.myelems[i] = newelem;
|
||||
|
||||
console.log('SALVATO', this.myelems[i])
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2173,6 +2219,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
_id: undefined,
|
||||
type: newtype,
|
||||
path: myelem.path,
|
||||
idPage: myelem.idPage,
|
||||
order: order ? order : 1000,
|
||||
active: true,
|
||||
container: ''
|
||||
|
||||
Reference in New Issue
Block a user