- Creazione di un Nuovo Catalogo (e la sua relativa pagina), a partire da un modello ed un catalogo esistente.
- Aggiunta dei bottoni sul Ccatalogocard
This commit is contained in:
@@ -21,6 +21,8 @@ import type {
|
||||
IProductInfo,
|
||||
IVariazione,
|
||||
IDestNewsletter,
|
||||
ICatalog,
|
||||
INewCatalog,
|
||||
} from '@model';
|
||||
import { ICity, IMySkill, ISites, IMyScheda } from '@model';
|
||||
import { static_data } from '@src/db/static_data';
|
||||
@@ -391,7 +393,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
getMyPagesOptionsTemplate: (state: IGlobalState) => (): any[] => {
|
||||
return state.mypage
|
||||
.filter((page: IMyPage) => page.isTemplate === true)
|
||||
.filter((mypage: IMyPage) => mypage.isTemplate === true)
|
||||
.map((page: IMyPage) => ({
|
||||
label: page.title,
|
||||
value: page._id,
|
||||
@@ -921,6 +923,10 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
}
|
||||
},
|
||||
|
||||
async aggiornaMenu(router: Router) {
|
||||
await this.addDynamicPages(router);
|
||||
},
|
||||
|
||||
setPaoArray_Delete(state: IGlobalState) {
|
||||
state.testp1.mioarray.pop();
|
||||
},
|
||||
@@ -2131,7 +2137,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
if (page.loadFirst) page.loaded = true;
|
||||
}
|
||||
this.myelems = res.data.myelems ? [...res.data.myelems] : [];
|
||||
this.crons = res.data.crons ? [...res.data.crons] : [];
|
||||
this.lista_cron = res.data.crons ? [...res.data.crons] : [];
|
||||
this.myschedas = [];
|
||||
this.myschedas = res.data.myschedas ? [...res.data.myschedas] : [];
|
||||
// console.log('this.mypage', this.mypage)
|
||||
@@ -2236,6 +2242,67 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
});
|
||||
},
|
||||
|
||||
async addNewCatalog(newCatalog: INewCatalog, router: Router): Promise<any> {
|
||||
const catalogStore = useCatalogStore();
|
||||
|
||||
return Api.SendReq('/catalogs/addnew', 'POST', { newCatalog })
|
||||
.then((res: any) => {
|
||||
let newPage: any = null;
|
||||
let newCatalog: any = null;
|
||||
let newElems: any = null;
|
||||
// console.table(res)
|
||||
if (res.data) {
|
||||
newPage = res.data.data.newPage;
|
||||
newElems = res.data.data.newElems;
|
||||
newCatalog = res.data.data.newCatalog;
|
||||
|
||||
// aggiorna i dati su mypage e Catalog in memoria
|
||||
if (newPage) {
|
||||
const index = this.mypage.findIndex(
|
||||
(rec: IMyPage) => rec._id === newPage._id
|
||||
);
|
||||
if (index >= 0) {
|
||||
this.mypage[index] = newPage;
|
||||
} else {
|
||||
this.mypage.push(newPage);
|
||||
}
|
||||
}
|
||||
|
||||
if (newCatalog) {
|
||||
const index = catalogStore.catalogs.findIndex(
|
||||
(rec: ICatalog) => rec._id === newCatalog._id
|
||||
);
|
||||
if (index >= 0) {
|
||||
catalogStore.catalogs[index] = newCatalog;
|
||||
} else {
|
||||
catalogStore.catalogs.push(newCatalog);
|
||||
}
|
||||
}
|
||||
|
||||
if (newElems && Array.isArray(newElems)) {
|
||||
newElems.forEach((newElem) => {
|
||||
const index = this.myelems.findIndex(
|
||||
(rec: IMyElem) => rec._id === newElem._id
|
||||
);
|
||||
if (index >= 0) {
|
||||
this.myelems[index] = newElem;
|
||||
} else {
|
||||
this.myelems.push(newElem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.aggiornaMenu(router);
|
||||
}
|
||||
|
||||
return { page: newPage, catalog: newCatalog };
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log('error addNewCatalog', error);
|
||||
return { page: null, catalog: null };
|
||||
});
|
||||
},
|
||||
|
||||
getArrStrByValueBinary(col: IColGridTable, val: any) {
|
||||
const arr = this.getArrByValueBinary(null, col, val);
|
||||
if (arr.length > 0) return arr.join(' - ');
|
||||
|
||||
Reference in New Issue
Block a user