new version Visualizzazione Service
This commit is contained in:
@@ -35,12 +35,17 @@ import { Router } from 'vue-router'
|
||||
import { useProjectStore } from '@store/Projects'
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { costanti } from '@costanti'
|
||||
import { IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
|
||||
import { IBookmark, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
|
||||
|
||||
import globalroutines from '../globalroutines/index'
|
||||
import { useNotifStore } from '@store/NotifStore'
|
||||
import { useCircuitStore } from './CircuitStore'
|
||||
|
||||
export const CMD_USER = {
|
||||
SET_FAVORITE: 1,
|
||||
SET_BOOKMARK: 2,
|
||||
}
|
||||
|
||||
export const DefaultUser: IUserFields = {
|
||||
_id: '',
|
||||
email: '',
|
||||
@@ -76,6 +81,8 @@ export const DefaultUser: IUserFields = {
|
||||
asked_groups: [],
|
||||
refused_groups: [],
|
||||
notifs: [],
|
||||
bookmark: [],
|
||||
favorite: [],
|
||||
notif_idCities: [],
|
||||
notif_provinces: [],
|
||||
notif_regions: [],
|
||||
@@ -141,6 +148,8 @@ export const DefaultProfile: IUserProfile = {
|
||||
asked_groups: [],
|
||||
refused_groups: [],
|
||||
notifs: [],
|
||||
bookmark: [],
|
||||
favorite: [],
|
||||
notif_idCities: [],
|
||||
notif_provinces: [],
|
||||
notif_regions: [],
|
||||
@@ -236,7 +245,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return { sortBy: 'name,username', descending: '1,1', page: 1, rowsNumber: 0, rowsPerPage: 10 }
|
||||
},
|
||||
getSortFieldsAvailable(): any[] {
|
||||
return [{ label: 'Username', value: {'username': 1, 'name': 1} }, { label: 'Nome', value: {'name': 1, 'username': 1} }, { label: 'Ultimi reg.', value: {'date_reg': -1, 'username': 1} }]
|
||||
return [{ label: 'Username', value: { 'username': 1, 'name': 1 } }, { label: 'Nome', value: { 'name': 1, 'username': 1 } }, { label: 'Ultimi reg.', value: { 'date_reg': -1, 'username': 1 } }]
|
||||
},
|
||||
|
||||
IsMyFriendByUsername(username: string): boolean {
|
||||
@@ -865,7 +874,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
value: step,
|
||||
}
|
||||
this.my.profile.stepTutorial = step
|
||||
const ris = await this.execDbOpUser({mydata})
|
||||
const ris = await this.execDbOpUser({ mydata })
|
||||
|
||||
return ris
|
||||
},
|
||||
@@ -877,7 +886,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
}
|
||||
if (this.my.profile.noNameSurname !== val) {
|
||||
this.my.profile.noNameSurname = val
|
||||
return await this.execDbOpUser({mydata})
|
||||
return await this.execDbOpUser({ mydata })
|
||||
}
|
||||
},
|
||||
async savenoCircuit(val: boolean) {
|
||||
@@ -888,7 +897,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
}
|
||||
if (this.my.profile.noCircuit !== val) {
|
||||
this.my.profile.noCircuit = val
|
||||
return await this.execDbOpUser({mydata})
|
||||
return await this.execDbOpUser({ mydata })
|
||||
}
|
||||
},
|
||||
async savenoFoto(val: boolean) {
|
||||
@@ -899,7 +908,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
}
|
||||
if (this.my.profile.noFoto !== val) {
|
||||
this.my.profile.noFoto = val
|
||||
return await this.execDbOpUser({mydata})
|
||||
return await this.execDbOpUser({ mydata })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1472,7 +1481,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
},
|
||||
|
||||
async loadGeneric(table: string, id: number, idnotif: string) {
|
||||
async loadGeneric(table: string, id: any, idnotif: string) {
|
||||
const data = {
|
||||
table,
|
||||
id,
|
||||
@@ -1629,6 +1638,59 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return {}
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async setFavorite($q: any, t: any, id: any, table: string) {
|
||||
let value = {}
|
||||
|
||||
const tab = tools.getNumTabByTable(table)
|
||||
|
||||
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.SET_FAVORITE, id, tab, value })
|
||||
.then((res) => {
|
||||
if (res && res.data.state === 1) {
|
||||
this.my.profile.favorite.push({ id, tab })
|
||||
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'))
|
||||
}
|
||||
}).catch((error) => {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
return {}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
isBookmarked(id: string, table: string) {
|
||||
const tab = tools.getNumTabByTable(table)
|
||||
const mybookmark = this.my.profile.bookmark.find((rec: IBookmark) => ((rec.id === id) && (rec.tab === tab)))
|
||||
return mybookmark
|
||||
},
|
||||
|
||||
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)))
|
||||
return myfavorite
|
||||
},
|
||||
|
||||
async setBookmark($q: any, t: any, id: any, table: string) {
|
||||
let value = {}
|
||||
|
||||
const tab = tools.getNumTabByTable(table)
|
||||
|
||||
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.SET_BOOKMARK, id, tab, value })
|
||||
.then((res) => {
|
||||
if (res && res.data.state === 1) {
|
||||
tools.showPositiveNotif($q, t('cmd.bookmark_set'))
|
||||
} else if (res && res.data.state === -1) {
|
||||
tools.showPositiveNotif($q, t('db.bookmark_unset'))
|
||||
}
|
||||
}).catch((error) => {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
return {}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user