- Gruppi (2)

This commit is contained in:
paoloar77
2022-02-04 23:48:53 +01:00
parent 45a771fab2
commit 498c28773f
26 changed files with 332 additions and 67 deletions

View File

@@ -5,6 +5,8 @@ import { tools } from '../../store/Modules/tools'
import { fieldsTable } from '@store/Modules/fieldsTable'
import { shared_consts } from '@/common/shared_vuejs'
import {
IColGridTable,
IFilter,
@@ -313,6 +315,15 @@ export default defineComponent({
function canModifyThisRec(rec: any) {
// console.log('rec', rec)
if (tablesel.value === 'mygroups') {
// is Admin ?
const trovato = rec.admins.find((myuser: any) => myuser.username === userStore.my.username)
if (trovato) {
return !!trovato
}
}
if (rec.hasOwnProperty('userId')) {
let userId = rec.userId
if (userId === userStore.my._id) {
@@ -819,6 +830,8 @@ export default defineComponent({
await createNewRecordDialog()
console.log('newRecord.value', newRecord.value)
serverData.value.push(newRecord.value)
pagination.value.rowsNumber++
@@ -882,6 +895,7 @@ export default defineComponent({
function exec_func_table(table: string, func: number, par: IParamDialog) {
if (func === lists.MenuAction.DELETE_RECTABLE) {
globalStore.DeleteRec({ table, id: par.param1 }).then((ris) => {
if (ris) {
@@ -1149,10 +1163,29 @@ export default defineComponent({
return ok
}
function getColMissing() {
let col: IColGridTable
for (col of mycolumns.value) {
if (col.required) {
// console.log('newRecord.value', newRecord.value, newRecord.value[col.name])
if (!newRecord.value[col.name]) {
// console.log('col.name', col.name)
return translate(col.label_trans)
}
}
}
return ''
}
async function saveNewRecord() {
// check if the field are setted
if (!enableSaveNewRec()) {
tools.showNeutralNotif($q, 'Si prega di compilare il campo \'' + getColMissing() + '\'', 5000)
return false
}
@@ -1243,10 +1276,21 @@ export default defineComponent({
return ((rec._id > 0 && typeof rec._id === 'number') || rec._id !== 'number') && rec !== -100
}
function showColCheck(col: IColGridTable, tipovis: number, visulabel:boolean, value: any = ''){
function showColCheck(col: IColGridTable, tipovis: number, visulabel:boolean, value: any = '', record: any = null){
const check = tools.checkIfShowField(col, tipovis, visulabel, value)
const valuePresent = (colVisib.value.includes(col.field! + col.subfield) || colVisib.value.includes(col.field + '.' + col.subfield))
let valuePresent = (colVisib.value.includes(col.field! + col.subfield) || colVisib.value.includes(col.field + '.' + col.subfield))
if (valuePresent && col.visibleif! > 0 && record) {
if (col.visib_field) {
if (col.visibleif === costanti.BINARY_CHECK) {
if (!tools.isBitActive(record[col.visib_field], col.visib_value))
valuePresent = false
}
}
}
return check && valuePresent
}
@@ -1337,6 +1381,7 @@ export default defineComponent({
myvertical,
showColCheck,
getValueExtra,
shared_consts,
}
}
})

View File

@@ -13,7 +13,7 @@
<q-space></q-space>
<div v-if="butt_modif_new">
<q-btn
v-if="mytable && mytable !== 'myskills'" rounded dense size="sm" flat
v-if="mytable && !shared_consts.TABLES_FINDER.includes(mytable)" rounded dense size="sm" flat
:color="canEdit ? 'positive' : 'light-gray'"
:disable="disabilita()"
:val="lists.MenuAction.CAN_EDIT_TABLE"
@@ -105,7 +105,7 @@
:class="$q.screen.lt.sm ? `` : `row` + ` text-blue `">
<span v-for="(item, index) in searchList" :key="index">
<CMySelect
:col="fieldsTable.getColByTable('myskills', item.key)"
:col="fieldsTable.getColByTable(mytable, item.key)"
v-if="(item.type === costanti.FieldType.select) || (item.type === costanti.FieldType.select_by_server)"
:label="labelcombo(item)"
v-model:value="item.value"
@@ -129,7 +129,7 @@
<CMySelect
v-if="item.type === costanti.FieldType.multiselect_by_server"
:col="fieldsTable.getColByTable('myskills', item.key)"
:col="fieldsTable.getColByTable(mytable, item.key)"
:multiselect_by_server="true"
:label="labelcombo(item)"
v-model:arrvalue="item.arrvalue"
@@ -261,7 +261,7 @@
<q-td
v-for="col in mycolumns" :key="col.name" :props="props">
<div
v-if="showColCheck(col, tools.TIPOVIS_SHOW_RECORD, true, 1)" class="tdclass">
v-if="showColCheck(col, tools.TIPOVIS_SHOW_RECORD, true, 1, props.row)" class="tdclass">
<div :class="getclrow(props.row)">
<CMyPopupEdit
:table="mytable"
@@ -331,6 +331,7 @@
<q-bar v-if="!visuinpage" dense class="bg-primary text-white full-height">
<span class=""> {{ props.row[col_title] }} </span>
<q-space/>
<q-btn
v-if="canModifyThisRec(props.row)"
flat round color="white" icon="fas fa-pencil-alt" size="sm"
@@ -444,7 +445,7 @@
<div
v-for="col in mycolumns" :key="col.name" class="newrec_fields">
<div
v-if="showColCheck(col, tools.TIPOVIS_NEW_RECORD, true) && col.foredit">
v-if="showColCheck(col, tools.TIPOVIS_NEW_RECORD, true, 0, newRecord) && col.foredit">
<div class="">
<CMyPopupEdit
:table="mytable"

View File

@@ -16,6 +16,10 @@ export default defineComponent({
type: Number,
required: true,
},
type_out: {
type: Number,
required: false,
},
optlab: {
type: String,
required: true,
@@ -66,9 +70,20 @@ export default defineComponent({
console.log('optlab', props.optlab)
console.log('myval.value', myval.value)
console.log('rec[props.optval]', rec[props.optval])
*/
// @ts-ignore
if (myval.value.includes(rec[props.optval])) {
let trovato = false
if (props.type_out === costanti.FieldType.object) {
// @ts-ignore
trovato = myval.value.find((recout) => recout[props.optval] === rec[props.optval])
} else {
// @ts-ignore
trovato = myval.value.includes(rec[props.optval])
}
if (trovato) {
const mydata: any = {
label: null,
value: rec[props.optval],

View File

@@ -2,7 +2,7 @@
import { tools } from '@store/Modules/tools'
import { CTitleBanner } from '../CTitleBanner'
import { defineComponent, ref, toRef } from 'vue'
import { defineComponent, onMounted, ref, toRef } from 'vue'
import { useQuasar } from 'quasar'
export default defineComponent({
@@ -38,7 +38,8 @@ export default defineComponent({
const $q = useQuasar()
const editor = ref(null)
const myvalue = toRef(props, 'value')
//const myvalue = toRef(props, 'value')
const myvalue = ref('')
const mycolor = ref('')
const showeditor= ref(true)
@@ -163,6 +164,15 @@ export default defineComponent({
// }
}
function mounted() {
if (props.value === undefined)
myvalue.value = ''
else
myvalue.value = props.value
}
onMounted(mounted)
return {
myfonts,
toolbarcomp,

View File

@@ -23,6 +23,7 @@
</q-popup-proxy>
</q-icon>
</q-btn>
<q-editor
ref="editor"
content-class="wrap_anywhere"

View File

@@ -8,9 +8,9 @@
</q-item-section>
<q-item-section @click="naviga(`/grp/` + grp.groupname)">
<q-item-label><strong>{{ grp.name }} {{ grp.surname }}</strong> ({{ grp.groupname }})
<q-item-label><strong>{{ grp.title }}</strong> ({{ grp.groupname }})
</q-item-label>
<q-item-label v-if="grp.profile" caption lines="1"><em>{{ grp.profile.qualifica }}</em></q-item-label>
<q-item-label v-if="grp.descr" caption lines="1"><em>{{ grp.descr }}</em></q-item-label>
</q-item-section>
<q-item-section side v-if="visu === costanti.MY_GROUPS">

View File

@@ -52,9 +52,9 @@ export default defineComponent({
let arr: any[] = []
try {
if (props.modelValue === costanti.GROUPS) {
arr = userStore.my.profile.groups
arr = userStore.my.profile.mygroups
} else if (props.modelValue === costanti.MY_GROUPS) {
arr = userStore.my.profile.groups
arr = userStore.my.profile.mygroups
// } else if (props.modelValue === costanti.REQ_GROUP) {
// arr = userStore.my.profile.req_groups
} else if (props.modelValue === costanti.ASK_SENT_GROUP) {
@@ -82,7 +82,7 @@ export default defineComponent({
})
const numGroups = computed(() => {
const arr = userStore.my.profile.groups
const arr = userStore.my.profile.mygroups
return (arr) ? arr.length : 0
})
@@ -97,7 +97,7 @@ export default defineComponent({
userStore.loadGroups(username.value).then((ris) => {
// console.log('ris', ris)
if (ris) {
userStore.my.profile.groups = ris.listUsersGroup ? ris.listUsersGroup : []
userStore.my.profile.mygroups = ris.listUsersGroup ? ris.listUsersGroup : []
userStore.groups = ris.listgroups ? ris.listgroups : []
userStore.my.profile.asked_groups = ris.listSentRequestGroups ? ris.listSentRequestGroups : []
filtroutente.value = [{ userId: userStore.my._id }]
@@ -117,7 +117,7 @@ export default defineComponent({
userStore.setGroupsCmd($q, t, username.value, groupnameDest, shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP, null).then((res) => {
if (res) {
userStore.my.profile.groups = userStore.my.profile.groups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
tools.showPositiveNotif($q, t('db.removedgroup'))
}
})
@@ -133,7 +133,7 @@ export default defineComponent({
}).onOk(() => {
userStore.setGroupsCmd($q, t, username.value, usernameDest, shared_consts.GROUPSCMD.BLOCK_GROUP, null).then((res) => {
if (res) {
userStore.my.profile.groups = userStore.my.profile.groups.filter((rec: IMyGroup) => rec.groupname !== usernameDest)
userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter((rec: IMyGroup) => rec.groupname !== usernameDest)
tools.showPositiveNotif($q, t('db.blockedgroup'))
}
})

View File

@@ -15,7 +15,6 @@
/>
</div>
<div v-if="finder" class="">
<div v-if="modelValue === costanti.FIND_GROUP">
<slot></slot>
</div>

View File

@@ -273,6 +273,9 @@ export default defineComponent({
}
function changevalRec(newval: any) {
if (col.value && col.value.allowchar === costanti.ALLOWCHAR_CODE) {
myvalue.value = tools.removespaces(newval)
}
console.log('popypedit: changevalRec', newval)
// console.log('row', props.row, 'col', props.mycol, 'newval', newval)
// console.log('row[col.value.name]', props.row[col.value.name])
@@ -280,6 +283,7 @@ export default defineComponent({
// console.log('image', newval)
}
myrow.value[col.value.name] = newval
// console.log('changevalRec update:row', newval)
emit('update:row', props.row)
if (props.isInModif)
@@ -590,13 +594,13 @@ export default defineComponent({
function getDirectoryGall() {
let ris = ''
if (fieldsTable.tableForUsers.includes(props.table)) {
console.log('1')
ris = 'profile/' + myrow.value['username'] + '/' + props.table
}else if (props.table === 'users') {
console.log('2')
ris = 'profile/' + userStore.my.username
}else if (props.table === 'mygroups') {
if (myrow.value.hasOwnProperty('groupname'))
ris = 'mygroups/' + myrow.value['groupname']
} else {
console.log('3')
ris = props.table
}
return ris
@@ -639,6 +643,16 @@ export default defineComponent({
}
function getToByCol(col: IColGridTable){
if (props.table === 'myskills') {
return '/mypage/'+ props.row['_id']
} else if (props.table === 'mygroups') {
return '/grp/' + props.row['groupname']
}
return ''
}
onBeforeMount(mounted)
crea()
@@ -677,6 +691,7 @@ export default defineComponent({
myImgGall,
noPopupeditByCol,
getTitleEditor,
getToByCol,
}
}
})

View File

@@ -30,17 +30,18 @@
@update:model-value="Savedb"></q-toggle>
</div>
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.string">
<div v-else-if="col.fieldtype === costanti.FieldType.string || col.fieldtype === costanti.FieldType.crypted">
<div v-if="visulabel || isInModif" :class="{ flex: !isInModif}">
<q-input
v-bind="$attrs"
v-model="myvalue"
autogrow
:autogrow="col.fieldtype !== costanti.FieldType.crypted"
:style="$q.screen.lt.sm ? 'min-width: 300px' : ''"
counter
:maxlength="col.maxlength ? col.maxlength : undefined"
:disable="disable"
:readonly="disable"
:type="col.fieldtype === costanti.FieldType.crypted ? `password` : `text`"
@keyup.enter.stop
@update:model-value="changevalRec"
autofocus
@@ -85,6 +86,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.hours">
<div v-if="isFieldDb()">
<CMySelect
:type_out="col.field_outtype"
label="Ore"
v-model:value="myvalue"
@update:value="changevalRec"
@@ -159,6 +161,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.nationality">
<div v-if="isInModif" class="justify-center q-gutter-sm clgutter q-mt-sm">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:label="col.label"
@@ -179,6 +182,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.intcode">
<div v-if="isInModif" class="justify-center q-gutter-sm clgutter q-mt-sm">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:label="col.label"
@@ -254,6 +258,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.multiselect">
<div v-if="isInModif">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:multiple="true"
@@ -309,6 +314,7 @@
<div v-else>
<CMyChipList
:type="col.fieldtype"
:type_out="col.field_outtype"
@update:value="changevalRec"
:value="myvalue"
:options="globalStore.getTableJoinByName(col.jointable, col.addall, col.filter)"
@@ -321,6 +327,7 @@
v-else-if="(col.fieldtype === costanti.FieldType.select) || (col.fieldtype === costanti.FieldType.select_by_server)">
<div v-if="isInModif">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:label="col.label"
@@ -342,6 +349,7 @@
<CMyChipList
myclass="text-center"
:type="col.fieldtype"
:type_out="col.field_outtype"
@update:value="changevalRec"
v-model:value="myvalue"
:options="globalStore.getTableJoinByName(col.jointable, col.addall, col.filter)"
@@ -352,6 +360,7 @@
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.multiselect_by_server">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:multiselect_by_server="true"
@@ -377,6 +386,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.star5">
<div v-if="isInModif">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:label="col.label"
@@ -432,7 +442,7 @@
<q-btn
v-if="myvalue && col.field_extra1"
icon="far fa-file-alt" :label="col.titlepopupedit" color="primary" text-color="white"
:to="`/mypage/`+row['_id']"
:to="getToByCol(col)"
>
</q-btn>
</div>
@@ -503,13 +513,14 @@
</q-checkbox>
<span v-html="visuValByType(myvalue, col, row)"></span>
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.string">
<div v-else-if="col.fieldtype === costanti.FieldType.string || col.fieldtype === costanti.FieldType.crypted">
<q-input
v-bind="$attrs"
counter
:type="col.fieldtype === costanti.FieldType.crypted ? 'password' : 'text'"
:maxlength="col.maxlength ? col.maxlength : undefined"
v-model="scope.value"
autogrow
:autogrow="col.fieldtype !== costanti.FieldType.crypted"
@keyup.enter.stop
autofocus>
@@ -540,6 +551,7 @@
</div>
<div v-if="isFieldDb()">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
label="Ore" v-model:value="myvalue"
@@ -563,6 +575,7 @@
<div
v-else-if="(col.fieldtype === costanti.FieldType.select) || (col.fieldtype === costanti.FieldType.select_by_server)">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:label="col.label"
@@ -581,6 +594,7 @@
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.multiselect_by_server">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:multiselect_by_server="true"
@@ -637,6 +651,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.nationality">
<div class="justify-center q-gutter-sm clgutter q-mt-sm">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:label="col.label"
@@ -657,6 +672,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.intcode">
<div class="justify-center q-gutter-sm clgutter q-mt-sm">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:label="col.label"
@@ -683,6 +699,7 @@
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.star5">
<CMySelect
:type_out="col.field_outtype"
:col="col"
:row="row"
:label="col.label"

View File

@@ -2,3 +2,8 @@
display: flex;
flex: 1;
}
.hint{
color: gray;
font-style: italic;
}

View File

@@ -39,10 +39,9 @@ export default defineComponent({
required: false,
default: ''
},
type: {
type_out: {
type: Number,
required: false,
default: 0
},
row: {
type: Object,
@@ -210,7 +209,24 @@ export default defineComponent({
console.log(' ½½½½½½½ changeval', newval)
if (props.multiple || props.multiselect_by_server) {
// localStorage.setItem(props.tablesel + '_' + newval, valori.value[newval])
myarrvalue.value = newval && newval['arrvalue'] ? newval['arrvalue'] : newval
if (props.type_out === costanti.FieldType.object) {
// debugger;
const arrout = []
for (const val of newval) {
let obj: any = {}
if (typeof val !== 'object') {
obj[props.optval] = val
arrout.push(obj)
} else {
arrout.push(val)
}
}
myarrvalue.value = arrout
} else {
myarrvalue.value = newval && newval['arrvalue'] ? newval['arrvalue'] : newval
}
saveOptInCookie(newval)
// console.log(' ----- Myselect changeval Arrvalue', myarrvalue.value)
@@ -303,15 +319,22 @@ export default defineComponent({
}
}
if (props.tablesel === 'friendsandme') {
debugger;
}
if (props.multiple) {
let arrrec = []
for (const val of props.arrvalue) {
rec = optionsreal.value.find((myrec: any) => val === (myrec[`${props.optval}`]))
if (rec) {
arrrec.push(rec[`${props.optval}`])
if (props.arrvalue) {
for (const val of props.arrvalue) {
rec = optionsreal.value.find((myrec: any) => val === (myrec[`${props.optval}`]))
if (rec) {
arrrec.push(rec[`${props.optval}`])
}
}
}
if (arrrec) {
if (arrrec.length > 0) {
if (props.funcgetvaluebyid)
myarrvalue.value = props.funcgetvaluebyid(arrrec)
else

View File

@@ -159,6 +159,7 @@
<q-item v-bind="itemProps">
<q-item-section>
<q-item-label>{{ opt[optlab] }}</q-item-label>
<q-item-label v-if="'hint' in opt" class="hint">{{ opt['hint'] }}</q-item-label>
</q-item-section>
<q-item-section side>
<q-toggle :model-value="selected" @update:value="toggleOption(opt)"/>
@@ -200,6 +201,7 @@
</q-item-section>
<q-item-section>
<q-item-label>{{ scope.opt[optlab] }}</q-item-label>
<q-item-label v-if="'hint' in scope.opt" class="hint">{{ scope.opt['hint'] }}</q-item-label>
</q-item-section>
</q-item>
</template>