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

@@ -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',
],
@@ -3103,10 +3115,16 @@ export const tools = {
${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)}`
}
} else {
if (withhtml) {
mystr = `<span class="cal__where-content">${this.getstrDateLong(myevent.dateTimeStart)}</span>
<span class="cal__hours-content">${$t('cal.starttime')} ${this.getstrTime(myevent.dateTimeStart)} </span>
${$t('cal.enddate')} ${this.getstrDateLong(myevent.dateTimeEnd)}
<span class="cal__hours-content">${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)} </span>`
} else {
mystr = `${this.getstrDateLong(myevent.dateTimeStart)}
${$t('cal.starttime')} ${this.getstrTime(myevent.dateTimeStart)}
${this.getstrDateLong(myevent.dateTimeEnd)}: ${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)}`
}
}
if (myevent.infoextra) {
@@ -4192,7 +4210,7 @@ export const tools = {
},
scrollToTopAll() {
window.scrollTo(0,0);
window.scrollTo(0, 0);
},
scrollToTop() {
const element = document.getElementById('mypage')
@@ -4512,7 +4530,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 +5042,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 +6371,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)
@@ -6943,10 +6970,10 @@ export const tools = {
visibile: true,
typeHosp: tools.getSelectionByTable(toolsext.TABTYPEHOSP, 2),
idContribType: tools.getSelectionByTable('contribtypes', []),
accomodation: [],
idCity: this.getCitySel(),
pub_to_share: tools.getSelectionByTable('pub_to_share', shared_consts.PUBTOSHARE.ALL, true),
photos: [],
accomodation: [],
descr: '',
note: '',
website: '',
@@ -7037,6 +7064,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) {
@@ -7730,7 +7758,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'))
}
@@ -7744,7 +7772,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'))
}
@@ -7758,7 +7786,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) {
@@ -7767,7 +7796,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 !

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