nuova veste grafica: myskills, mygoods, mybachecas, myhosps,
- cambiato id (da numero a stringa)
This commit is contained in:
@@ -17,6 +17,11 @@ export const costanti = {
|
||||
CERCO: 2,
|
||||
},
|
||||
|
||||
TIPOFAVBOOK: {
|
||||
FAVORITE: 1,
|
||||
BOOKMARK: 2,
|
||||
},
|
||||
|
||||
ENABLE_FRIENDS: false,
|
||||
ENABLE_CONTI_COLLETTIVI: true,
|
||||
|
||||
@@ -105,6 +110,7 @@ export const costanti = {
|
||||
table: 'mygoods',
|
||||
visuonstat: true,
|
||||
small: false,
|
||||
showfavorite: true,
|
||||
},
|
||||
{
|
||||
visible: true,
|
||||
@@ -118,6 +124,7 @@ export const costanti = {
|
||||
table: 'myskills',
|
||||
visuonstat: true,
|
||||
small: false,
|
||||
showfavorite: true,
|
||||
},
|
||||
{
|
||||
visible: true,
|
||||
@@ -133,6 +140,7 @@ export const costanti = {
|
||||
small: false,
|
||||
table: 'myhosps',
|
||||
visuonstat: true,
|
||||
showfavorite: true,
|
||||
},
|
||||
{
|
||||
visible: false,
|
||||
@@ -186,6 +194,7 @@ export const costanti = {
|
||||
table: 'mybachecas',
|
||||
visuonstat: true,
|
||||
small: false,
|
||||
showfavorite: true,
|
||||
},
|
||||
{
|
||||
visible: false,
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
ITodo,
|
||||
IUserFields,
|
||||
Privacy,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport, ISpecialField, IAccount, IMyCircuit, ISendCoin, IMovement, IMovVisu, INotif, IMyElem, IMyCard, ILabelValue, ILabelValueStr, IAnim, ILang, IGroupShort, IPagination,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport, ISpecialField, IAccount, IMyCircuit, ISendCoin, IMovement, IMovVisu, INotif, IMyElem, IMyCard, ILabelValue, ILabelValueStr, IAnim, ILang, IGroupShort, IPagination, IFavorite, IBookmark,
|
||||
} from '@model'
|
||||
|
||||
import { fieldsTable } from '@store/Modules/fieldsTable'
|
||||
@@ -116,7 +116,19 @@ export const tools = {
|
||||
'teal',
|
||||
'lime',
|
||||
'orange',
|
||||
'deeporange',
|
||||
'deep-orange',
|
||||
'yellow',
|
||||
'blue',
|
||||
'green',
|
||||
'purple',
|
||||
'deep-purple',
|
||||
'indigo',
|
||||
'light-blue',
|
||||
'cyan',
|
||||
'teal',
|
||||
'lime',
|
||||
'orange',
|
||||
'deep-orange',
|
||||
'yellow',
|
||||
],
|
||||
|
||||
@@ -4192,7 +4204,7 @@ export const tools = {
|
||||
},
|
||||
|
||||
scrollToTopAll() {
|
||||
window.scrollTo(0,0);
|
||||
window.scrollTo(0, 0);
|
||||
},
|
||||
scrollToTop() {
|
||||
const element = document.getElementById('mypage')
|
||||
@@ -4512,7 +4524,16 @@ export const tools = {
|
||||
},
|
||||
|
||||
getlinkhref(mylink: string, text: string) {
|
||||
return '<a href="' + mylink + '" target="_blank">' + text + '</a>'
|
||||
if (mylink) {
|
||||
if (!mylink.startsWith('http')) {
|
||||
mylink = 'https://' + mylink
|
||||
}
|
||||
|
||||
return '<a href="' + mylink + '" target="_blank">' + text + '</a>'
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getNationsByNationality(nat: string) {
|
||||
@@ -5015,7 +5036,7 @@ export const tools = {
|
||||
}
|
||||
let add = ''
|
||||
if (aportador_solidario) {
|
||||
add = '?start=inv_' + aportador_solidario + '_ex_' + regexpire
|
||||
add = '?start=inv#' + aportador_solidario + '#ex#' + regexpire
|
||||
}
|
||||
|
||||
return mylink + add
|
||||
@@ -6344,7 +6365,7 @@ export const tools = {
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST, null, {groupname}).then((res) => {
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST, null, { groupname }).then((res) => {
|
||||
if (res && res.result) {
|
||||
if (userStore.my.profile.mycircuits && username === userStore.my.username) {
|
||||
userStore.my.profile.mycircuits = userStore.my.profile.mycircuits.filter((rec: IMyCircuit) => rec.circuitname !== circuitname)
|
||||
@@ -7036,6 +7057,7 @@ export const tools = {
|
||||
},
|
||||
|
||||
getPathByTableAndRec(table: string, rec: any) {
|
||||
|
||||
if (shared_consts.TABLES_REC_ID.includes(table)) {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + rec['_id']
|
||||
} else if (table === toolsext.TABMYGROUPS) {
|
||||
@@ -7729,7 +7751,7 @@ export const tools = {
|
||||
|
||||
await userStore.setUserReceiveRIS(username, '').then((data) => {
|
||||
if (data.code === serv_constants.RIS_CODE_OK) {
|
||||
this.showPositiveNotif($q, t('circuit.coins_requestedris', {username}), 6000)
|
||||
this.showPositiveNotif($q, t('circuit.coins_requestedris', { username }), 6000)
|
||||
} else {
|
||||
this.showNegativeNotif($q, t('db.recfailed'))
|
||||
}
|
||||
@@ -7743,7 +7765,7 @@ export const tools = {
|
||||
|
||||
await userStore.setUserReceiveRIS('', groupname).then((data) => {
|
||||
if (data.code === serv_constants.RIS_CODE_OK) {
|
||||
this.showPositiveNotif($q, t('circuit.coins_requestedrisgroup', {groupname}), 6000)
|
||||
this.showPositiveNotif($q, t('circuit.coins_requestedrisgroup', { groupname }), 6000)
|
||||
} else {
|
||||
this.showNegativeNotif($q, t('db.recfailed'))
|
||||
}
|
||||
@@ -7757,7 +7779,8 @@ export const tools = {
|
||||
},
|
||||
|
||||
getNumTabByTable(table: string) {
|
||||
return shared_consts.MYTABS.findIndex((rec: any) => rec.table === table)
|
||||
const myrec = shared_consts.MYTABS.find((rec: any) => rec.table === table)
|
||||
return myrec ? myrec.id : -1
|
||||
},
|
||||
|
||||
removeItemOnce(arr: any, value: any) {
|
||||
@@ -7766,7 +7789,39 @@ export const tools = {
|
||||
arr.splice(index, 1)
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
},
|
||||
|
||||
indexOfObject(arr: any, obj: any) {
|
||||
let l = arr.length, i, k, ok;
|
||||
for (let i = 0; i < l; i++) {
|
||||
ok = true;
|
||||
for (k in obj) if (obj.hasOwnProperty(k)) {
|
||||
if (arr[i][k] !== obj[k]) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ok) return i;
|
||||
}
|
||||
return -1; // no match
|
||||
},
|
||||
|
||||
removeIObjectOnce(arr: any, obj: IBookmark | IFavorite) {
|
||||
const index = this.indexOfObject(arr, obj)
|
||||
if (index > -1) {
|
||||
arr.splice(index, 1)
|
||||
}
|
||||
return arr;
|
||||
},
|
||||
|
||||
optionsTable(table: string) {
|
||||
if (shared_consts.TABLES_FAVORITE_BOOKMARK.includes(table))
|
||||
return shared_consts.OPTIONS_ADD_COUNT_FAVORITE
|
||||
|
||||
return 0
|
||||
},
|
||||
|
||||
|
||||
|
||||
// FINE !
|
||||
|
||||
|
||||
@@ -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 {}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user