- Add New Record directly by the QSelect

This commit is contained in:
paoloar77
2022-01-28 00:57:28 +01:00
parent 5842fa69e1
commit 5f51c231eb
19 changed files with 434 additions and 181 deletions

View File

@@ -1,4 +1,5 @@
import {
computed,
defineComponent, onBeforeMount, onBeforeUnmount, onMounted, ref, toRef, toRefs, watch,
} from 'vue'
@@ -32,6 +33,19 @@ export default defineComponent({
const filtercustom: any = ref([])
const searchList = ref(<ISearchList[]>[])
const idSector = computed(() => {
let myval = 0
searchList.value.forEach((rec) => {
console.log(' rec', rec)
if (rec.table === 'sectors') {
console.log('trovato')
myval = rec.value
}
})
console.log('IDSECTOR = ' + myval)
return myval
})
function mounted() {
/*arrfilterand.value = [
{
@@ -98,7 +112,7 @@ export default defineComponent({
useinput: true,
},
{
label: 'Specializz.',
label: 'Specializzazione',
table: 'subskills',
key: 'idSubSkill',
value: 0,
@@ -205,6 +219,7 @@ export default defineComponent({
function getdefaultnewrec(): IMySkill {
return {
_id: 0,
idSector: 0,
idSkill: 0,
idSubSkill: [],
idStatusSkill: [],
@@ -236,6 +251,7 @@ export default defineComponent({
lk_proj: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
idSubSkill: 1,
idStatusSkill: 1,
@@ -292,6 +308,7 @@ export default defineComponent({
arrfilterand,
filtercustom,
searchList,
idSector,
}
},
})

View File

@@ -1,6 +1,6 @@
<template>
<div class="q-pa-sm bi-border-all">
<div class="q-ma-sm q-gutter-sm q-pa-xs bg-green">
<div class="bi-border-all">
<div class="q-ma-xs q-gutter-xs q-pa-xs bg-green">
<CGridTableRec
v-if="searchList.length > 0"
prop_mytable="myskills"
@@ -9,7 +9,7 @@
prop_colkey="idSkill"
col_title="subTitle"
:vertical="true"
nodataLabel="Nessuna Competenza trovata"
:nodataLabel="idSector > 0 ? 'Nessuna Competenza trovata': 'Selezionare un Settore'"
:prop_search="true"
:finder="true"
:choose_visutype="true"

View File

@@ -275,14 +275,14 @@ export default defineComponent({
// Delete File on server:
const ris = await globalStore.DeleteFile({ filename })
console.log('ris', ris)
// console.log('ris', ris)
if (ris)
deleted(rec)
})
}
function save() {
console.log('CGallery save')
console.log('CGallery save', gallerylist.value)
if (gallerylist.value.length > 0) {
if (!props.single) {
emit('showandsave', gallerylist.value)
@@ -290,7 +290,7 @@ export default defineComponent({
emit('showandsave', gallerylist.value[0].imagefile)
}
} else {
emit('showandsave', '')
emit('showandsave', !props.single ? [] : '')
}
}

View File

@@ -91,7 +91,7 @@
<div v-if="edit" class="q-gutter-sm " style="max-height: 200px; width: 208px;">
<q-uploader
label="Aggiungi Immagine"
accept=".jpg, image/*, .pdf"
accept="image/jpeg, image/jpg, image/png, .pdf"
:url="getUrl()"
:headers="tools.getheaders()"
:max-file-size="3000000"
@@ -206,7 +206,7 @@
<div class="q-gutter-sm " style="max-height: 200px; width: 208px;">
<q-uploader
label="Aggiungi Immagine"
accept=".jpg, image/*, .pdf"
accept="image/jpeg, image/jpg, image/png, .pdf"
:url="getUrl()"
:headers="tools.getheaders()"
:max-file-size="2000000"

View File

@@ -802,6 +802,7 @@ export default defineComponent({
}
async function createNewRecord() {
await createNewRecordDialog()
@@ -947,12 +948,9 @@ export default defineComponent({
}
function visCol(col: IColGridTable) {
if (col.visuonlyEditVal) {
if (canEdit.value) {
return col.visuonlyEditVal
} else {
return false
}
if ((!tools.isBitActive(col.showWhen, costanti.showWhen.NewRec)) && !tools.isBitActive(col.showWhen, costanti.showWhen.InView)
&& !tools.isBitActive(col.showWhen, costanti.showWhen.InView_OnlyifExist) && tools.isBitActive(col.showWhen, costanti.showWhen.InEdit)) {
return (canEdit.value)
} else {
return true
}
@@ -1129,9 +1127,8 @@ export default defineComponent({
mycolumns.value.forEach((col: IColGridTable) => {
if (col.required) {
console.log('newRecord.value', newRecord.value, newRecord.value[col.name])
// console.log('newRecord.value', newRecord.value, newRecord.value[col.name])
if (!newRecord.value[col.name]) {
ok = false
}
}
@@ -1202,8 +1199,8 @@ export default defineComponent({
const data = await globalStore.saveTable(mydata)
.then((ris) => {
// console.log('ris', ris)
if (ris) {
// console.log('ris', ris)
editRecordBool.value = false
const indrec = serverData.value.findIndex((rec: IMySkill) => rec._id === ris._id)
console.log('indrec', indrec, serverData.value[indrec])
@@ -1234,11 +1231,12 @@ export default defineComponent({
return ((rec._id > 0 && typeof rec._id === 'number') || rec._id !== 'number') && rec !== -100
}
function showColCheck(col: IColGridTable, newrec: boolean){
return (colVisib.value.includes(col.field! + col.subfield) || colVisib.value.includes(col.field + '.' + col.subfield)) &&
(!col.showOnlyNewRec || (col.showOnlyNewRec && newrec)) &&
(col.visible) &&
(!props.visuinpage || (col.visuinpage && props.visuinpage))
function showColCheck(col: IColGridTable, tipovis: number, visulabel:boolean, value: any = ''){
const check = tools.checkIfShowField(col, tipovis, visulabel, value)
const valuePresent = (colVisib.value.includes(col.field! + col.subfield) || colVisib.value.includes(col.field + '.' + col.subfield))
return check && valuePresent
}
function getValueExtra(col: IColGridTable, record: any) {

View File

@@ -65,7 +65,7 @@
:props="props"
class="text-italic text-weight-bold"
>
<span v-if="col && showColCheck(col, false)">
<span v-if="col && showColCheck(col, tools.TIPOVIS_SHOW_RECORD, true)">
{{ col.label }}
</span>
@@ -102,7 +102,7 @@
<template v-slot:top-left>
<div v-if="searchList"
:class="$q.screen.lt.sm ? `` : `row` + ` text-blue`">
:class="$q.screen.lt.sm ? `` : `row` + ` text-blue `">
<span v-for="(item, index) in searchList" :key="index">
<CMySelect
v-if="(item.type === costanti.FieldType.select) || (item.type === costanti.FieldType.select_by_server)"
@@ -252,7 +252,7 @@
<q-td
v-for="col in mycolumns" :key="col.name" :props="props">
<div
v-if="showColCheck(col, false)" class="tdclass">
v-if="showColCheck(col, tools.TIPOVIS_SHOW_RECORD, true, 1)" class="tdclass">
<div :class="getclrow(props.row)">
<CMyPopupEdit
:table="mytable"
@@ -306,7 +306,7 @@
class="q-pa-xs col-xs-12 col-sm-6 col-md-4 col-lg-3 grid-style-transition"
:style="props.selected ? 'transform: scale(0.95);' : ''"
>
<q-card :class="props.selected ? 'bg-grey-2' : ''" style="min-width: 200px;">
<q-card :class="props.selected ? 'bg-grey-2 my-card' : 'my-card'">
<q-bar v-if="!visuinpage" dense class="bg-primary text-white full-height">
<span class=""> {{ props.row[col_title] }} </span>
<q-space/>
@@ -328,9 +328,7 @@
<q-list dense>
<div v-for="col in mycolumns" :key="col.name">
<q-item v-if="showColCheck(col, false) &&
(!col.noshowifnone || (col.noshowifnone && tools.getValue(props.row,col.field, col.subfield))
)"
<q-item v-if="showColCheck(col, tools.TIPOVIS_SHOW_RECORD, false, tools.getValue(props.row,col.field, col.subfield))"
:class="clByCol(col)" class="riduci_pad">
<q-item-section avatar v-if="col.icon">
@@ -378,7 +376,7 @@
<div
class="q-ma-xs q-pa-xs text-center rounded-borders q-list--bordered"
v-for="mycol in mycolumns" :key="mycol.name">
<div v-if="showColCheck(mycol, false)">
<div v-if="showColCheck(mycol, tools.TIPOVIS_SHOW_RECORD, false)">
<div class="row items-center justify-center q-gutter-md q-ma-xs">
<div class="q-ma-xs">
<q-field rounded outlined bg-color="orange-3" dense>
@@ -426,7 +424,7 @@
<div
v-for="col in mycolumns" :key="col.name" class="newrec_fields">
<div
v-if="showColCheck(col, true) && col.foredit">
v-if="showColCheck(col, tools.TIPOVIS_NEW_RECORD, true) && col.foredit">
<div class="">
<CMyPopupEdit
:table="mytable"
@@ -469,7 +467,7 @@
<div
v-for="col in mycolumns" :key="col.name">
<div
v-if="showColCheck(col, false) && col.foredit">
v-if="showColCheck(col, tools.TIPOVIS_EDIT_RECORD, false) && col.foredit">
<div>
<CMyPopupEdit
:table="mytable"

View File

@@ -139,7 +139,7 @@ export default defineComponent({
// Carica il profilo di quest'utente
if (username.value) {
userStore.loadFriends(username.value).then((ris) => {
console.log('ris', ris)
// console.log('ris', ris)
if (ris) {
userStore.my.profile.friends = ris.listFriends ? ris.listFriends : []
userStore.my.profile.req_friends = ris.listRequestFriends ? ris.listRequestFriends : []

View File

@@ -251,6 +251,27 @@ export default defineComponent({
}
}
async function addNewValue(value: any) {
console.log('addNewValue', value, col.value)
if (col.value.allowNewValue && col.value.jointable) {
let myrec: any = {}
let mylabel = fieldsTable.getLabelByTable(col.value.jointable)
myrec[mylabel] = value
if (col.value.filter_field && props.value_extra) {
myrec[col.value.filter_field] = props.value_extra
}
// console.log('value_extra', props.value_extra)
if (props.table) {
return await globalStore.saveNewRecord(col.value.jointable, myrec)
}
}
return null
}
function changevalRec(newval: any) {
console.log('popypedit: changevalRec', newval)
// console.log('row', props.row, 'col', props.mycol, 'newval', newval)
@@ -280,25 +301,29 @@ export default defineComponent({
function mounted() {
// console.log('mounted', 'isFieldDb()', isFieldDb())
if (isFieldDb()) {
try {
// console.log('mounted', 'isFieldDb()', isFieldDb())
if (isFieldDb()) {
} else {
if (props.subfield !== '') {
if (props.row[props.field] === undefined) {
myrow.value[props.field] = {}
myvalue.value = ''
} else {
myvalue.value = myrow.value[props.field][props.subfield]
}
} else {
if (props.field !== '')
myvalue.value = myrow.value[props.field]
else {
// @ts-ignore
myvalue.value = myrow.value
if (props.subfield !== '') {
if (props.row[props.field] === undefined) {
myrow.value[props.field] = {}
myvalue.value = ''
} else {
myvalue.value = myrow.value[props.field][props.subfield]
}
} else {
if (props.field !== '')
myvalue.value = myrow.value[props.field]
else {
// @ts-ignore
myvalue.value = myrow.value
}
}
}
} catch (e) {
}
// console.log('popupedit: myvalue.value', myvalue.value)
@@ -520,10 +545,6 @@ export default defineComponent({
}
}
function visInNewRec(col: any) {
return (!col.notShowInNewRec || (col.showOnlyNewRec && props.insertMode)) && (!col.noShowView || (col.noShowView && props.isInModif))
}
function getclassCol(col: any) {
if (col) {
let mycl = (col.disable || isviewfield()) ? '' : 'colmodif'
@@ -631,6 +652,7 @@ export default defineComponent({
isviewfield,
changeval,
changevalRec,
addNewValue,
changevalRecHours,
updatedata,
OpenEdit,
@@ -638,7 +660,6 @@ export default defineComponent({
annulla,
Savedb,
visuValByType,
visInNewRec,
getclassCol,
selectcountry,
intcode_change,

View File

@@ -1,6 +1,6 @@
<template>
<div :class="getclassCol(col)">
<div v-if="(visInNewRec(col) && visulabel) || (!visulabel && !col.showOnlyNewRec && !col.noShowView) " style="flex-grow: 1;">
<div v-if="tools.checkIfShowField(col, (isInModif ? tools.TIPOVIS_EDIT_RECORD : 0) + (insertMode ? tools.TIPOVIS_NEW_RECORD : 0), visulabel, myvalue)" style="flex-grow: 1;">
<div
:class="{ flex: !isInModif, 'justify-center': true }">
<div>
@@ -91,6 +91,7 @@
@update:value="changevalRec"
optval="_id" optlab="label"
:useinput="false"
:col="col"
:options="tools.SelectHours">
</CMySelect>
</div>
@@ -158,6 +159,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
:col="col"
:label="col.label"
v-model:value="myvalue"
@update:value="changevalRec"
@@ -176,6 +178,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
:col="col"
:label="col.label"
v-model:value="myvalue"
@update:value="changevalRec"
@@ -250,6 +253,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.multiselect">
<div v-if="isInModif">
<CMySelect
:col="col"
:multiple="true"
:withToggle="true"
:label="col.label"
@@ -266,7 +270,8 @@
:optlab="fieldsTable.getLabelByTable(col.jointable)"
:options="globalStore.getTableJoinByName(col.jointable, col.addall, col.filter)"
:sola_lettura="!isInModif"
:useinput="false">
:useinput="col.allowNewValue"
:newvaluefunc="addNewValue">
</CMySelect>
<!--<q-select
@@ -314,18 +319,20 @@
v-else-if="(col.fieldtype === costanti.FieldType.select) || (col.fieldtype === costanti.FieldType.select_by_server)">
<div v-if="isInModif">
<CMySelect
:col="col"
:label="col.label"
v-model:value="myvalue"
:pickup="col.fieldtype === costanti.FieldType.select_by_server"
:tablesel="col.type === costanti.FieldType.select_by_server ? tablesel : ''"
@update:value="changevalRec"
:newvaluefunc="addNewValue"
:filter_table="col.filter_table"
:filter_field="col.filter_field"
:value_extra="value_extra"
:optval="fieldsTable.getKeyByTable(col.jointable)"
:optlab="fieldsTable.getLabelByTable(col.jointable)"
:options="globalStore.getTableJoinByName(col.jointable, col.addall, col.filter)"
:useinput="false">
:useinput="col.allowNewValue">
</CMySelect>
</div>
<div v-else>
@@ -342,6 +349,7 @@
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.multiselect_by_server">
<CMySelect
:col="col"
:multiselect_by_server="true"
:label="col.label"
v-model:arrvalue="myvalue"
@@ -365,6 +373,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.star5">
<div v-if="isInModif">
<CMySelect
:col="col"
:label="col.label"
v-model:value="myvalue"
@update:value="changevalRec"
@@ -400,7 +409,7 @@
</p>
<div v-if="!isFieldDb()">
<CMyEditor
v-model:value="myvalue" :title="getTitleEditor(col, row) && !isInModif" @keyup.enter.stop
v-model:value="myvalue" :title="!isInModif ? getTitleEditor(col, row) : ''" @keyup.enter.stop
:showButtons="false"
:canModify="canModify"
@update:value="changevalRec"
@@ -529,6 +538,7 @@
</div>
<div v-if="isFieldDb()">
<CMySelect
:col="col"
label="Ore" v-model:value="myvalue"
optval="value" optlab="label"
:dense="false"
@@ -550,6 +560,7 @@
<div
v-else-if="(col.fieldtype === costanti.FieldType.select) || (col.fieldtype === costanti.FieldType.select_by_server)">
<CMySelect
:col="col"
:label="col.label"
v-model:value="scope.value"
:pickup="col.fieldtype === costanti.FieldType.select_by_server"
@@ -557,14 +568,16 @@
:filter_table="col.filter_table"
:filter_field="col.filter_field"
:value_extra="value_extra"
:newvaluefunc="addNewValue"
:optval="fieldsTable.getKeyByTable(col.jointable)"
:optlab="fieldsTable.getLabelByTable(col.jointable)"
:options="globalStore.getTableJoinByName(col.jointable, col.addall, col.filter)"
:useinput="false">
:useinput="col.allowNewValue">
</CMySelect>
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.multiselect_by_server">
<CMySelect
:col="col"
:multiselect_by_server="true"
:label="col.label"
v-model:arrvalue="scope.value"
@@ -597,6 +610,8 @@
map-options
:options="globalStore.getTableJoinByName(col.jointable, col.addall, col.filter)"
class="combowidth"
:useinput="col.allowNewValue"
:newvaluefunc="addNewValue"
:option-value="fieldsTable.getKeyByTable(col.jointable)"
@update:model-value="changeval">
@@ -617,6 +632,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.nationality">
<div class="justify-center q-gutter-sm clgutter q-mt-sm">
<CMySelect
:col="col"
:label="col.label"
v-model:value="scope.value"
@update:value="changevalRec"
@@ -635,6 +651,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.intcode">
<div class="justify-center q-gutter-sm clgutter q-mt-sm">
<CMySelect
:col="col"
:label="col.label"
v-model:value="scope.value"
@update:value="changevalRec"
@@ -659,6 +676,7 @@
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.star5">
<CMySelect
:col="col"
:label="col.label"
v-model:value="scope.value"
:optval="fieldsTable.getKeyByTable(col.jointable)"

View File

@@ -1,4 +1,4 @@
import { computed, defineComponent, onMounted, ref, watch } from 'vue'
import { computed, defineComponent, onMounted, PropType, ref, toRef, watch } from 'vue'
import { useI18n } from '@src/boot/i18n'
import { useUserStore } from '@store/UserStore'
import { useGlobalStore } from '@store/globalStore'
@@ -6,6 +6,8 @@ import { useQuasar } from 'quasar'
import { costanti } from '@costanti'
import { fieldsTable } from '@store/Modules/fieldsTable'
import { shared_consts } from '@/common/shared_vuejs'
import { IColGridTable, IOperators } from 'model'
import { tools } from '@store/Modules/tools'
export default defineComponent({
name: 'CMySelect',
@@ -42,6 +44,13 @@ export default defineComponent({
required: false,
default: 0
},
col: {
type: Object as PropType<IColGridTable>,
required: false,
default: () => {
return { name: '' }
},
},
filter_table: {
type: String,
required: false,
@@ -122,19 +131,10 @@ export default defineComponent({
const myarrvalue = ref(<any[]>[])
const arrtempOpt = ref(<any[]>[])
const optionsreal: any = []
const valoriload = computed(() => {
let myarr = props.options
if (props.addall) {
let myobj: any = {}
if (typeof props.optlab === 'string') {
myobj[props.optlab] = '(Tutti)'
myobj[props.optval] = costanti.FILTER_TUTTI
}
myarr = [myobj, ...myarr]
}
return myarr
return updateArrOptions()
})
watch(() => props.options, (value: any, oldval: any) => {
@@ -146,13 +146,13 @@ export default defineComponent({
},
)
watch(() => props.value, (value: any, oldval: any) => {
mounted()
update()
},
)
watch(() => props.arrvalue, (value: any, oldval: any) => {
console.log(' MODIF props.arrvalue', props.arrvalue)
mounted()
update()
},
)
@@ -222,16 +222,22 @@ export default defineComponent({
}
function mounted() {
optionsreal.value = props.options
update()
}
function update() {
// console.log('update')
// console.log(' #### mounted myselect', props.options, 'arrvalue', myarrvalue.value)
let rec: any
if (props.options) {
if (optionsreal.value) {
if (!props.multiselect_by_server) {
rec = props.options.find((myrec: any) => myrec[`${props.optval}`] === props.value)
rec = optionsreal.value.find((myrec: any) => myrec[`${props.optval}`] === props.value)
}
}
if (props.multiselect_by_server) {
const num = parseInt(localStorage.getItem(props.tablesel + 'NUM')!)
console.log('num LOADED ', num)
// console.log('num LOADED ', num)
arrtempOpt.value = []
if (props.addall) {
let myobj: any = {}
@@ -262,72 +268,109 @@ export default defineComponent({
}
}
}
if (rec) {
if (props.funcgetvaluebyid)
myvalue.value = props.funcgetvaluebyid(rec[`${props.optval}`])
else
myvalue.value = rec[`${props.optlab}`]
} else {
// if (!props.useinput) {
if (props.value) {
myvalue.value = props.value
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 (arrrec) {
if (props.funcgetvaluebyid)
myarrvalue.value = props.funcgetvaluebyid(arrrec)
else
myarrvalue.value = arrrec
} else {
if (props.arrvalue) {
myarrvalue.value = props.arrvalue
}
}
// }
}
// console.log('@@@ VALORI CHANGED (4)', valori.value)
if (!props.multiselect_by_server) {
valori.value = valoriload.value
} else {
if (rec) {
if (props.funcgetvaluebyid)
myvalue.value = props.funcgetvaluebyid(rec[`${props.optval}`])
else
myvalue.value = rec[`${props.optlab}`]
} else {
// if (!props.useinput) {
if (props.value) {
myvalue.value = props.value
}
// }
}
// console.log('myvalue', props.tablesel, myvalue.value)
// console.log('props.value', props.value)
}
if (props.multiselect_by_server) {
valori.value = arrtempOpt.value
} else {
valori.value = valoriload.value
}
// console.log('cmyselect: myvalue.value', myvalue.value)
}
function updateArrOptions() {
let myarr: any = []
if (props.col.jointable) {
optionsreal.value = globalStore.getTableJoinByName(props.col.jointable, props.col.addall, props.col.filter)
}
myarr = optionsreal.value
if (!fieldsTable.tableRemotePickup.includes(props.tablesel)) {
let needle: any = props.value_extra
// console.log('needle', needle, 'props.multiple', props.multiple)
if (props.filter_table) {
// console.log(' FILTERTABLE', props.filter_field, myarr)
if (props.multiple) {
myarr = myarr.filter((rec: any) => rec[props.filter_field] === needle)
} else {
myarr = myarr.filter((rec: any) => rec[props.filter_field].includes(needle))
}
// console.log(' RISSSSSSSSS: ', myarr)
}
}
if (props.addall) {
let myobj: any = {}
if (typeof props.optlab === 'string') {
myobj[props.optlab] = '(Tutti)'
myobj[props.optval] = costanti.FILTER_TUTTI
}
if (myarr)
myarr = [myobj, ...myarr]
// console.log(' myarr: ', myarr)
}
return myarr
}
function filterFn(val: any, update: any, abort: any) {
update(
async () => {
async () => {
console.log('Filter val', val, val.length)
let myarr: any = []
if (!fieldsTable.tableRemotePickup.includes(props.tablesel)) {
myarr = props.options
myarr = updateArrOptions()
if (!fieldsTable.tableRemotePickup.includes(props.tablesel)) {
if (myarr && myarr.length > 0) {
valori.value = myarr
} else {
if (props.filter_table) {
valori.value = []
}
}
return
}
let needle: any = props.value_extra
// console.log('needle', needle)
if (props.filter_table) {
// console.log(' FILTERTABLE', props.filter_field, myarr)
if (props.multiple) {
myarr = myarr.filter((rec: any) => rec[props.filter_field] === needle)
} else {
myarr = myarr.filter((rec: any) => rec[props.filter_field].includes(needle))
}
// console.log(' RISSSSSSSSS: ', myarr)
}
if (props.addall) {
let myobj: any = {}
if (typeof props.optlab === 'string') {
myobj[props.optlab] = '(Tutti)'
myobj[props.optval] = costanti.FILTER_TUTTI
}
if (myarr)
myarr = [myobj, ...myarr]
// console.log(' myarr: ', myarr)
}
if (myarr && myarr.length > 0) {
valori.value = myarr
} else {
if (props.filter_table) {
valori.value = []
}
}
return
}
if (val.length <= 1) {
if (val.length <= 1) {
console.log('@@@ LENGTH <= 1')
abort()
return
@@ -339,7 +382,7 @@ export default defineComponent({
if (fieldsTable.tableRemotePickup.includes(props.tablesel)) {
try {
myarr = props.options
myarr = optionsreal.value
if (mystr !== '')
// myarr = [{_id:1, prov: 'RN', descr: 'Rimini'}]
myarr = await globalStore.loadPickup({ table: props.tablesel, search: mystr.trim() })
@@ -354,16 +397,15 @@ export default defineComponent({
}
// const needle = val.toLocaleLowerCase()
// optFiltered.value = optFiltered.value.filter((v: any) => v.toLocaleLowerCase().indexOf(needle) > -1)
}
if (props.addall) {
let myobj: any = {}
if (typeof props.optlab === 'string') {
myobj[props.optlab] = '(Tutti)'
myobj[props.optval] = costanti.FILTER_TUTTI
}
if (props.addall) {
let myobj: any = {}
if (typeof props.optlab === 'string') {
myobj[props.optlab] = '(Tutti)'
myobj[props.optval] = costanti.FILTER_TUTTI
myarr = [myobj, ...myarr]
}
myarr = [myobj, ...myarr]
}
if (myarr && myarr.length > 0) {
@@ -377,10 +419,12 @@ export default defineComponent({
},
// "ref" is the Vue reference to the QSelect
(ref: any) => {
// console.log('ref.options', ref.options)
if (val !== '' && ref.options.length > 0) {
ref.setOptionIndex(-1) // reset optionIndex in case there is something selected
ref.moveOptionSelection(1, true) // focus the first selectable option and do not update the input-value
if (!props.useinput) {
// console.log('ref.options', ref.options)
if (val !== '' && ref.options.length > 0) {
ref.setOptionIndex(-1) // reset optionIndex in case there is something selected
ref.moveOptionSelection(1, true) // focus the first selectable option and do not update the input-value
}
}
}
)
@@ -394,6 +438,62 @@ export default defineComponent({
return (rec._id > 0 && typeof rec._id === 'number') || rec._id !== 'number'
}
async function newvaluefuncfirst(value: any, done: any) {
if (props.newvaluefunc && props.col) {
const fieldval = fieldsTable.getLabelByTable(props.col.jointable!)
// console.log('fieldval', fieldval, 'optionsreal.value', optionsreal.value)
// Se esiste già, non crearlo
const esiste = optionsreal.value.find((rec: any) => {
// console.log('rec[fieldval]',rec[fieldval], value.toLowerCase())
return rec[fieldval].toLowerCase() === value.toLowerCase() && (rec[props.filter_field] === props.value_extra)
})
console.log('esiste', esiste)
if (!esiste || (esiste && esiste.length === 0)) {
// console.log('non esiste, lo creo ! ', value)
const newrec = await props.newvaluefunc(tools.CapitalizeAllWords(value))
if (newrec) {
if (props.col && props.col.jointable) {
// Reload
// console.log(' A1', optionsreal.value)
// valori.value = valoriload.value
// optionsreal.value = valori.value
console.log('DOPO', optionsreal.value)
}
console.log('newrec', newrec)
const myid = fieldsTable.getKeyByTable(props.col.jointable!)
const recfound = valori.value.find((rec: any) => rec[myid] === newrec[myid])
if (!recfound) {
done(newrec, 'add-unique')
}
// console.log('myid', myid, optionsreal.value)
// console.log('recfound',recfound)
// console.log('newrec[myid]',newrec[myid])
/*if (recfound) {
const arrout = [...myarrvalue.value]
if (!arrout.includes(recfound[myid])) {
arrout.push(recfound[myid])
}
console.log(' arrout (1)', arrout)
if (props.multiple || props.multiselect_by_server) {
if (myid) {
done(newrec, 'add-unique')
}
} else {
done(recfound[myid], 'add-unique')
}
/* if (props.multiple || props.multiselect_by_server) {
console.log('arrout (2)', arrout)
changeval(arrout)
}
}*/
}
}
}
}
onMounted(mounted)
@@ -406,6 +506,7 @@ export default defineComponent({
fieldsTable,
checkIfShowRec,
abortFilterFn,
newvaluefuncfirst,
}
}
})

