ver: 0.5.62

Conti Collettivi visibili solo se sei admin...
This commit is contained in:
Surya Paolo
2023-02-02 02:31:09 +01:00
parent cfa2457147
commit d5831e3dbf
13 changed files with 196 additions and 81 deletions

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.61" APP_VERSION="0.5.62"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13" APP_ID="13"
DIRECTORY_LOCAL="newfreeplanet" DIRECTORY_LOCAL="newfreeplanet"

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.61" APP_VERSION="0.5.62"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13" APP_ID="13"
DIRECTORY_LOCAL=newfreeplanet DIRECTORY_LOCAL=newfreeplanet

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.61" APP_VERSION="0.5.62"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13" APP_ID="13"
DIRECTORY_LOCAL="newfreeplanet" DIRECTORY_LOCAL="newfreeplanet"

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.61" APP_VERSION="0.5.62"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13" APP_ID="13"
DIRECTORY_LOCAL=newfreeplanet DIRECTORY_LOCAL=newfreeplanet

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.61" APP_VERSION="0.5.62"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="14" APP_ID="14"
DIRECTORY_LOCAL="newfreeplanet" DIRECTORY_LOCAL="newfreeplanet"

View File

@@ -38,11 +38,6 @@ export default defineComponent({
required: false, required: false,
default: null, default: null,
}, },
from_contocom: {
type: String,
required: false,
default: '',
},
to_contocom: { to_contocom: {
type: String, type: String,
required: false, required: false,
@@ -65,20 +60,29 @@ export default defineComponent({
const from_username = ref(userStore.my.username) const from_username = ref(userStore.my.username)
const from_groupname = ref('') const from_groupname = ref('')
const from_contocom = ref('')
const circuitsel = ref('') const circuitsel = ref('')
const qty = ref(<string | number>'') const qty = ref(<string | number>'')
const causal = ref('') const causal = ref('')
const loading = ref(false)
const bothcircuits = ref(<any>[]) const bothcircuits = ref(<any>[])
const groupSel = ref(<IMyGroup | null | undefined>null) const groupSel = ref(<IMyGroup | null | undefined>null)
const circuitloaded = ref(<ICircuit | undefined>undefined) const circuittoload = ref(<ICircuit | undefined>undefined)
const circuitloaded = ref(<ICircuit>{})
const circuitdest = ref(<ICircuit | undefined>undefined) const circuitdest = ref(<ICircuit | undefined>undefined)
const accountloaded = ref(<IAccount | undefined | null>undefined) const accountloaded = ref(<IAccount | undefined | null>undefined)
const accountdest = ref(<IAccount | undefined>undefined) const accountdest = ref(<IAccount | undefined>undefined)
const remainingCoins = ref(0) const remainingCoins = ref(0)
const maxsendable = ref(0) const maxsendable = ref(0)
const numstep = ref(0) const numstep = ref(0)
const arrTypesAccounts = ref(<any>[
{
label: t('circuit.user'),
value: costanti.AccountType.USER,
},
])
const tipoConto = ref(costanti.AccountType.USER) const tipoConto = ref(costanti.AccountType.USER)
const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '') const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '')
@@ -113,31 +117,65 @@ export default defineComponent({
show.value = newval show.value = newval
}) })
function aggiorna() { async function aggiorna() {
loading.value = true
groupSel.value = null groupSel.value = null
from_contocom.value = ''
accountloaded.value = null accountloaded.value = null
circuitloaded.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value) circuittoload.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value)
if (circuitloaded.value) { if (circuittoload.value) {
await userStore.loadCircuit(circuittoload.value.path, '').then(({ data, status }: { data: any, status: number }) => {
try {
arrTypesAccounts.value = [
{
label: t('circuit.user'),
value: costanti.AccountType.USER,
},
]
if (!!data.circuit) {
circuitloaded.value = data.circuit
if (tipoConto.value === costanti.AccountType.USER) { if (tipoConto.value === costanti.AccountType.USER) {
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id) accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
} else if (tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT) {
groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname)
accountloaded.value = groupSel.value ? groupSel.value.account : null
} else if (tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT) { } else if (tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT) {
groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname) groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname)
accountloaded.value = groupSel.value ? groupSel.value.account : null accountloaded.value = groupSel.value ? groupSel.value.account : null
} else if (tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT) {
from_contocom.value = circuitloaded.value.path
accountloaded.value = circuitloaded.value ? circuitloaded.value.account : null
} }
groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin() groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin(circuitloaded.value.name)
console.log('groupsListAdmin.value', groupsListAdmin.value)
arrGroupsList.value = [] arrGroupsList.value = []
if (groupsListAdmin.value) {
for (const group of groupsListAdmin.value) { for (const group of groupsListAdmin.value) {
arrGroupsList.value.push({ label: group.groupname, value: group.groupname }); arrGroupsList.value.push({ label: group.groupname, value: group.groupname });
} }
}
if (tools.iAmAdminCircuit(circuitloaded.value.name)) if (arrGroupsList.value.length > 0) {
arrGroupsList.value.push({ label: circuitloaded.value.name, value: circuitloaded.value.path }); arrTypesAccounts.value.push(
{
label: t('circuit.conticollettivi'),
value: costanti.AccountType.COLLECTIVE_ACCOUNT,
})
}
if (tools.iCanSendCoinsSuperUserCircuit(circuitsel.value)) {
arrTypesAccounts.value.push({
label: t('circuit.contocom'),
value: costanti.AccountType.COMMUNITY_ACCOUNT,
})
}
// if (tools.iAmAdminCircuit(circuitloaded.value.name))
// arrGroupsList.value.push({ label: circuitloaded.value.name, value: circuitloaded.value.path });
// accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id) // accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
if (accountloaded.value) { if (accountloaded.value) {
@@ -169,12 +207,22 @@ export default defineComponent({
} }
} }
} }
}
} finally {
loading.value = false
}
})
} }
} }
function mounted() { function mounted() {
arrTypesAccounts.value = [
{
label: t('circuit.user'),
value: costanti.AccountType.USER,
},
]
// .... // ....
if (props.to_user) { if (props.to_user) {
@@ -255,7 +303,7 @@ export default defineComponent({
myrecsendcoin.groupdest = props.to_group ? props.to_group.groupname : '' myrecsendcoin.groupdest = props.to_group ? props.to_group.groupname : ''
myrecsendcoin.contoComDest = props.to_contocom myrecsendcoin.contoComDest = props.to_contocom
myrecsendcoin.grouporig = tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT ? from_groupname.value : '' myrecsendcoin.grouporig = tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT ? from_groupname.value : ''
myrecsendcoin.contoComOrig = tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT ? props.from_contocom : '' myrecsendcoin.contoComOrig = tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT ? from_contocom.value : ''
myrecsendcoin.dest = props.to_user ? props.to_user.username : '' myrecsendcoin.dest = props.to_user ? props.to_user.username : ''
@@ -302,6 +350,9 @@ export default defineComponent({
tipoConto, tipoConto,
arrGroupsList, arrGroupsList,
from_groupname, from_groupname,
from_contocom,
arrTypesAccounts,
loading,
} }
}, },
}) })

