new version Visualizzazione Service

This commit is contained in:
Surya Paolo
2023-04-04 15:27:03 +02:00
parent 0365c58326
commit edcd244397
35 changed files with 841 additions and 55 deletions

View File

@@ -88,6 +88,11 @@ export const useCalendarStore = defineStore('CalendarStore', {
const ctrec = mystate.contribtype.find((mycontr) => mycontr._id === id)
return (ctrec) ? ctrec.label : ''
},
getColByContribType: (mystate: ICalendarState) => (id: string) => {
const ctrec = mystate.contribtype.find((mycontr) => mycontr._id === id)
return (ctrec && ctrec.color) ? ctrec.color : 'green'
},
getContribtypeRecByLabel: (mystate: ICalendarState) => (label: string) => {
const ctrec = mystate.contribtype.find((mycontr) => mycontr.label === label)

View File

@@ -3177,6 +3177,17 @@ export const tools = {
return ''
},
getstrDateMonthTimeLong(mytimestamp: Date | number | string | undefined) {
// console.log('getstrDate', mytimestamp)
if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMM YY - HH:mm')
return ''
},
getstrDateMonthLong(mytimestamp: Date | number | string | undefined) {
// console.log('getstrDate', mytimestamp)
if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMMM YYYY')
return ''
},
getstrDateMonthWeekTimeShort(mytimestamp: Date | number | string | undefined) {
// console.log('getstrDate', mytimestamp)
if (mytimestamp) return `${this.getDayOfWeek(mytimestamp)} ${date.formatDate(mytimestamp, 'DD MMM - HH:mm')}`
@@ -6827,7 +6838,6 @@ export const tools = {
getdefaultnewrec_MySkill(): any {
return {
_id: 0,
idSector: tools.getSelectionByTable('sectors', 0, true),
idSkill: tools.getSelectionByTable('skills', 0, true),
idStatusSkill: tools.getSelectionByTable('statusSkills', [1]),
@@ -6846,8 +6856,6 @@ export const tools = {
getdefaultnewrec_MyGoods(): any {
return {
_id: 0,
// idSectorGood: 0,
// idGood: 0,
// idStatusSkill: [],
@@ -6877,7 +6885,6 @@ export const tools = {
getdefaultnewrec_MyGroup(): any {
return {
_id: 0,
groupname: '',
photos: [],
visibility: 0,
@@ -6912,7 +6919,6 @@ export const tools = {
getdefaultnewrec_MyBacheca(): any {
return {
_id: 0,
idSector: tools.getSelectionByTable('sectors', 0, true),
idSkill: tools.getSelectionByTable('skills', 0, true),
idStatusSkill: tools.getSelectionByTable('statusSkills', []),
@@ -6935,7 +6941,6 @@ export const tools = {
getdefaultnewrec_MyHosp(): any {
return {
visibile: true,
_id: 0,
typeHosp: tools.getSelectionByTable(toolsext.TABTYPEHOSP, 2),
idContribType: tools.getSelectionByTable('contribtypes', []),
idCity: this.getCitySel(),
@@ -7749,6 +7754,18 @@ export const tools = {
getPagination(table: string): IPagination {
return { sortBy: 'desc', descending: true, page: 1, rowsNumber: 0, rowsPerPage: 10 }
},
getNumTabByTable(table: string) {
return shared_consts.MYTABS.findIndex((rec: any) => rec.table === table)
},
removeItemOnce(arr: any, value: any) {
const index = arr.indexOf(value)
if (index > -1) {
arr.splice(index, 1)
}
return arr;
}
// FINE !

View File

@@ -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 {}
})
},
},
})

View File

@@ -1025,7 +1025,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
path = path.substring(1)
const mypage = this.getPage(`/${path}`)
console.log('mypage', mypage)
// console.log('mypage', mypage)
// Controlla se l'ho già caricato
if (!!mypage && (!!mypage.content || mypage.loadFirst || mypage.loaded)) {