aktre modifiche sistemando...

This commit is contained in:
Surya Paolo
2023-04-07 21:48:33 +02:00
parent 32b2eb4755
commit 5789567cd2
24 changed files with 401 additions and 163 deletions

View File

@@ -35,7 +35,7 @@ import { Router } from 'vue-router'
import { useProjectStore } from '@store/Projects'
import { shared_consts } from '@/common/shared_vuejs'
import { costanti } from '@costanti'
import { IBookmark, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
import { IBookmark, IFavBook, IFavorite, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
import globalroutines from '../globalroutines/index'
import { useNotifStore } from '@store/NotifStore'
@@ -83,6 +83,8 @@ export const DefaultUser: IUserFields = {
notifs: [],
bookmark: [],
favorite: [],
myfav: [],
mybook: [],
notif_idCities: [],
notif_provinces: [],
notif_regions: [],
@@ -150,6 +152,8 @@ export const DefaultProfile: IUserProfile = {
notifs: [],
bookmark: [],
favorite: [],
myfav: [],
mybook: [],
notif_idCities: [],
notif_provinces: [],
notif_regions: [],
@@ -1474,6 +1478,7 @@ export const useUserStore = defineStore('UserStore', {
return Api.SendReq('/myskills/page', 'POST', data)
.then((res) => {
console.log('res.data', res)
return res.data
}).catch((error) => {
return {}
@@ -1492,6 +1497,7 @@ export const useUserStore = defineStore('UserStore', {
.then((res) => {
return res.data
}).catch((error) => {
console.error('err', error)
return {}
})
@@ -1640,19 +1646,28 @@ export const useUserStore = defineStore('UserStore', {
},
async setFavorite($q: any, t: any, id: any, table: string) {
let value = {}
async setFavorite($q: any, t: any, id: any, table: string, myrec: any) {
let value = false
console.log('table', table)
const tab = tools.getNumTabByTable(table)
value = this.isFavorite(id, table) ? false : true
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.SET_FAVORITE, id, tab, value })
.then((res) => {
if (res && res.data.state === 1) {
if (!myrec.myfav)
myrec.myfav = []
this.my.profile.favorite.push({ id, tab })
if (myrec)
myrec.myfav.push({ username: this.my.username })
tools.showPositiveNotif($q, t('cmd.favorite_set'))
} else if (res && res.data.state === -1) {
this.my.profile.favorite = tools.removeItemOnce(this.my.profile.favorite, { id, tab })
tools.showPositiveNotif($q, t('db.favorite_unset'))
this.my.profile.favorite = tools.removeIObjectOnce(this.my.profile.favorite, { id, tab })
if (myrec && myrec.myfav)
myrec.myfav = myrec.myfav.filter((rec: IFavBook) => rec.username !== this.my.username)
tools.showPositiveNotif($q, t('cmd.favorite_unset'))
}
}).catch((error) => {
tools.showNegativeNotif($q, t('db.recfailed'))
@@ -1669,23 +1684,34 @@ export const useUserStore = defineStore('UserStore', {
isFavorite(id: string, table: string) {
const tab = tools.getNumTabByTable(table)
const myfavorite = this.my.profile.favorite.find((rec: IBookmark) => ((rec.id === id) && (rec.tab === tab)))
const myfavorite = this.my.profile.favorite.find((rec: IFavorite) => ((rec.id === id) && (rec.tab === tab)))
return myfavorite
},
async setBookmark($q: any, t: any, id: any, table: string) {
let value = {}
async setBookmark($q: any, t: any, id: any, table: string, myrec: any) {
let value = false
const tab = tools.getNumTabByTable(table)
value = this.isBookmarked(id, table) ? false : true
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.SET_BOOKMARK, id, tab, value })
.then((res) => {
if (res && res.data.state === 1) {
if (!myrec.mybook)
myrec.mybook = []
this.my.profile.bookmark.push({ id, tab })
if (myrec)
myrec.mybook.push({ username: this.my.username })
tools.showPositiveNotif($q, t('cmd.bookmark_set'))
} else if (res && res.data.state === -1) {
tools.showPositiveNotif($q, t('db.bookmark_unset'))
this.my.profile.bookmark = tools.removeIObjectOnce(this.my.profile.bookmark, { id, tab })
if (myrec && myrec.mybook)
myrec.mybook = myrec.mybook.filter((rec: IFavBook) => rec.username !== this.my.username)
tools.showPositiveNotif($q, t('cmd.bookmark_unset'))
}
}).catch((error) => {
console.error('error', error)
tools.showNegativeNotif($q, t('db.recfailed'))
return {}
})