View File

@@ -45,13 +45,7 @@
toggle-color="primary" toggle-color="primary"
color="white" color="white"
text-color="primary" text-color="primary"
:options="[ :options="arrTypesAccounts"
{ label: $t('circuit.user'), value: costanti.AccountType.USER },
{
label: $t('circuit.contocom'),
value: costanti.AccountType.COMMUNITY_ACCOUNT,
},
]"
/> />
</div> </div>
<q-input <q-input
@@ -61,7 +55,9 @@
readonly readonly
> >
</q-input> </q-input>
<div v-else> <div
v-else-if="tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT"
>
<q-select <q-select
v-model="from_groupname" v-model="from_groupname"
:options="arrGroupsList" :options="arrGroupsList"
@@ -73,6 +69,17 @@
<!-- Mostra i gruppi su cui sei Admin --> <!-- Mostra i gruppi su cui sei Admin -->
</q-select> </q-select>
</div> </div>
<div
v-else-if="tipoConto === costanti.AccountType.COMMUNITY_ACCOUNT"
>
<q-input
v-model="from_contocom"
:label="$t('circuit.contocom')"
readonly
class="q-my-sm"
>
</q-input>
</div>
<CSaldo <CSaldo
v-if="circuitloaded" v-if="circuitloaded"
@@ -122,6 +129,10 @@
</CMyGroupOnlyView> </CMyGroupOnlyView>
</q-banner> </q-banner>
<q-inner-loading id="spinner" :showing="loading">
<q-spinner-tail size="6em" color="primary" />
</q-inner-loading>
<div v-if="circuitloaded"> <div v-if="circuitloaded">
<q-banner <q-banner
v-if="!circuitloaded.transactionsEnabled" v-if="!circuitloaded.transactionsEnabled"
@@ -212,18 +223,30 @@
v-if="circuitloaded" v-if="circuitloaded"
:disable=" :disable="
qtyRef qtyRef
? qtyRef.hasError || !circuitloaded.transactionsEnabled || ? qtyRef.hasError ||
((tipoConto === costanti.AccountType.USER) && to_user && (from_username === to_user.username)) || !circuitloaded.transactionsEnabled ||
((tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT) && !from_groupname) || (tipoConto === costanti.AccountType.USER &&
((tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT) && to_group && from_groupname && (to_group.groupname === from_groupname)) || to_user &&
((tipoConto === costanti.AccountType.COMMUNITY_ACCOUNT) && !to_contocom) from_username === to_user.username) ||
(tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT &&
!from_groupname) ||
(tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT &&
to_group &&
from_groupname &&
to_group.groupname === from_groupname) ||
(tipoConto === costanti.AccountType.COMMUNITY_ACCOUNT &&
!from_contocom)
: false : false
" "
:label=" :label="
$t('circuit.sendcoinsto', { $t('circuit.sendcoinsto', {
qty, qty,
coin: circuitsel, coin: circuitsel,
dest: to_group ? to_group.groupname : (to_user ? to_user.username : to_contocom), dest: to_group
? to_group.groupname
: to_user
? to_user.username
: to_contocom,
}) })
" "
color="positive" color="positive"

