From bf1e9fc982678c829e1d24eaaa63e03563a470b9 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Thu, 1 Dec 2022 16:55:22 +0100 Subject: [PATCH] FILTRO CITTA Sopra ogni pagina ! --- .../CBarSelection/CBarSelection.scss | 72 ++++ src/components/CBarSelection/CBarSelection.ts | 334 ++++++++++++++++++ .../CBarSelection/CBarSelection.vue | 250 +++++++++++++ src/components/CBarSelection/index.ts | 1 + src/components/CFinder/CFinder.ts | 18 +- src/components/CFinder/CFinder.vue | 42 ++- src/components/CGridTableRec/CGridTableRec.ts | 29 +- src/components/CMyElem/CMyElem.vue | 7 +- src/components/CMySelect/CMySelect.ts | 113 ++++-- src/components/CTitlePage/CTitlePage.ts | 10 +- src/components/CTitlePage/CTitlePage.vue | 35 +- src/components/MyHeader/MyHeader.ts | 2 + src/components/index.ts | 1 + src/css/app.scss | 1 + .../toolbar/coinsPopover/coinsPopover.ts | 12 +- .../toolbar/notifPopover/notifPopover.ts | 9 +- src/mixins/mixin-users.ts | 6 + src/model/GlobalStore.ts | 5 + src/root/eventi/eventi.vue | 2 - src/root/goods/goods.vue | 1 - src/root/hosp/hosp.vue | 1 - src/root/provapao/provapao.vue | 2 - src/root/services/services.vue | 3 +- src/store/Modules/costanti.ts | 6 + src/store/Modules/tools.ts | 11 + src/store/globalStore.ts | 1 + 26 files changed, 900 insertions(+), 74 deletions(-) create mode 100755 src/components/CBarSelection/CBarSelection.scss create mode 100755 src/components/CBarSelection/CBarSelection.ts create mode 100755 src/components/CBarSelection/CBarSelection.vue create mode 100755 src/components/CBarSelection/index.ts diff --git a/src/components/CBarSelection/CBarSelection.scss b/src/components/CBarSelection/CBarSelection.scss new file mode 100755 index 00000000..9c36fa47 --- /dev/null +++ b/src/components/CBarSelection/CBarSelection.scss @@ -0,0 +1,72 @@ +.colmodif { + cursor: pointer; +} + +.coldate { + max-width: 250px; + min-width: 200px; +} + +.tdclass, .trclass{ + min-height: 20px !important; + margin-top: 5px; +} + +.q-table td { + padding-left: 1px; + padding-right: 2px; + padding-top: 0; + padding-bottom: 0; + &__title { + font-size: 1rem; + } +} + +.q-table { + &__col { + font-size: 1rem; + color: gray; + } +} + +.newrec_fields{ + display: flex; + padding: 2px; + margin: 2px; + align-items: center; + justify-content: center; +} + +.riduci_pad { + min-height: 30px; + padding: 4px 8px !important; +} + + +.q-table__top{ + padding-top: 0 !important; +} + + +.barselection { + display: flex; + align-items: center; + justify-content: space-around; +} + +.myitem { + padding: 0px 6px 0px 6px !important; +} + +.myitem-0 { + flex-grow: 0; + padding-left: 2px; +} + +.myitem-1 { + flex-grow: 0; +} + +.myitem-2 { + flex-grow: 1; +} diff --git a/src/components/CBarSelection/CBarSelection.ts b/src/components/CBarSelection/CBarSelection.ts new file mode 100755 index 00000000..19bda666 --- /dev/null +++ b/src/components/CBarSelection/CBarSelection.ts @@ -0,0 +1,334 @@ +import { inject, defineComponent, PropType, ref, watch, toRef, onMounted, toRefs, computed } from 'vue' +import { useI18n } from '@src/boot/i18n' + +import { tools } from '../../store/Modules/tools' + +import { fieldsTable } from '@store/Modules/fieldsTable' + +import { shared_consts } from '@/common/shared_vuejs' + +import { + IColGridTable, + IFilter, + ITableRec, + ISearchList, + IPagination, + IParamDialog, + IMySkill +} from 'model' +import { lists } from '@store/Modules/lists' +import { IParamsQuery } from 'model' +import { CMyPopupEdit } from '../CMyPopupEdit' +import { CMyFriends } from '../CMyFriends' +import { CMyUser } from '../CMyUser' +import { CMyGroups } from '../CMyGroups' +import { CMyFieldDb } from '../CMyFieldDb' +import { CMyRecCard } from '../CMyRecCard' +import { CMyRecGrpCard } from '../CMyRecGrpCard' +import { CMyRecCircuitCard } from '../CMyRecCircuitCard' +import { CMySelect } from '../CMySelect' +import { CTitleBanner } from '../CTitleBanner' + +import { useUserStore } from '@store/UserStore' +import { useGlobalStore } from '@store/globalStore' +import { useQuasar, exportFile } from 'quasar' +import { costanti } from '@costanti' +import translate from '@/globalroutines/util' +import { toolsext } from '@store/Modules/toolsext' +import { CMyCardPopup } from '@/components/CMyCardPopup' +import { CMyCardGrpPopup } from '@/components/CMyCardGrpPopup' +import { CMyCardCircuitPopup } from '@/components/CMyCardCircuitPopup' +import { useRouter } from 'vue-router' + +export default defineComponent({ + name: 'CBarSelection', + props: { + table: { + type: String, + required: true, + }, + prop_search: { + type: Boolean, + required: false, + default: true, + }, + mytitle: { + type: String, + required: false, + default: '', + }, + myicon: { + type: String, + required: false, + default: '', + }, + mycolor: { + type: String, + required: false, + default: '', + }, + hint: { + type: String, + required: false, + default: 'Cerca', + }, + }, + components: { + CMyPopupEdit, CTitleBanner, CMyFieldDb, CMySelect, CMyFriends, CMyGroups, + CMyUser, CMyRecCard, CMyCardPopup, CMyRecGrpCard, CMyCardGrpPopup, CMyCardCircuitPopup, + CMyRecCircuitCard + }, + setup(props, { emit }) { + const $q = useQuasar() + const { t } = useI18n() + const userStore = useUserStore() + const globalStore = useGlobalStore() + const isfinishLoading = computed(() => globalStore.finishLoading) + + const $router = useRouter() + + const search = ref('') + const loading = ref(false) + + const visupagedialog = ref(false) + const myrecdialog = ref(null) + + const myinfscroll = ref(null) + + const serverData: any = ref([]) + const numRecLoaded = ref(0) + const changetable = ref(false) + const searchList = ref([] as ISearchList[]) + + const actual = '' + + const tablesel = ref('') + const myfilter = ref('') + const myfilterand: any = ref([]) + let rowsel: any = {} + const dark = true + const canEdit = ref(false) + const optionsMainCards = ref() + + let returnedCount = 0 + const colVisib: any = ref([]) + const colExtra: any = ref([]) + const actualDate: any = ref(null as any) + + const rowclicksel = ref(null as any) + const colclicksel = ref(null) + + const selector = inject('selector', {}) + const showfilter = ref(false) // filtri avanzati + + const filter = ref(0) + const filtergrp = ref(costanti.MY_GROUPS) + + const mycolumns = ref([]) + + const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean) => { + // console.log('valoriopt', item.table) + return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter) + }) + + watch(() => props.table, (newval, oldval) => { + tablesel.value = props.table + }) + + + + const labelcombo = computed(() => (item: any) => { + let lab = item.label + if (item.showcount) + lab += ' (' + valoriopt.value(item, false, false).length + ')' + return lab + }) + + const myselector = computed({ + get: () => globalStore.myselector, + set: val => { + globalStore.myselector = val + }, + }) + + function refresh() { + // + // emit('updatesearch', ) + } + + function setProvinceByRegion(tableprov: string, tabregion: string, newval: any) { + + const recRegion = searchList.value.find((rec) => rec.table === tabregion) + if (recRegion) + tools.setCookie(tools.COOK_SEARCH + tabregion, newval) + + for (const item of searchList.value) { + if (item.table === tableprov) { + const valsaved = tools.getCookie(tools.COOK_SEARCH + tableprov + '_' + newval, costanti.FILTER_TUTTI) + const rec = searchList.value.find((myrec) => myrec.table === tableprov) // check if exist + let trovato = false + let arrvalues = [] + if (rec) { + arrvalues = valoriopt.value(rec.value, false, false) + if (arrvalues) + trovato = arrvalues.find((myrec: any) => myrec[myrec.key] === valsaved) + } + if (valsaved && trovato) + item.value = valsaved + else { + if (arrvalues) { + item.value = costanti.FILTER_TUTTI + } + } + } else if (item.table === toolsext.TABCITIES) { + const valsaved = tools.getCookie(tools.COOK_SEARCH + toolsext.TABCITIES + '_' + newval, costanti.FILTER_TUTTI) + const rec = searchList.value.find((myrec) => myrec.table === toolsext.TABCITIES) // check if exist + let trovato = false + let arrvalues = [] + if (rec) { + arrvalues = valoriopt.value(rec.value, false, false) + if (arrvalues) + trovato = arrvalues.find((myrec: any) => myrec[myrec.key] === valsaved) + } + if (valsaved && trovato) + item.value = valsaved + else { + if (arrvalues) { + item.value = costanti.FILTER_TUTTI + } + } + } + } + + } + + function searchval(newval: any, table: any) { + // console.log('REFRR searchval', newval, table) + + globalStore.myselector = { table, data: newval } + // console.log('globalStore.myselector', globalStore.myselector) + + tools.setCookie(tools.COOK_SEARCH + table, newval) + + if (table === toolsext.TABREGIONS) { + setProvinceByRegion(toolsext.TABPROVINCE, table, newval) + } else if (table === toolsext.TABGOODS) { + const recSector = searchList.value.find((rec) => rec.table === toolsext.TABSECTORGOODS) + if (recSector) { + tools.setCookie(tools.COOK_SEARCH + table + '_' + recSector.value, newval) + } + // setCategBySector('sectorgoods', table, newval) + } + + + refresh() + } + + function getRowsNumberCount() { + + return returnedCount + } + + + function created() { + // + + } + + function doSearch() { + // console.log('REFRR - doSearch') + refresh() + } + + function mounted() { + + optionsMainCards.value = [] + let obj = { label: '', value: '', icon: '' } + for (let i = 0; i < costanti.MAINCARDS.length - 1; i++) { + let rec: any = costanti.MAINCARDS[i] + if (rec.table) { + obj.label = rec.title + obj.value = rec.table + obj.icon = rec.icon + optionsMainCards.value.push({...obj}) + } + } + + tablesel.value = props.table + + console.log(' . TABLE =', props.table) + mycolumns.value = fieldsTable.getArrColsByTable(props.table) + + searchList.value = [ + { + label: 'Comune', + table: 'cities', + key: 'idCity', + type: costanti.FieldType.select_by_server, + value: tools.getCookie(tools.COOK_SEARCH + 'cities', costanti.FILTER_TUTTI), + addall: true, + arrvalue: [], + useinput: true, + filter: null, + tablesel: 'cities', + }, + ] + } + + function visButtRow() { + return false + } + + function gotoPageSel() { + const rec = costanti.MAINCARDS.find((rec: any) => rec.table === tablesel.value) + if (rec) { + $router.push(rec.to) + } + } + + created() + onMounted(mounted) + + return { + isfinishLoading, + search, + canEdit, + rowclicksel, + colVisib, + colExtra, + colclicksel, + loading, + serverData, + myfilter, + lists, + myfilterand, + tools, + costanti, + toolsext, + fieldsTable, + globalStore, + searchList, + searchval, + valoriopt, + labelcombo, + filter, + filtergrp, + shared_consts, + showfilter, + visupagedialog, + myrecdialog, + actualDate, + actual, + numRecLoaded, + myinfscroll, + t, + mycolumns, + visButtRow, + doSearch, + myselector, + optionsMainCards, + tablesel, + gotoPageSel, + } + } +}) diff --git a/src/components/CBarSelection/CBarSelection.vue b/src/components/CBarSelection/CBarSelection.vue new file mode 100755 index 00000000..132e293d --- /dev/null +++ b/src/components/CBarSelection/CBarSelection.vue @@ -0,0 +1,250 @@ + + + + diff --git a/src/components/CBarSelection/index.ts b/src/components/CBarSelection/index.ts new file mode 100755 index 00000000..ef47f400 --- /dev/null +++ b/src/components/CBarSelection/index.ts @@ -0,0 +1 @@ +export {default as CBarSelection} from './CBarSelection.vue' diff --git a/src/components/CFinder/CFinder.ts b/src/components/CFinder/CFinder.ts index 5ad638eb..162cfcb3 100755 --- a/src/components/CFinder/CFinder.ts +++ b/src/components/CFinder/CFinder.ts @@ -1,6 +1,6 @@ import { computed, - defineComponent, onBeforeMount, onBeforeUnmount, onMounted, ref, toRef, toRefs, watch, + provide, defineComponent, onBeforeMount, onBeforeUnmount, onMounted, ref, toRef, toRefs, watch, } from 'vue' import { tools } from '@store/Modules/tools' @@ -9,6 +9,7 @@ import { costanti } from '@costanti' import { useGlobalStore } from '@store/globalStore' import { useUserStore } from '@store/UserStore' +import { CTitlePage } from '@/components/CTitlePage' import { CGridTableRec } from '@/components/CGridTableRec' import { IColGridTable, IMyBacheca, IMySkill, ISearchList, ISkill } from 'model' import { shared_consts } from '@/common/shared_vuejs' @@ -27,13 +28,18 @@ export default defineComponent({ showFilterPersonal: { type: Boolean, required: false, - default: true, + default: false, }, noButtAdd: { type: Boolean, required: false, default: false, }, + selector: { + type: Object, + required: false, + default: null, + }, ind: { type: Number, required: false, @@ -41,7 +47,7 @@ export default defineComponent({ } }, components: { - CMyFieldDb, CGridTableRec, + CMyFieldDb, CGridTableRec, CTitlePage, }, setup(props, { attrs, slots, emit }) { const { t } = useI18n() @@ -49,6 +55,10 @@ export default defineComponent({ const globalStore = useGlobalStore() const userStore = useUserStore() + const myselector = ref({}) + + provide('myselector', myselector) + const arrfilterand: any = ref([]) const filtercustom: any = ref([]) const searchList_Servizi = ref([]) @@ -245,11 +255,13 @@ export default defineComponent({ ] } else { + /* myoptions.value = [ { label: '🌎 Tutti', value: tools.FILTER_ALL }, { label: '👤 Personali', value: tools.FILTER_MYREC }, // {label: 'Seguo', value: tools.FILTER_MYFOLLOW}, ] + */ } function getFilterSkills(recSkill: any, index: number, arr: any) { diff --git a/src/components/CFinder/CFinder.vue b/src/components/CFinder/CFinder.vue index a29b4426..8566a448 100755 --- a/src/components/CFinder/CFinder.vue +++ b/src/components/CFinder/CFinder.vue @@ -1,9 +1,8 @@