- Catalogo: Aggiunta di Schede
This commit is contained in:
@@ -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