View File

@@ -1266,7 +1266,7 @@ const msg_it = {
qta_not_valid: 'Quantità non valida', qta_not_valid: 'Quantità non valida',
qta_max_to_send: 'Quantità massima inviabile {maxqta} {symbol}', qta_max_to_send: 'Quantità massima inviabile {maxqta} {symbol}',
transaction_suspended: 'Transazioni sospese', transaction_suspended: 'Transazioni sospese',
choosecontocom: 'Scegli il tuo Conto Comunitario', choosecontocom: 'Scegli il tuo Conto Collettivo',
contocom: 'Conto Comunitario', contocom: 'Conto Comunitario',
user: 'Utente', user: 'Utente',
sender: 'Mittente', sender: 'Mittente',

View File

@@ -6417,6 +6417,29 @@ export const tools = {
}, },
iCanSendCoinsSuperUserCircuit(circuitname: string) {
const userStore = useUserStore()
let risultato = false
if (userStore.my.profile.manage_mycircuits) {
const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => {
if (circuit.name === circuitname) {
return true
}
})
// console.log('ris', ris)
if (ris && ris.admins) {
const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username)
risultato = !!isadmin
}
}
return risultato
},
iAmPartOfThisGroup(grp: IMyGroup) { iAmPartOfThisGroup(grp: IMyGroup) {
const userStore = useUserStore() const userStore = useUserStore()
return userStore.my.profile.mygroups.findIndex((rec: IMyGroup) => rec.groupname === grp.groupname) >= 0 return userStore.my.profile.mygroups.findIndex((rec: IMyGroup) => rec.groupname === grp.groupname) >= 0

View File

@@ -85,6 +85,7 @@ export const useNotifStore = defineStore('NotifStore', {
} }
}, },
updateArrRecNotifFromServer(arrrecnotif: INotif[]) { updateArrRecNotifFromServer(arrrecnotif: INotif[]) {
console.log('arrrecnotif', arrrecnotif)
if (arrrecnotif && arrrecnotif.length > 0) { if (arrrecnotif && arrrecnotif.length > 0) {
this.last_notifs = arrrecnotif this.last_notifs = arrrecnotif

View File

@@ -254,8 +254,15 @@ export const useUserStore = defineStore('UserStore', {
} }
}, },
GroupsListWhereIAmAdmin(): IMyGroup[] { GroupsListWhereIAmAdmin(circuitname: string): any {
return this.my.profile.manage_mygroups console.log('GL', circuitname)
try {
const arr: any = this.my.profile.manage_mygroups.filter((group: IMyGroup) => (group.mycircuits!.findIndex((circ: IMyCircuit) => circ.circuitname === circuitname) >= 0))
console.log('arr', arr)
return arr
} catch (e) {
return []
}
}, },
hoContiCollettiviDaAmministrare(): boolean { hoContiCollettiviDaAmministrare(): boolean {
@@ -1288,13 +1295,21 @@ export const useUserStore = defineStore('UserStore', {
}, },
async loadCircuit(path: string, idnotif: string) { async loadCircuit(path: string, idnotif: string) {
const notifStore = useNotifStore()
const data = { const data = {
path, path,
idnotif, idnotif,
lastdr: notifStore.getLastDataRead(this.my.username),
} }
return Api.SendReq('/circuit/load', 'POST', data) return Api.SendReq('/circuit/load', 'POST', data)
.then((res) => { .then((res) => {
if (res && res.data.arrrecnotif) {
notifStore.updateArrRecNotifFromServer(res.data.arrrecnotif)
}
if (res.data.useraccounts && res.data.useraccounts.length > 0) {
this.my.profile.useraccounts = res.data.useraccounts
}
return { data: res.data, status: res.status } return { data: res.data, status: res.status }
}).catch((error) => { }).catch((error) => {
return { data: null, status: error.status } return { data: null, status: error.status }

View File

@@ -101,8 +101,6 @@ export default defineComponent({
async function loadCircuit() { async function loadCircuit() {
tabcircuit.value = tools.getCookie(tools.COOK_TAB_CIRCUIT + path.value, 'info')
loading.value = true loading.value = true
// Carica il profilo di quest'utente // Carica il profilo di quest'utente
if (path.value) { if (path.value) {
@@ -285,10 +283,12 @@ export default defineComponent({
} }
async function mounted() { async function mounted() {
tabcircuit.value = tools.getCookie(tools.COOK_TAB_CIRCUIT + path.value, 'info')
await loadCircuit() await loadCircuit()
if (userStore.my.username) if (userStore.my.username && circuit.value)
groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin() groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin(circuit.value.name)
} }
@@ -457,6 +457,7 @@ export default defineComponent({
groupnameSel, groupnameSel,
showsendCoinTo, showsendCoinTo,
showrules, showrules,
loadCircuit,
} }
} }
}) })

View File

@@ -207,6 +207,7 @@
:label="t('shared.info1')" :label="t('shared.info1')"
name="info" name="info"
icon="fas fa-info" icon="fas fa-info"
@click="loadCircuit()"
></q-tab> ></q-tab>
<q-tab <q-tab
v-if=" v-if="