From cab0562de768e741e4dbdab49538326fbff6c58c Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Sat, 11 Dec 2021 00:25:35 +0100 Subject: [PATCH] - Aggiunto Filtri - Finder --- src/common/shared_vuejs.ts | 3 +- src/components/CFinder/CFinder.scss | 29 ++++ src/components/CFinder/CFinder.ts | 148 ++++++++++++++++++ src/components/CFinder/CFinder.vue | 32 ++++ src/components/CFinder/index.ts | 1 + src/components/CGallery/CGallery.ts | 1 + src/components/CGridTableRec/CGridTableRec.ts | 82 +++++++++- .../CGridTableRec/CGridTableRec.vue | 97 +++++++++--- src/components/CHours/CHours.vue | 2 +- src/components/CMyPopupEdit/CMyPopupEdit.ts | 12 +- src/components/CMyPopupEdit/CMyPopupEdit.vue | 2 - src/components/CMySelect/CMySelect.ts | 24 ++- src/components/CMySelect/CMySelect.vue | 4 +- src/components/CShareWithUs/CShareWithUs.ts | 2 + src/components/CSkill/CSkill.ts | 15 ++ src/components/CSkill/CSkill.vue | 3 +- src/model/GlobalStore.ts | 12 +- src/root/home/home.ts | 3 +- src/root/home/home.vue | 3 +- src/rootgen/admin/usersList/usersList.ts | 7 + src/statics/lang/it.js | 3 +- src/store/Modules/costanti.ts | 2 + src/store/Modules/fieldsTable.ts | 9 +- src/store/Modules/tools.ts | 1 + src/store/globalStore.ts | 16 +- 25 files changed, 465 insertions(+), 48 deletions(-) create mode 100755 src/components/CFinder/CFinder.scss create mode 100755 src/components/CFinder/CFinder.ts create mode 100755 src/components/CFinder/CFinder.vue create mode 100755 src/components/CFinder/index.ts diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index 274bc73d..078291a0 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -27,7 +27,6 @@ export const shared_consts = { FILTER_USER_CODICE_AUTH_TELEGRAM: 64, FILTER_USER_NO_EMAIL_VERIFICATA: 128, FILTER_USER_NO_DREAM: 256, - FILTER_EXTRALIST_DELETED: 512, FILTER_USER_TELEGRAM_BLOCKED: 1024, FILTER_ATTIVI: 2048, FILTER_NASCOSTI: 4096, @@ -40,6 +39,8 @@ export const shared_consts = { FILTER_TO_MAKE_MEMBERSHIP_CARD: 524288, FILTER_MEMBERSHIP_CARD_OK: 1048576, + FILTER_MYSKILL_SKILL: 1, + REPORT_FILT_RESP: 1, REPORT_FILT_ATTIVITA: 2, diff --git a/src/components/CFinder/CFinder.scss b/src/components/CFinder/CFinder.scss new file mode 100755 index 00000000..ab083089 --- /dev/null +++ b/src/components/CFinder/CFinder.scss @@ -0,0 +1,29 @@ + +.cltitlebg{ + +} + +.titletext { + color: white; + font-size: 3rem; + font-weight: 500; + line-height: 3rem; + text-shadow: .25rem .25rem .5rem black; + letter-spacing: .00937em; + opacity: 0.9; +} + +@media (max-width: 718px) { + // PER VERSIONE MOBILE + .titletext { + color: white; + font-size: 2rem; + font-weight: 500; + line-height: 2rem; + text-shadow: .25rem .25rem .5rem black; + } +} + +.q-img__content > div{ + background: rgba(0,0,0,0.17) !important; +} diff --git a/src/components/CFinder/CFinder.ts b/src/components/CFinder/CFinder.ts new file mode 100755 index 00000000..fe41fe91 --- /dev/null +++ b/src/components/CFinder/CFinder.ts @@ -0,0 +1,148 @@ +import { + defineComponent, onBeforeMount, onBeforeUnmount, onMounted, ref, toRef, toRefs, watch, +} from 'vue' + +import { tools } from '@store/Modules/tools' +import { CMyFieldDb } from '@/components/CMyFieldDb' +import { costanti } from '@costanti' +import { useGlobalStore } from '@store/globalStore' +import { useUserStore } from '@store/UserStore' +import { colmySkills } from '@store/Modules/fieldsTable' +import { CGridTableRec } from '@/components/CGridTableRec' +import { IMySkill, ISearchList, ISkill } from 'model' +import { shared_consts } from '@/common/shared_vuejs' + +export default defineComponent({ + name: 'CFinder', + props: { + defaultnewrec: { + type: Function, + required: false, + }, + }, + components: { + CMyFieldDb, CGridTableRec, + }, + setup(props, { attrs, slots, emit }) { + const mytable = 'users' + const globalStore = useGlobalStore() + const userStore = useUserStore() + + const arrfilterand: any = ref([]) + const filtercustom: any = ref([]) + const searchList = ref([]) + + function mounted() { + /*arrfilterand.value = [ + { + label: 'Competenze', + value: shared_consts.FILTER_MYSKILL_SKILL + }, + + ]*/ + + searchList.value = [ + { + label: 'Settore', + table: 'sectors', + key: 'idSector', + value: costanti.FILTER_TUTTI, + type: costanti.FieldType.select, + }, + { + label: 'Competenza', + table: 'skills', + key: 'idSkill', + value: costanti.FILTER_TUTTI, + type: costanti.FieldType.select, + }, + { + label: 'Citta', + table: 'cities', + key: 'idCity', + value: costanti.FILTER_TUTTI, + type: costanti.FieldType.multiselect, + }, + { + label: 'Livello', + table: 'levels', + key: 'numLevel', + value: costanti.FILTER_TUTTI, + type: costanti.FieldType.select, + }, + { + label: 'Stato', + table: 'statusSkills', + key: 'idStatusSkill', + value: costanti.FILTER_TUTTI, + type: costanti.FieldType.multiselect, + }, + + ] + + filtercustom.value = [] + } + + async function createNewRecordInUserTable() { + console.log('createNewRecordInUserTable') + + let mydata = { + table: mytable, + data: { + userId: userStore.my._id, + data: {}, + field: 'myskills' + } + }; + + if (props.defaultnewrec) { + + mydata.data.data = props.defaultnewrec + } + + console.log('mydata', mydata) + const data = await globalStore.saveSubRec(mydata) + } + + function getdefaultnewrec(): any { + return { + _id: 0, + idSkill: 0, + idStatusSkill: [], + idCity: [], + NumLevel: 0, + photos: [], + note: '', + subTitle: '', + } + } + + + function extraparams() { + return { + lk_tab: 'users', + lk_LF: 'userId', + lk_FF: '_id', + lk_as: 'user', + af_objId_tab: 'myId', + lk_proj: { + idSkill: 1, idStatusSkill: 1, idCity: 1, numLevel: 1, photos: 1, note: 1, subTitle: 1, date_created:1, date_updated: 1, + userId: 1, username: 1, name: 1, surname: 1 + } + } + } + + onMounted(mounted) + + return { + tools, + costanti, + colmySkills, + getdefaultnewrec, + extraparams, + arrfilterand, + filtercustom, + searchList, + } + }, +}) diff --git a/src/components/CFinder/CFinder.vue b/src/components/CFinder/CFinder.vue new file mode 100755 index 00000000..4cfc529a --- /dev/null +++ b/src/components/CFinder/CFinder.vue @@ -0,0 +1,32 @@ + + + + diff --git a/src/components/CFinder/index.ts b/src/components/CFinder/index.ts new file mode 100755 index 00000000..7fd2c1d2 --- /dev/null +++ b/src/components/CFinder/index.ts @@ -0,0 +1 @@ +export { default as CFinder } from './CFinder.vue' diff --git a/src/components/CGallery/CGallery.ts b/src/components/CGallery/CGallery.ts index 01ab056b..cea7e300 100755 --- a/src/components/CGallery/CGallery.ts +++ b/src/components/CGallery/CGallery.ts @@ -71,6 +71,7 @@ export default defineComponent({ gallerylist.value = [ ] } + } function showandsave(value: any) { diff --git a/src/components/CGridTableRec/CGridTableRec.ts b/src/components/CGridTableRec/CGridTableRec.ts index 1b3b8e30..b207b3b7 100755 --- a/src/components/CGridTableRec/CGridTableRec.ts +++ b/src/components/CGridTableRec/CGridTableRec.ts @@ -3,10 +3,13 @@ import { useI18n } from '@src/boot/i18n' import { tools } from '../../store/Modules/tools' +import { fieldsTable } from '@store/Modules/fieldsTable' + import { IColGridTable, IFilter, ITableRec, + ISearchList, IPagination, IParamDialog, IEvents, @@ -16,6 +19,8 @@ import { import { lists } from '../../store/Modules/lists' import { IParamsQuery } from '../../model/GlobalStore' import { CMyPopupEdit } from '../CMyPopupEdit' +import { CMyFieldDb } from '../CMyFieldDb' +import { CMySelect } from '../CMySelect' import { CTitleBanner } from '../CTitleBanner' import { useUserStore } from '@store/UserStore' @@ -53,6 +58,16 @@ export default defineComponent({ required: false, default: true, }, + butt_modif_new: { + type: Boolean, + required: false, + default: true, + }, + finder: { + type: Boolean, + required: false, + default: false, + }, vertical: { type: Boolean, required: false, @@ -83,6 +98,11 @@ export default defineComponent({ required: false, default: null, }, + prop_searchList: { + type: Object as PropType, + required: false, + default: null, + }, arrfilters: { type: Object as PropType, required: false, @@ -95,6 +115,13 @@ export default defineComponent({ return [] } }, + filtercustom: { + type: Array, + required: false, + default: () => { + return [] + } + }, extraparams: { required: false, default: {}, @@ -116,7 +143,7 @@ export default defineComponent({ default: '', }, }, - components: { CMyPopupEdit, CTitleBanner }, + components: { CMyPopupEdit, CTitleBanner, CMyFieldDb, CMySelect }, setup(props, { emit }) { const $q = useQuasar() const { t } = useI18n() @@ -145,6 +172,7 @@ export default defineComponent({ const serverData: any = ref([]) const spinner_visible = ref(false) + const searchList = toRef(props, 'prop_searchList') let idsel = '' let colsel = ref({ name: '', field: '' }) @@ -153,6 +181,7 @@ export default defineComponent({ let separator: 'horizontal' const myfilter = ref('') const myfilterand: any = ref([]) + const myfiltercustom: any = ref([]) let rowsel: any = {} let dark = true const canEdit = ref(false) @@ -169,6 +198,15 @@ export default defineComponent({ const mycodeid = toRef(props, 'prop_codeId') + watch(searchList.value, (to: any, from: any) => { + refresh() + }) + + function searchval(newval: any) { + console.log('searchval') + refresh() + } + // emulate 'SELECT count(*) FROM ...WHERE...' function getRowsNumberCount(myfilter?: any) { @@ -188,7 +226,7 @@ export default defineComponent({ // emulate ajax call // SELECT * FROM ... WHERE...LIMIT... - async function fetchFromServer(startRow: any, endRow: any, param_myfilter: any, param_myfilterand: any, sortBy: any, descending: any) { + async function fetchFromServer(startRow: any, endRow: any, param_myfilter: any, param_myfilterand: any, filtercustom: any, sortBy: any, descending: any) { let myobj: any = {} if (sortBy) { @@ -202,12 +240,29 @@ export default defineComponent({ // console.log('sortBy', sortBy) + let filtersearch: ISearchList[] = [] + + if (searchList.value) { + searchList.value.forEach((item: ISearchList) => { + if (item.value > 0) { + let myarr: ISearchList + let objitem: any = {} + objitem[item.key] = item.value + filtersearch.push(objitem) + } + }) + } + + let params: IParamsQuery = { table: mytable.value, startRow, endRow, filter: param_myfilter, filterand: param_myfilterand, + // @ts-ignore + filtersearch: filtersearch, + filtercustom, sortBy: myobj, descending, userId: userStore.my._id, @@ -217,6 +272,7 @@ export default defineComponent({ params.codeId = mycodeid.value // console.log('params', params) + console.log('props.extraparams', props.extraparams) params = { ...params, ...props.extraparams } @@ -243,6 +299,7 @@ export default defineComponent({ const { page, rowsPerPage, rowsNumber, sortBy, descending } = props.pagination const myfilternow = myfilter.value const myfilterandnow = myfilterand.value + const myfiltercustomnow = myfiltercustom.value savefilter() @@ -269,7 +326,7 @@ export default defineComponent({ serverData.value = [] // fetch data from "server" - return fetchFromServer(startRow, endRow, myfilternow, myfilterandnow, sortBy, descending).then((ris: any) => { + return fetchFromServer(startRow, endRow, myfilternow, myfilterandnow, myfiltercustomnow, sortBy, descending).then((ris: any) => { pagination.value.rowsNumber = getRowsNumberCount(myfilter) @@ -340,6 +397,10 @@ export default defineComponent({ refresh() }) + watch(() => myfiltercustom.value, (newval, oldval) => { + refresh() + }) + function isTutor() { return userStore.isTutor } @@ -542,7 +603,6 @@ export default defineComponent({ mycolumns.value = props.prop_mycolumns colkey.value = props.prop_colkey pagination.value = props.prop_pagination - } function mounted() { @@ -553,6 +613,7 @@ export default defineComponent({ tablesel.value = tools.getCookie('tablesel', tablesel.value) } myfilterand.value = props.filterdef + myfiltercustom.value = props.filtercustom // console.log('tablesel', tablesel) if (tablesel.value === '') { @@ -867,6 +928,8 @@ export default defineComponent({ mydata.data = recModif.value + const oldrec = serverData.value.find((rec: IMySkill) => rec._id === recModif.value._id) + const data = await globalStore.saveTable(mydata) .then((ris) => { if (ris) { @@ -874,6 +937,11 @@ export default defineComponent({ editRecordBool.value = false const indrec = serverData.value.findIndex((rec: IMySkill) => rec._id === ris._id) console.log('indrec', indrec, serverData.value[indrec]) + mycolumns.value.forEach((col:IColGridTable) => { + if (!col.foredit) { + ris[col.name] = oldrec[col.name] + } + }) if (indrec >= 0) serverData.value[indrec] = ris } @@ -954,7 +1022,13 @@ export default defineComponent({ spinner_visible, tablesel, myfilterand, + myfiltercustom, tools, + costanti, + fieldsTable, + globalStore, + searchList, + searchval, } } }) diff --git a/src/components/CGridTableRec/CGridTableRec.vue b/src/components/CGridTableRec/CGridTableRec.vue index 2463a9df..13deeac2 100755 --- a/src/components/CGridTableRec/CGridTableRec.vue +++ b/src/components/CGridTableRec/CGridTableRec.vue @@ -43,20 +43,22 @@
{{ mytitle }}
- - - +
+ + + - + +
@@ -126,6 +128,55 @@ + + +