- 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:
@@ -1,7 +1,16 @@
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
import type { ICatalogState } from '@src/model';
|
||||
import { IAccount, ICircuit, ICatalog, IGlobalState, IGroupShort, IMyCircuit, IMyGroup, IUserFields } from '@src/model';
|
||||
import {
|
||||
IAccount,
|
||||
ICircuit,
|
||||
ICatalog,
|
||||
IGlobalState,
|
||||
IGroupShort,
|
||||
IMyCircuit,
|
||||
IMyGroup,
|
||||
IUserFields,
|
||||
} from '@src/model';
|
||||
import { tools } from '@tools';
|
||||
import translate from '@src/globalroutines/util';
|
||||
|
||||
@@ -26,18 +35,28 @@ export const useCatalogStore = defineStore('CatalogStore', {
|
||||
}),
|
||||
|
||||
getters: {
|
||||
getCatalogById: (state) => (id: string): ICatalog => {
|
||||
return state.catalogs.find((cat: ICatalog) => cat._id === id) || null;
|
||||
getCatalogById:
|
||||
(state) =>
|
||||
(id: string): ICatalog => {
|
||||
return state.catalogs.find((cat: ICatalog) => cat._id === id) || null;
|
||||
},
|
||||
|
||||
getCatalogsList: (state) => (): { label: string; value: string }[] => {
|
||||
return [
|
||||
{ label: '[Nessuno]', value: '' },
|
||||
...state.catalogs.map((cat: ICatalog) => {
|
||||
return { label: cat.title, value: cat._id };
|
||||
}),
|
||||
];
|
||||
},
|
||||
|
||||
getCatalogsList: (state) => (): {label: string, value: string}[] => {
|
||||
return state.catalogs.map((cat: ICatalog) => {
|
||||
return {label: cat.title, value: cat._id};
|
||||
});
|
||||
},
|
||||
getCatalogByIdPageAssigned: (state) => (idPage: string): ICatalog => {
|
||||
return state.catalogs.find((cat: ICatalog) => cat.idPageAssigned === idPage) || null;
|
||||
},
|
||||
getCatalogByIdPageAssigned:
|
||||
(state) =>
|
||||
(idPage: string): ICatalog => {
|
||||
return (
|
||||
state.catalogs.find((cat: ICatalog) => cat.idPageAssigned === idPage) || null
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
@@ -72,13 +91,21 @@ export const useCatalogStore = defineStore('CatalogStore', {
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error loadCatalogById', error);
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error);
|
||||
return new Types.AxiosError(
|
||||
serv_constants.RIS_CODE_ERR,
|
||||
null,
|
||||
toolsext.ERR_GENERICO,
|
||||
error
|
||||
);
|
||||
});
|
||||
|
||||
return ris;
|
||||
},
|
||||
|
||||
async loadProductsOnlyByIdPageCatalog(idPage: string, forzacaricamento: boolean = false) {
|
||||
async loadProductsOnlyByIdPageCatalog(
|
||||
idPage: string,
|
||||
forzacaricamento: boolean = false
|
||||
) {
|
||||
// controlla se è stata già caricata in memoria
|
||||
|
||||
const productStore = useProducts();
|
||||
@@ -101,7 +128,9 @@ export const useCatalogStore = defineStore('CatalogStore', {
|
||||
updateDataCatalog(catalog: ICatalog) {
|
||||
if (catalog) {
|
||||
// Update catalog from server
|
||||
const indelem = this.catalogs.findIndex((reccatalog: ICatalogCompleto) => reccatalog._id === catalog._id);
|
||||
const indelem = this.catalogs.findIndex(
|
||||
(reccatalog: ICatalogCompleto) => reccatalog._id === catalog._id
|
||||
);
|
||||
if (indelem >= 0) {
|
||||
this.catalogs[indelem] = { ...catalog };
|
||||
this.catalogs[indelem].prodotti_caricati_inmem = true;
|
||||
|
||||
Reference in New Issue
Block a user