View File

@@ -119,8 +119,7 @@
:input-class="myclass"
:use-input="useinput"
input-debounce="0"
@new-value="newvaluefunc"
new-value-mode="add-unique"
@new-value="newvaluefuncfirst"
map-options
emit-value
stack-label
@@ -176,12 +175,13 @@
@update:model-value="changeval"
@filter="filterFn"
:label="label"
:use-input="useinput"
@new-value="newvaluefuncfirst"
emit-value
options-selected-class="text-deep-orange"
map-options
v-bind="$attrs"
class="combowidth"
>
class="combowidth">
<template v-slot:option="scope">
<q-item v-bind="scope.itemProps">
<q-item-section avatar>

View File

@@ -68,6 +68,7 @@ export default defineComponent({
function getdefaultnewrec(): IMySkill {
return {
_id: 0,
idSector: 0,
idSkill: 0,
idSubSkill: [],
idStatusSkill: [],
@@ -102,6 +103,7 @@ export default defineComponent({
lk_proj: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
idSubSkill: 1,
idStatusSkill: 1,
@@ -132,6 +134,7 @@ export default defineComponent({
lk_proj: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
idSubSkill: 1,
idStatusSkill: 1,

View File

@@ -868,7 +868,7 @@ $heightBtn: 100%;
}
.combowidth {
min-width: 100px;
min-width: 180px;
@media (max-width: 450px) {
min-width: 250px;
}

View File

@@ -502,19 +502,15 @@ export interface IColGridTable {
addall?: boolean
filter?: any
resultjoin?: string[]
visuonlyEditVal?: boolean
noshowifnone?: boolean
notShowInNewRec?: boolean
tablesel?: string
notsave?: boolean
showOnlyNewRec?: boolean
visuinpage?: boolean
noShowView?: boolean
showWhen?: number
maxlength?: number
filter_table?: string
filter_field?: string
field_extra1?: string
subfield_extra1?: string
allowNewValue?: boolean
}
export interface ITableRec {
@@ -650,6 +646,7 @@ export interface ICity {
export interface IMySkill {
_id: number
idSector: number
idSkill: number
idSubSkill: number[]
idStatusSkill: number[]

View File

@@ -598,6 +598,7 @@ const msg_it = {
newproj: 'Titolo Progetto',
newsubproj: 'Titolo Sotto-Progetto',
insertbottom: 'Inserisci Nuovo Project',
shortdescr: 'Breve Descrizione',
longdescr: 'Descrizione',
note: 'Note',
hoursplanned: 'Ore Preventivate',
@@ -809,7 +810,7 @@ const msg_it = {
photos: 'Foto',
note: 'Note',
short_node: 'Breve Nota',
subskill: 'Specializz.',
subskill: 'Specializzazione',
},
level: {
name: 'Livello',

View File

@@ -28,6 +28,14 @@ export const costanti = {
DRAGULA: false,
showWhen: {
NewRec: 1,
InPage: 2,
InEdit: 4,
InView: 8,
InView_OnlyifExist: 16,
},
TABEVENTS: 'myevents',
NOFIELD: 'nofield',

View File

@@ -56,6 +56,7 @@ function AddCol(params: IColGridTable) {
titlepopupedit: (params.titlepopupedit === undefined) ? '' : params.titlepopupedit,
field_extra1: (params.field_extra1 === undefined) ? '' : params.field_extra1,
subfield_extra1: (params.subfield_extra1 === undefined) ? '' : params.subfield_extra1,
allowNewValue: (params.allowNewValue === undefined) ? false : params.allowNewValue,
visible: (params.visible === undefined) ? true : params.visible,
icon: (params.icon === undefined) ? '' : params.icon,
action: (params.action === undefined) ? '' : params.action,
@@ -63,18 +64,13 @@ function AddCol(params: IColGridTable) {
fieldtype: (params.fieldtype === undefined) ? costanti.FieldType.string : params.fieldtype,
tipovisu: (params.tipovisu === undefined) ? costanti.TipoVisu.TESTO : params.tipovisu,
link: (params.link === undefined) ? '' : params.link,
visuonlyEditVal: (params.visuonlyEditVal === undefined) ? false : params.visuonlyEditVal,
askaction: (params.askaction === undefined) ? '' : params.askaction,
tablesel: (params.tablesel === undefined) ? '' : params.tablesel,
jointable: (params.jointable === undefined) ? '' : params.jointable,
addall: (params.addall === undefined) ? false : params.addall,
filter: (params.filter === undefined) ? null : params.filter,
noshowifnone: (params.noshowifnone === undefined) ? false : params.noshowifnone,
showWhen: (params.showWhen === undefined) ? costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView : params.showWhen,
noshowlabel: (params.noshowlabel === undefined) ? false : params.noshowlabel,
notShowInNewRec: (params.notShowInNewRec === undefined) ? false : params.notShowInNewRec,
showOnlyNewRec: (params.showOnlyNewRec === undefined) ? false : params.showOnlyNewRec,
visuinpage: (params.visuinpage === undefined) ? false : params.visuinpage,
noShowView: (params.noShowView === undefined) ? false : params.noShowView,
notsave: (params.notsave === undefined) ? false : params.notsave,
filter_table: (params.filter_table === undefined) ? '' : params.filter_table,
maxlength: (params.maxlength === undefined) ? 0 : params.maxlength,
@@ -272,7 +268,7 @@ export const colTableHours = [
// AddCol({ name: 'time_start', label_trans: 'hours.time_start', fieldtype: costanti.FieldType.number }),
// AddCol({ name: 'time_end', label_trans: 'hours.time_end', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'descr', label_trans: 'hours.note' }),
AddCol({ name: 'username', label_trans: 'reg.username_short', notShowInNewRec: true }),
AddCol({ name: 'username', label_trans: 'reg.username_short', showWhen: costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView }),
AddCol(DeleteRec),
AddCol(DuplicateRec),
]
@@ -426,13 +422,16 @@ export const colmySkills = [
}), */
//AddCol({ name: 'name', label_trans: 'reg.name', fieldtype: costanti.FieldType.string }),
//AddCol({ name: 'surname', label_trans: 'reg.surname', fieldtype: costanti.FieldType.string }),
AddCol({ name: 'subTitle', label_trans: 'event.title', fieldtype: costanti.FieldType.string, noshowifnone: true, maxlength: 70, noshowlabel: true, noShowView: true }),
AddCol({ name: 'subTitle', label_trans: 'event.title', fieldtype: costanti.FieldType.string,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit , maxlength: 70, noshowlabel: true }),
AddCol({ name: 'descr', label_trans: 'proj.shortdescr', fieldtype: costanti.FieldType.string,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist, noshowlabel: true, maxlength: 200 }),
AddCol({
name: 'photos',
label_trans: 'skill.photos',
fieldtype: costanti.FieldType.listimages,
jointable: '',
noshowifnone: true,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
}),
AddCol({
name: 'idSector',
@@ -440,8 +439,7 @@ export const colmySkills = [
fieldtype: costanti.FieldType.select,
required: true,
jointable: 'sectors',
notsave: true,
showOnlyNewRec: true,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InEdit,
visible: true,
}),
AddCol({
@@ -454,48 +452,47 @@ export const colmySkills = [
filter_field: 'idSector',
noshowlabel: true,
icon: 'far fa-id-card',
visuinpage: true,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView,
allowNewValue: true,
}),
AddCol({
name: 'idSubSkill',
label_trans: 'skill.subskill',
fieldtype: costanti.FieldType.multiselect,
required: true,
required: false,
jointable: 'subskills',
filter_table: 'skills',
filter_field: 'idSkill',
noshowlabel: true,
icon: 'fas fa-scroll',
visuinpage: true,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView,
allowNewValue: true,
}),
AddCol({
name: 'numLevel',
label_trans: 'level.name',
fieldtype: costanti.FieldType.star5,
required: true,
required: false,
jointable: 'levels',
noshowifnone: true,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
noshowlabel: true,
icon: 'fas fa-layer-group',
visuinpage: true,
}),
AddCol({
name: 'idStatusSkill',
label_trans: 'statusSkill.name',
fieldtype: costanti.FieldType.multiselect,
jointable: 'statusSkills',
noshowifnone: true,
visuinpage: true,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
}),
AddCol({
name: 'idContribType',
label_trans: 'contribtype.name',
fieldtype: costanti.FieldType.multiselect,
jointable: 'contribtypes',
noshowifnone: true,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
noshowlabel: true,
icon: 'fas fa-hands-helping',
visuinpage: true,
}),
AddCol({
name: 'idCity',
@@ -505,11 +502,12 @@ export const colmySkills = [
tablesel: 'cities',
noshowlabel: true,
icon: 'fas fa-map-marker-alt',
visuinpage: true,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView,
}),
AddCol({ name: 'username', label_trans: 'reg.username', foredit: false, tipovisu: costanti.TipoVisu.LINK, link: '/my/username', noshowlabel: true }),
AddCol({ name: 'note', label_trans: 'proj.longdescr', fieldtype: costanti.FieldType.html, noshowifnone: true,
titlepopupedit: 'Dettagli:', field_extra1: 'username', subfield_extra1: '' }),
AddCol({ name: 'note', label_trans: 'proj.longdescr', fieldtype: costanti.FieldType.html,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
titlepopupedit: 'Dettagli', field_extra1: 'username', subfield_extra1: '' }),
AddCol(DuplicateRec),
AddCol(ModifRec),
AddCol(DeleteRec),
@@ -1822,7 +1820,7 @@ export const fieldsTable = {
},
{
value: 'subskills',
label: 'Specializz',
label: 'Specializzazione',
columns: colSubSkills,
colkey: '_id',
collabel: 'descr',

View File

@@ -1,5 +1,6 @@
import { translation } from '@store/Modules/translation'
import {
IColGridTable,
IColl,
ICollaborations, IDataToSet,
IEvents, IFriends,
@@ -61,6 +62,11 @@ export const tools = {
TYPECONF_ZOOM: 'zoom',
TYPECONF_JITSI: 'jitsi',
TIPOVIS_NEW_RECORD: 1,
TIPOVIS_EDIT_RECORD: 2,
TIPOVIS_SHOW_RECORD: 4,
TIPOVIS_SHOW_INPAGE: 8,
APORTADOR_SOLIDARIO: 'apsol',
IDAPP_AYNI: '7',
@@ -1477,7 +1483,7 @@ export const tools = {
} else {
ris = myimage
}
}catch (e) {
} catch (e) {
return myimage
}
@@ -4582,6 +4588,30 @@ export const tools = {
return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0')
},
checkIfShowField(col: IColGridTable, tipovis: number, visulabel: boolean, valuePresent: any = '') {
let check = (col.visible)
if (tipovis === tools.TIPOVIS_NEW_RECORD) {
check = check && tools.isBitActive(col.showWhen, costanti.showWhen.NewRec)
} else if (tipovis === tools.TIPOVIS_EDIT_RECORD) {
check = check && tools.isBitActive(col.showWhen, costanti.showWhen.InEdit)
} else if (tipovis === tools.TIPOVIS_SHOW_RECORD) {
if (tools.isBitActive(col.showWhen, costanti.showWhen.InView_OnlyifExist)) {
check = check && valuePresent
} else {
check = check && tools.isBitActive(col.showWhen, costanti.showWhen.InView)
}
} else if (tipovis === tools.TIPOVIS_SHOW_INPAGE) {
check = check && tools.isBitActive(col.showWhen, costanti.showWhen.InPage)
}
return check
// (!col.noShowView || (col.noShowView && isInModif)) ||
// (!visulabel && !col.showOnlyNewRec && !col.noShowView)
},
// getLocale() {
// if (navigator.languages && navigator.languages.length > 0) {

View File

@@ -470,6 +470,48 @@ export const useGlobalStore = defineStore('GlobalStore', {
}
},
UpdateValuesInMemoryByTable(mydata: any, table: string): void {
try {
const mylist = this.getListByTable(table)
const mykey = fieldsTable.getKeyByTable(table)
const id = mydata[mykey]
console.log('mylist', mylist)
console.log('mykey', mykey)
console.log('id', id)
if (mylist) {
const myrec = mylist.find((event: any) => event[mykey] === id)
// console.log('myrec', myrec)
if (myrec) {
// console.log('key', value, myrec[key])
for (const [key, value] of Object.entries(mydata)) {
myrec[key] = value
}
}
console.log('update: ', myrec)
}
} catch (e) {
console.error(e)
}
},
newValueInMemoryByTable(mydata: any, table: string): void {
try {
const mylist = this.getListByTable(table)
if (mylist) {
mylist.push(mydata)
}
} catch (e) {
console.error(e)
}
},
createPushSubscription() {
// If Already subscribed, don't send to the Server DB
@@ -799,6 +841,27 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async saveNewRecord(mytable: string, myrec: any) {
const userStore = useUserStore()
console.log('saveNewRecord', mytable, myrec)
const mydata: any = {
table: mytable,
data: myrec
}
mydata.data.userId = userStore.my._id
const ris = await this.saveTable(mydata)
if (ris) {
this.newValueInMemoryByTable(ris, mytable);
}
console.log('saveNewRecord', ris)
return ris
},
async saveFieldValue(mydata: IDataToSet) {
// const userStore = useUserStore()
return Api.SendReq('/chval', 'PATCH', { data: mydata })