Webpage Editor functionality

This commit is contained in:
paoloar77
2022-11-10 19:32:56 +01:00
parent 2bd31200b4
commit 9fe37c9f3c
38 changed files with 1387 additions and 384 deletions

View File

@@ -5,8 +5,8 @@ import {
IConfig,
IDataToSet,
IGlobalState,
IListRoutes,
IMyPage, IParamsPickup,
IListRoutes, IMyElem,
IMyPage, IMySkill, IParamsPickup,
IParamsQuery,
ISettings,
StateConnection,
@@ -178,6 +178,10 @@ export const useGlobalStore = defineStore('GlobalStore', {
getPage: (state: IGlobalState) => (path: string): IMyPage | undefined => state.mypage.find((page) => (`/${page.path}`) === path),
getMyElems: (state: IGlobalState) => (path: string): IMyElem[] | [] => {
return state.myelems.filter((page: IMyElem) => (page.path === path)).sort((a: any, b: any) => a.order - b.order)
},
getmenu: (state: IGlobalState): any => {
// console.log('getmenu', cfgrouter.getmenu())
@@ -1727,6 +1731,52 @@ export const useGlobalStore = defineStore('GlobalStore', {
},
async delMyElem($q: any, t: any, myelem: IMyElem) {
if (!myelem._id)
return false
return await this.DeleteRec({table: 'myelems', id: myelem._id }).then((ris) => {
if (ris) {
this.myelems = this.myelems.filter((rec) => rec._id !== myelem._id)
tools.showPositiveNotif($q, t('db.deletedrecord'))
} else {
tools.showNegativeNotif($q, t('db.recdelfailed'))
}
})
},
async saveMyElem($q: any, t: any, myelem: IMyElem) {
const mydata = {
table: 'myelems',
data: {}
}
mydata.data = myelem
return await this.saveTable(mydata)
.then((ris) => {
if (ris) {
tools.showPositiveNotif($q, t('db.recupdated'))
} else {
tools.showNegativeNotif($q, t('db.recfailed'))
}
return ris
}).catch((e) => {
tools.showNegativeNotif($q, t('db.recfailed'))
return false
})
},
async addNewElem($q: any, t: any, myelem: IMyElem) {
const myrec = await this.saveMyElem($q, t, myelem)
if (myrec) {
myelem._id = myrec._id
this.myelems.push(myelem)
}
},
},
})