Webpage Editor functionality
This commit is contained in:
@@ -126,6 +126,7 @@ export const colgallery = [
|
||||
export const colmyelems = [
|
||||
AddCol({ name: 'active', label_trans: 'myelems.active', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'title', label_trans: 'myelems.title' }),
|
||||
AddCol({ name: 'path', label_trans: 'myelems.path' }),
|
||||
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' }),
|
||||
|
||||
@@ -29,6 +29,7 @@ import { static_data } from '@src/db/static_data'
|
||||
|
||||
|
||||
import bcrypt from 'bcryptjs'
|
||||
|
||||
import { useTodoStore } from '@store/Todos'
|
||||
import { Router } from 'vue-router'
|
||||
import { useProjectStore } from '@store/Projects'
|
||||
@@ -257,7 +258,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
// Check if is this User!
|
||||
if (this.my.username === username) return this.my
|
||||
|
||||
let trovato:any = null
|
||||
let trovato: any = null
|
||||
if (this.usersList) trovato = this.usersList.find((item: any) => item.username === username)
|
||||
|
||||
if (trovato) {
|
||||
@@ -283,7 +284,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
},
|
||||
|
||||
getImgUserByUsername(username: string): string {
|
||||
let img = this.getImgByUsername(username)
|
||||
const img = this.getImgByUsername(username)
|
||||
return img ? img : 'images/noimg-user.svg'
|
||||
},
|
||||
|
||||
@@ -309,6 +310,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return costanti.DIR_UPLOAD + 'profile/' + userparam.username + '/' + userparam.profile.img
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
if (!reale)
|
||||
return 'images/noimg.png'
|
||||
@@ -363,6 +365,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
if (circ.photos && circ.photos.length > 0)
|
||||
return costanti.DIR_UPLOAD + 'circuits/' + circ.path + '/' + circ.photos[0].imagefile
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
return 'images/noimg.png'
|
||||
},
|
||||
@@ -370,9 +373,10 @@ export const useUserStore = defineStore('UserStore', {
|
||||
getImgByGroup(group: IMyGroup): string {
|
||||
|
||||
try {
|
||||
//++Todo: Sistemare!
|
||||
// ++Todo: Sistemare!
|
||||
return costanti.DIR_UPLOAD + 'mygroups/' + group.groupname + '/' + group.photos[0].imagefile
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
return 'images/noimg.png'
|
||||
},
|
||||
@@ -411,7 +415,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
},
|
||||
|
||||
getNameSurnameByUsername(username: string): string {
|
||||
let user = this.getUserByUsername(username)
|
||||
const user = this.getUserByUsername(username)
|
||||
if (user) return `${user.name} ` + !!user.surname ? user.surname : ''
|
||||
return `(${username})`
|
||||
},
|
||||
@@ -420,7 +424,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
// Check if is this User!
|
||||
if (this.my._id === userId) return this.my
|
||||
|
||||
let trovato:any = null
|
||||
let trovato: any = null
|
||||
|
||||
if (this.usersList) trovato = this.usersList.find((item: any) => item._id === userId)
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user