From fc8a954eb0101339e949ffea4d2b81d75fffd72c Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Wed, 14 May 2025 15:02:14 +0200 Subject: [PATCH] - Generazione della Raccolta dei Cataloghi (web e Stampa), e creazione del PDF Online. - Lista Raccolta Cataloghi, aggiungi/togli catalogo. --- src/common/shared_vuejs.ts | 22 +- src/components/CGridOriz/CGridOriz.ts | 8 +- src/components/CGridTableRec/CGridTableRec.ts | 14 +- .../CGridTableRec/CGridTableRec.vue | 11 + src/components/CMyEditElem/CMyEditElem.vue | 15 +- src/components/CMyElem/CMyElem.ts | 6 +- src/components/CMyElem/CMyElem.vue | 27 +- .../CMyRecRaccoltaCataloghi.scss | 83 + .../CMyRecRaccoltaCataloghi.ts | 195 + .../CMyRecRaccoltaCataloghi.vue | 196 + .../CMyRecRaccoltaCataloghi/index.ts | 1 + src/components/CProductTable/CProductTable.ts | 667 +- .../CProductTable/CProductTable.vue | 5 +- src/components/CRaccolta/CRaccolta.scss | 0 src/components/CRaccolta/CRaccolta.ts | 57 + src/components/CRaccolta/CRaccolta.vue | 14 + src/components/CRaccolta/index.ts | 1 + .../CRaccoltaCataloghi.scss | 0 .../CRaccoltaCataloghi/CRaccoltaCataloghi.ts | 231 + .../CRaccoltaCataloghi/CRaccoltaCataloghi.vue | 47 + src/components/CRaccoltaCataloghi/index.ts | 1 + .../CSearchProduct/CSearchProduct.ts | 357 +- .../CSearchProduct/CSearchProduct.vue | 19 + src/mixins/mixin-base.ts | 7 + src/model/CatalogStore.ts | 25 + src/statics/lang/it.js | 6 + src/store/CatalogStore.ts | 7 +- src/store/Modules/fieldsTable.ts | 61 + src/store/Modules/tools.ts | 7289 +++++++++-------- src/store/Modules/toolsext.ts | 1 + src/store/Products.ts | 1 + src/store/globalStore.ts | 33 + src/views/ecommerce/catalogo/catalogo.ts | 23 +- src/views/ecommerce/catalogo/catalogo.vue | 2 + .../ecommerce/raccoltacataloghi/index.ts | 1 + .../raccoltacataloghi/raccoltacataloghi.scss | 166 + .../raccoltacataloghi/raccoltacataloghi.ts | 430 + .../raccoltacataloghi/raccoltacataloghi.vue | 184 + tsconfig.json | 5 +- 39 files changed, 6149 insertions(+), 4069 deletions(-) create mode 100755 src/components/CMyRecRaccoltaCataloghi/CMyRecRaccoltaCataloghi.scss create mode 100755 src/components/CMyRecRaccoltaCataloghi/CMyRecRaccoltaCataloghi.ts create mode 100755 src/components/CMyRecRaccoltaCataloghi/CMyRecRaccoltaCataloghi.vue create mode 100755 src/components/CMyRecRaccoltaCataloghi/index.ts create mode 100755 src/components/CRaccolta/CRaccolta.scss create mode 100755 src/components/CRaccolta/CRaccolta.ts create mode 100755 src/components/CRaccolta/CRaccolta.vue create mode 100755 src/components/CRaccolta/index.ts create mode 100755 src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.scss create mode 100755 src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.ts create mode 100755 src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.vue create mode 100755 src/components/CRaccoltaCataloghi/index.ts create mode 100755 src/views/ecommerce/raccoltacataloghi/index.ts create mode 100755 src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.scss create mode 100755 src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.ts create mode 100755 src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.vue diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index 376eadc1..2739ad67 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -161,6 +161,7 @@ export const shared_consts = { VISUVIDEOPROMOANDPDF: 290, ECOMMERCE: 300, CATALOGO: 310, + RACCOLTA: 315, TOOLSAI: 320, MAPPA: 350, MAPPAUTENTI: 360, @@ -171,6 +172,7 @@ export const shared_consts = { QRCODE: 410, CATALOGLIST: 420, SEARCHPRODUCT: 430, + RACCOLTE_CATALOGHI: 450, }, QUERYTYPE_MYGROUP: 1, @@ -327,6 +329,7 @@ export const shared_consts = { TABLES_ATTIVITAS: 'attivitas', TABLES_CATALOG: 'catalogs', TABLES_LISTA_EDITORI: 'lista_editori', + TABLES_RACCOLTACATALOGHIS: 'raccoltacataloghis', TABFILTRI_UTENTE: 'filtriutente', @@ -426,7 +429,7 @@ export const shared_consts = { TABLES_UPDATE_LASTIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots'], TABLES_FINDER: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups'], - TABLES_VISU_CMYSRECCARD: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups', 'catalogs'], + TABLES_VISU_CMYSRECCARD: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups', 'catalogs', 'raccoltacataloghis'], TABLES_SHOW_ADTYPE: ['myskills', 'mygoods', 'myhosps'], TABLES_VISU_LISTA_USER: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'users'], @@ -438,10 +441,10 @@ export const shared_consts = { TABLES_VISU_IMG: ['myskills', 'myhosps', 'mygoods', 'mygroups'], TABLES_DIRECTORY_A_PARTE: ['mygroups'], TABLES_WITH_ADMINS: ['mygroups', 'circuits'], - TABLES_DIRECTORY_SINGLE_IMG: ['circuits', 'catalogs'], + TABLES_DIRECTORY_SINGLE_IMG: ['circuits', 'catalogs', 'raccoltacataloghis'], TABLES_IMAGEFILE_SINGOLO: ['productInfos'], - TABLES_PER_EDITORI: ['catalogs'], + TABLES_PER_EDITORI: ['catalogs', 'raccoltacataloghis'], TABLES_VISU_MAP: 'attivitas', @@ -1824,6 +1827,10 @@ export const shared_consts = { value: 420, label: 'Lista Cataloghi', }, + { + value: 450, + label: 'Raccolte Cataloghi', + }, { value: 430, // SEARCHPRODUCT label: 'Cerca Prodotto', @@ -1927,6 +1934,10 @@ export const shared_consts = { value: 310, label: 'CATALOGO', }, + { + value: 315, + label: 'RACCOLTA CATALOGHI', + }, { value: 350, label: 'MAPPA', @@ -2510,5 +2521,10 @@ export const shared_consts = { {value: 10, label: 'TEST'}, ], + WHERE_INSERT: { + ONTOP: '0', + ONBOTTOM: '1', + }, + } diff --git a/src/components/CGridOriz/CGridOriz.ts b/src/components/CGridOriz/CGridOriz.ts index 3a818e31..6fe5252c 100755 --- a/src/components/CGridOriz/CGridOriz.ts +++ b/src/components/CGridOriz/CGridOriz.ts @@ -94,6 +94,7 @@ export default defineComponent({ const searchList_Hosp = ref([]) const searchList_Attivita = ref([]) const searchList_Cataloghi = ref([]) + const searchList_RaccoltaCataloghi = ref([]) const search = ref('') const myrecfiltertoggle = ref(tools.FILTER_ALL) @@ -105,7 +106,7 @@ export default defineComponent({ function gettablesList() { - if (props.table === 'catalogs') + if (props.table === 'catalogs' || props.table === 'raccoltarataloghis') return func.gettablesListByTable(props.table) } @@ -183,6 +184,8 @@ export default defineComponent({ return { sortBy: 'numMembers', descending: true, page: 1, rowsNumber: 0, rowsPerPage: 20 } else if (props.table === shared_consts.TABLES_CATALOG) return { sortBy: 'title', descending: false, page: 1, rowsNumber: 0, rowsPerPage: 25 } + else if (props.table === shared_consts.TABLES_RACCOLTACATALOGHIS) + return { sortBy: 'title', descending: false, page: 1, rowsNumber: 0, rowsPerPage: 25 } else if (props.table === toolsext.TABUSER) return userStore.getMypaginationMembers() else if (shared_consts.TABLES_ORDER_DATE_UPDATED.includes(props.table)) @@ -210,6 +213,8 @@ export default defineComponent({ return searchList_Attivita.value else if (props.table === shared_consts.TABLES_CATALOG) return searchList_Cataloghi.value + else if (props.table === shared_consts.TABLES_RACCOLTACATALOGHIS) + return searchList_RaccoltaCataloghi.value return [] }) @@ -656,6 +661,7 @@ export default defineComponent({ ] searchList_Cataloghi.value = tools.getsearchList_Cataloghi(props.isCatalogoGenerale) + searchList_RaccoltaCataloghi.value = tools.getsearchList_RaccoltaCataloghi() searchList_Hosp.value = [ { diff --git a/src/components/CGridTableRec/CGridTableRec.ts b/src/components/CGridTableRec/CGridTableRec.ts index 4df35dfb..33bd112b 100755 --- a/src/components/CGridTableRec/CGridTableRec.ts +++ b/src/components/CGridTableRec/CGridTableRec.ts @@ -32,6 +32,7 @@ import { CMyGroups } from '../CMyGroups' import { CMyFieldDb } from '../CMyFieldDb' import { CMyRecCard } from '../CMyRecCard' import { CMyRecCatalog } from '../CMyRecCatalog' +import { CMyRecRaccoltaCataloghi } from '../CMyRecRaccoltaCataloghi' import { CMapByTable } from '../CMapByTable' import { CMyRecGrpCard } from '../CMyRecGrpCard' import { CMyRecCircuitCard } from '../CMyRecCircuitCard' @@ -361,7 +362,7 @@ export default defineComponent({ components: { CMyPopupEdit, CTitleBanner, CMyFieldDb, CMySelect, CMyFriends, CMyGroups, CMyUser, CMyRecCard, CMyRecCatalog, CMyCardPopup, CMyRecGrpCard, CMyCardGrpPopup, CMyCardCircuitPopup, - CMyRecCircuitCard, CMyCardService, CNotifSettings, CMapByTable, CSingleMovement, + CMyRecCircuitCard, CMyCardService, CNotifSettings, CMapByTable, CSingleMovement, CMyRecRaccoltaCataloghi, }, setup(props, { emit }) { const $q = useQuasar() @@ -2853,6 +2854,16 @@ export default defineComponent({ } + function getisDettagliByRaccolta() { + const rec = searchList.value.find((myrec) => myrec.table === ('finto_racc_' + myrec.key) && myrec.key === 'dettagli') + if (rec) { + return rec.value + } + + return false + } + + created() return { @@ -2989,6 +3000,7 @@ export default defineComponent({ onIntersection, showfilteradv, getisDettagliByCatalog, + getisDettagliByRaccolta, } } }) diff --git a/src/components/CGridTableRec/CGridTableRec.vue b/src/components/CGridTableRec/CGridTableRec.vue index 9fb715af..c6da1185 100755 --- a/src/components/CGridTableRec/CGridTableRec.vue +++ b/src/components/CGridTableRec/CGridTableRec.vue @@ -584,6 +584,17 @@ :margin_right="margin_right" > + +
+
- +
@@ -379,6 +379,28 @@
+
+
Raccolte Cataloghi
+ + + + + + + + + + + + + + +
CStatusReg
@@ -443,6 +465,9 @@
+
+ +
MAPPA:
+ + + + + +
+
+ {{ $t('racccat.numcataloghi') }}: + {{ numcataloghistr }} +
+
+   + PDF OnLine + aggiornato al ({{ tools.getstrDate(myrec.data_online) }}) +
+
+   + PDF per Stampa + aggiornato al ({{ tools.getstrDate(myrec.data_online_stampa) }}) +
+
+ Lista generata il: + {{ tools.getstrDate(myrec.data_lista_generata) || '(non ancora generata)' }} da + {{ myrec.username_lista_generata }} + +
+
+ +
+ + + + + + + + + + + + + + + + + {{ myrec.title }} + + + + +
+
+ +
+ + + +
+
+
+ + + +
+ + + + diff --git a/src/components/CMyRecRaccoltaCataloghi/index.ts b/src/components/CMyRecRaccoltaCataloghi/index.ts new file mode 100755 index 00000000..a87b83ad --- /dev/null +++ b/src/components/CMyRecRaccoltaCataloghi/index.ts @@ -0,0 +1 @@ +export { default as CMyRecRaccoltaCataloghi } from './CMyRecRaccoltaCataloghi.vue' diff --git a/src/components/CProductTable/CProductTable.ts b/src/components/CProductTable/CProductTable.ts index 27f3be0a..e384077d 100755 --- a/src/components/CProductTable/CProductTable.ts +++ b/src/components/CProductTable/CProductTable.ts @@ -1,35 +1,35 @@ -import { PropType, computed, defineComponent, onMounted, ref, watch } from "vue"; -import draggable from 'vuedraggable' +import { PropType, computed, defineComponent, onMounted, ref, watch } from 'vue'; +import draggable from 'vuedraggable'; -import { tools } from '@tools' +import { tools } from '@tools'; -import { useGlobalStore } from '@src/store/globalStore' +import { useGlobalStore } from '@src/store/globalStore'; -import { CMyValueDb } from '@src/components/CMyValueDb' -import { CSchedaProdotto } from '@src/components/CSchedaProdotto' -import { CSearchProduct } from '@src/components/CSearchProduct' -import { CMyDialog } from '@src/components/CMyDialog' +import { CMyValueDb } from '@src/components/CMyValueDb'; +import { CSchedaProdotto } from '@src/components/CSchedaProdotto'; +import { CSearchProduct } from '@src/components/CSearchProduct'; +import { CMyDialog } from '@src/components/CMyDialog'; -import { costanti } from '@costanti' -import { IAuthor, ICatProd } from "app/src/model"; - -import type { - IMyScheda, - IOptCatalogo, - IProduct -} from '@src/model'; -import { shared_consts } from "app/src/common/shared_vuejs"; -import { useProducts } from "app/src/store/Products"; -import { CViewTable } from "../CViewTable"; -import { CLabel } from "../CLabel"; -import { useI18n } from "vue-i18n"; +import { costanti } from '@costanti'; +import { IAuthor, ICatProd } from 'app/src/model'; +import type { IMyScheda, IOptCatalogo, IProduct } from '@src/model'; +import { shared_consts } from 'app/src/common/shared_vuejs'; +import { useProducts } from 'app/src/store/Products'; +import { CViewTable } from '../CViewTable'; +import { CLabel } from '../CLabel'; +import { useI18n } from 'vue-i18n'; export default defineComponent({ - name: "CProductTable", - emits: ["update:lista_prodotti", "update:optcatalogo", "rigenera"], + name: 'CProductTable', + emits: ['update:lista_prodotti', 'update:optcatalogo', 'rigenera'], components: { - draggable, CSearchProduct, CMyDialog, CMyValueDb, CViewTable, CLabel, + draggable, + CSearchProduct, + CMyDialog, + CMyValueDb, + CViewTable, + CLabel, CSchedaProdotto, }, props: { @@ -37,6 +37,10 @@ export default defineComponent({ type: Array, required: true, }, + table: { + type: String, + required: true, + }, optcatalogo: { type: Object as PropType, required: false, @@ -45,53 +49,52 @@ export default defineComponent({ scheda: { type: Object as PropType, required: false, - default: () => ({ - - }), + default: () => ({}), }, }, setup(props, { emit }) { // Copia locale della lista_prodotti per manipolazione interna - const internalProducts = ref([...props.lista_prodotti || []]); + const internalProducts = ref([...(props.lista_prodotti || [])]); - const { t } = useI18n() + const { t } = useI18n(); - const globalStore = useGlobalStore() - const products = useProducts() + const globalStore = useGlobalStore(); + const products = useProducts(); - const showProd = ref(false) - const selProd = ref(null) + const showProd = ref(false); + const selProd = ref(null); - const cmd = ref(shared_consts.SCHEDA_PRODOTTO.CMD_NONE) + const cmd = ref(shared_consts.SCHEDA_PRODOTTO.CMD_NONE); - const showQtaDisponibile = ref(false) - const loading = ref(true) - const visufromgm = ref(false) - const updatefromgm = ref(false) - const field_updated_fromGM = ref('') + const showQtaDisponibile = ref(false); + const loading = ref(true); + const visufromgm = ref(false); + const updatefromgm = ref(false); + const field_updated_fromGM = ref(''); - const modifOn = ref(false) + const modifOn = ref(false); - const sortAttribute = ref('') - const sortDirection = ref(1) + const sortAttribute = ref(''); + const sortDirection = ref(1); - const optionscatalogo = ref({ maxlength: 0 }) + const addstr = ref(''); + + const optionscatalogo = ref({ maxlength: 0 }); function handleUpdate(newList) { - internalProducts.value = newList - emit('update:lista_prodotti', internalProducts.value) + internalProducts.value = newList; + emit('update:lista_prodotti', internalProducts.value); } const editOn = computed({ get(): boolean { - return globalStore.editOn ? globalStore.editOn : false + return globalStore.editOn ? globalStore.editOn : false; }, set(value: boolean) { - return tools.updateEditOn(value) - } - }) - + return tools.updateEditOn(value); + }, + }); // Aggiorna la copia locale quando il prop cambia watch( @@ -99,172 +102,276 @@ export default defineComponent({ (newVal) => { internalProducts.value = [...newVal]; } - ), { deep: true }; + ), + { deep: true }; + + const allColumns = ref([]); // Colonne della tabella - const allColumns = [ - { name: "pos", label: "Ind", field: "pos", align: "left", style: "width: 50px", notsortable: true }, - { name: "drag", label: "Ord", field: "", align: "left", style: "width: 50px", edit: true, noexp: true, notsortable: true }, - { name: "validato", label: "Val", field: "validato", align: "left", style: "", }, - { name: "image", label: "Foto", field: "image", align: "center", noexp: true, notsortable: true }, - { name: "name", label: "Titolo", field: "name", align: "left" }, - { name: "sottotitolo", label: "Sottotitolo", field: "sottotitolo", align: "left" }, - { name: "authors", label: "Autore", field: "authors", align: "left" }, - { name: "isbn", label: "ISBN", field: "isbn", align: "left" }, - { name: "trafiletto", label: "Sinossi", field: "trafiletto", align: "left" }, - { name: "catprods", label: "Argomento", field: "catprods", align: "left" }, - { name: "edizione", label: "Edizione", field: "edizione", align: "left" }, - { name: "casaeditrice", label: "Casa Editrice", field: "casaeditrice", align: "left" }, - { name: "idCollana", label: "Collana", field: "idCollana", align: "left" }, - { name: "stato", label: "Stato", field: "stato", align: "left" }, - { name: "tipologia", label: "Tipologia", field: "tipologia", align: "left" }, - { name: "tipoformato", label: "Formato", field: "tipoformato", align: "left" }, - { name: "pagine", label: "Pag.", field: "pagine", align: "right" }, - { name: "prezzo", label: "€", field: "prezzo", align: "right" }, - { name: "prezzo_sconto", label: "€ (sconto)", field: "prezzo_sconto", align: "right" }, - { name: "date_pub", label: "Pubblicato", field: "date_pub", align: "left" }, + const allColumns_Raccolta = ref([ + { name: 'pos', label: 'Ind', field: 'pos', align: 'left', style: 'width: 50px', notsortable: true }, + { + name: 'drag', + label: 'Ord', + field: '', + align: 'left', + style: 'width: 50px', + edit: true, + noexp: true, + notsortable: true, + }, + { name: 'image', label: 'Foto', field: 'image', align: 'center', noexp: true, notsortable: true }, + { name: 'title', label: 'Titolo', field: 'title', align: 'left' }, + { name: 'pdf_generato', label: 'Generato', field: 'pdf_generato', align: 'center' }, + { name: 'data_generato', label: 'Data Generato', field: 'data_generato', align: 'center' }, + { name: 'pdf_generato_stampa', label: 'Generato Stampa', field: 'pdf_generato_stampa', align: 'center' }, + { name: 'data_generato_stampa', label: 'Data Generato Stampa', field: 'data_generato_stampa', align: 'center' }, + { name: 'pdf_online', label: 'PDF OnLine', field: 'pdf_online', align: 'center' }, + { name: 'pdf_online_stampa', label: 'PDF OnLine Stampa', field: 'pdf_online_stampa', align: 'center' }, + { name: 'data_online', label: 'Data Online', field: 'data_online', align: 'center' }, + { name: 'data_online_stampa', label: 'Data Online Stampa', field: 'data_online_stampa', align: 'center' }, + { + name: 'actions', + label: 'Azioni', + field: '', + align: 'center', + visu: costanti.VISUCAMPI.PER_EDITORE, + noexp: true, + notsortable: true, + }, + ]); + + const allColumns_Catalog = ref([ + { name: 'pos', label: 'Ind', field: 'pos', align: 'left', style: 'width: 50px', notsortable: true }, + { + name: 'drag', + label: 'Ord', + field: '', + align: 'left', + style: 'width: 50px', + edit: true, + noexp: true, + notsortable: true, + }, + { name: 'validato', label: 'Val', field: 'validato', align: 'left', style: '' }, + { name: 'image', label: 'Foto', field: 'image', align: 'center', noexp: true, notsortable: true }, + { name: 'name', label: 'Titolo', field: 'name', align: 'left' }, + { name: 'sottotitolo', label: 'Sottotitolo', field: 'sottotitolo', align: 'left' }, + { name: 'authors', label: 'Autore', field: 'authors', align: 'left' }, + { name: 'isbn', label: 'ISBN', field: 'isbn', align: 'left' }, + { name: 'trafiletto', label: 'Sinossi', field: 'trafiletto', align: 'left' }, + { name: 'catprods', label: 'Argomento', field: 'catprods', align: 'left' }, + { name: 'edizione', label: 'Edizione', field: 'edizione', align: 'left' }, + { name: 'casaeditrice', label: 'Casa Editrice', field: 'casaeditrice', align: 'left' }, + { name: 'idCollana', label: 'Collana', field: 'idCollana', align: 'left' }, + { name: 'stato', label: 'Stato', field: 'stato', align: 'left' }, + { name: 'tipologia', label: 'Tipologia', field: 'tipologia', align: 'left' }, + { name: 'tipoformato', label: 'Formato', field: 'tipoformato', align: 'left' }, + { name: 'pagine', label: 'Pag.', field: 'pagine', align: 'right' }, + { name: 'prezzo', label: '€', field: 'prezzo', align: 'right' }, + { name: 'prezzo_sconto', label: '€ (sconto)', field: 'prezzo_sconto', align: 'right' }, + { name: 'date_pub', label: 'Pubblicato', field: 'date_pub', align: 'left' }, //{ name: "ranking", label: "Class.", field: "ranking", align: "right" }, //{ name: "rank3M", label: "Class. 3M", field: "rank3M", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, //{ name: "rank6M", label: "Class. 6M", field: "rank6M", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, //{ name: "rank1Y", label: "Class. 1Y", field: "rank1Y", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "totVen", label: "Vend", field: "totVen", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "vLast6M", label: "Ven 6M", field: "vLast6M", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "fatLast6M", label: "Fat 6M", field: "fatLast6M", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "fatLast1Y", label: "Fat 1A", field: "fatLast1Y", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "fatLast2Y", label: "Fat 2A", field: "fatLast2Y", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "totFat", label: "Fat 5A", field: "totFat", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "ult_ord", label: "Ult. Ordine", field: "ult_ord", align: "left", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "quantity", label: "Magazz.", field: "quantity", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "actions", label: "Azioni", field: "", align: "center", visu: costanti.VISUCAMPI.PER_EDITORE, noexp: true, notsortable: true }, - ]; + { name: 'totVen', label: 'Vend', field: 'totVen', align: 'right', visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: 'vLast6M', label: 'Ven 6M', field: 'vLast6M', align: 'right', visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: 'fatLast6M', label: 'Fat 6M', field: 'fatLast6M', align: 'right', visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: 'fatLast1Y', label: 'Fat 1A', field: 'fatLast1Y', align: 'right', visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: 'fatLast2Y', label: 'Fat 2A', field: 'fatLast2Y', align: 'right', visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: 'totFat', label: 'Fat 5A', field: 'totFat', align: 'right', visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: 'ult_ord', label: 'Ult. Ordine', field: 'ult_ord', align: 'left', visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: 'quantity', label: 'Magazz.', field: 'quantity', align: 'right', visu: costanti.VISUCAMPI.PER_EDITORE }, + { + name: 'actions', + label: 'Azioni', + field: '', + align: 'center', + visu: costanti.VISUCAMPI.PER_EDITORE, + noexp: true, + notsortable: true, + }, + ]); async function mounted() { - console.log('mounted CProductTable') - loading.value = true + console.log('mounted CProductTable'); + loading.value = true; - optionscatalogo.value = { - maxlength: props.scheda?.testo_bottom?.maxlength + if (props.table === shared_consts.TABLES_CATALOG) { + selectedColumns.value = selectedColumns_Catalogs.value; + } else { + selectedColumns.value = tools.isUtente() ? selectedColumns_Utenti.value : selectedColumns_Editori.value; } - const savedColumns = tools.getCookie("selColCat_2"); + addstr.value = tools.addstrCookie(props.table); + + if (props.table === 'products') { + allColumns.value = allColumns_Catalog.value; + } else if (props.table === 'catalogs') { + allColumns.value = allColumns_Raccolta.value; + } + + optionscatalogo.value = { + maxlength: props.scheda?.testo_bottom?.maxlength, + }; + + const savedColumns = tools.getCookie(addstr.value + 'selColCat_2'); if (savedColumns) { selectedColumns.value = savedColumns; } - const savedSortAttribute = tools.getCookie("sortAttr"); + const savedSortAttribute = tools.getCookie(addstr.value + 'sortAttr'); if (savedSortAttribute && props.optcatalogo.showListaArgomenti) { if (isColumnVisible(savedSortAttribute)) { sortAttribute.value = savedSortAttribute; - const savedSortDir = tools.getCookie("sortDir"); + const savedSortDir = tools.getCookie(addstr.value + 'sortDir'); if (savedSortDir) { sortDirection.value = savedSortDir; } - } } - loading.value = false + loading.value = false; } - function getFieldValue(element: any, field: any): any { - if (!element) - return '' + if (!element) return ''; try { - switch (field.field) { - case 'image': - return element.productInfo?.imagefile - ? tools.getFullFileNameByImageFile('productInfos', element.productInfo?.imagefile) - : element.productInfo?.image_link; + if (props.table === shared_consts.TABLES_CATALOG) { + const catalog = element; + switch (field.field) { + case 'active': + return catalog.active; + case 'title': + return catalog.title; + case 'pdf_generato': + return catalog.pdf_generato + ? `PDF` + : ''; + case 'pdf_generato_stampa': + return catalog.pdf_generato_stampa + ? `PDF` + : ''; + case 'data_generato': + return tools.getstrDate(catalog.data_generato); + case 'data_generato_stampa': + return tools.getstrDate(catalog.data_generato_stampa); + case 'pdf_online': + return catalog.pdf_online + ? `PDF` + : ''; + case 'pdf_online_stampa': + return catalog.pdf_online_stampa + ? `PDF` + : ''; + case 'data_online': + return tools.getstrDate(catalog.data_online); + case 'data_online_stampa': + return tools.getstrDate(catalog.data_online_stampa); + case 'image': + return catalog.foto_collana?.imagefile + ? tools.getFullFileNameByImageFile(shared_consts.TABLES_CATALOG, catalog.foto_collana?.imagefile) + : ''; + } + } else { + switch (field.field) { + case 'image': + return element.productInfo?.imagefile + ? tools.getFullFileNameByImageFile('productInfos', element.productInfo?.imagefile) + : element.productInfo?.image_link; - case 'name': - return element.productInfo?.name; + case 'name': + return element.productInfo?.name; - case 'sottotitolo': - return element.productInfo?.sottotitolo; + case 'sottotitolo': + return element.productInfo?.sottotitolo; - case 'authors': - return formatAuthors(element.productInfo?.authors); + case 'authors': + return formatAuthors(element.productInfo?.authors); - case 'validato': - return element.validaprod?.esito === costanti.VALIDATO.SI ? 'SI' : (element.validaprod?.esito === costanti.VALIDATO.TO_RESOLV ? 'ERR' : 'NO'); + case 'validato': + return element.validaprod?.esito === costanti.VALIDATO.SI + ? 'SI' + : element.validaprod?.esito === costanti.VALIDATO.TO_RESOLV + ? 'ERR' + : 'NO'; - case 'isbn': - return element.isbn; + case 'isbn': + return element.isbn; - case 'trafiletto': - return element.productInfo?.descr_trafiletto_catalogo?.length > 100 ? 'SI' : 'NO'; + case 'trafiletto': + return element.productInfo?.descr_trafiletto_catalogo?.length > 100 ? 'SI' : 'NO'; - case 'catprods': - return tools.formatCatProds(element.productInfo?.catprods); + case 'catprods': + return tools.formatCatProds(element.productInfo?.catprods); - case 'edizione': - return element.arrvariazioni?.[0]?.edizione; + case 'edizione': + return element.arrvariazioni?.[0]?.edizione; - case 'casaeditrice': - return products.getCasaEditriceByIdPublisher(element.productInfo?.idPublisher); + case 'casaeditrice': + return products.getCasaEditriceByIdPublisher(element.productInfo?.idPublisher); - case 'idCollana': - return tools.formatCollane(element.productInfo?.idCollana); + case 'idCollana': + return tools.formatCollane(element.productInfo?.idCollana); - case 'stato': - return products.getDescrStatiProdottoByIdStatoProdotto(element.productInfo?.idStatoProdotto || ''); + case 'stato': + return products.getDescrStatiProdottoByIdStatoProdotto(element.productInfo?.idStatoProdotto || ''); - case 'tipologia': - return products.getDescrByIdTipologia(element.arrvariazioni?.[0]?.idTipologia || ''); + case 'tipologia': + return products.getDescrByIdTipologia(element.arrvariazioni?.[0]?.idTipologia || ''); - case 'tipoformato': - return products.getDescrByIdTipoFormato(element.arrvariazioni?.[0]?.idTipoFormato || ''); + case 'tipoformato': + return products.getDescrByIdTipoFormato(element.arrvariazioni?.[0]?.idTipoFormato || ''); - case 'date_pub': - return tools.getstrDate(element.productInfo?.date_pub); + case 'date_pub': + return tools.getstrDate(element.productInfo?.date_pub); - case 'prezzo': - return element.price ? '€ ' + element.price.toFixed(2) : ''; + case 'prezzo': + return element.price ? '€ ' + element.price.toFixed(2) : ''; - case 'prezzo_sconto': - return element.sale_price ? '€ ' + element.sale_price.toFixed(2) : ''; + case 'prezzo_sconto': + return element.sale_price ? '€ ' + element.sale_price.toFixed(2) : ''; - case 'rank3M': - return element.productInfo?.rank3M; + case 'rank3M': + return element.productInfo?.rank3M; - case 'rank6M': - return element.productInfo?.rank6M; + case 'rank6M': + return element.productInfo?.rank6M; - case 'rank1Y': - return element.productInfo?.rank1Y; + case 'rank1Y': + return element.productInfo?.rank1Y; - case 'pagine': - return element.arrvariazioni?.[0]?.pagine; + case 'pagine': + return element.arrvariazioni?.[0]?.pagine; - case 'totVen': - return element.productInfo?.totVen; + case 'totVen': + return element.productInfo?.totVen; - case 'totFat': - return element.productInfo?.totFat; + case 'totFat': + return element.productInfo?.totFat; - case 'fatLast6M': - return element.productInfo?.fatLast6M; + case 'fatLast6M': + return element.productInfo?.fatLast6M; - case 'fatLast1Y': - return element.productInfo?.fatLast1Y; + case 'fatLast1Y': + return element.productInfo?.fatLast1Y; - case 'fatLast2Y': - return element.productInfo?.fatLast2Y; + case 'fatLast2Y': + return element.productInfo?.fatLast2Y; - case 'ult_ord': - return tools.getstrDate(element.productInfo?.dataUltimoOrdine); + case 'ult_ord': + return tools.getstrDate(element.productInfo?.dataUltimoOrdine); - case 'quantity': - if (tools.isUtente()) - return tools.getDescrQuantitàByQuantity(element.arrvariazioni?.[0]?.quantita); - else - return element.arrvariazioni?.[0]?.quantita; + case 'quantity': + if (tools.isUtente()) return tools.getDescrQuantitàByQuantity(element.arrvariazioni?.[0]?.quantita); + else return element.arrvariazioni?.[0]?.quantita; - default: - return null; + default: + return null; + } } } catch (e) { console.error('Errore getFieldValue:', e, element, field); @@ -273,13 +380,10 @@ export default defineComponent({ } function getFieldClass(element: any, field: any): string { - if (!element) - return '' + if (!element) return ''; switch (field.field) { case 'trafiletto': - return element.productInfo?.descr_trafiletto_catalogo?.length > 100 - ? 'text-green' - : 'text-red'; + return element.productInfo?.descr_trafiletto_catalogo?.length > 100 ? 'text-green' : 'text-red'; case 'stato': if (products.isProssimaUscita(element.productInfo)) { @@ -332,8 +436,7 @@ export default defineComponent({ } function getFieldStyle(element: any, field: any): Record { - if (!element) - return {} + if (!element) return {}; switch (field.field) { case 'prezzo': @@ -344,11 +447,11 @@ export default defineComponent({ cursor: 'pointer', textAlign: 'center', color: 'white', - } + }; case 'image': return { width: '50px', - height: '50px' + height: '50px', }; case 'pagine': @@ -359,12 +462,12 @@ export default defineComponent({ case 'fatLast2Y': case 'quantity': return { - textAlign: 'right' + textAlign: 'right', }; case 'trafiletto': return { - textAlign: 'center' + textAlign: 'center', }; default: @@ -374,9 +477,8 @@ export default defineComponent({ let cookieValue: [] | null = null; - let keyvalue = 'selColCat_2' - if (tools.isUtente()) - keyvalue += '_utente' + let keyvalue = addstr.value + 'selColCat_2'; + if (tools.isUtente()) keyvalue += '_utente'; try { cookieValue = tools.getCookie(keyvalue); // Se il cookie esiste e contiene una stringa JSON valida @@ -386,100 +488,139 @@ export default defineComponent({ cookieValue = []; // In caso di errore, inizializza come array vuoto } - const selectedColumns_Editori = ref(cookieValue.length > 0 ? cookieValue : ["pos", "drag", "validato", "image", "name", "authors", "isbn", "catprods", "stato", "date_pub", "pagine", "trafiletto", "fatLast1Y", "quantity", "actions"]); - const selectedColumns_Utenti = ref(cookieValue.length > 0 ? cookieValue : ["pos", "image", "name", "authors", "isbn", "catprods", "stato", "date_pub", "pagine", "trafiletto", "quantity"]); + const selectedColumns_Editori = ref( + cookieValue.length > 0 + ? cookieValue + : [ + 'pos', + 'drag', + 'validato', + 'image', + 'name', + 'authors', + 'isbn', + 'catprods', + 'stato', + 'date_pub', + 'pagine', + 'trafiletto', + 'fatLast1Y', + 'quantity', + 'actions', + ] + ); + const selectedColumns_Utenti = ref( + cookieValue.length > 0 + ? cookieValue + : [ + 'pos', + 'image', + 'name', + 'authors', + 'isbn', + 'catprods', + 'stato', + 'date_pub', + 'pagine', + 'trafiletto', + 'quantity', + ] + ); + const selectedColumns_Catalogs = ref( + cookieValue.length > 0 ? cookieValue : ['pos', 'drag', 'image', 'title', 'pdf_generato', 'actions'] + ); - const selectedColumns = computed({ - get: () => tools.isUtente() ? selectedColumns_Utenti.value : selectedColumns_Editori.value, - set: (value) => { - if (tools.isUtente()) { - selectedColumns_Utenti.value = value; - } else { - selectedColumns_Editori.value = value; - } - } - }); + const selectedColumns = ref([]); // 3. Funzione per verificare se una colonna è visibile (isColumnVisible) const isColumnVisible = (column, real?: boolean) => { if (column === 'actions' && !real) { - return false + return false; } if (internalProducts.value?.length > 1000) { if (column === 'image') { - return false + return false; } } - const ok = allColumns.some((col) => col.name === column) && (!props.optcatalogo.showListaArgomenti || (props.optcatalogo.showListaArgomenti && !column.edit)) + const ok = + allColumns.value.some((col) => col.name === column) && + (!props.optcatalogo.showListaArgomenti || (props.optcatalogo.showListaArgomenti && !column.edit)); return selectedColumns.value.includes(column) && ok; - } + }; const getColumnLabelByName = (name: string): string => { - const column = allColumns.find((col) => col.name === name); + const column = allColumns.value.find((col) => col.name === name); return column ? column.label : ''; - } + }; // Funzione per eliminare un prodotto const removeProduct = (product) => { internalProducts.value = internalProducts.value.filter((p: any) => p._id !== product._id); - emit("update:lista_prodotti", internalProducts.value); // Notifica il parent del cambiamento - } + emit('update:lista_prodotti', internalProducts.value); // Notifica il parent del cambiamento + }; // 8. Salvataggio delle colonne selezionate in un cookie const saveSelectedColumns = () => { - tools.setCookie("selColCat_2", JSON.stringify(selectedColumns.value)); + tools.setCookie(addstr.value + 'selColCat_2', JSON.stringify(selectedColumns.value)); }; // 9. Watcher per salvare automaticamente le preferenze quando cambiano - watch(() => selectedColumns.value, () => { - saveSelectedColumns(); - }); + watch( + () => selectedColumns.value, + () => { + saveSelectedColumns(); + } + ); - watch(() => sortAttribute.value, (newVal) => { - tools.setCookie("sortAttr", newVal); - }); - - watch(() => sortDirection.value, (newVal) => { - tools.setCookie("sortDir", newVal); - }); + watch( + () => sortAttribute.value, + (newVal) => { + tools.setCookie(addstr.value + 'sortAttr', newVal); + } + ); + watch( + () => sortDirection.value, + (newVal) => { + tools.setCookie(addstr.value + 'sortDir', newVal); + } + ); // Funzione chiamata alla fine del drag-and-drop const onDragEnd = () => { // console.log("Nuovo ordine:", internalProducts.value); - emit("update:lista_prodotti", internalProducts.value); // Notifica il parent del cambiamento - } + emit('update:lista_prodotti', internalProducts.value); // Notifica il parent del cambiamento + }; function formatAuthors(authors: IAuthor[] | undefined | null): string { if (!authors || !Array.isArray(authors)) { - return ""; // Restituisci una stringa vuota se authors non è un array valido + return ''; // Restituisci una stringa vuota se authors non è un array valido } // Estrai il nome e il cognome di ogni autore e uniscili con ', ' return authors - .map((author) => `${author.name ?? ""} ${author.surname ?? ""}`.trim()) + .map((author) => `${author.name ?? ''} ${author.surname ?? ''}`.trim()) .filter((name) => name.length > 0) // Filtra eventuali nomi vuoti - .join(", "); + .join(', '); } - function showProduct(element: any) { - selProd.value = element + selProd.value = element; - showProd.value = true + showProd.value = true; } function modifyProduct(element: any) { if (element) { - selProd.value = element + selProd.value = element; - cmd.value = shared_consts.SCHEDA_PRODOTTO.CMD_MODIFICA - modifOn.value = true + cmd.value = shared_consts.SCHEDA_PRODOTTO.CMD_MODIFICA; + modifOn.value = true; } } function updateProduct(element: any) { - selProd.value = element + selProd.value = element; // Aggiorna l'elemento nella lista interna internalProducts.value = internalProducts.value.map((prod: any) => { @@ -489,17 +630,16 @@ export default defineComponent({ return prod; }); - emit("update:lista_prodotti", internalProducts.value); // Notifica il parent del cambiamento - + emit('update:lista_prodotti', internalProducts.value); // Notifica il parent del cambiamento } async function updateproductmodif(element: any) { - console.log('PRODUCT TABLE: updateproductmodif') + console.log('PRODUCT TABLE: updateproductmodif'); try { if (element?._id) { - selProd.value = await products.getProductById(element?._id) + selProd.value = await products.getProductById(element?._id); } else { - selProd.value = await products.getProductById(selProd.value?._id) + selProd.value = await products.getProductById(selProd.value?._id); } // update record inside internalProducts @@ -509,36 +649,34 @@ export default defineComponent({ } return prod; }); - - - } catch (e) { - console.error('err', e) + console.error('err', e); } } async function refreshFieldFromGM(field: string) { if (selProd.value) { - loading.value = true - updatefromgm.value = true - field_updated_fromGM.value = '' - field_updated_fromGM.value = await globalStore.getGM_FieldOf_T_Web_Articoli(selProd.value.productInfo.sku!, field, shared_consts.CmdQueryMs.GET) - loading.value = false + loading.value = true; + updatefromgm.value = true; + field_updated_fromGM.value = ''; + field_updated_fromGM.value = await globalStore.getGM_FieldOf_T_Web_Articoli( + selProd.value.productInfo.sku!, + field, + shared_consts.CmdQueryMs.GET + ); + loading.value = false; } - } const sortTable = (sortAttributeToSort: string) => { - - if (!props.optcatalogo.showListaArgomenti) - return false + if (!props.optcatalogo.showListaArgomenti) return false; if (sortAttributeToSort) { if (sortAttribute.value === sortAttributeToSort) { - sortDirection.value = -sortDirection.value + sortDirection.value = -sortDirection.value; } else { - sortAttribute.value = sortAttributeToSort - sortDirection.value = 1 + sortAttribute.value = sortAttributeToSort; + sortDirection.value = 1; } internalProducts.value = internalProducts.value.sort((a: any, b: any) => { const aVal = getFieldValue(a, { field: sortAttributeToSort }); @@ -546,7 +684,12 @@ export default defineComponent({ if (aVal instanceof Date && bVal instanceof Date) { return sortDirection.value === 1 ? aVal.getTime() - bVal.getTime() : bVal.getTime() - aVal.getTime(); } - if (typeof aVal === 'string' && typeof bVal === 'string' && aVal.match(/^\d{1,2}\/\d{1,2}\/\d{4}$/) && bVal.match(/^\d{1,2}\/\d{1,2}\/\d{4}$/)) { + if ( + typeof aVal === 'string' && + typeof bVal === 'string' && + aVal.match(/^\d{1,2}\/\d{1,2}\/\d{4}$/) && + bVal.match(/^\d{1,2}\/\d{1,2}\/\d{4}$/) + ) { const aDate = new Date(aVal.split('/').reverse().join('-')); const bDate = new Date(bVal.split('/').reverse().join('-')); return sortDirection.value === 1 ? aDate.getTime() - bDate.getTime() : bDate.getTime() - aDate.getTime(); @@ -557,19 +700,21 @@ export default defineComponent({ if (typeof aVal === 'string' && typeof bVal === 'string') { return sortDirection.value === 1 ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal); } - return sortDirection.value === 1 ? String(aVal).localeCompare(String(bVal)) : String(bVal).localeCompare(String(aVal)); - }) + return sortDirection.value === 1 + ? String(aVal).localeCompare(String(bVal)) + : String(bVal).localeCompare(String(aVal)); + }); } - } + }; function rigenera() { - emit('rigenera') + emit('rigenera'); } function getFieldClick(element: any, field: any): (() => void) | null { switch (field.field) { case 'validato': - return () => modifyProduct(element) + return () => modifyProduct(element); case 'image': return () => showProduct(element); @@ -593,16 +738,19 @@ export default defineComponent({ function exportToCSV() { const csvContent = [ selectedColumns.value - .filter((col) => !allColumns.find((c) => c.name === col)?.noexp) + .filter((col) => !allColumns.value.find((c) => c.name === col)?.noexp) .map((col) => getColumnLabelByName(col)) .join('|'), ...internalProducts.value.map((product: any) => { return selectedColumns.value - .filter((col) => !allColumns.find((c) => c.name === col)?.noexp) + .filter((col) => !allColumns.value.find((c) => c.name === col)?.noexp) .map((col: string) => { - const field = { field: col }; - return field.field === 'pos' ? internalProducts.value.indexOf(product) + 1 : getFieldValue(product, field); - }).join('|'); + const field = { field: col }; + return field.field === 'pos' + ? internalProducts.value.indexOf(product) + 1 + : getFieldValue(product, field); + }) + .join('|'); }), ].join('\r\n'); @@ -618,14 +766,24 @@ export default defineComponent({ document.body.appendChild(link); link.click(); document.body.removeChild(link); - } - function isSortable(field: string) : boolean { - return allColumns && !allColumns.find((col) => col.name === field)?.notsortable; + function isSortable(field: string): boolean { + return allColumns && !allColumns.value.find((col) => col.name === field)?.notsortable; } - onMounted(mounted) + function getImageByElement(element) { + let image = ''; + if (props.table === shared_consts.TABLES_CATALOG) { + image = element.foto_collana?.imagefile; + } else { + image = element.productInfo?.imagefile; + } + + return image; + } + + onMounted(mounted); return { allColumns, @@ -666,6 +824,7 @@ export default defineComponent({ handleUpdate, exportToCSV, isSortable, - } - } -}) + getImageByElement, + }; + }, +}); diff --git a/src/components/CProductTable/CProductTable.vue b/src/components/CProductTable/CProductTable.vue index 25c7e585..8de07443 100755 --- a/src/components/CProductTable/CProductTable.vue +++ b/src/components/CProductTable/CProductTable.vue @@ -111,8 +111,8 @@ diff --git a/src/components/CRaccolta/CRaccolta.scss b/src/components/CRaccolta/CRaccolta.scss new file mode 100755 index 00000000..e69de29b diff --git a/src/components/CRaccolta/CRaccolta.ts b/src/components/CRaccolta/CRaccolta.ts new file mode 100755 index 00000000..72f6cba7 --- /dev/null +++ b/src/components/CRaccolta/CRaccolta.ts @@ -0,0 +1,57 @@ +import type { PropType} from 'vue'; +import { defineComponent, ref, watch } from 'vue' + +import { RaccoltaCataloghi } from '@src/views/ecommerce/raccoltacataloghi' +import type { IOptCatalogo } from '@src/model' + +export default defineComponent({ + name: 'CRaccolta', + components: { RaccoltaCataloghi }, + emits: ['update:modelValue', 'updateCatalogo'], + props: { + // add options IOptCatalogo + modelValue: { + type: Object as PropType, + required: true, + }, + idPage: { + type: String, + required: false, + default: '', + }, + }, + + setup(props, { emit }) { + // Crea una copia locale reattiva di modelValue + const localCatalogo = ref({ ...props.modelValue }); + + // Watcher per sincronizzare le modifiche di modelValue + watch(() => props.modelValue, (newVal) => { + localCatalogo.value = { ...newVal }; + // updateCatalogoPadre() + }, { deep: true }); + + function updateCatalogoPadre() { + emit('update:modelValue', localCatalogo.value); + emit('updateCatalogo', localCatalogo.value); + } + + // Metodo per aggiornare il valore del catalogo + const updateCatalogo = (updatedCatalogo: IOptCatalogo) => { + localCatalogo.value = updatedCatalogo; // Aggiorna la copia locale + updateCatalogoPadre() + }; + + function updateCatalogoEmit(updatedCatalogo: IOptCatalogo) { + console.log('updateCatalogoEmit') + localCatalogo.value = updatedCatalogo; // Aggiorna la copia locale + updateCatalogoPadre() + + } + + return { + localCatalogo, + updateCatalogoEmit, + }; + } +}) diff --git a/src/components/CRaccolta/CRaccolta.vue b/src/components/CRaccolta/CRaccolta.vue new file mode 100755 index 00000000..00962d83 --- /dev/null +++ b/src/components/CRaccolta/CRaccolta.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/src/components/CRaccolta/index.ts b/src/components/CRaccolta/index.ts new file mode 100755 index 00000000..d42192c5 --- /dev/null +++ b/src/components/CRaccolta/index.ts @@ -0,0 +1 @@ +export {default as CRaccolta} from './CRaccolta.vue' diff --git a/src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.scss b/src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.scss new file mode 100755 index 00000000..e69de29b diff --git a/src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.ts b/src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.ts new file mode 100755 index 00000000..3d0f8087 --- /dev/null +++ b/src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.ts @@ -0,0 +1,231 @@ +import { + computed, + provide, defineComponent, onBeforeMount, onBeforeUnmount, onMounted, ref, toRef, toRefs, watch, +} from 'vue' + +import { tools } from '@tools' +import { CMyFieldDb } from '@src/components/CMyFieldDb' +import { costanti } from '@costanti' +import { useGlobalStore } from '@store/globalStore' +import { useUserStore } from '@store/UserStore' + +import { CTitlePage } from '@src/components/CTitlePage' +import { CGridTableRec } from '@src/components/CGridTableRec' +import type { IColGridTable, ISearchList } from 'model'; +import { IMyBacheca, IMySkill, ISkill } from 'model' +import { shared_consts } from '@src/common/shared_vuejs' +import { useI18n } from 'vue-i18n' +import { toolsext } from '@store/Modules/toolsext' +import { fieldsTable } from '@store/Modules/fieldsTable' +import { useQuasar } from 'quasar' + +export default defineComponent({ + name: 'CRaccoltaCataloghi', + emits: ['clickButtBar'], + props: { + ind: { + type: Number, + required: false, + default: -1, + }, + prop_search: { + type: Boolean, + required: false, + default: true, + }, + finder: { + type: Boolean, + required: false, + default: true, + }, + heightcarousel: { + type: String, + required: false, + default: '', + }, + heightcard: { + type: String, + required: false, + default: '400px', + }, + widthcard: { + type: String, + required: false, + default: '300px', + }, + heightimg: { + type: String, + required: false, + default: '150px', + }, + widthimg: { + type: String, + required: false, + default: '300px', + }, + }, + components: { + CMyFieldDb, CGridTableRec, CTitlePage, + }, + setup(props, { attrs, slots, emit }) { + const { t } = useI18n() + const $q = useQuasar() + const globalStore = useGlobalStore() + const userStore = useUserStore() + + const table = ref('raccoltacataloghis') + + const arrfilterand: any = ref([]) + const filtercustom: any = ref([]) + + const search = ref('') + const myrecfiltertoggle = ref(tools.FILTER_ALL) + + const prop_colkey = ref('') + const col_title = ref('') + const col_footer = ref('') + const col_tabfooter = ref('') + + const strextra = ref('') + const myoptions = ref([]) + + const col = ref([]) + + const myCatRef = ref(null) + + const getRaccoltaCataloghiByMyPage = computed((): IRaccoltaCatalogo | undefined => { + return catalogStore.raccoltacataloghis?.find((raccolta: IRaccoltaCatalogo) => raccolta.idPageAssigned === props.idPage); + }); + + function updatefilter(value: any) { + // + } + + const pagina_collegata = computed(() => { + + let linkpage = '' + + const idpag = myrec.value.idPageAssigned + if (idpag) { + const mypage = globalStore.getPageById(idpag) + if (mypage) + linkpage = mypage.path! + } + + return linkpage + + }) + + + + watch(() => myrecfiltertoggle.value, (value: any, oldval: any) => { + updatefilter(value) + }, + ) + + const mypagination = computed(() => { + return { sortBy: 'title', descending: false, page: 1, rowsNumber: 0, rowsPerPage: 10 } + }) + + function naviga(path: string) { + $router.push(path) + } + + const showType = computed(() => { + return costanti.SHOW_MYCARD + }) + + const hint = computed(() => { + return 'digita la Raccolta da cercare' + }) + + const visuType = computed(() => { + return false // $q.screen.gt.xs + }) + + const noMsgRecord = computed(() => { + return 'Nessun dato trovato con i filtri selezionati' + }) + + + function mounted() { + + const obj = tools.getParamsByTable(table.value) + + + prop_colkey.value = obj.prop_colkey + col_title.value = obj.col_title + col_footer.value = obj.col_footer + col_tabfooter.value = obj.col_tabfooter + + filtercustom.value = [] + + col.value = fieldsTable.getArrColsByTable(table.value) + } + + function salvaListaRaccoltaCataloghi(ricarica: boolean) { + // Estrai solo gli ID dei prodotti filtrati + const myarr = [...getRaccoltaCataloghiByMyPage.value.lista_cataloghi]; + const catalogIds = myarr.map((catalog) => catalog._id); + + let mydata = { + lista_cataloghi: catalogIds, + }; + + // Salva gli ID dei prodotti nel catalogo + tools.saveFieldToServer($q, 'raccoltacataloghis', getRaccoltaCataloghiByMyPage.value._id, mydata, true, true); + + } + + function mySortFieldsAvailable() { + if (table.value === toolsext.TABUSER) { + return userStore.getSortFieldsAvailable() + } + + return [] + } + + function doSearch() { + // + } + + function clickButtBar(item: any) { + if (myCatRef.value) { + myCatRef.value.clickButtBar(item) + } + + // emit('clickButtBar', item) + } + + onMounted(mounted) + + return { + t, + tools, + costanti, + arrfilterand, + filtercustom, + search, + doSearch, + myrecfiltertoggle, + prop_colkey, + col_title, + col_footer, + col_tabfooter, + col, + toolsext, + mypagination, + noMsgRecord, + showType, + visuType, + hint, + myoptions, + mySortFieldsAvailable, + clickButtBar, + myCatRef, + table, + pagina_collegata, + naviga, + } + }, +}) diff --git a/src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.vue b/src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.vue new file mode 100755 index 00000000..f47b9042 --- /dev/null +++ b/src/components/CRaccoltaCataloghi/CRaccoltaCataloghi.vue @@ -0,0 +1,47 @@ + + + + diff --git a/src/components/CRaccoltaCataloghi/index.ts b/src/components/CRaccoltaCataloghi/index.ts new file mode 100755 index 00000000..09bc4b85 --- /dev/null +++ b/src/components/CRaccoltaCataloghi/index.ts @@ -0,0 +1 @@ +export { default as CRaccoltaCataloghi } from './CRaccoltaCataloghi.vue' diff --git a/src/components/CSearchProduct/CSearchProduct.ts b/src/components/CSearchProduct/CSearchProduct.ts index cfa6cbe8..af786d66 100755 --- a/src/components/CSearchProduct/CSearchProduct.ts +++ b/src/components/CSearchProduct/CSearchProduct.ts @@ -1,28 +1,25 @@ import type { PropType } from 'vue'; -import { defineComponent, onMounted, ref, watch, computed } from 'vue' -import { tools } from '@tools' -import { useUserStore } from '@store/UserStore' -import { useRouter } from 'vue-router' -import { useGlobalStore } from '@store/globalStore' -import { useProducts } from '@store/Products' -import { useI18n } from 'vue-i18n' -import { toolsext } from '@store/Modules/toolsext' -import { useQuasar } from 'quasar' -import { costanti } from '@costanti' +import { defineComponent, onMounted, ref, watch, computed } from 'vue'; +import { tools } from '@tools'; +import { useUserStore } from '@store/UserStore'; +import { useCatalogStore } from '@store/CatalogStore' +import { useRouter } from 'vue-router'; +import { useGlobalStore } from '@store/globalStore'; +import { useProducts } from '@store/Products'; +import { useI18n } from 'vue-i18n'; +import { toolsext } from '@store/Modules/toolsext'; +import { useQuasar } from 'quasar'; +import { costanti } from '@costanti'; -import { shared_consts } from '@src/common/shared_vuejs' -import { CProductCard } from '@src/components/CProductCard' +import { shared_consts } from '@src/common/shared_vuejs'; +import { CProductCard } from '@src/components/CProductCard'; -import { CMySelect } from '@src/components/CMySelect' -import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard' -import { CSelectUserActive } from '@src/components/CSelectUserActive' -import type { - IOptCatalogo, - IProduct, ISearchList -} from 'model'; +import { CMySelect } from '@src/components/CMySelect'; +import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard'; +import { CSelectUserActive } from '@src/components/CSelectUserActive'; +import type { IOptCatalogo, IProduct, ISearchList } from 'model'; - -import { fieldsTable } from '@store/Modules/fieldsTable' +import { fieldsTable } from '@store/Modules/fieldsTable'; import Products from 'app/src/rootgen/admin/products/products.vue'; export default defineComponent({ @@ -35,6 +32,10 @@ export default defineComponent({ required: false, default: null, }, + table: { + type: String, + required: true, + }, idprodtoshow: { type: String, required: false, @@ -57,124 +58,155 @@ export default defineComponent({ }, }, setup(props, { emit }) { - const userStore = useUserStore() - const globalStore = useGlobalStore() - const productStore = useProducts() - const router = useRouter() - const $q = useQuasar() - const { t } = useI18n() + const userStore = useUserStore(); + const globalStore = useGlobalStore(); + const productStore = useProducts(); + const catalogStore = useCatalogStore(); + const router = useRouter(); + const $q = useQuasar(); + const { t } = useI18n(); - const search = ref('') - const focus = ref(false) + const search = ref(''); + const focus = ref(false); - const loadpage = ref(false) - const refreshpage = ref(false) - const show_hide = ref(false) + const loadpage = ref(false); + const refreshpage = ref(false); + const show_hide = ref(false); - const mycolumns = ref([]) + const mycolumns = ref([]); - const idPage = ref('') - const selauthor = ref('') + const where = ref('') - const searchList = ref([]) + const idPage = ref(''); + const selauthor = ref(''); + + const searchList = ref([]); const optcatalogo = ref(null); - const myproduct = ref({}) + const myproduct = ref({}); + + const addstr = ref('') const labelcombo = computed(() => (item: any) => { - let lab = item.label - if (item.showcount) - lab += ' (' + valoriopt.value(item, false, false).length + ')' - return lab - }) + let lab = item.label; + if (item.showcount) lab += ' (' + valoriopt.value(item, false, false).length + ')'; + return lab; + }); const listaRicerca = computed(() => { - const mylist = searchList.value.find((rec: any) => rec.table === 'products' && rec.key === 'titolo') - - return mylist - }) + let key = '' + if (props.table === shared_consts.TABLES_CATALOG) { + key = 'title' + } else { + key = 'titolo' + } + const mylist = searchList.value.find((rec: any) => rec.table === props.table && rec.key === key); + return mylist; + }); const searchText = computed(() => { - const lista = listaRicerca.value - return lista && lista.value && tools.existProp(lista.value, 'name') ? lista.value.name : '' - }) + const lista = listaRicerca.value; + let key = '' + if (props.table === shared_consts.TABLES_CATALOG) { + key = 'title' + } else { + key = 'name' + } + return lista && lista.value && tools.existProp(lista.value, key) ? lista.value[key] : ''; + }); const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean = false) => { // console.log('valoriopt', item.table) - return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter) - }) + return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter); + }); - watch(() => searchText.value, (newval, oldval) => { - console.log('searchText=', searchText.value) - const id = getSearchId() - loadProduct(id) - - }) - watch(() => myproduct.value, (newval, oldval) => { - console.log('myproduct', myproduct.value) - // loadProduct(myproduct.value._id) - updateproductmodif(myproduct.value) - }) + watch( + () => searchText.value, + (newval, oldval) => { + console.log('searchText=', searchText.value); + const id = getSearchId(); + loadProduct(id); + } + ); + watch( + () => myproduct.value, + (newval, oldval) => { + console.log('myproduct', myproduct.value); + // loadProduct(myproduct.value._id) + updateproductmodif(myproduct.value); + } + ); async function loadProduct(id: string) { // Carica il prodotto - console.log('loadProduct', id) + console.log('loadProduct', id); - if (id) { - myproduct.value = await productStore.loadProductById(id) - } else { - myproduct.value = null + if (props.table === 'products') { + if (id) { + myproduct.value = await productStore.loadProductById(id); + } else { + myproduct.value = null; + } + + } else if (props.table === 'catalogs') { + if (id) { + myproduct.value = await catalogStore.getCatalogById(id); + } else { + myproduct.value = null; + } } + saveSearch(); - saveSearch() - - console.log('myproduct.value', myproduct.value) - + console.log('myproduct.value', myproduct.value); } + watch( + () => where.value, + (newval, oldval) => { + tools.setCookie(addstr.value + 'WHE', newval); + } + ); + function saveSearch() { if (!props.idprodtoshow && !props.empty) { if (myproduct.value) { - tools.setCookie(tools.COOK_LAST_PROD_SEARCH, myproduct.value._id.toString()) + tools.setCookie(addstr.value + tools.COOK_LAST_PROD_SEARCH, myproduct.value._id.toString()); } else { - tools.setCookie(tools.COOK_LAST_PROD_SEARCH, '') + tools.setCookie(addstr.value + tools.COOK_LAST_PROD_SEARCH, ''); } } if (!myproduct.value) { - tools.setCookie(tools.COOK_LAST_PROD_SEARCH, '') + tools.setCookie(addstr.value + tools.COOK_LAST_PROD_SEARCH, ''); } } function resetSearch() { - const mialista = listaRicerca.value + const mialista = listaRicerca.value; if (mialista && mialista.value && tools.existProp(mialista.value, 'name')) { - mialista.value = null + mialista.value = null; } - search.value = '' + search.value = ''; } - function getSearchId(): string { - const lista = listaRicerca.value - return lista && lista.value && lista.value._id ? lista.value._id : '' + const lista = listaRicerca.value; + return lista && lista.value && lista.value._id ? lista.value._id : ''; } function populateDataWithlinkIdTemplate() { // console.log('populateDataWithlinkIdTemplate') if (optcatalogo.value) { - for (const recscheda of optcatalogo.value.arrSchede!) { if (recscheda.scheda?.linkIdTemplate) { // ricopia da Template: - const myscheda = globalStore.sovrascriviSchedaFromTemplate(recscheda.scheda?.linkIdTemplate, recscheda) + const myscheda = globalStore.sovrascriviSchedaFromTemplate(recscheda.scheda?.linkIdTemplate, recscheda); if (myscheda) { - recscheda.scheda = { ...myscheda } + recscheda.scheda = { ...myscheda }; } - } } } @@ -182,139 +214,164 @@ export default defineComponent({ // console.log(' FINE - populateDataWithlinkIdTemplate') } + function isProductLibro() { + return props.table === 'products'; + } async function mounted() { // console.log('mounted Catalogo') + addstr.value = tools.addstrCookie(props.table) + + where.value = tools.getCookie(addstr.value + 'WHE', shared_consts.WHERE_INSERT.ONTOP); + if (props.modelValue) { - optcatalogo.value = props.modelValue + optcatalogo.value = props.modelValue; } else { - optcatalogo.value = globalStore.createCatalogoVuoto() - productStore.addNewScheda(optcatalogo.value) + optcatalogo.value = globalStore.createCatalogoVuoto(); + productStore.addNewScheda(optcatalogo.value); if (props.nameLinkTemplate) { - const linkIdTemplate = globalStore.getLinkIdTemplateByName(props.nameLinkTemplate) - if (linkIdTemplate) - optcatalogo.value.arrSchede[0].scheda.linkIdTemplate = linkIdTemplate + const linkIdTemplate = globalStore.getLinkIdTemplateByName(props.nameLinkTemplate); + if (linkIdTemplate) optcatalogo.value.arrSchede[0].scheda.linkIdTemplate = linkIdTemplate; } else { - optcatalogo.value.arrSchede[0].scheda.name = 'SEARCH_NEW' + optcatalogo.value.arrSchede[0].scheda.name = 'SEARCH_NEW'; } } - const id = props.idprodtoshow || (!props.empty ? tools.getCookie(tools.COOK_LAST_PROD_SEARCH, '') : '') + let id = null; + if (props.table === 'products') { + id = props.idprodtoshow || (!props.empty ? tools.getCookie(addstr.value + tools.COOK_LAST_PROD_SEARCH, '') : ''); + } if (props.nameLinkTemplate) { - populateDataWithlinkIdTemplate() + populateDataWithlinkIdTemplate(); } if (props.visu === shared_consts.VISU_SEARCHPROD_MODE.INSERT) { - focus.value = true + focus.value = true; } - loadpage.value = false + loadpage.value = false; if (id) { - await loadProduct(id) + await loadProduct(id); } + mycolumns.value = fieldsTable.getArrColsByTable(props.table); - mycolumns.value = fieldsTable.getArrColsByTable('products') + if (isProductLibro()) { + searchList.value = [ + { + visible: true, + label: 'Cerca un Titolo o un Autore', + table: 'products', + key: 'titolo', + type: costanti.FieldType.select_by_server, + value: myproduct.value, + collabel: collabel, + arrvalue: [], + useinput: true, + filter: null, + tablesel: 'products', + dense: false, + }, + ]; + } else { + searchList.value = [ + { + visible: true, + label: 'Cerca un Catalogo', + table: 'catalogs', + key: 'title', + type: costanti.FieldType.select_by_server, + value: myproduct.value, + collabel: 'title', + arrvalue: [], + useinput: true, + filter: null, + tablesel: 'catalogs', + dense: false, + }, + ]; - searchList.value = [ - { - visible: true, - label: 'Cerca un Titolo o un Autore', - table: 'products', - key: 'titolo', - type: costanti.FieldType.select_by_server, - value: myproduct.value, - collabel: collabel, - arrvalue: [], - useinput: true, - filter: null, - tablesel: 'products', - dense: false, - }, - ] + } // Inizializza - loadpage.value = true - + loadpage.value = true; } - - function naviga(path: string) { - router.push(path) + router.push(path); } function collabel(rec: any) { - - let label = '' - if (rec && rec.productInfo) { - if (productStore.isNovitaById(rec.productInfo.date_pub)) - label += `🌟 ` + let label = ''; + if (rec && rec.productInfo && props.table === 'products') { + if (productStore.isNovitaById(rec.productInfo.date_pub)) label += `🌟 `; label += `${rec.productInfo.name}`; if (Array.isArray(rec.productInfo.authors)) { const authors = rec.productInfo.authors.map((a: any) => `${a.name} ${a.surname}`).join(', '); label += ` - (${authors})`; } else { - label += rec.productInfo.authors ? ` - (${rec.productInfo.authors.name} ${rec.productInfo.authors.surname}) ` : ''; + label += rec.productInfo.authors + ? ` - (${rec.productInfo.authors.name} ${rec.productInfo.authors.surname}) ` + : ''; } if (rec.productInfo.idStatoProdotto) { if (!productStore.isPubblicatoById(rec.productInfo.idStatoProdotto)) - label += ' (' + productStore.getDescrStatiProdottoByIdStatoProdotto(rec.productInfo.idStatoProdotto || '') + ')' + label += + ' (' + productStore.getDescrStatiProdottoByIdStatoProdotto(rec.productInfo.idStatoProdotto || '') + ')'; } if (productStore.isEsaurito(rec)) { - label += ' (Attualmente non disponibile)' + label += ' (Attualmente non disponibile)'; } // console.log('Computed label:', label) + } else { + if (rec && rec.name) label = rec.name; + else label = ''; } - return label + return label; } function insertProd() { - // console.log('insertProd') - emit('insert', myproduct.value) + console.log('insertProd', myproduct.value) + emit('insert', myproduct.value, where.value); } function clickClose() { - searchList.value[0].value = '' - myproduct.value = null - emit('close') + searchList.value[0].value = ''; + myproduct.value = null; + emit('close'); } function updateproductmodif(element: IProduct) { - console.log('CSEARCHPRODUCT: updateproductmodif') - emit('updateproductmodif', element) + console.log('CSEARCHPRODUCT: updateproductmodif'); + emit('updateproductmodif', element); } async function searchOnGM(mystr: string) { // refreshSingleBookFromGM({usaDBGMLocale: false}) - const options = { - - } - const ris = await globalStore.updateAllBookFromGM_T_Web_Articoli({ sku: '', isbn: mystr, ...options }) + const options = {}; + const ris = await globalStore.updateAllBookFromGM_T_Web_Articoli({ sku: '', isbn: mystr, ...options }); if (ris) { - - const id = getSearchId() - loadProduct(id) - updateproductmodif(myproduct.value) + const id = getSearchId(); + loadProduct(id); + updateproductmodif(myproduct.value); // await updateproduct(false) if (ris.error) { - tools.showNegativeNotif($q, ris.error) + tools.showNegativeNotif($q, ris.error); } else { - tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK')) + tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK')); } // updatefromgm.value = false } - } - onMounted(mounted) + onMounted(mounted); return { userStore, @@ -345,7 +402,7 @@ export default defineComponent({ saveSearch, updateproductmodif, searchOnGM, - } - } -}) - + where, + }; + }, +}); diff --git a/src/components/CSearchProduct/CSearchProduct.vue b/src/components/CSearchProduct/CSearchProduct.vue index 28e73c6f..f2b207e1 100755 --- a/src/components/CSearchProduct/CSearchProduct.vue +++ b/src/components/CSearchProduct/CSearchProduct.vue @@ -51,6 +51,25 @@
+
+ +
+
rec._id === id) + if (idcat >= 0 && key) { + const myfield = key as keyof IRaccoltaCatalogo + catalogStore.raccoltacataloghis[idcat][myfield] = value + } } console.log('mydatatosave', mydatatosave) diff --git a/src/model/CatalogStore.ts b/src/model/CatalogStore.ts index 955eb477..f79d53e4 100755 --- a/src/model/CatalogStore.ts +++ b/src/model/CatalogStore.ts @@ -42,7 +42,32 @@ export interface ICatalog { lista_prodotti?: IProduct[] isCatalogoGenerale?: boolean } +export interface IRaccoltaCatalogo { + _id: string + idapp: string + active?: boolean + title: string + foto_raccolta?: IImg, + + idPageAssigned?: string + idPageAssigned_stampa?: string + + nomefile_da_generare?: string + + pdf_generato?: string + data_generato?: Date + pdf_online?: string + data_online?: Date + + pdf_generato_stampa?: string + data_generato_stampa?: Date + pdf_online_stampa?: string + data_online_stampa?: Date + + lista_cataloghi?: ICatalog[] +} export interface ICatalogState { catalogs?: ICatalog[] + raccoltacataloghis?: IRaccoltaCatalogo[] } diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js index 5224d3e5..48b0efb6 100755 --- a/src/statics/lang/it.js +++ b/src/statics/lang/it.js @@ -2111,6 +2111,12 @@ const msg_it = { status: 'Stato', }, + racccat: { + title: 'Titolo', + numcataloghi: 'Numero di Cataloghi', + foto_raccolta: 'Foto Raccolta', + } + }, }; diff --git a/src/store/CatalogStore.ts b/src/store/CatalogStore.ts index 2c27021b..feefd90d 100755 --- a/src/store/CatalogStore.ts +++ b/src/store/CatalogStore.ts @@ -28,7 +28,12 @@ export const useCatalogStore = defineStore('CatalogStore', { catalogs: [{ _id: '', idapp: '', title: '' }] }), - getters: {}, + getters: { + getCatalogById: (state) => (id: string) => { + return state.catalogs.find((cat: ICatalog) => cat._id === id); + }, + + }, actions: { diff --git a/src/store/Modules/fieldsTable.ts b/src/store/Modules/fieldsTable.ts index a78f22aa..354ead4c 100755 --- a/src/store/Modules/fieldsTable.ts +++ b/src/store/Modules/fieldsTable.ts @@ -124,6 +124,58 @@ export const colmailinglist = [ AddCol(DeleteRec), ] +export const colTableRaccoltaCataloghi = [ + AddCol({ name: 'title', label_trans: 'racccat.title' }), + AddCol({ + name: 'foto_raccolta', + label_trans: 'racccat.foto_raccolta', + fieldtype: costanti.FieldType.image, + jointable: '', + showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit, + isadvanced_field: false, + }), + AddCol({ + name: 'idPageAssigned', + label_trans: 'cataloglist.idPageAssigned', + fieldtype: costanti.FieldType.select, + jointable: 'mypages_id', + }), + AddCol({ + name: 'idPageAssigned_stampa', + label_trans: 'cataloglist.idPageAssigned_stampa', + fieldtype: costanti.FieldType.select, + jointable: 'mypages_id', + }), + + AddCol({ + name: 'nomefile_da_generare', + label_trans: 'cataloglist.nomefile_generare', + }), + + /*AddCol({ + name: 'pdf_generato', + label_trans: 'cataloglist.pdf_generato', + }), + AddCol({ + name: 'pdf_generato_stampa', + label_trans: 'cataloglist.pdf_generato_stampa', + }), + + AddCol({ + name: 'pdf_online', + label_trans: 'cataloglist.pdf_online', + }), + AddCol({ + name: 'pdf_online_stampa', + label_trans: 'cataloglist.pdf_online_stampa', + }),*/ + + + AddCol(ModifRec), + AddCol(DuplicateRec), + AddCol(DeleteRec), +] + export const colTableCatalogList = [ AddCol({ name: 'active', label_trans: 'myelems.pubblica_online', fieldtype: costanti.FieldType.boolean }), AddCol({ name: 'title', label_trans: 'gallery.title' }), @@ -4311,11 +4363,13 @@ export const fieldsTable = { + // Tabelle che hanno il /pickup tableRemotePickup: [ 'countries', 'phones', 'cities', 'products', + 'catalogs', ], tableWithUsername: [ @@ -5213,6 +5267,13 @@ export const fieldsTable = { colkey: '_id', collabel: 'title', }, + { + value: 'raccoltacataloghis', + label: 'Raccolta Cataloghi', + columns: colTableRaccoltaCataloghi, + colkey: '_id', + collabel: 'title', + }, { value: 'schedeopt', label: 'Template Cataloghi', diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index 8eb3d2cb..ddf6f79e 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -1,14 +1,18 @@ -import { i18n } from 'src/boot/i18n' // Importa l'istanza di i18n configurata in Quasar +import { i18n } from 'src/boot/i18n'; // Importa l'istanza di i18n configurata in Quasar -import { translation } from '@store/Modules/translation' +import { translation } from '@store/Modules/translation'; // import languages from '@src/db/lang/languages'; import type { IColGridTable, IColl, - ICollaborations, IDataToSet, - IEvents, IFriends, IMyGroup, ICircuit, + ICollaborations, + IDataToSet, + IEvents, + IFriends, + IMyGroup, + ICircuit, IListRoutes, IParamDialog, IPathFile, @@ -16,7 +20,22 @@ import type { ITimeLineMain, ITodo, IOrder, - IUserFields, IImgGallery, IMsgGlobParam, ISpecialField, IMyCircuit, ISendCoin, IMovVisu, IMyElem, IMyCard, ILabelValueStr, IAnim, ILang, IGroupShort, IPagination, IFavorite, IBookmark, + IUserFields, + IImgGallery, + IMsgGlobParam, + ISpecialField, + IMyCircuit, + ISendCoin, + IMovVisu, + IMyElem, + IMyCard, + ILabelValueStr, + IAnim, + ILang, + IGroupShort, + IPagination, + IFavorite, + IBookmark, IMovQuery, IDimensioni, ISize, @@ -27,61 +46,56 @@ import type { IOptCatalogo, IPagina, IMyScheda, - ICollana + ICollana, } from '@model'; -import { - Privacy, - TipoVisu -} from '@model' +import { Privacy, TipoVisu } from '@model'; -import MixinBase from '@src/mixins/mixin-base' +import MixinBase from '@src/mixins/mixin-base'; -import { fieldsTable } from '@store/Modules/fieldsTable' +import { fieldsTable } from '@store/Modules/fieldsTable'; -import { lists } from '@store/Modules/lists' -import { costanti } from '@store/Modules/costanti' -import { copyToClipboard, date, Screen, useQuasar, colors, Cookies, scroll } from 'quasar' +import { lists } from '@store/Modules/lists'; +import { costanti } from '@store/Modules/costanti'; +import { copyToClipboard, date, Screen, useQuasar, colors, Cookies, scroll } from 'quasar'; -const { getScrollTarget, setVerticalScrollPosition } = scroll -import { func_tools, toolsext } from '@store/Modules/toolsext' -import { preloadedimages, static_data } from '@src/db/static_data' -import { useGlobalStore } from '@store/globalStore' -import globalroutines from '../../globalroutines/index' +const { getScrollTarget, setVerticalScrollPosition } = scroll; +import { func_tools, toolsext } from '@store/Modules/toolsext'; +import { preloadedimages, static_data } from '@src/db/static_data'; +import { useGlobalStore } from '@store/globalStore'; +import globalroutines from '../../globalroutines/index'; -import { RouteNames } from '@src/router/route-names' -import messages from '@src/statics/i18n' -import { shared_consts } from '@src/common/shared_vuejs' -import * as ApiTables from '@store/Modules/ApiTables' -import translate from '@src/globalroutines/util' -import { serv_constants } from '@store/Modules/serv_constants' -import { useProjectStore } from '@store/Projects' -import { useTodoStore } from '@store/Todos' -import { useUserStore } from '@store/UserStore' -import { useCircuitStore } from '@store/CircuitStore' -import { useCalendarStore } from '@store/CalendarStore' -import type { Router } from 'vue-router' +import { RouteNames } from '@src/router/route-names'; +import messages from '@src/statics/i18n'; +import { shared_consts } from '@src/common/shared_vuejs'; +import * as ApiTables from '@store/Modules/ApiTables'; +import translate from '@src/globalroutines/util'; +import { serv_constants } from '@store/Modules/serv_constants'; +import { useProjectStore } from '@store/Projects'; +import { useTodoStore } from '@store/Todos'; +import { useUserStore } from '@store/UserStore'; +import { useCircuitStore } from '@store/CircuitStore'; +import { useCalendarStore } from '@store/CalendarStore'; +import type { Router } from 'vue-router'; import type { AxiosResponse } from 'axios'; -import { default as Axios } from 'axios' -import { PayloadMessageTypes } from '@src/common' -import { useNotifStore } from '@store/NotifStore' +import { default as Axios } from 'axios'; +import { PayloadMessageTypes } from '@src/common'; +import { useNotifStore } from '@store/NotifStore'; import { useProducts } from '../Products'; const { t } = i18n.global; export interface INotify { - color?: string - textColor?: string - icon?: string + color?: string; + textColor?: string; + icon?: string; } - export const tools = { CAN_EDIT: 'q-ce', TABBED_DASHBOARD: 't-db', TABBED_HOME: 't-home', TABBED_NAVE: 't-nave', - FILTER_ALL: 0, FILTER_MYREC: 1, FILTER_MYFOLLOW: 2, @@ -316,7 +330,7 @@ export const tools = { value: shared_consts.ConfSite.Notif_Reg_Bot_ToManagers, }, { - label: 'Notif Reg Push (all\'Admin)', + label: "Notif Reg Push (all'Admin)", value: shared_consts.ConfSite.Notif_Reg_Push_Admin, }, { @@ -324,7 +338,7 @@ export const tools = { value: shared_consts.ConfSite.AskInvitantesulBot, }, { - label: 'Chiedi l\'Username sul Bot', + label: "Chiedi l'Username sul Bot", value: shared_consts.ConfSite.AskUsernameSulBot, }, { @@ -339,7 +353,6 @@ export const tools = { label: 'Username Telegram in fase di Registrazione', value: shared_consts.ConfSite.askUSernameTelegramToTheReg, }, - ], SelectMetodiPagamento: [ @@ -422,7 +435,7 @@ export const tools = { SelectListOrientamentoPDF: [ { label: 'Verticale', value: 'portrait' }, - { label: 'orizzontale', value: 'landscape' } + { label: 'orizzontale', value: 'landscape' }, ], SelectListUnitPDF: [ @@ -633,7 +646,6 @@ export const tools = { label: '377 €', value: 377, }, - ], SelectDocType: [ @@ -803,7 +815,6 @@ export const tools = { label: 'Delay 5s', value: 'animate__delay-5s', }, - ], SelectListTimingType: [ @@ -831,8 +842,6 @@ export const tools = { label: 'Ease-In-Out', value: 'animate__ease-in-out', }, - - ], SelectListAnimation: [ @@ -1056,9 +1065,6 @@ export const tools = { label: 'lightSpeedOut Right', value: 'animate__lightSpeedOutRight', }, - - - ], SelectListClass: [ @@ -1443,56 +1449,51 @@ export const tools = { icon: 'expand_less', }, ], - es: - [ - { - id: 1, - label: 'Ninguno', - value: 0, // Status.NONE - icon: 'expand_less', - }, - { - id: 2, - label: 'Abierto', - value: 1, // Status.OPENED - icon: 'expand_less', - }, - { - id: 3, - label: 'Completado', - value: 10, // Status.COMPLETED - icon: 'expand_less', - }, - ], - enUs: - [ - { - id: 1, - label: 'None', - value: 0, // Status.NONE - icon: 'expand_less', - }, - { - id: 2, - label: 'Opened', - value: 1, // Status.OPENED - icon: 'expand_less', - }, - { - id: 3, - label: 'Completed', - value: 10, // Status.COMPLETED - icon: 'expand_less', - }, - ], - + es: [ + { + id: 1, + label: 'Ninguno', + value: 0, // Status.NONE + icon: 'expand_less', + }, + { + id: 2, + label: 'Abierto', + value: 1, // Status.OPENED + icon: 'expand_less', + }, + { + id: 3, + label: 'Completado', + value: 10, // Status.COMPLETED + icon: 'expand_less', + }, + ], + enUs: [ + { + id: 1, + label: 'None', + value: 0, // Status.NONE + icon: 'expand_less', + }, + { + id: 2, + label: 'Opened', + value: 1, // Status.OPENED + icon: 'expand_less', + }, + { + id: 3, + label: 'Completed', + value: 10, // Status.COMPLETED + icon: 'expand_less', + }, + ], }, - INDEX_MENU_DELETE: 4, - menuPopupTodo: - { + menuPopupTodo: { it: [ { id: 5, @@ -1568,158 +1569,156 @@ export const tools = { checked: true, }, ], - es: - [ - { - id: 5, - disable: false, - label: 'Cortar', - value: lists.MenuAction.CUT, - icon: 'undo', - }, - { - id: 7, - disable: false, - label: 'Editar', - value: lists.MenuAction.EDIT, - icon: 'create', - }, - { - id: 8, - disable: false, - label: 'Borrar', - value: lists.MenuAction.DELETE, - icon: 'delete', - checked: false, - }, - { - id: 10, - disable: false, - label: '', - value: lists.MenuAction.PROGRESS_BAR, - icon: 'rowing', - checked: true, - }, - { - id: 20, - disable: false, - label: 'Establecer Prioridad', - value: lists.MenuAction.PRIORITY, - icon: 'rowing', - checked: false, - arrlista: lists.selectPriority.es, - }, - { - id: 21, - disable: false, - label: translation.es.proj.themecolor, - value: lists.MenuAction.THEME, - icon: 'format_color_text', - checked: false, - arrlista: lists.selectTheme, - }, - { - id: 22, - disable: false, - label: translation.es.proj.themebgcolor, - value: lists.MenuAction.THEMEBG, - icon: 'format_color_fill', - checked: false, - arrlista: lists.selectTheme, - }, - { - id: 30, - disable: false, - label: 'Completado', - value: lists.MenuAction.COMPLETED, - icon: 'check_circle', - checked: true, - }, - { - id: 40, - disable: false, - label: 'Establecer expiración', - value: lists.MenuAction.TOGGLE_EXPIRING, - icon: 'date_range', - checked: true, - }, - ], - enUs: - [ - { - id: 5, - disable: false, - label: 'Cut', - value: lists.MenuAction.CUT, - icon: 'undo', - }, - { - id: 7, - disable: false, - label: 'Edit', - value: lists.MenuAction.EDIT, - icon: 'create', - }, - { - id: 8, - disable: false, - label: 'Delete', - value: lists.MenuAction.DELETE, - icon: 'trash', - checked: false, - }, - { - id: 10, - disable: false, - label: '', - value: lists.MenuAction.PROGRESS_BAR, - icon: 'check_circle', - checked: true, - }, - { - id: 20, - disable: false, - label: 'Set Priority', - value: lists.MenuAction.PRIORITY, - icon: 'high_priority', - checked: false, - arrlista: lists.selectPriority.enUs, - }, - { - id: 21, - disable: false, - label: translation.enUs.proj.themecolor, - value: lists.MenuAction.THEME, - icon: 'format_color_text', - checked: false, - arrlista: lists.selectTheme, - }, - { - id: 22, - disable: false, - label: translation.enUs.proj.themebgcolor, - value: lists.MenuAction.THEMEBG, - icon: 'format_color_fill', - checked: false, - arrlista: lists.selectTheme, - }, - { - id: 30, - disable: false, - label: 'Completed', - value: lists.MenuAction.COMPLETED, - icon: 'check_circle', - checked: true, - }, - { - id: 40, - disable: false, - label: 'Set Expiring', - value: lists.MenuAction.TOGGLE_EXPIRING, - icon: 'date_range', - checked: true, - }, - ], + es: [ + { + id: 5, + disable: false, + label: 'Cortar', + value: lists.MenuAction.CUT, + icon: 'undo', + }, + { + id: 7, + disable: false, + label: 'Editar', + value: lists.MenuAction.EDIT, + icon: 'create', + }, + { + id: 8, + disable: false, + label: 'Borrar', + value: lists.MenuAction.DELETE, + icon: 'delete', + checked: false, + }, + { + id: 10, + disable: false, + label: '', + value: lists.MenuAction.PROGRESS_BAR, + icon: 'rowing', + checked: true, + }, + { + id: 20, + disable: false, + label: 'Establecer Prioridad', + value: lists.MenuAction.PRIORITY, + icon: 'rowing', + checked: false, + arrlista: lists.selectPriority.es, + }, + { + id: 21, + disable: false, + label: translation.es.proj.themecolor, + value: lists.MenuAction.THEME, + icon: 'format_color_text', + checked: false, + arrlista: lists.selectTheme, + }, + { + id: 22, + disable: false, + label: translation.es.proj.themebgcolor, + value: lists.MenuAction.THEMEBG, + icon: 'format_color_fill', + checked: false, + arrlista: lists.selectTheme, + }, + { + id: 30, + disable: false, + label: 'Completado', + value: lists.MenuAction.COMPLETED, + icon: 'check_circle', + checked: true, + }, + { + id: 40, + disable: false, + label: 'Establecer expiración', + value: lists.MenuAction.TOGGLE_EXPIRING, + icon: 'date_range', + checked: true, + }, + ], + enUs: [ + { + id: 5, + disable: false, + label: 'Cut', + value: lists.MenuAction.CUT, + icon: 'undo', + }, + { + id: 7, + disable: false, + label: 'Edit', + value: lists.MenuAction.EDIT, + icon: 'create', + }, + { + id: 8, + disable: false, + label: 'Delete', + value: lists.MenuAction.DELETE, + icon: 'trash', + checked: false, + }, + { + id: 10, + disable: false, + label: '', + value: lists.MenuAction.PROGRESS_BAR, + icon: 'check_circle', + checked: true, + }, + { + id: 20, + disable: false, + label: 'Set Priority', + value: lists.MenuAction.PRIORITY, + icon: 'high_priority', + checked: false, + arrlista: lists.selectPriority.enUs, + }, + { + id: 21, + disable: false, + label: translation.enUs.proj.themecolor, + value: lists.MenuAction.THEME, + icon: 'format_color_text', + checked: false, + arrlista: lists.selectTheme, + }, + { + id: 22, + disable: false, + label: translation.enUs.proj.themebgcolor, + value: lists.MenuAction.THEMEBG, + icon: 'format_color_fill', + checked: false, + arrlista: lists.selectTheme, + }, + { + id: 30, + disable: false, + label: 'Completed', + value: lists.MenuAction.COMPLETED, + icon: 'check_circle', + checked: true, + }, + { + id: 40, + disable: false, + label: 'Set Expiring', + value: lists.MenuAction.TOGGLE_EXPIRING, + icon: 'date_range', + checked: true, + }, + ], }, menuPopupProj: { @@ -1773,108 +1772,106 @@ export const tools = { arrlista: lists.selectTheme, }, ], - es: - [ - { - id: 5, - disable: false, - label: 'Cortar', - value: lists.MenuAction.CUT, - icon: 'undo', - }, - { - id: 10, - disable: false, - label: 'Editar', - value: lists.MenuAction.EDIT, - icon: 'create', - }, - { - id: 11, - disable: false, - label: 'Borrar', - value: 100, // DELETE - icon: 'delete', - checked: false, - }, - { - id: 40, - disable: false, - label: 'Establecer expiración', - value: lists.MenuAction.TOGGLE_EXPIRING, - icon: 'date_range', - checked: true, - }, - { - id: 45, - disable: false, - label: translation.es.proj.themecolor, - value: lists.MenuAction.THEME, - icon: 'format_color_text', - checked: false, - arrlista: lists.selectTheme, - }, - { - id: 46, - disable: false, - label: translation.es.proj.themebgcolor, - value: lists.MenuAction.THEMEBG, - icon: 'format_color_fill', - checked: false, - arrlista: lists.selectTheme, - }, - ], - enUs: - [ - { - id: 5, - disable: false, - label: 'Cut', - value: 71, // CUT - icon: 'undo', - }, - { - id: 10, - disable: false, - label: 'Edit', - value: lists.MenuAction.EDIT, - icon: 'create', - }, - { - id: 40, - disable: false, - label: 'Set Expiring', - value: 101, // TOGGLE_EXPIRING - icon: 'date_range', - checked: true, - }, - { - id: 45, - disable: false, - label: translation.enUs.proj.themecolor, - value: lists.MenuAction.THEME, - icon: 'format_color_text', - checked: false, - arrlista: lists.selectTheme, - }, - { - id: 46, - disable: false, - label: translation.enUs.proj.themebgcolor, - value: lists.MenuAction.THEMEBG, - icon: 'format_color_fill', - checked: false, - arrlista: lists.selectTheme, - }, - { - id: 50, - disable: false, - label: 'Delete', - value: 100, // DELETE - icon: 'trash', - checked: false, - }, - ], + es: [ + { + id: 5, + disable: false, + label: 'Cortar', + value: lists.MenuAction.CUT, + icon: 'undo', + }, + { + id: 10, + disable: false, + label: 'Editar', + value: lists.MenuAction.EDIT, + icon: 'create', + }, + { + id: 11, + disable: false, + label: 'Borrar', + value: 100, // DELETE + icon: 'delete', + checked: false, + }, + { + id: 40, + disable: false, + label: 'Establecer expiración', + value: lists.MenuAction.TOGGLE_EXPIRING, + icon: 'date_range', + checked: true, + }, + { + id: 45, + disable: false, + label: translation.es.proj.themecolor, + value: lists.MenuAction.THEME, + icon: 'format_color_text', + checked: false, + arrlista: lists.selectTheme, + }, + { + id: 46, + disable: false, + label: translation.es.proj.themebgcolor, + value: lists.MenuAction.THEMEBG, + icon: 'format_color_fill', + checked: false, + arrlista: lists.selectTheme, + }, + ], + enUs: [ + { + id: 5, + disable: false, + label: 'Cut', + value: 71, // CUT + icon: 'undo', + }, + { + id: 10, + disable: false, + label: 'Edit', + value: lists.MenuAction.EDIT, + icon: 'create', + }, + { + id: 40, + disable: false, + label: 'Set Expiring', + value: 101, // TOGGLE_EXPIRING + icon: 'date_range', + checked: true, + }, + { + id: 45, + disable: false, + label: translation.enUs.proj.themecolor, + value: lists.MenuAction.THEME, + icon: 'format_color_text', + checked: false, + arrlista: lists.selectTheme, + }, + { + id: 46, + disable: false, + label: translation.enUs.proj.themebgcolor, + value: lists.MenuAction.THEMEBG, + icon: 'format_color_fill', + checked: false, + arrlista: lists.selectTheme, + }, + { + id: 50, + disable: false, + label: 'Delete', + value: 100, // DELETE + icon: 'trash', + checked: false, + }, + ], }, menuPopupConfigTodo: { @@ -1887,26 +1884,24 @@ export const tools = { icon: 'rowing', }, ], - es: - [ - { - id: 10, - disable: false, - label: 'Mostrar Tareas', - value: 150, - icon: 'rowing', - }, - ], - enUs: - [ - { - id: 10, - disable: false, - label: 'Show Task', - value: 150, - icon: 'rowing', - }, - ], + es: [ + { + id: 10, + disable: false, + label: 'Mostrar Tareas', + value: 150, + icon: 'rowing', + }, + ], + enUs: [ + { + id: 10, + disable: false, + label: 'Show Task', + value: 150, + icon: 'rowing', + }, + ], }, menuPopupConfigProject: { @@ -1940,54 +1935,52 @@ export const tools = { icon: 'rowing', }, ], - es: - [ - { - id: 3, - disable: false, - label: translation.es.action.paste, - value: 72, // Action.PASTE - icon: 'file_copy', - }, - { - id: 5, - disable: false, - label: translation.es.proj.newsubproj, - value: 200, // ADD_PROJECT - icon: 'next_week', - }, - { - id: 10, - disable: false, - label: translation.es.task.showtask, - value: 150, - icon: 'rowing', - }, - ], - enUs: - [ - { - id: 3, - disable: false, - label: translation.enUs.action.paste, - value: 72, // Action.PASTE - icon: 'file_copy', - }, - { - id: 5, - disable: false, - label: translation.enUs.proj.newsubproj, - value: 200, // ADD_PROJECT - icon: 'next_week', - }, - { - id: 10, - disable: false, - label: translation.enUs.task.showtask, - value: 150, - icon: 'rowing', - }, - ], + es: [ + { + id: 3, + disable: false, + label: translation.es.action.paste, + value: 72, // Action.PASTE + icon: 'file_copy', + }, + { + id: 5, + disable: false, + label: translation.es.proj.newsubproj, + value: 200, // ADD_PROJECT + icon: 'next_week', + }, + { + id: 10, + disable: false, + label: translation.es.task.showtask, + value: 150, + icon: 'rowing', + }, + ], + enUs: [ + { + id: 3, + disable: false, + label: translation.enUs.action.paste, + value: 72, // Action.PASTE + icon: 'file_copy', + }, + { + id: 5, + disable: false, + label: translation.enUs.proj.newsubproj, + value: 200, // ADD_PROJECT + icon: 'next_week', + }, + { + id: 10, + disable: false, + label: translation.enUs.task.showtask, + value: 150, + icon: 'rowing', + }, + ], }, menuPopupConfigMAINProject: { @@ -2007,40 +2000,38 @@ export const tools = { icon: 'next_week', }, ], - es: - [ - { - id: 3, - disable: false, - label: translation.es.action.paste, - value: 72, // Action.PASTE - icon: 'file_copy', - }, - { - id: 5, - disable: false, - label: translation.es.proj.newproj, - value: 200, // ADD_PROJECT - icon: 'next_week', - }, - ], - enUs: - [ - { - id: 3, - disable: false, - label: translation.enUs.action.paste, - value: 72, // Action.PASTE - icon: 'file_copy', - }, - { - id: 5, - disable: false, - label: translation.enUs.proj.newproj, - value: 200, // ADD_PROJECT - icon: 'next_week', - }, - ], + es: [ + { + id: 3, + disable: false, + label: translation.es.action.paste, + value: 72, // Action.PASTE + icon: 'file_copy', + }, + { + id: 5, + disable: false, + label: translation.es.proj.newproj, + value: 200, // ADD_PROJECT + icon: 'next_week', + }, + ], + enUs: [ + { + id: 3, + disable: false, + label: translation.enUs.action.paste, + value: 72, // Action.PASTE + icon: 'file_copy', + }, + { + id: 5, + disable: false, + label: translation.enUs.proj.newproj, + value: 200, // ADD_PROJECT + icon: 'next_week', + }, + ], }, listOptionShowTask: { @@ -2070,238 +2061,272 @@ export const tools = { checked: true, }, ], - es: - [ - { - id: 10, - disable: false, - label: 'Mostrar los ultimos N completados', - value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED, - icon: 'rowing', - checked: true, - }, - { - id: 20, - disable: false, - label: 'Tareas para completar', - value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE, - icon: 'rowing', - checked: false, - }, - { - id: 30, - disable: false, - label: 'Todos las Tareas', - value: costanti.ShowTypeTask.SHOW_ALL, - icon: 'check_circle', - checked: true, - }, - ], - enUs: - [ - { - id: 10, - disable: false, - label: 'Show last N Completed', - value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED, - icon: 'rowing', - checked: true, - }, - { - id: 20, - disable: false, - label: 'Task to complete', - value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE, - icon: 'rowing', - checked: false, - }, - { - id: 30, - disable: false, - label: 'All Tasks', - value: costanti.ShowTypeTask.SHOW_ALL, - icon: 'check_circle', - checked: true, - }, - ], + es: [ + { + id: 10, + disable: false, + label: 'Mostrar los ultimos N completados', + value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED, + icon: 'rowing', + checked: true, + }, + { + id: 20, + disable: false, + label: 'Tareas para completar', + value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE, + icon: 'rowing', + checked: false, + }, + { + id: 30, + disable: false, + label: 'Todos las Tareas', + value: costanti.ShowTypeTask.SHOW_ALL, + icon: 'check_circle', + checked: true, + }, + ], + enUs: [ + { + id: 10, + disable: false, + label: 'Show last N Completed', + value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED, + icon: 'rowing', + checked: true, + }, + { + id: 20, + disable: false, + label: 'Task to complete', + value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE, + icon: 'rowing', + checked: false, + }, + { + id: 30, + disable: false, + label: 'All Tasks', + value: costanti.ShowTypeTask.SHOW_ALL, + icon: 'check_circle', + checked: true, + }, + ], }, getServerHost() { - try { - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); if (globalStore.serverHost) { - return globalStore.serverHost + return globalStore.serverHost; } else { - return globalStore.getServerHost() + return globalStore.getServerHost(); } } catch (e) { - return import.meta.env.VITE_MONGODB_HOST + return import.meta.env.VITE_MONGODB_HOST; } - }, getTitlePriority(priority: number): string { - let cl = '' + let cl = ''; if (priority === this.Priority.PRIORITY_HIGH) { - cl = 'high_priority' + cl = 'high_priority'; } else if (priority === this.Priority.PRIORITY_NORMAL) { - cl = 'medium_priority' + cl = 'medium_priority'; } else if (priority === this.Priority.PRIORITY_LOW) { - cl = 'low_priority' + cl = 'low_priority'; } - return `${cl} titlePriority` + return `${cl} titlePriority`; }, getStatusListByInd(index: number) { try { // @ts-ignore - const arr: any = this.selectStatus[toolsext.getLocale() || 'it'] + const arr: any = this.selectStatus[toolsext.getLocale() || 'it']; for (const rec of arr) { if (rec.value === index) { - return rec.label + return rec.label; } } } catch (e) { - console.log('Error: ', e) + console.log('Error: ', e); } - return '' + return ''; }, getPriorityByInd(index: number) { // console.log('LANG in PRIOR', toolsext.getLocale()) try { // @ts-ignore - const arr: any = lists.selectPriority[toolsext.getLocale() || 'it'] + const arr: any = lists.selectPriority[toolsext.getLocale() || 'it']; for (const rec of arr) { if (rec.value === index) { - return rec.label + return rec.label; } } } catch (e) { - console.log('Error: ', e) + console.log('Error: ', e); } - return '' + return ''; }, logelem(mystr: string, elem: any) { - console.log(mystr, 'elem [', elem._id, '] ', elem.descr, 'pos', elem.pos, ' Pr(', this.getPriorityByInd(elem.priority), ') modif=', elem.modified) + console.log( + mystr, + 'elem [', + elem._id, + '] ', + elem.descr, + 'pos', + elem.pos, + ' Pr(', + this.getPriorityByInd(elem.priority), + ') modif=', + elem.modified + ); }, getelemprojstr(elem: any) { - return elem.descr + ' [id= ' + elem._id + '] ' + 'pos: ' + elem.pos + ']\n' + return elem.descr + ' [id= ' + elem._id + '] ' + 'pos: ' + elem.pos + ']\n'; }, logga_arrproj(myarr: IProject[]) { - let mystr = '\n' + let mystr = '\n'; myarr.forEach((item) => { - mystr += this.getelemprojstr(item) + ' ' - }) + mystr += this.getelemprojstr(item) + ' '; + }); - return mystr + return mystr; }, logelemprj(mystr: string, elem: any) { - console.log(mystr, this.getelemprojstr(elem)) + console.log(mystr, this.getelemprojstr(elem)); }, getstrelem(elem: any) { - return 'elem [' + elem._id + '] ' + elem.descr + ' Pr(' + this.getPriorityByInd(elem.priority) + ') modif=' + elem.modified + ' ' + return ( + 'elem [' + + elem._id + + '] ' + + elem.descr + + ' Pr(' + + this.getPriorityByInd(elem.priority) + + ') modif=' + + elem.modified + + ' ' + ); }, logga_arr(myarr: ITodo[]) { - let mystr = '\n' + let mystr = '\n'; myarr.forEach((item) => { - mystr += '[' + item.pos + '] ' + item.descr + ' Pr(' + this.getPriorityByInd(item.priority || 0) + ')' + ' modif=' + item.modified + '\n' + mystr += + '[' + + item.pos + + '] ' + + item.descr + + ' Pr(' + + this.getPriorityByInd(item.priority || 0) + + ')' + + ' modif=' + + item.modified + + '\n'; // mystr += '[' + item.pos + '] ' + item.descr + '\n' - }) + }); - return mystr + return mystr; }, touchmove(scrollable: any) { if (window) { - window.addEventListener('touchmove', (e) => { - // console.log('touchmove') - if (!scrollable) { - e.preventDefault() - } - }, { passive: false }) + window.addEventListener( + 'touchmove', + (e) => { + // console.log('touchmove') + if (!scrollable) { + e.preventDefault(); + } + }, + { passive: false } + ); } }, jsonCopy(src: any) { - return JSON.parse(JSON.stringify(src)) + return JSON.parse(JSON.stringify(src)); }, getItemLS(item: any): any { - let ris = localStorage.getItem(item) - if ((ris == null) || (ris === '') || (ris === 'null') || !ris) { - ris = '' + let ris = localStorage.getItem(item); + if (ris == null || ris === '' || ris === 'null' || !ris) { + ris = ''; } - return ris + return ris; }, strToObj(mystr: string): any { try { if (mystr) { - mystr = decodeURIComponent(mystr) - return JSON.parse(mystr) - } else - return null + mystr = decodeURIComponent(mystr); + return JSON.parse(mystr); + } else return null; } catch (e) { - return null + return null; } }, objToStr(myobj: any): string { - return JSON.stringify(myobj) + return JSON.stringify(myobj); }, notifyarraychanged(array: any) { if (array.length > 0) { - array.splice(array.length - 1, 1, array[array.length - 1]) + array.splice(array.length - 1, 1, array[array.length - 1]); } }, isOkIndex(myarr: any, index: number) { - return (index >= 0 && index < myarr.length) + return index >= 0 && index < myarr.length; }, async swapGeneralElem(nametable: string, myarr: any, itemdragend: any, listFieldsToChange: any) { - - const arrprec = [...myarr] + const arrprec = [...myarr]; if (itemdragend.field === 'priority') { // get last elem priority - console.log('get last elem priority') - itemdragend.newIndex = this.getLastFirstElemPriority(myarr, itemdragend.prioritychosen, itemdragend.atfirst, itemdragend.idelemtochange) - itemdragend.oldIndex = this.getIndexById(myarr, itemdragend.idelemtochange) + console.log('get last elem priority'); + itemdragend.newIndex = this.getLastFirstElemPriority( + myarr, + itemdragend.prioritychosen, + itemdragend.atfirst, + itemdragend.idelemtochange + ); + itemdragend.oldIndex = this.getIndexById(myarr, itemdragend.idelemtochange); - console.log('swapElems PRIORITY', itemdragend) + console.log('swapElems PRIORITY', itemdragend); } if (itemdragend.newIndex === itemdragend.oldIndex) { - return + return; } - console.log('swapGeneralElem', 'new =', itemdragend.newIndex, 'Old =', itemdragend.oldIndex, itemdragend) + console.log('swapGeneralElem', 'new =', itemdragend.newIndex, 'Old =', itemdragend.oldIndex, itemdragend); if (this.isOkIndex(myarr, itemdragend.newIndex) && this.isOkIndex(myarr, itemdragend.oldIndex)) { - - console.log('*** SPLICE!') - console.log(' PRIMA!', this.logga_arrproj(myarr)) - myarr.splice(itemdragend.newIndex, 0, myarr.splice(itemdragend.oldIndex, 1)[0]) - console.log(' DOPO!', this.logga_arrproj(myarr)) + console.log('*** SPLICE!'); + console.log(' PRIMA!', this.logga_arrproj(myarr)); + myarr.splice(itemdragend.newIndex, 0, myarr.splice(itemdragend.oldIndex, 1)[0]); + console.log(' DOPO!', this.logga_arrproj(myarr)); // Ora inverti gli indici - const indold = itemdragend.oldIndex - itemdragend.oldIndex = itemdragend.newIndex - itemdragend.newIndex = indold + const indold = itemdragend.oldIndex; + itemdragend.oldIndex = itemdragend.newIndex; + itemdragend.newIndex = indold; /* if (nametable === 'todos') { @@ -2335,46 +2360,44 @@ export const tools = { } } */ - let status = 0 + let status = 0; // const arr = lists.selectPriority[toolsext.getLocale()] // for (const priority of arr) { for (let i = 0; i < myarr.length; ++i) { if (nametable === 'todos') { - status = myarr[i].statustodo + status = myarr[i].statustodo; } else if (nametable === 'projects') { - status = myarr[i].statusproj + status = myarr[i].statusproj; } if (status !== this.Status.COMPLETED) { - myarr[i].pos = i + myarr[i].pos = i; - const findelem = arrprec.find((rec) => rec._id === myarr[i]._id) + const findelem = arrprec.find((rec) => rec._id === myarr[i]._id); if (findelem !== myarr[i].pos) { - myarr[i].modified = true - await ApiTables.table_ModifyRecord(nametable, myarr[i], listFieldsToChange, 'pos') + myarr[i].modified = true; + await ApiTables.table_ModifyRecord(nametable, myarr[i], listFieldsToChange, 'pos'); } } - } for (let i = 0; i < myarr.length; ++i) { if (nametable === 'todos') { - status = myarr[i].statustodo + status = myarr[i].statustodo; } else if (nametable === 'projects') { - status = myarr[i].statusproj + status = myarr[i].statusproj; } // (myarr[i].priority === priority.value) - if ((status === this.Status.COMPLETED)) { - myarr[i].pos = 1000 + i + if (status === this.Status.COMPLETED) { + myarr[i].pos = 1000 + i; - const findelem = arrprec.find((rec) => rec._id === myarr[i]._id) + const findelem = arrprec.find((rec) => rec._id === myarr[i]._id); if (findelem !== myarr[i].pos) { - myarr[i].modified = true - await ApiTables.table_ModifyRecord(nametable, myarr[i], listFieldsToChange, 'pos') + myarr[i].modified = true; + await ApiTables.table_ModifyRecord(nametable, myarr[i], listFieldsToChange, 'pos'); } } - } // } @@ -2400,377 +2423,358 @@ export const tools = { */ - this.notifyarraychanged(myarr) + this.notifyarraychanged(myarr); // console.log('arr FINALE', this.logga_arrproj(myarr)) // Update the records: } - } - , - - - isLoggedToSystem(): boolean { - const tok = this.getItemLS(toolsext.localStorage.token) - return !!tok }, - + isLoggedToSystem(): boolean { + const tok = this.getItemLS(toolsext.localStorage.token); + return !!tok; + }, askfornotification($q: any) { //T_TOLTO - console.log('askfornotification', $q) - this.showNotif($q, t('notification.waitingconfirm'), { color: 'positive', icon: 'notifications' }) + console.log('askfornotification', $q); + this.showNotif($q, t('notification.waitingconfirm'), { color: 'positive', icon: 'notifications' }); Notification.requestPermission((result) => { - console.log('User Choice', result) + console.log('User Choice', result); if (result === 'granted') { - this.showNotif($q, t('notification.confirmed'), { color: 'positive', icon: 'notifications' }) + this.showNotif($q, t('notification.confirmed'), { color: 'positive', icon: 'notifications' }); } else { - this.showNotif($q, t('notification.denied'), { color: 'negative', icon: 'notifications' }) + this.showNotif($q, t('notification.denied'), { color: 'negative', icon: 'notifications' }); - this.displayConfirmNotification() + this.displayConfirmNotification(); } - }) + }); }, getimgbysize(dir: string, file: string): string { - const myimage = dir + file + const myimage = dir + file; // console.log('includes = ', static_data.preLoadImages.map((a) => a.imgname).includes(myimage), myimage) - let ris = '' + let ris = ''; try { // @ts-ignore - if (this.isMobile() && (preloadedimages().map((a) => a.imgname).includes(myimage))) { - ris = `${dir}mobile/${file}` + if ( + this.isMobile() && + preloadedimages() + .map((a) => a.imgname) + .includes(myimage) + ) { + ris = `${dir}mobile/${file}`; } else { - ris = myimage + ris = myimage; } } catch (e) { - return myimage + return myimage; } // console.log('getimgbysize', ris) - return ris + return ris; }, getaltimg(dir: string, file: string, alt?: string): string { - const myimage = dir + file - const myrec = static_data.preLoadImages.find((rec) => rec.imgname === myimage) - if (myrec) return (myrec) ? myrec.alt : 'my image' - return alt || '' + const myimage = dir + file; + const myrec = static_data.preLoadImages.find((rec) => rec.imgname === myimage); + if (myrec) return myrec ? myrec.alt : 'my image'; + return alt || ''; }, getimgFullpathbysize(fileimg: string): IPathFile { - if (!fileimg) return { path: '', file: fileimg } - const ind = fileimg.lastIndexOf('/') + if (!fileimg) return { path: '', file: fileimg }; + const ind = fileimg.lastIndexOf('/'); if (ind > 0) { - return { path: fileimg.substring(0, ind + 1), file: fileimg.substring(ind + 1) } + return { path: fileimg.substring(0, ind + 1), file: fileimg.substring(ind + 1) }; } - return { path: '', file: fileimg } + return { path: '', file: fileimg }; }, - async createNewRecord($q: any, table: string, data: any, withnotif = true) { const mydata = { table, data, - } + }; //T_TOLTO + const globalStore = useGlobalStore(); - const globalStore = useGlobalStore() - - - return await globalStore.saveTable(mydata) - .then((record) => { - if (withnotif) { - if (record) { - this.showPositiveNotif($q, t('db.recupdated')) - } else { - this.showNegativeNotif($q, t('db.recfailed')) - } + return await globalStore.saveTable(mydata).then((record) => { + if (withnotif) { + if (record) { + this.showPositiveNotif($q, t('db.recupdated')); + } else { + this.showNegativeNotif($q, t('db.recfailed')); } - return record - }) + } + return record; + }); }, isObject(anything: any) { // Object.create(null) instanceof Object → false - return Object(anything) === anything + return Object(anything) === anything; }, isFunc(anything: any) { - return (typeof anything === 'function') + return typeof anything === 'function'; }, isDebug() { - return import.meta.env.DEV + return import.meta.env.DEV; }, isTest() { try { - return import.meta.env.VITE_VUE_APP_ISTEST === '1' + return import.meta.env.VITE_VUE_APP_ISTEST === '1'; } catch (e) { - return false + return false; } }, isLocale() { try { - return import.meta.env.VITE_VUE_APP_INLOCALE === '1' + return import.meta.env.VITE_VUE_APP_INLOCALE === '1'; } catch (e) { - return false + return false; } }, notshowPwd(payload: any) { - const mypay = { ...payload } + const mypay = { ...payload }; try { if (mypay.password) { - mypay.password = '**********' + mypay.password = '**********'; } } catch (e) { - console.log('error', e) + console.log('error', e); } - return mypay + return mypay; }, - getIndexById(myarr: any, id: any) { - if (myarr === undefined) - return -1 - return myarr.indexOf(this.getElemById(myarr, id)) - } - , - - getElemById(myarr: any, id: any) { - if (myarr === undefined) - return null - // console.log('getElemById', myarr, id) - return myarr.find((elem: any) => elem._id === id) - } - , - - getElemPrevById(myarr: any, id: any) { - if (myarr === undefined) - return null - return myarr.find((elem: any) => elem.id_prev === id) + if (myarr === undefined) return -1; + return myarr.indexOf(this.getElemById(myarr, id)); + }, + getElemById(myarr: any, id: any) { + if (myarr === undefined) return null; + // console.log('getElemById', myarr, id) + return myarr.find((elem: any) => elem._id === id); + }, + getElemPrevById(myarr: any, id: any) { + if (myarr === undefined) return null; + return myarr.find((elem: any) => elem.id_prev === id); }, - getLastFirstElemPriority(myarr: any, priority: number, atfirst: boolean, escludiId: string) { if (myarr === null) { - return -1 + return -1; } - let trovato = false + let trovato = false; - console.log('priority', priority) + console.log('priority', priority); for (let indrec = 0; indrec < myarr.length; indrec++) { - if ((myarr[indrec].priority === priority) && (myarr[indrec]._id !== escludiId)) { - trovato = true + if (myarr[indrec].priority === priority && myarr[indrec]._id !== escludiId) { + trovato = true; if (atfirst) { - return indrec - 1 + return indrec - 1; } } else { if (trovato) { - return indrec + return indrec; } } } - console.log('trovato?', trovato, 'indrec') + console.log('trovato?', trovato, 'indrec'); if (trovato) { - return myarr.length - 1 + return myarr.length - 1; } else { if (priority === this.Priority.PRIORITY_LOW) { - return myarr.length - 1 + return myarr.length - 1; } else if (priority === this.Priority.PRIORITY_HIGH) { - return 0 + return 0; } } - } - , - + }, getFirstList(myarr: any) { - return myarr.find((elem: any) => elem.id_prev === ApiTables.LIST_START) - } - , - + return myarr.find((elem: any) => elem.id_prev === ApiTables.LIST_START); + }, getModulesByTable(nametable: string) { - const projects = useProjectStore() - const todos = useTodoStore() + const projects = useProjectStore(); + const todos = useTodoStore(); if (nametable === 'todos') { - return todos + return todos; } else if (nametable === 'projects') { - return projects + return projects; } - } - , - + }, setArrayMainByTable(nametable: string, myarr: any) { if (nametable === 'todos') { - const todos = useTodoStore() - todos.todos = this.jsonCopy(myarr) - return todos.todos + const todos = useTodoStore(); + todos.todos = this.jsonCopy(myarr); + return todos.todos; } else if (nametable === 'projects') { - const projects = useProjectStore() - projects.projects = this.jsonCopy(myarr) - return projects.projects + const projects = useProjectStore(); + projects.projects = this.jsonCopy(myarr); + return projects.projects; } }, getmyid(id: string) { - return 'row' + id - } - , - + return 'row' + id; + }, getLastListNotCompleted(nametable: string, cat: string, tipoproj: string) { // console.log('getLastListNotCompleted') // const module = this.getModulesByTable(nametable) - let arr: any = [] - const projects = useProjectStore() - const todos = useTodoStore() - if (nametable === 'projects') - arr = projects.projs_dacompletare(cat, tipoproj) - else if (nametable === 'todos') - arr = todos.items_dacompletare(cat) + let arr: any = []; + const projects = useProjectStore(); + const todos = useTodoStore(); + if (nametable === 'projects') arr = projects.projs_dacompletare(cat, tipoproj); + else if (nametable === 'todos') arr = todos.items_dacompletare(cat); - if (arr) - return (arr.length > 0) ? arr[arr.length - 1] : null - else - return null + if (arr) return arr.length > 0 ? arr[arr.length - 1] : null; + else return null; }, getElemByIndex(myarr: any, index: number) { if (index >= 0 && index < myarr.length) { - return myarr[index] + return myarr[index]; } else { - return null + return null; } - } - , - + }, existArr(x: any) { - return x = (typeof x !== 'undefined' && x instanceof Array) ? x : [] - } - , - + return (x = typeof x !== 'undefined' && x instanceof Array ? x : []); + }, json2array(json: any) { - const result: any = [] - const keys = Object.keys(json) + const result: any = []; + const keys = Object.keys(json); keys.forEach((key) => { - result.push(json[key]) - }) - return result + result.push(json[key]); + }); + return result; }, - visumenu(elem: IListRoutes) { // : IListRoutes + visumenu(elem: IListRoutes) { + // : IListRoutes - const userStore = useUserStore() - let visu = ((elem.onlyAdmin && userStore.isAdmin) || (elem.onlyManager && userStore.isManager) - || (elem.onlySocioResidente && userStore.my.profile.socioresidente) - || (elem.onlyConsiglio && userStore.my.profile.consiglio) - || (elem.onlyNotSoci && !userStore.my.profile.socio) - || (elem.onlyFacilitatore && userStore.isFacilitatore) - || (elem.onlyEditor && userStore.isEditor) - || (elem.onlyCommerciale && userStore.isCommerciale) - || (elem.onlyGrafico && userStore.isGrafico) - || (elem.onlyDepartment && userStore.isDepartment) - || ((!elem.onlyAdmin) && (!elem.onlyManager) && (!elem.onlyFacilitatore) && (!elem.onlyEditor) && (!elem.onlyDepartment) - && (!elem.onlySocioResidente) && (!elem.onlyConsiglio) && (!elem.onlyNotSoci))) && elem.active + const userStore = useUserStore(); + let visu = + ((elem.onlyAdmin && userStore.isAdmin) || + (elem.onlyManager && userStore.isManager) || + (elem.onlySocioResidente && userStore.my.profile.socioresidente) || + (elem.onlyConsiglio && userStore.my.profile.consiglio) || + (elem.onlyNotSoci && !userStore.my.profile.socio) || + (elem.onlyFacilitatore && userStore.isFacilitatore) || + (elem.onlyEditor && userStore.isEditor) || + (elem.onlyCommerciale && userStore.isCommerciale) || + (elem.onlyGrafico && userStore.isGrafico) || + (elem.onlyDepartment && userStore.isDepartment) || + (!elem.onlyAdmin && + !elem.onlyManager && + !elem.onlyFacilitatore && + !elem.onlyEditor && + !elem.onlyDepartment && + !elem.onlySocioResidente && + !elem.onlyConsiglio && + !elem.onlyNotSoci)) && + elem.active; if (!this.isLoggedToSystem()) { - if (elem.onlyif_logged) - visu = false + if (elem.onlyif_logged) visu = false; } if (elem.meta && elem.meta.requiresAuth) { - visu = visu && this.isLoggedToSystem() + visu = visu && this.isLoggedToSystem(); } // console.log('MENU visu', elem.path, visu) - return visu + return visu; }, executefunc(mythisq: any, table: string, func: number, par: IParamDialog, mythis?: any) { - const globalStore = useGlobalStore() - const calendarStore = useCalendarStore() + const globalStore = useGlobalStore(); + const calendarStore = useCalendarStore(); //T_TOLTO - if (func === lists.MenuAction.DELETE) { // console.log('param1', par.param1) - calendarStore.CancelBookingEvent({ - ideventbook: par.param1, - notify: par.param2 === true ? '1' : '0', - }).then((ris: any) => { - if (ris) { - this.showPositiveNotif(mythisq, t('cal.canceledbooking') + ' "' + par.param3 + '"') - } else { - this.showNegativeNotif(mythisq, t('cal.cancelederrorbooking')) - } - }) + calendarStore + .CancelBookingEvent({ + ideventbook: par.param1, + notify: par.param2 === true ? '1' : '0', + }) + .then((ris: any) => { + if (ris) { + this.showPositiveNotif(mythisq, t('cal.canceledbooking') + ' "' + par.param3 + '"'); + } else { + this.showNegativeNotif(mythisq, t('cal.cancelederrorbooking')); + } + }); } else if (func === lists.MenuAction.DELETE_EVENT) { // console.log('param1', par.param1, 'id', par.param1._id) calendarStore.CancelEvent({ id: par.param1._id }).then((ris: any) => { if (ris) { // Remove this record from my list - calendarStore.eventlist = calendarStore.eventlist.filter((event: IEvents) => (event._id !== par.param1._id)) - this.showPositiveNotif(mythisq, t('cal.canceledevent') + ' "' + par.param1.title + '"') + calendarStore.eventlist = calendarStore.eventlist.filter((event: IEvents) => event._id !== par.param1._id); + this.showPositiveNotif(mythisq, t('cal.canceledevent') + ' "' + par.param1.title + '"'); } else { - this.showNegativeNotif(mythisq, t('cal.cancelederrorevent')) + this.showNegativeNotif(mythisq, t('cal.cancelederrorevent')); } - }) + }); } else if (func === lists.MenuAction.DELETE_RECTABLE) { // console.log('param1', par.param1) globalStore.DeleteRec({ table, id: par.param1 }).then((ris) => { if (ris) { - mythis.ActionAfterYes(func, par.param2, null) - this.showPositiveNotif(mythisq, t('db.deletedrecord')) + mythis.ActionAfterYes(func, par.param2, null); + this.showPositiveNotif(mythisq, t('db.deletedrecord')); } else { - this.showNegativeNotif(mythisq, t('db.recdelfailed')) + this.showNegativeNotif(mythisq, t('db.recdelfailed')); } - }) + }); } else if (func === lists.MenuAction.DUPLICATE_RECTABLE) { // console.log('param1', par.param1) globalStore.DuplicateRec({ table, id: par.param1 }).then((ris) => { if (ris) { - mythis.ActionAfterYes(func, par.param2, ris.data) - this.showPositiveNotif(mythisq, t('db.duplicatedrecord')) - } else - this.showNegativeNotif(mythisq, t('db.recdupfailed')) - }) + mythis.ActionAfterYes(func, par.param2, ris.data); + this.showPositiveNotif(mythisq, t('db.duplicatedrecord')); + } else this.showNegativeNotif(mythisq, t('db.recdupfailed')); + }); } else if (func === lists.MenuAction.INVIA_MSG_A_DONATORI) { // console.log('param1', par.param1) - globalStore.InviaMsgADonatori({ - msgobj: par.param1, - navemediatore: par.param2, - tipomsg: par.param1.tipomsg, - }).then((ris) => { - if (ris) { - if (par.param1.inviareale) - this.showPositiveNotif(mythisq, t('dashboard.msg_donatori_ok')) - this.askConfirm(mythisq, '', ris.strout, translate('dialog.yes'), translate('dialog.no'), '', 0, 0, {}) - } else - this.showNegativeNotif(mythisq, t('db.recfailed')) - }) - } else if (func === lists.MenuAction.INVIA_MSG_A_SINGOLO) { - // console.log('param1', par.param1) - globalStore.InviaMsgADonatori({ - msgobj: par.param1, - navemediatore: par.param2, - tipomsg: par.param1.tipomsg, - }) + globalStore + .InviaMsgADonatori({ + msgobj: par.param1, + navemediatore: par.param2, + tipomsg: par.param1.tipomsg, + }) .then((ris) => { if (ris) { - this.showPositiveNotif(mythisq, t('cal.sendmsg_sent')) - } else - this.showNegativeNotif(mythisq, t('db.recfailed')) + if (par.param1.inviareale) this.showPositiveNotif(mythisq, t('dashboard.msg_donatori_ok')); + this.askConfirm(mythisq, '', ris.strout, translate('dialog.yes'), translate('dialog.no'), '', 0, 0, {}); + } else this.showNegativeNotif(mythisq, t('db.recfailed')); + }); + } else if (func === lists.MenuAction.INVIA_MSG_A_SINGOLO) { + // console.log('param1', par.param1) + globalStore + .InviaMsgADonatori({ + msgobj: par.param1, + navemediatore: par.param2, + tipomsg: par.param1.tipomsg, }) + .then((ris) => { + if (ris) { + this.showPositiveNotif(mythisq, t('cal.sendmsg_sent')); + } else this.showNegativeNotif(mythisq, t('db.recfailed')); + }); } else if (func === lists.MenuAction.DONO_INVIATO) { const mydatatosave: IDataToSet = { id: par.param1._id, @@ -2782,19 +2786,18 @@ export const tools = { commento_al_sognatore: par.param1.commento_al_sognatore, }, notifBot: null, - } + }; if (par.param3) { - mydatatosave.notifBot = { un: par.param2, txt: par.param3 } + mydatatosave.notifBot = { un: par.param2, txt: par.param3 }; } globalStore.saveFieldValue(mydatatosave).then((ris) => { if (ris) { - mythis.ActionAfterYes(func, par.param1, par.param2) - this.showPositiveNotif(mythisq, t('dashboard.fatto_dono')) - } else - this.showNegativeNotif(mythisq, t('db.recfailed')) - }) + mythis.ActionAfterYes(func, par.param1, par.param2); + this.showPositiveNotif(mythisq, t('dashboard.fatto_dono')); + } else this.showNegativeNotif(mythisq, t('db.recfailed')); + }); } else if (func === lists.MenuAction.DONO_RICEVUTO) { const mydatatosave: IDataToSet = { id: par.param1._id, @@ -2803,7 +2806,7 @@ export const tools = { unset: null, notifBot: null, tipomsg: this.TipoMsg.SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE, - } + }; if (par.param1.date_made_gift) { mydatatosave.fieldsvalue = { @@ -2811,105 +2814,114 @@ export const tools = { riga: par.param1.riga, col: par.param1.col, date_made_gift: par.param1.date_made_gift, - } + }; } else { - mydatatosave.fieldsvalue = { made_gift: par.param1.made_gift, riga: par.param1.riga, col: par.param1.col } + mydatatosave.fieldsvalue = { made_gift: par.param1.made_gift, riga: par.param1.riga, col: par.param1.col }; } if (par.param1.annulla) { if (par.param1.annulla) { - mydatatosave.fieldsvalue = { made_gift: false, riga: par.param1.riga, col: par.param1.col } - mydatatosave.unset = { date_made_gift: 1, received_gift: 1 } + mydatatosave.fieldsvalue = { made_gift: false, riga: par.param1.riga, col: par.param1.col }; + mydatatosave.unset = { date_made_gift: 1, received_gift: 1 }; } } if (par.param3) { - mydatatosave.notifBot = { un: par.param2, txt: par.param3 } + mydatatosave.notifBot = { un: par.param2, txt: par.param3 }; } globalStore.saveFieldValue(mydatatosave).then((ris) => { if (ris) { - mythis.ActionAfterYes(func, par.param1, par.param2) - let msg = t('dashboard.ricevuto_dono_ok') + mythis.ActionAfterYes(func, par.param1, par.param2); + let msg = t('dashboard.ricevuto_dono_ok'); if (par.param1.annulla) { - if (par.param1.annulla) - msg = 'Dono Annullato' + if (par.param1.annulla) msg = 'Dono Annullato'; } - this.showPositiveNotif(mythisq, msg) + this.showPositiveNotif(mythisq, msg); } else { - this.showNegativeNotif(mythisq, t('db.recfailed')) + this.showNegativeNotif(mythisq, t('db.recfailed')); } - }) + }); } }, async saveFieldToServer(mythisq: any, table: string, id: any, mydata: any, notif = true, aggiornainmem = true) { - const mydatatosave = { id, table, fieldsvalue: mydata, notifBot: null, aggiornainmem, - } + }; - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); //T_TOLTO - return await globalStore.saveFieldValue(mydatatosave).then((ris) => { if (ris) { - if (notif) - this.showPositiveNotif(mythisq, t('db.recupdated')) + if (notif) this.showPositiveNotif(mythisq, t('db.recupdated')); } else { - this.showNegativeNotif(mythisq, t('db.recfailed')) + this.showNegativeNotif(mythisq, t('db.recfailed')); } - }) - + }); }, - askConfirm($q: any, mytitle: string, mytext: string, ok: string, cancel: string, table: string, funcok: number, funccancel: number, par: IParamDialog, mythis?: any) { - return $q.dialog({ - message: mytext, - html: true, - ok: { - label: ok, - push: true, - }, - title: mytitle, - cancel: true, - persistent: false, - }).onOk(() => { - // console.log('OK') - this.executefunc($q, table, funcok, par, mythis) - return true - }).onCancel(() => { - // console.log('CANCEL') - this.executefunc($q, table, funccancel, par, mythis) - return false - }) + askConfirm( + $q: any, + mytitle: string, + mytext: string, + ok: string, + cancel: string, + table: string, + funcok: number, + funccancel: number, + par: IParamDialog, + mythis?: any + ) { + return $q + .dialog({ + message: mytext, + html: true, + ok: { + label: ok, + push: true, + }, + title: mytitle, + cancel: true, + persistent: false, + }) + .onOk(() => { + // console.log('OK') + this.executefunc($q, table, funcok, par, mythis); + return true; + }) + .onCancel(() => { + // console.log('CANCEL') + this.executefunc($q, table, funccancel, par, mythis); + return false; + }); }, showPositiveNotif(q: any, msg: string, time?: number, group?: any) { - this.showNotif(q, msg, { color: 'positive', icon: 'notifications' }, time, group) + this.showNotif(q, msg, { color: 'positive', icon: 'notifications' }, time, group); }, showNegativeNotif(q: any, msg: string, time = 5000, group?: any) { - this.showNotif(q, msg, { color: 'negative', icon: 'notifications' }, time, group) + this.showNotif(q, msg, { color: 'negative', icon: 'notifications' }, time, group); }, showNeutralNotif(q: any, msg: string, time = 10000) { - this.showNotif(q, msg, { color: 'info', icon: 'notifications' }, time) + this.showNotif(q, msg, { color: 'info', icon: 'notifications' }, time); }, showNotif(q: any, msg: string, data?: INotify | null, time?: number, group?: any) { - let myicon = data ? data.icon : 'ion-add' + let myicon = data ? data.icon : 'ion-add'; if (!myicon) { - myicon = 'ion-add' + myicon = 'ion-add'; } - let mycolor = data ? data.color : 'primary' + let mycolor = data ? data.color : 'primary'; if (!mycolor) { - mycolor = 'primary' + mycolor = 'primary'; } q.notify({ group: group ?? '', @@ -2918,114 +2930,114 @@ export const tools = { classes: 'my-notif-class', color: mycolor, timeout: time || 4000, - }) + }); }, isRegistered() { - return localStorage.getItem(toolsext.localStorage.userId) !== '' - } - , - + return localStorage.getItem(toolsext.localStorage.userId) !== ''; + }, checkIfUserExist(mythis?: any) { - const userStore = useUserStore() + const userStore = useUserStore(); if (userStore.isUserInvalid) { - this.showNotif(mythis.$q, mythis.$t('todo.usernotdefined')) - return false + this.showNotif(mythis.$q, mythis.$t('todo.usernotdefined')); + return false; } if (!this.isRegistered()) { // Not logged - this.showNotif(mythis.$q, mythis.$t('user.notregistered')) - return false + this.showNotif(mythis.$q, mythis.$t('user.notregistered')); + return false; } - return true + return true; }, getLangUsed() { - return static_data.lang_available.map((m: ILang) => m.value) + return static_data.lang_available.map((m: ILang) => m.value); }, checkLangPassed($q: any, $router: Router, mylangpass: string) { // console.log('checkLangPassed ', mylang) - const userStore = useUserStore() + const userStore = useUserStore(); - let mylang: string = mylangpass + let mylang: string = mylangpass; // const mybrowserLang = Quasar.lang.isoName if (mylang !== '') { - if ((mylang.toLowerCase() === 'enus') || (mylang.toLowerCase() === 'en-us') || (mylang.toLowerCase() === 'uk') - || (mylang.toLowerCase() === 'uk-uk') || (mylang.toLowerCase() === 'en-uk') || (mylang.toLowerCase() === 'en-gb') - || (mylang.toLowerCase() === 'gb-gb')) { - mylang = 'enUs' + if ( + mylang.toLowerCase() === 'enus' || + mylang.toLowerCase() === 'en-us' || + mylang.toLowerCase() === 'uk' || + mylang.toLowerCase() === 'uk-uk' || + mylang.toLowerCase() === 'en-uk' || + mylang.toLowerCase() === 'en-gb' || + mylang.toLowerCase() === 'gb-gb' + ) { + mylang = 'enUs'; } - if ((mylang.toLowerCase() === 'es') || (mylang.toLowerCase() === 'es-es') || (mylang.toLowerCase() === 'eses')) { - mylang = 'es' + if (mylang.toLowerCase() === 'es' || mylang.toLowerCase() === 'es-es' || mylang.toLowerCase() === 'eses') { + mylang = 'es'; } - if ((mylang.toLowerCase() === 'pt') || (mylang.toLowerCase() === 'pt-pt') || (mylang.toLowerCase() === 'ptpt')) { - mylang = 'pt' + if (mylang.toLowerCase() === 'pt' || mylang.toLowerCase() === 'pt-pt' || mylang.toLowerCase() === 'ptpt') { + mylang = 'pt'; } - if ((mylang.toLowerCase() === 'fr') || (mylang.toLowerCase() === 'fr-fr') || (mylang.toLowerCase() === 'frfr')) { - mylang = 'fr' + if (mylang.toLowerCase() === 'fr' || mylang.toLowerCase() === 'fr-fr' || mylang.toLowerCase() === 'frfr') { + mylang = 'fr'; } - if ((mylang.toLowerCase() === 'it') || (mylang.toLowerCase() === 'it-it') || (mylang.toLowerCase() === 'itit')) { - mylang = 'it' + if (mylang.toLowerCase() === 'it' || mylang.toLowerCase() === 'it-it' || mylang.toLowerCase() === 'itit') { + mylang = 'it'; } - if ((mylang.toLowerCase() === 'si') || (mylang.toLowerCase() === 'si-si') || (mylang.toLowerCase() === 'sisi')) { - mylang = 'si' + if (mylang.toLowerCase() === 'si' || mylang.toLowerCase() === 'si-si' || mylang.toLowerCase() === 'sisi') { + mylang = 'si'; } - // console.log('static_data.arrLangUsed', static_data.arrLangUsed, 'mylang', mylang) - if (!(static_data.arrLangUsed.includes(mylang))) { + if (!static_data.arrLangUsed.includes(mylang)) { // console.log('non incluso ', mylang) // mylang = static_data.arrLangUsed[0] - mylang = 'it' + mylang = 'it'; // Metti come default - userStore.setlang($q, $router, mylang) + userStore.setlang($q, $router, mylang); } - } if (!mylang) { - mylang = import.meta.env.VITE_LANG_DEFAULT! - console.log('LANG DEFAULT: ', mylang) + mylang = import.meta.env.VITE_LANG_DEFAULT!; + console.log('LANG DEFAULT: ', mylang); } if (toolsext.getLocale(true) === '') { - userStore.setlang($q, $router, mylang) + userStore.setlang($q, $router, mylang); } // console.log('mylang calc : ', mylang) - return mylang + return mylang; }, getlang() { - return toolsext.getLocale() + return toolsext.getLocale(); }, getimglogo() { - return `/images/${import.meta.env.VITE_LOGO_REG}` + return `/images/${import.meta.env.VITE_LOGO_REG}`; }, consolelogpao(strlog: string, strlog2: any = '', strlog3: any = '') { // @ts-ignore - globalroutines('log', `${strlog} ${strlog2} ${strlog3}`, null) + globalroutines('log', `${strlog} ${strlog2} ${strlog3}`, null); }, aspettansec(numsec: number) { return new Promise((resolve, reject) => { setTimeout(() => { - resolve('anything') - }, numsec) - }) - } - , - + resolve('anything'); + }, numsec); + }); + }, dragula_option($service: any, dragname: any) { //++Todo: Dragula /*$service.options(dragname, @@ -3043,53 +3055,51 @@ export const tools = { }) */ - } - , - + }, // _.cloneDeep( Per clonare un oggetto mapSort(linkedList: any) { - console.log('mapSort') - let sortedList = [] - const map = new Map() - let currentId = null + console.log('mapSort'); + let sortedList = []; + const map = new Map(); + let currentId = null; // console.log('linkedList', linkedList) // index the linked list by previous_item_id for (let i = 0; i < linkedList.length; i++) { - const item = linkedList[i] + const item = linkedList[i]; // this.logelemprj(i, item) if (item.id_prev === ApiTables.LIST_START) { // first item - currentId = String(item._id) + currentId = String(item._id); // console.log('currentId', currentId); - sortedList.push(item) + sortedList.push(item); } else { - map.set(item.id_prev, i) + map.set(item.id_prev, i); } } // let i2 = 0 while (sortedList.length < linkedList.length) { // get the item with a previous item ID referencing the current item - const nextItem: any = linkedList[map.get(currentId)] + const nextItem: any = linkedList[map.get(currentId)]; if (nextItem === undefined) { - break + break; } - sortedList.push(nextItem) + sortedList.push(nextItem); // this.logelemprj('FATTO:' + i, nextItem) - currentId = String(nextItem._id) + currentId = String(nextItem._id); // i2++ } if (sortedList.length < linkedList.length) { - console.log('!!!!! NON CI SONO TUTTI !!!!!', sortedList.length, linkedList.length) + console.log('!!!!! NON CI SONO TUTTI !!!!!', sortedList.length, linkedList.length); // Forget something not in a List ! for (const itemlinked of linkedList) { - const elemtrov = sortedList.find((item) => item._id === itemlinked._id) + const elemtrov = sortedList.find((item) => item._id === itemlinked._id); if (elemtrov === undefined) { - sortedList.push(itemlinked) + sortedList.push(itemlinked); } } } @@ -3098,188 +3108,183 @@ export const tools = { if (sortedList) { if (sortedList.length > 0) { if (sortedList[0].priority !== undefined) { - const sortednew = [] - let myarr = [] + const sortednew = []; + let myarr = []; for (const priorelem of lists.selectPriority.it) { - const myprior = priorelem.value - myarr = sortedList.filter((item) => item.priority === myprior) - if (myarr !== undefined) - sortednew.push(...myarr) + const myprior = priorelem.value; + myarr = sortedList.filter((item) => item.priority === myprior); + if (myarr !== undefined) sortednew.push(...myarr); } - sortedList = sortednew + sortedList = sortednew; } } } // console.log('DOPO sortedList', sortedList) - return sortedList + return sortedList; }, getProgressClassColor(progress: number) { if (progress > 66) { - return 'highperc' + return 'highperc'; } else if (progress > 33) { - return 'medperc' + return 'medperc'; } else { - return 'lowperc' + return 'lowperc'; } - } - , - + }, getProgressColor(progress: number) { if (progress > 66) { - return 'green' + return 'green'; } else if (progress > 33) { - return 'blue' + return 'blue'; } else { - return 'red' + return 'red'; } }, hasManyDays(mydatestart: Date | number | string | undefined, mydateend: Date | number | string | undefined) { - if (mydateend) - return this.getstrDate(mydatestart) !== this.getstrDate(mydateend) - else - return false + if (mydateend) return this.getstrDate(mydatestart) !== this.getstrDate(mydateend); + else return false; }, isManager() { - const userStore = useUserStore() - return userStore.isManager || userStore.isAdmin + const userStore = useUserStore(); + return userStore.isManager || userStore.isAdmin; }, isSeller() { - const userStore = useUserStore() - return userStore.isManager || userStore.isAdmin + const userStore = useUserStore(); + return userStore.isManager || userStore.isAdmin; }, isSocioResidente() { - const userStore = useUserStore() - return userStore.my.profile ? userStore.my.profile.socioresidente : false + const userStore = useUserStore(); + return userStore.my.profile ? userStore.my.profile.socioresidente : false; }, isConsiglio() { - const userStore = useUserStore() - return userStore.my.profile ? userStore.my.profile.consiglio : false + const userStore = useUserStore(); + return userStore.my.profile ? userStore.my.profile.consiglio : false; }, isSocio() { - const userStore = useUserStore() - return userStore.my.profile ? userStore.my.profile.socio : false + const userStore = useUserStore(); + return userStore.my.profile ? userStore.my.profile.socio : false; }, isResp() { - const userStore = useUserStore() - return userStore.my.profile.resplist + const userStore = useUserStore(); + return userStore.my.profile.resplist; }, isWorkers() { - const userStore = useUserStore() - return userStore.my.profile.workerslist + const userStore = useUserStore(); + return userStore.my.profile.workerslist; }, isDepartment() { - const userStore = useUserStore() - return userStore.isDepartment + const userStore = useUserStore(); + return userStore.isDepartment; }, isAdmin() { - const userStore = useUserStore() - return userStore.isAdmin + const userStore = useUserStore(); + return userStore.isAdmin; }, isFacilitatore() { - const userStore = useUserStore() - return userStore.isFacilitatore + const userStore = useUserStore(); + return userStore.isFacilitatore; }, isZoomeri() { - const userStore = useUserStore() - return userStore.isZoomeri + const userStore = useUserStore(); + return userStore.isZoomeri; }, isEditor() { - const userStore = useUserStore() - return userStore.isEditor || userStore.isAdmin + const userStore = useUserStore(); + return userStore.isEditor || userStore.isAdmin; }, isGrafico() { - const userStore = useUserStore() - return userStore.isGrafico || userStore.isAdmin + const userStore = useUserStore(); + return userStore.isGrafico || userStore.isAdmin; }, isCommerciale() { - const userStore = useUserStore() - return userStore.isCommerciale || userStore.isAdmin + const userStore = useUserStore(); + return userStore.isCommerciale || userStore.isAdmin; }, isTeacher() { - const userStore = useUserStore() - return userStore.isTeacher + const userStore = useUserStore(); + return userStore.isTeacher; }, getstrDate(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YYYY') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YYYY'); + return ''; }, getstrDateShort(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YY') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YY'); + return ''; }, getstrMonth(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'MMMM YYYY') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'MMMM YYYY'); + return ''; }, getstrMonth3Letters(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'MMM') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'MMM'); + return ''; }, getstrDay(mytimestamp: Date | number | string | undefined) { - if (mytimestamp) return date.formatDate(mytimestamp, 'D') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'D'); + return ''; }, getstrDateYY(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YY') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YY'); + return ''; }, getstrDateLong(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - const dayofweek = this.getDayOfWeek(mytimestamp) - if (mytimestamp) return `${dayofweek} ${date.formatDate(mytimestamp, 'DD/MM/YYYY')}` - return '' + const dayofweek = this.getDayOfWeek(mytimestamp); + if (mytimestamp) return `${dayofweek} ${date.formatDate(mytimestamp, 'DD/MM/YYYY')}`; + return ''; }, getstrshortDate(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM'); + return ''; }, getstrshortDateTime(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM HH:mm') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM HH:mm'); + return ''; }, getstrshortDayDateTime(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD HH:mm') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD HH:mm'); + return ''; }, getstrTime(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'HH:mm') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'HH:mm'); + return ''; }, getstrShortDate(mydate: Date | number | string | undefined) { @@ -3290,21 +3295,20 @@ export const tools = { month: 'short', year: 'numeric', // timeZone: 'UTC' - }) + }); try { if (DateFormatter) { // @ts-ignore - const date1 = new Date(mydate) - return DateFormatter.format(date1) + const date1 = new Date(mydate); + return DateFormatter.format(date1); } - return mydate + return mydate; } catch (e) { - return '' + return ''; } } catch (e) { - return '' + return ''; } - }, getstrVeryShortDate(mydate: Date | number | string | undefined) { const DateFormatter = new Intl.DateTimeFormat(toolsext.getLocale() || void 0, { @@ -3312,16 +3316,16 @@ export const tools = { day: 'numeric', month: 'short', // timeZone: 'UTC' - }) + }); try { if (DateFormatter) { // @ts-ignore - const date1 = new Date(mydate) - return DateFormatter.format(date1) + const date1 = new Date(mydate); + return DateFormatter.format(date1); } - return mydate + return mydate; } catch (e) { - return '' + return ''; } }, @@ -3330,49 +3334,47 @@ export const tools = { weekday: 'long', day: 'numeric', // timeZone: 'UTC' - }) + }); try { if (DateFormatter) { - const date1 = new Date(mydate) - return DateFormatter.format(date1) + const date1 = new Date(mydate); + return DateFormatter.format(date1); } - return mydate + return mydate; } catch (e) { - return '' + return ''; } }, getstrDateTimeEvent($t: any, myevent: IEvents, withhtml: boolean, acapo: boolean = false) { - let mystr = '' + let mystr = ''; // is same day? if (this.getstrDate(myevent.dateTimeStart) === this.getstrDate(myevent.dateTimeEnd)) { if (withhtml) { mystr += `${this.getstrDateLong(myevent.dateTimeStart)} ${$t('cal.starttime')} ${this.getstrTime(myevent.dateTimeStart)} - ${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)}` + ${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)}`; } else { mystr = `${this.getstrDateLong(myevent.dateTimeStart)} - ${$t('cal.starttime')} ${this.getstrTime(myevent.dateTimeStart)}` + ${$t('cal.starttime')} ${this.getstrTime(myevent.dateTimeStart)}`; - if (acapo) - mystr += `` + if (acapo) mystr += ``; - mystr += `${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)}` + mystr += `${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)}`; } } else { if (withhtml) { mystr = `${this.getstrDateLong(myevent.dateTimeStart)} - ${$t('cal.dalle')} ${this.getstrTime(myevent.dateTimeStart)} ` + ${$t('cal.dalle')} ${this.getstrTime(myevent.dateTimeStart)} `; - if (acapo) - mystr += `
` + if (acapo) mystr += `
`; mystr += `${$t('cal.enddate')} ${this.getstrDateLong(myevent.dateTimeEnd)} - ${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)} ` + ${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)} `; } else { mystr = `${this.getstrDateLong(myevent.dateTimeStart)} ${$t('cal.dalle')} ${this.getstrTime(myevent.dateTimeStart)} - ${this.getstrDateLong(myevent.dateTimeEnd)}: ${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)}` + ${this.getstrDateLong(myevent.dateTimeEnd)}: ${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)}`; } } @@ -3381,222 +3383,220 @@ export const tools = { ${$t('cal.hours')}: ${myevent.infoextra}
- ` + `; } - return mystr + return mystr; }, getstrDateTimeEventSimple(myevent: IEvents) { - let mystr = '' + let mystr = ''; // is same day? if (this.getstrShortDate(myevent.dateTimeStart) === this.getstrShortDate(myevent.dateTimeEnd)) { mystr = `${this.getstrShortDate(myevent.dateTimeStart)} - - ${this.getstrTime(myevent.dateTimeStart)}` + - ${this.getstrTime(myevent.dateTimeStart)}`; } else { - mystr = `${this.getstrVeryVeryShortDate(myevent.dateTimeStart)} - ${this.getstrShortDate(myevent.dateTimeEnd)}` - + mystr = `${this.getstrVeryVeryShortDate(myevent.dateTimeStart)} - ${this.getstrShortDate(myevent.dateTimeEnd)}`; } - return mystr + return mystr; }, - getstrDateTimeEventShort(myevent: IEvents) { - let mystr = '' + let mystr = ''; // is same day? if (this.getstrShortDate(myevent.dateTimeStart) === this.getstrShortDate(myevent.dateTimeEnd)) { mystr = `${this.getstrVeryShortDate(myevent.dateTimeStart)} - h. ${this.getstrTime(myevent.dateTimeStart)}` + h. ${this.getstrTime(myevent.dateTimeStart)}`; } else { - mystr = `${this.getstrVeryShortDate(myevent.dateTimeStart)} - ${this.getstrVeryShortDate(myevent.dateTimeEnd)}` + mystr = `${this.getstrVeryShortDate(myevent.dateTimeStart)} - ${this.getstrVeryShortDate(myevent.dateTimeEnd)}`; } - return mystr + return mystr; }, getstrDateTime(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YYYY HH:mm') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YYYY HH:mm'); + return ''; }, getstrDateTimeAll(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YYYY HH:mm:ss') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM/YYYY HH:mm:ss'); + return ''; }, getstrTimeAll(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'HH:mm:ss') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'HH:mm:ss'); + return ''; }, getstrDateTimeShort(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM HH:mm') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MM HH:mm'); + return ''; }, getstrDateTimeLong(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MMM/YYYY HH:mm') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD/MMM/YYYY HH:mm'); + return ''; }, getstrDateMonthTimeShort(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMM HH:mm') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMM HH:mm'); + return ''; }, getstrDateMonthTimeLong(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMM YY - HH:mm') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMM YY - HH:mm'); + return ''; }, getstrDateMonthLong(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMMM YYYY') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMMM YYYY'); + return ''; }, getstrDateMonthWeekTimeShort(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return `${this.getDayOfWeek(mytimestamp)} ${date.formatDate(mytimestamp, 'DD MMM - HH:mm')}` - return '' + if (mytimestamp) return `${this.getDayOfWeek(mytimestamp)} ${date.formatDate(mytimestamp, 'DD MMM - HH:mm')}`; + return ''; }, getstrDateEmailTime(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) //T_TOLTO - if (mytimestamp) return `${date.formatDate(mytimestamp, 'DD/MM/YYYY')} ${t('cal.starttime')} ${date.formatDate(mytimestamp, 'HH:mm')}` - return '' + if (mytimestamp) + return `${date.formatDate(mytimestamp, 'DD/MM/YYYY')} ${t('cal.starttime')} ${date.formatDate(mytimestamp, 'HH:mm')}`; + return ''; }, getstrMMMDate(mytimestamp: Date | number | string | undefined) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMM YYYY') - return '' + if (mytimestamp) return date.formatDate(mytimestamp, 'DD MMM YYYY'); + return ''; }, getstrYYMMDDDate(mytimestamp: Date | number | string | undefined) { - return date.formatDate(mytimestamp, 'YYYY-MM-DD') + return date.formatDate(mytimestamp, 'YYYY-MM-DD'); }, getstrYYMMDDDateTime(mytimestamp: Date | number | string | undefined) { - return date.formatDate(mytimestamp, 'YYYY-MM-DD HH:mm') + return date.formatDate(mytimestamp, 'YYYY-MM-DD HH:mm'); }, getstrYYMMDDHHMMDateTime(mytimestamp: Date | number | string | undefined) { - return date.formatDate(mytimestamp, 'YYYY-MM-DD_HH:mm') + return date.formatDate(mytimestamp, 'YYYY-MM-DD_HH:mm'); }, getstrYYMMDDDateTimeAll(mytimestamp: Date | number | string | undefined) { - return date.formatDate(mytimestamp, 'YYYY-MM-DD HH:mm:ss') + return date.formatDate(mytimestamp, 'YYYY-MM-DD HH:mm:ss'); }, getstrdateToDate(strdate: string) { - const mydate = new Date(strdate) - return mydate + const mydate = new Date(strdate); + return mydate; }, gettimestampstrDate(mydatestr: Date | number | string | undefined) { if (mydatestr) { - const mydate = new Date(mydatestr) - if (mydate) return mydate.getTime() + const mydate = new Date(mydatestr); + if (mydate) return mydate.getTime(); } - return 0 + return 0; }, // mystrdate "26.04.2013" convertstrtoDate(mystrdate: string) { if (mystrdate.length < 10) { - return null + return null; } - console.log('mystrdate', mystrdate) + console.log('mystrdate', mystrdate); - const pattern = /(\d{2})\/(\d{2})\/(\d{4})/ - const strdate = mystrdate.replace(pattern, '$3-$2-$1') - let mydate = null + const pattern = /(\d{2})\/(\d{2})\/(\d{4})/; + const strdate = mystrdate.replace(pattern, '$3-$2-$1'); + let mydate = null; if (date.isValid(strdate)) { - mydate = new Date(strdate) + mydate = new Date(strdate); } else { - return null + return null; } // console.log('mystrdate', mystrdate, strdate, mydate) - return mydate + return mydate; }, capitalize(value: any) { if (!value) { - return '' + return ''; } - const myval = value.toString() - return myval.charAt(0).toUpperCase() + myval.slice(1) + const myval = value.toString(); + return myval.charAt(0).toUpperCase() + myval.slice(1); }, firstchars(value: any, numchars = 200, capitalizeFirst = false) { if (!value) { - return '' + return ''; } try { - let mycar = value.substring(0, numchars) - if (value.length > numchars) mycar += '...' + let mycar = value.substring(0, numchars); + if (value.length > numchars) mycar += '...'; if (capitalizeFirst) { mycar = mycar.charAt(0).toUpperCase() + mycar.slice(1); } - return mycar + return mycar; } catch (e) { - return value + return value; } }, firstchars_onedot(value: any, numchars = 200) { if (!value) { - return '' + return ''; } try { - let mycar = value.substring(0, numchars) - if (value.length > numchars) - mycar += '.' - return mycar + let mycar = value.substring(0, numchars); + if (value.length > numchars) mycar += '.'; + return mycar; } catch (e) { - return value + return value; } }, getDateFromISOString(mydate): Date { - const mydate2 = new Date(mydate) - return mydate2 + const mydate2 = new Date(mydate); + return mydate2; }, getDateNow() { - const mydate = new Date() - return mydate + const mydate = new Date(); + return mydate; }, getDateYYYYMMDD_Today() { // Ottieni la data attuale nel formato YYYY-MM-DD const today = new Date(); const formattedDate = today.toISOString().split('T')[0]; // Format YYYY-MM-DD - return formattedDate + return formattedDate; }, isDateArrived(mydate: Date | number | string | undefined) { - const datenow = this.getDateNow() - const diff = date.getDateDiff(datenow, mydate) + const datenow = this.getDateNow(); + const diff = date.getDateDiff(datenow, mydate); // console.log('diff = ' + diff) if (diff >= -1) { - return true + return true; } - return false + return false; }, getDayOfWeek(mydate: Date | number | string | undefined) { // @ts-ignore - const dayOfWeek = new Date(mydate).getDay() + const dayOfWeek = new Date(mydate).getDay(); - const mylang = toolsext.getLocale() + const mylang = toolsext.getLocale(); const myday: any = { it: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'], @@ -3606,59 +3606,59 @@ export const tools = { pt: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'], de: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'], si: ['Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'četrtek', 'Petek', 'Sobota'], - } + }; - return Number.isNaN(dayOfWeek) ? '' : myday[mylang][dayOfWeek].substring(0, 3) + return Number.isNaN(dayOfWeek) ? '' : myday[mylang][dayOfWeek].substring(0, 3); }, isSunday(mydate: Date | number | string | undefined) { // @ts-ignore - const dayOfWeek = new Date(mydate).getDay() - return dayOfWeek === 0 + const dayOfWeek = new Date(mydate).getDay(); + return dayOfWeek === 0; }, getDateNowEvent() { - return this.addMinutes(this.getDateNow(), -60 * 4) + return this.addMinutes(this.getDateNow(), -60 * 4); }, getDateNull() { - return new Date(0) + return new Date(0); }, getTimeNow() { - return new Date().getTime() + return new Date().getTime(); }, getTimestampsNow() { - return new Date().valueOf() + return new Date().valueOf(); }, gettimestampByDate(mydate: Date) { - return mydate.toString() + return mydate.toString(); }, isMainProject(idproj: string) { - return idproj === import.meta.env.VITE_PROJECT_ID_MAIN + return idproj === import.meta.env.VITE_PROJECT_ID_MAIN; }, getUrlByTipoProj(tipoproj: string, name?: string) { - if (name) return `/${name}/` - return `/${tipoproj}/` + if (name) return `/${name}/`; + return `/${tipoproj}/`; }, getprivacyreadbytipoproj(tipoproj: string) { - if (tipoproj === RouteNames.myprojects) return Privacy.inherited - return Privacy.all + if (tipoproj === RouteNames.myprojects) return Privacy.inherited; + return Privacy.all; }, getprivacywritebytipoproj(tipoproj: string) { - return Privacy.inherited + return Privacy.inherited; }, addRoute(myarr: any, values: any) { - myarr.push(values) + myarr.push(values); }, displayConfirmNotification() { - let options: any = null + let options: any = null; if ('serviceWorker' in navigator) { options = { body: 'You successfully subscribed to our Notification service!', @@ -3669,41 +3669,35 @@ export const tools = { vibrate: [100, 50, 200], badge: '/myicons/app-icon-96x96.png', tag: 'confirm-notification', - renotify: true, // if it's already sent, will Vibrate anyway + renotify: true, // if it's already sent, will Vibrate anyway actions: [ { action: 'confirm', title: 'Okay', icon: '/myicons/app-icon-96x96.png' }, { action: 'cancel', title: 'Cancel', icon: '/myicons/app-icon-96x96.png' }, ], - } + }; if ('serviceWorker' in navigator) { - navigator.serviceWorker.ready - .then((swreg) => { - swreg.showNotification('Successfully subscribed!', options) - }) + navigator.serviceWorker.ready.then((swreg) => { + swreg.showNotification('Successfully subscribed!', options); + }); } } - } - , - + }, dataURItoBlob(dataURI: any) { - const byteString = atob(dataURI.split(',')[1]) - const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0] - const ab = new ArrayBuffer(byteString.length) - const ia = new Uint8Array(ab) + const byteString = atob(dataURI.split(',')[1]); + const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; + const ab = new ArrayBuffer(byteString.length); + const ia = new Uint8Array(ab); for (let i = 0; i < byteString.length; i++) { - ia[i] = byteString.charCodeAt(i) + ia[i] = byteString.charCodeAt(i); } - const blob = new Blob([ab], { type: mimeString }) - return blob - } - , - + const blob = new Blob([ab], { type: mimeString }); + return blob; + }, showNotificationExample() { - let options: any = null + let options: any = null; //T_TOLTO - if ('serviceWorker' in navigator) { options = { body: t('notification.subscribed'), @@ -3714,117 +3708,108 @@ export const tools = { vibrate: [100, 50, 200], badge: '/images/android-chrome-192x192.png', tag: 'confirm-notification', - renotify: true, // if it's already sent, will Vibrate anyway + renotify: true, // if it's already sent, will Vibrate anyway actions: [ { action: 'confirm', title: t('dialog.ok'), icon: '/images/android-chrome-192x192.png' }, // { action: 'cancel', title: 'Cancel', icon: '/statics/images/android-chrome-192x192.png', } ], - } + }; - navigator.serviceWorker.ready - .then((swreg) => { - swreg.showNotification('aaa', options) - }) + navigator.serviceWorker.ready.then((swreg) => { + swreg.showNotification('aaa', options); + }); } }, getemailto(text: string) { - return 'mailto:' + text + return 'mailto:' + text; }, heightgallery(coeff: any) { // console.log('heightgallery') - return this.heightGallVal(coeff).toString() + 'px' + return this.heightGallVal(coeff).toString() + 'px'; }, heightGallVal(coeff = 1.33) { - let maxh2 = 0 + let maxh2 = 0; - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); - const myw = Screen.width + const myw = Screen.width; if (!this.isMobile()) - // if (globalStore.leftDrawerOpen) - // myw -= 300 if (!this.isMobile()) + // if (globalStore.leftDrawerOpen) + // myw -= 300 // if (globalStore.rightDrawerOpen) // myw -= 300 - maxh2 = (myw / coeff) + 20 - if (maxh2 > 500) - maxh2 = 500 + maxh2 = myw / coeff + 20; + if (maxh2 > 500) maxh2 = 500; - return maxh2 + return maxh2; }, myheight_imgtitle(myheight?: number, myheightmobile?: number) { - let maxheight = 0 + let maxheight = 0; if (myheight) { - maxheight = myheight + maxheight = myheight; if (myheight > 0) { if (myheight > 1000) { - maxheight = 1000 + maxheight = 1000; } else { - maxheight = myheight + maxheight = myheight; } } } else { - maxheight = 500 + maxheight = 500; } - const maxh2 = this.heightGallVal() + const maxh2 = this.heightGallVal(); // console.log('maxh2', maxh2) // console.log('maxheight', maxheight) - let ris = 0 + let ris = 0; - if (maxh2 < maxheight) - ris = maxh2 - else - ris = maxheight + if (maxh2 < maxheight) ris = maxh2; + else ris = maxheight; if (myheightmobile) { - if (this.isMobile() && maxh2 > myheightmobile) - ris = myheightmobile + if (this.isMobile() && maxh2 > myheightmobile) ris = myheightmobile; } // console.log('ris', ris) - return ris - } - , - + return ris; + }, myheight_dialog() { if (Screen.width < 410) { - return '337' + return '337'; } else if (Screen.width < 600) { - return '450' + return '450'; } else if (Screen.width < 800) { - return '550' + return '550'; } else if (Screen.width < 900) { - return '700' + return '700'; } else if (Screen.width < 1000) { - return '800' + return '800'; } else if (Screen.width < 1100) { - return '900' + return '900'; } else { - return Screen.width - 200 + return Screen.width - 200; } }, styles_imgtitle(sized?: string) { if (sized) { - return sized + return sized; } else { if (Screen.width < 410) { - return 'max-height: 250px' + return 'max-height: 250px'; } else { - return 'max-height: 350px' + return 'max-height: 350px'; } } - } - , - + }, /* dateonline.getTime() + const dateonline = this.addDays(this.getDateNow(), -1); + return user.lasttimeonline && new Date(user.lasttimeonline).getTime() > dateonline.getTime(); } catch (e) { - return false + return false; } }, isVerifiedByUser(user: IUserFields) { try { - return user.verified_by_aportador + return user.verified_by_aportador; } catch (e) { - return false + return false; } }, notisVerifiedByUser(user: IUserFields) { try { - return user && this.existProp(user, 'verified_by_aportador') && user.verified_by_aportador === false + return user && this.existProp(user, 'verified_by_aportador') && user.verified_by_aportador === false; } catch (e) { - return false + return false; } }, addMinutes(mydate: Date, minutes: number) { - return date.addToDate(mydate, { minutes }) + return date.addToDate(mydate, { minutes }); }, gettitlemain(datamain: ITimeLineMain) { - if (datamain.titlemain[toolsext.getLocale()]) - return datamain.titlemain[toolsext.getLocale()] + if (datamain.titlemain[toolsext.getLocale()]) return datamain.titlemain[toolsext.getLocale()]; else { - return datamain.titlemain[static_data.arrLangUsed[0]] + return datamain.titlemain[static_data.arrLangUsed[0]]; } - - } - , + }, getwwithwhocoll(datamain: ICollaborations) { - if (datamain.withwhom_title[toolsext.getLocale()]) - return datamain.withwhom_title[toolsext.getLocale()] + if (datamain.withwhom_title[toolsext.getLocale()]) return datamain.withwhom_title[toolsext.getLocale()]; else { - return datamain.withwhom_title[static_data.arrLangUsed[0]] + return datamain.withwhom_title[static_data.arrLangUsed[0]]; } - - } - , + }, gettextcoll(data: IColl) { - if (data.subtitle[toolsext.getLocale()]) - return data.subtitle[toolsext.getLocale()] + if (data.subtitle[toolsext.getLocale()]) return data.subtitle[toolsext.getLocale()]; else { - return data.subtitle[static_data.arrLangUsed[0]] + return data.subtitle[static_data.arrLangUsed[0]]; } }, gettitlecoll(data: IColl) { - if (data.title[toolsext.getLocale()]) - return data.title[toolsext.getLocale()] + if (data.title[toolsext.getLocale()]) return data.title[toolsext.getLocale()]; else { - return data.title[static_data.arrLangUsed[0]] + return data.title[static_data.arrLangUsed[0]]; } - } - , - gettextdescr(data: { [index: string]: any }, numdescr = 'description', - ) { + }, + gettextdescr(data: { [index: string]: any }, numdescr = 'description') { if (data[numdescr]) { - if (data[numdescr][toolsext.getLocale()]) - return data[numdescr][toolsext.getLocale()] + if (data[numdescr][toolsext.getLocale()]) return data[numdescr][toolsext.getLocale()]; else { - return data[numdescr][static_data.arrLangUsed[0]] + return data[numdescr][static_data.arrLangUsed[0]]; } } else { - return '' + return ''; } - } - , - + }, getlink(data: any) { - if (data.link_text[toolsext.getLocale()]) - return data.link_text[toolsext.getLocale()] + if (data.link_text[toolsext.getLocale()]) return data.link_text[toolsext.getLocale()]; else { - return data.link_text[static_data.arrLangUsed[0]] + return data.link_text[static_data.arrLangUsed[0]]; } - }, getlinkurl(data: any) { if (data.link_url_lang) { if (data.link_url_lang[toolsext.getLocale()]) { - return data.link_url_lang[toolsext.getLocale()] + return data.link_url_lang[toolsext.getLocale()]; } else { - return data.link_url + return data.link_url; } } else { - return data.link_url + return data.link_url; } - }, appid() { - return this.getEnv('VITE_APP_ID') + return this.getEnv('VITE_APP_ID'); }, getLabelByItem(item: any) { - if (item.name) - return translate(item.name) - else - return item.text - + if (item.name) return translate(item.name); + else return item.text; }, getimgev(ev: IEvents) { if (ev) { - if (ev.img_small) - return '' + ev.img_small - else if (ev.img) - return '' + ev.img - else - return '' + if (ev.img_small) return '' + ev.img_small; + else if (ev.img) return '' + ev.img; + else return ''; } - return '' + return ''; }, - convertHTMLtoText(myhtml: string) { - let msg = myhtml - msg = msg.replace('"', '"') - msg = msg.replace('>', '>') - msg = msg.replace('<', '<') - msg = msg.replace('&', '&') - msg = msg.replace('
', '\n') + let msg = myhtml; + msg = msg.replace('"', '"'); + msg = msg.replace('>', '>'); + msg = msg.replace('<', '<'); + msg = msg.replace('&', '&'); + msg = msg.replace('
', '\n'); - return msg - } - , + return msg; + }, gettextevent(myevent: any) { // return '"' + myevent.title + '" (' + func_tools.getDateStr(myevent.date) + ') - ' + myevent.time - return '"' + (myevent.title ? myevent.title : (myevent.descr ? myevent.descr : '')) + '" (' + this.getstrDateEmailTime(myevent.dateTimeStart) + ')' + return ( + '"' + + (myevent.title ? myevent.title : myevent.descr ? myevent.descr : '') + + '" (' + + this.getstrDateEmailTime(myevent.dateTimeStart) + + ')' + ); }, getlangforQuasar(mylang: string) { - if (mylang === 'enUs') - return 'en-us' - else - return mylang + if (mylang === 'enUs') return 'en-us'; + else return mylang; }, setLangAtt($q: any, $router: Router, mylang: string) { - console.log('setLangAtt =', mylang); const globalStore = useGlobalStore(); @@ -4088,271 +4038,298 @@ export const tools = { }, getIdApp() { - return this.getEnv('VITE_APP_ID') + return this.getEnv('VITE_APP_ID'); }, getappname(short?: boolean) { //T_TOLTO - if (short) { - return t('ws.siteshortname') + return t('ws.siteshortname'); } - return t('ws.sitename') + return t('ws.sitename'); }, getproc() { - return 'Testo: ' + import.meta.env.VITE_LOGO_REG + return 'Testo: ' + import.meta.env.VITE_LOGO_REG; }, loginOk($router: Router, route: any, mythisq: any, ispageLogin: boolean) { - console.log('loginOk') - const userStore = useUserStore() + console.log('loginOk'); + const userStore = useUserStore(); if (toolsext.getLocale() !== '') { // mythisq.$i18n.locale = toolsext.getLocale() } else { - userStore.setlang(mythisq, $router, mythisq.lang.getLocale()) - } // Set Lang + userStore.setlang(mythisq, $router, mythisq.lang.getLocale()); + } // Set Lang if (import.meta.env.VITE_DEBUG) { - console.log('LANG ORA=', toolsext.getLocale()) + console.log('LANG ORA=', toolsext.getLocale()); } - globalroutines('loadapp', '') - - this.SignIncheckErrors(mythisq, $router, route, this.OK, ispageLogin) - } - , + globalroutines('loadapp', ''); + this.SignIncheckErrors(mythisq, $router, route, this.OK, ispageLogin); + }, loginInCorso(mythisq: any) { // console.log('loginInCorso') //T_TOLTO - - - const msg = t('login.incorso') + const msg = t('login.incorso'); // if (import.meta.env.VITE_DEBUG) { // msg += ' ' + import.meta.env.VITE_MONGODB_HOST // } - mythisq.loading.show({ message: msg }) + mythisq.loading.show({ message: msg }); }, getUrlSite() { - const url = window.location.href - const arr = url.split('/') - return arr[0] + '//' + arr[2] + const url = window.location.href; + const arr = url.split('/'); + return arr[0] + '//' + arr[2]; }, SignIncheckErrors(mythisq: any, $router: Router, route: any, riscode: any, ispageLogin?: boolean) { - console.log('SignIncheckErrors: ', riscode) + console.log('SignIncheckErrors: ', riscode); //T_TOLTO - - const globalStore = useGlobalStore() - const userStore = useUserStore() + const globalStore = useGlobalStore(); + const userStore = useUserStore(); try { if (riscode === this.OK) { - this.showNotif(mythisq, t('login.completato'), { color: 'positive', icon: 'check' }) + this.showNotif(mythisq, t('login.completato'), { color: 'positive', icon: 'check' }); // console.log('mythis.$router.name', route.name) if (ispageLogin) { - if (route.name !== '/') - $router.push('/') + if (route.name !== '/') $router.push('/'); } } else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) { - // Wait N seconds to avoid calling many times... return new Promise((resolve, reject) => { setTimeout(() => { - resolve('anything') - }, 3000) + resolve('anything'); + }, 3000); }).then(() => { setTimeout(() => { // console.log('HIDE...') - mythisq.loading.hide() - }, 500) - this.showNotif(mythisq, t('login.errato'), { color: 'negative', icon: 'notifications' }) + mythisq.loading.hide(); + }, 500); + this.showNotif(mythisq, t('login.errato'), { color: 'negative', icon: 'notifications' }); // iswaitingforRes = false if (ispageLogin) { - globalStore.rightDrawerOpen = true + globalStore.rightDrawerOpen = true; // mythis.$router.push('/signin') } - }) - + }); } else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR_SUBACCOUNT) { - // Wait N seconds to avoid calling many times... return new Promise((resolve, reject) => { setTimeout(() => { - resolve('anything') - }, 1000) + resolve('anything'); + }, 1000); }).then(() => { setTimeout(() => { // console.log('HIDE...') - mythisq.loading.hide() - }, 500) - this.showNotif(mythisq, t('login.subaccount'), { color: 'negative', icon: 'notifications' }) + mythisq.loading.hide(); + }, 500); + this.showNotif(mythisq, t('login.subaccount'), { color: 'negative', icon: 'notifications' }); // mythis.iswaitingforRes = false if (ispageLogin) { - globalStore.rightDrawerOpen = true + globalStore.rightDrawerOpen = true; // mythis.$router.push('/signin') } - }) - + }); } else if (riscode === toolsext.ERR_SERVERFETCH) { - this.showNotif(mythisq, t('fetch.errore_server'), { color: 'negative', icon: 'notifications' }) + this.showNotif(mythisq, t('fetch.errore_server'), { color: 'negative', icon: 'notifications' }); } else if (riscode === toolsext.ERR_GENERICO) { - const msg = t('fetch.errore_generico') + userStore.getMsgError(riscode) - this.showNotif(mythisq, msg, { color: 'negative', icon: 'notifications' }) + const msg = t('fetch.errore_generico') + userStore.getMsgError(riscode); + this.showNotif(mythisq, msg, { color: 'negative', icon: 'notifications' }); } else { - this.showNotif(mythisq, 'Errore num ' + riscode, { color: 'negative', icon: 'notifications' }) + this.showNotif(mythisq, 'Errore num ' + riscode, { color: 'negative', icon: 'notifications' }); } if (riscode !== serv_constants.RIS_CODE_LOGIN_ERR) { // mythis.iswaitingforRes = false setTimeout(() => { - mythisq.loading.hide() - }, 200) + mythisq.loading.hide(); + }, 200); } - } finally { // ... } }, checkErrors(mythisq: any, riscode: number, msg: string) { - console.log('checkErrors', riscode) + console.log('checkErrors', riscode); //T_TOLTO - const userStore = useUserStore() + const userStore = useUserStore(); if (riscode === serv_constants.RIS_CODE_REC_ALREADY_EXIST_NAME) { - this.showNegativeNotif(mythisq, t('reg.err.rec_already_exist_name') + ' ' + msg) + this.showNegativeNotif(mythisq, t('reg.err.rec_already_exist_name') + ' ' + msg); } else if (riscode === serv_constants.RIS_CODE_REC_ALREADY_EXIST_CODE) { - this.showNegativeNotif(mythisq, t('reg.err.rec_already_exist_code') + ' ' + msg) + this.showNegativeNotif(mythisq, t('reg.err.rec_already_exist_code') + ' ' + msg); } else if (riscode === serv_constants.RIS_CODE_REC_ALREADY_EXIST_SYMBOL) { - this.showNegativeNotif(mythisq, t('reg.err.rec_already_exist_symbol') + ' ' + msg) + this.showNegativeNotif(mythisq, t('reg.err.rec_already_exist_symbol') + ' ' + msg); } else if (riscode === serv_constants.RIS_CODE_REC_DUPLICATED_DESCR_CITY_USER) { - this.showNegativeNotif(mythisq, t('reg.err.rec_duplicated_descr_city_user') + ' ' + msg) + this.showNegativeNotif(mythisq, t('reg.err.rec_duplicated_descr_city_user') + ' ' + msg); } }, - SignUpcheckErrors(mythisq: any, $router: any, riscode: number, msg: string) { - console.log('SignUpcheckErrors', riscode) - const endload = true + console.log('SignUpcheckErrors', riscode); + const endload = true; - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO - if (riscode === serv_constants.RIS_CODE_EMAIL_ALREADY_EXIST) { - this.showNotif(mythisq, t('reg.err.duplicate_email')) + this.showNotif(mythisq, t('reg.err.duplicate_email')); } else if (riscode === serv_constants.RIS_CODE_USER_ALREADY_EXIST) { - this.showNegativeNotif(mythisq, t('reg.err.user_already_exist')) + this.showNegativeNotif(mythisq, t('reg.err.user_already_exist')); } else if (riscode === serv_constants.RIS_CODE_USER_EXTRALIST_NOTFOUND) { - - this.showNegativeNotif(mythisq, t('reg.err.user_extralist_not_found') + ' ' + msg) + this.showNegativeNotif(mythisq, t('reg.err.user_extralist_not_found') + ' ' + msg); } else if (riscode === serv_constants.RIS_CODE_USER_APORTADOR_NOT_VALID) { - - this.showNegativeNotif(mythisq, t('reg.err.user_aportador_not_valid') + ' ' + msg) - - + this.showNegativeNotif(mythisq, t('reg.err.user_aportador_not_valid') + ' ' + msg); } else if (riscode === serv_constants.RIS_CODE_USERNAME_NOT_VALID) { - this.showNotif(mythisq, t('reg.err.username_not_valid')) + this.showNotif(mythisq, t('reg.err.username_not_valid')); } else if (riscode === serv_constants.RIS_CODE_USERNAME_ALREADY_EXIST) { - this.showNotif(mythisq, t('reg.err.duplicate_username')) + this.showNotif(mythisq, t('reg.err.duplicate_username')); } else if (riscode === toolsext.ERR_SERVERFETCH) { - this.showNotif(mythisq, t('fetch.errore_server')) + this.showNotif(mythisq, t('fetch.errore_server')); } else if (riscode === toolsext.ERR_GENERICO) { - const msg2 = t('fetch.errore_generico') + userStore.getMsgError(riscode) - this.showNotif(mythisq, msg2) + const msg2 = t('fetch.errore_generico') + userStore.getMsgError(riscode); + this.showNotif(mythisq, msg2); } else if (riscode === this.OK) { - console.log('VAI A SIGNIN:') - $router.replace('/signin') + console.log('VAI A SIGNIN:'); + $router.replace('/signin'); /*this.showNotif(mythisq, t('components.authentication.email_verification.link_sent', { botname: t('ws.botname') }), { color: 'green', textColor: 'black', }) */ - this.showNotif(mythisq, t('components.authentication.email_verification.reg_ok', { botname: this.getBotName() }), { - color: 'green', - textColor: 'black', - }) + this.showNotif( + mythisq, + t('components.authentication.email_verification.reg_ok', { botname: this.getBotName() }), + { + color: 'green', + textColor: 'black', + } + ); } else if (riscode === serv_constants.RIS_ISCRIZIONE_OK) { - $router.replace('/') + $router.replace('/'); this.showNotif(mythisq, t('components.authentication.iscrizione_ok', { botname: this.getBotName() }), { color: 'green', textColor: 'black', - }) + }); } else { - this.showNotif(mythisq, 'Errore num ' + riscode) + this.showNotif(mythisq, 'Errore num ' + riscode); } - return endload + return endload; }, isCssColor(color: any) { - return !!color && !!color.match(/^(#|(rgb|hsl)a?\()/) + return !!color && !!color.match(/^(#|(rgb|hsl)a?\()/); }, displayClasses(eventparam: any) { return { // [`bg-${eventparam.bgcolor}`]: !this.isCssColor(eventparam.bgcolor), 'text-white': !this.isCssColor(eventparam.bgcolor), - } + }; }, displayStyles(eventparam: any) { - const s = { color: '' } + const s = { color: '' }; - let mycol = eventparam.bgcolor + let mycol = eventparam.bgcolor; if (!this.isCssColor(eventparam.bgcolor)) { - mycol = this.colourNameToHex(mycol) + mycol = this.colourNameToHex(mycol); } if (this.isCssColor(mycol)) { // s['background-color'] = eventparam.bgcolor - s.color = colors.luminosity(mycol) > 0.5 ? 'black' : 'white' + s.color = colors.luminosity(mycol) > 0.5 ? 'black' : 'white'; } - return s + return s; }, CancelBookingEvent(mythisq: any, eventparam: IEvents, bookeventid: string, notify: boolean) { - console.log('CancelBookingEvent ', eventparam) - this.askConfirm(mythisq, translate('cal.titlebooking'), translate('cal.cancelbooking') + ' ' + this.gettextevent(eventparam) + '?', translate('dialog.yes'), translate('dialog.no'), '', lists.MenuAction.DELETE, 0, { - param1: bookeventid, - param2: notify, - param3: eventparam.title, - }) + console.log('CancelBookingEvent ', eventparam); + this.askConfirm( + mythisq, + translate('cal.titlebooking'), + translate('cal.cancelbooking') + ' ' + this.gettextevent(eventparam) + '?', + translate('dialog.yes'), + translate('dialog.no'), + '', + lists.MenuAction.DELETE, + 0, + { + param1: bookeventid, + param2: notify, + param3: eventparam.title, + } + ); }, CancelEvent(mythisq: any, eventparam: IEvents) { - console.log('CancelEvent ', eventparam) - this.askConfirm(mythisq, translate('cal.event'), translate('cal.cancelevent') + ' ' + this.gettextevent(eventparam) + '?', translate('dialog.yes'), translate('dialog.no'), '', lists.MenuAction.DELETE_EVENT, 0, { - param1: eventparam, - param2: true, - }) + console.log('CancelEvent ', eventparam); + this.askConfirm( + mythisq, + translate('cal.event'), + translate('cal.cancelevent') + ' ' + this.gettextevent(eventparam) + '?', + translate('dialog.yes'), + translate('dialog.no'), + '', + lists.MenuAction.DELETE_EVENT, + 0, + { + param1: eventparam, + param2: true, + } + ); }, AskGiaPartecipatoZoom(mythisq: any, user: any) { - console.log('AskGiaPartecipatoZoom', user.username) - this.askConfirm(mythisq, translate('steps.zoom_gia_partecipato'), translate('steps.zoom_gia_partecipato'), translate('dialog.yes'), translate('dialog.no'), '', lists.MenuAction.ZOOM_GIA_PARTECIPATO, 0, { - param1: user, - param2: user, - param3: 'Confermato', - }) + console.log('AskGiaPartecipatoZoom', user.username); + this.askConfirm( + mythisq, + translate('steps.zoom_gia_partecipato'), + translate('steps.zoom_gia_partecipato'), + translate('dialog.yes'), + translate('dialog.no'), + '', + lists.MenuAction.ZOOM_GIA_PARTECIPATO, + 0, + { + param1: user, + param2: user, + param3: 'Confermato', + } + ); }, ActionRecTable(mythisq: any, action: number, table: string, id: string, item: any, askaction: any) { // console.log('ActionRecTable', id) - return this.askConfirm(mythisq, 'Action', translate(askaction) + '?', translate('dialog.yes'), translate('dialog.no'), table, action, 0, { - param1: id, - param2: item, - }, this) + return this.askConfirm( + mythisq, + 'Action', + translate(askaction) + '?', + translate('dialog.yes'), + translate('dialog.no'), + table, + action, + 0, + { + param1: id, + param2: item, + }, + this + ); }, getheight(mythis: any) { // return height() - return mythis.$q.screen.height + return mythis.$q.screen.height; }, getwidth(mythisq: any, withright = false, withleft = true): number { - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); // return height() - const myw = mythisq.screen.width + const myw = mythisq.screen.width; if (withleft) { //if (globalStore.leftDrawerOpen) // myw -= 300 @@ -4361,115 +4338,109 @@ export const tools = { if (withright) //if (globalStore.rightDrawerOpen) // myw -= 300 - return myw - + return myw; }, getwidthscale(mythis: any, mywidthpass: string, maxwidth: string): number { - let mywidth = parseInt(mywidthpass, 10) + let mywidth = parseInt(mywidthpass, 10); if (this.isMobile()) { // if (mywidth > this.getwidth(mythis) - 20) - mywidth = this.getwidth(mythis, false, false) - 32 + mywidth = this.getwidth(mythis, false, false) - 32; // console.log('mywidth', mywidth) - return mywidth + return mywidth; } else { // console.log('this.getwidth(mythis) = ', this.getwidth(mythis)) - let myw: number = mywidth + ((this.getwidth(mythis, true) - mywidth) * 0.6) + let myw: number = mywidth + (this.getwidth(mythis, true) - mywidth) * 0.6; // console.log('myw1 = ', myw) - if (myw > parseInt(maxwidth, 10)) - myw = parseInt(maxwidth, 10) - if (myw > this.getwidth(mythis) - 24) - myw = this.getwidth(mythis) - 24 + if (myw > parseInt(maxwidth, 10)) myw = parseInt(maxwidth, 10); + if (myw > this.getwidth(mythis) - 24) myw = this.getwidth(mythis) - 24; // console.log('myw = ', myw) - return myw + return myw; } }, getheightbywidth(mythis: any, mywidth: string, myheight: string, maxwidth: string) { // console.log('getheightbywidth') - const myw = this.getwidthscale(mythis, mywidth, maxwidth) - return myw * (parseInt(myheight, 10) / parseInt(mywidth)) + const myw = this.getwidthscale(mythis, mywidth, maxwidth); + return myw * (parseInt(myheight, 10) / parseInt(mywidth)); }, isIsoDate(str: string) { - if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(str)) return false - const d = new Date(str) - return d.toISOString() === str + if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(str)) return false; + const d = new Date(str); + return d.toISOString() === str; }, getLastDateReadReset() { - return new Date(1999, 1, 1, 0, 0, 0) + return new Date(1999, 1, 1, 0, 0, 0); }, isBitActive(bit: any, whattofind: any) { if (whattofind > 0) { - return ((bit & whattofind) === whattofind) + return (bit & whattofind) === whattofind; } - return false + return false; }, - SetBit(myval: any, bit: any) { // Utilizza l'operatore OR per abilitare il bit specificato - return myval | bit + return myval | bit; }, UnSetBit(myval: any, bit: any) { // Utilizza l'operatore AND con il complemento per disabilitare il bit specificato - return myval & ~bit + return myval & ~bit; }, getUnique(arr: any, comp: any) { - return arr - // @ts-ignore - .map(e => e[comp]) + return ( + arr + // @ts-ignore + .map((e) => e[comp]) - // store the keys of the unique objects - // @ts-ignore - .map((e, i, final) => final.indexOf(e) === i && i) + // store the keys of the unique objects + // @ts-ignore + .map((e, i, final) => final.indexOf(e) === i && i) - // eliminate the dead keys & store unique objects - // @ts-ignore - .filter(e => arr[e]).map(e => arr[e]) + // eliminate the dead keys & store unique objects + // @ts-ignore + .filter((e) => arr[e]) + .map((e) => arr[e]) + ); }, getColorByIndexBest(index: any) { - if (index < this.listBestColor.length - 1) - return this.listBestColor[index] - else - return 'primary' + if (index < this.listBestColor.length - 1) return this.listBestColor[index]; + else return 'primary'; }, convstrToNum(myval: any): number { - if (typeof myval == 'number' && !isNaN(myval)) { if (Number.isInteger(myval)) { - return myval + return myval; } else { // @ts-ignore - return parseFloat(myval) + return parseFloat(myval); } } - return parseFloat(myval) + return parseFloat(myval); }, getCookie(mytok: any, def?: any, convertint: any = false, convertbool: any = false) { - const ris = Cookies.get(mytok) + const ris = Cookies.get(mytok); // console.log('getCookie', mytok, ris) - if (ris === 'null') - return def + if (ris === 'null') return def; - if (ris === '-100') - return -100 + if (ris === '-100') return -100; if (convertint && !!ris) { - return parseInt(ris, 10) + return parseInt(ris, 10); } if (convertbool && !!ris) { - return ris ? true : false + return ris ? true : false; } // if (typeof(ris) == 'number') { @@ -4477,48 +4448,43 @@ export const tools = { // } if (ris) { - return ris + return ris; } else { - return def + return def; } }, getCookieBool(mytok: any, def?: any) { - const ris = Cookies.get(mytok) - if (ris === 'null') - return def - - return ris === '1' ? true : false + const ris = Cookies.get(mytok); + if (ris === 'null') return def; + return ris === '1' ? true : false; }, localStSetItem(item: string, value: string) { - if (localStorage.getItem('cookie-id') === 'decline') - return null + if (localStorage.getItem('cookie-id') === 'decline') return null; - localStorage.setItem(item, value) + localStorage.setItem(item, value); }, localStReal(item: string, value: string) { - localStorage.setItem(item, value) + localStorage.setItem(item, value); }, setCookie(mytok: any, value: string) { // console.log('setCookie', mytok, value) - if (localStorage.getItem('cookie-id') === 'decline') - return null + if (localStorage.getItem('cookie-id') === 'decline') return null; - return Cookies.set(mytok, value) + return Cookies.set(mytok, value); }, setCookieBool(mytok: any, valbool: boolean) { - if (localStorage.getItem('cookie-id') === 'decline') - return null + if (localStorage.getItem('cookie-id') === 'decline') return null; - return Cookies.set(mytok, valbool ? '1' : '0') + return Cookies.set(mytok, valbool ? '1' : '0'); }, removeCookie(mytok: any) { - return Cookies.remove(mytok) + return Cookies.remove(mytok); }, scrollToTopAll() { @@ -4529,20 +4495,20 @@ export const tools = { }, scrollToTop() { - const element = document.getElementById('mypage') - this.scrollToElement(element) + const element = document.getElementById('mypage'); + this.scrollToElement(element); }, scrollToElementId(myid: string) { - const element = document.getElementById(myid) - this.scrollToElement(element) + const element = document.getElementById(myid); + this.scrollToElement(element); }, scrollToElement(el: any) { if (el) { - const target = getScrollTarget(el) - const offset = el.offsetTop - const duration = 500 - console.log('target', target, 'offset', offset, 'duration', duration) - setVerticalScrollPosition(target, offset, duration) + const target = getScrollTarget(el); + const offset = el.offsetTop; + const duration = 500; + console.log('target', target, 'offset', offset, 'duration', duration); + setVerticalScrollPosition(target, offset, duration); } }, @@ -4551,1209 +4517,1203 @@ export const tools = { }, getCellForWhatsapp(numbercell: string) { - if (!numbercell) return '' - let mynum = numbercell.replace(/-/g, '') - const globalStore = useGlobalStore() - const intcode = globalStore.getValueSettingsByKey('INT_CODE', false) + if (!numbercell) return ''; + let mynum = numbercell.replace(/-/g, ''); + const globalStore = useGlobalStore(); + const intcode = globalStore.getValueSettingsByKey('INT_CODE', false); if (numbercell) { - if (numbercell.substring(0, 1) !== '+') mynum = intcode + mynum - else mynum = mynum.substring(1) + if (numbercell.substring(0, 1) !== '+') mynum = intcode + mynum; + else mynum = mynum.substring(1); } else { - return '' + return ''; } - return mynum + return mynum; }, getHttpForWhatsapp(numbercell: string) { - if (!numbercell) return '' - const mynum = this.getCellForWhatsapp(numbercell) - if (mynum) return `https://wa.me/${mynum}` - return '' + if (!numbercell) return ''; + const mynum = this.getCellForWhatsapp(numbercell); + if (mynum) return `https://wa.me/${mynum}`; + return ''; }, getHttpForTelegram(usertelegram: string) { - if (usertelegram) return `https://t.me/${usertelegram}` - return '' + if (usertelegram) return `https://t.me/${usertelegram}`; + return ''; }, getsuffisso() { - if (this.isTest()) return 'T: ' - return '' + if (this.isTest()) return 'T: '; + return ''; }, geturlupload() { - return this.getServerHost() + `/uploadnew/${this.getvers()}/` + return this.getServerHost() + `/uploadnew/${this.getvers()}/`; }, escapeslash(mystr: string) { - return mystr.replace(/\//g, 'Ç') + return mystr.replace(/\//g, 'Ç'); }, geturlrelativeprofile() { - return this.getDirUpload() + 'profile' + return this.getDirUpload() + 'profile'; }, getvers() { - return import.meta.env.VITE_APP_VERSION + return import.meta.env.VITE_APP_VERSION; }, getWssUrl(): string | URL { - const myurl = import.meta.env.VITE_APP_URL - if (myurl) - return myurl.replace(/(https?:\/\/[^:]+):\d+/, `$1:3000`).replace(/^http/, 'wss'); - else - return '' + const myurl = import.meta.env.VITE_APP_URL; + if (myurl) return myurl.replace(/(https?:\/\/[^:]+):\d+/, `$1:3000`).replace(/^http/, 'wss'); + else return ''; }, getheaders() { - const userStore = useUserStore() - return [{ name: 'x-auth', value: userStore.x_auth_token }, { name: 'x-refrtok', value: userStore.refreshToken }] + const userStore = useUserStore(); + return [ + { name: 'x-auth', value: userStore.x_auth_token }, + { name: 'x-refrtok', value: userStore.refreshToken }, + ]; }, getextfile(filename: string) { if (filename) { try { - const mystr = filename.split('.') - if (mystr) - return mystr.pop().toLowerCase() + const mystr = filename.split('.'); + if (mystr) return mystr.pop().toLowerCase(); } catch (e) { - return '' + return ''; } } - return '' + return ''; }, getelembylang(arr: any) { - const mylang = toolsext.getLocale() + const mylang = toolsext.getLocale(); for (const elem in arr) { - if (arr[elem][mylang]) - return arr[elem][mylang] + if (arr[elem][mylang]) return arr[elem][mylang]; } }, isChristmasHoliday() { - const now = new Date() - return ((now.getMonth() === 11 && now.getDate() > 20) || (now.getMonth() === 0 && now.getDate() < 8)) + const now = new Date(); + return (now.getMonth() === 11 && now.getDate() > 20) || (now.getMonth() === 0 && now.getDate() < 8); }, CapitalizeAllWords(str: string | undefined) { - if (str === undefined) - return '' - const splitStr = str.toLowerCase().split(' ') + if (str === undefined) return ''; + const splitStr = str.toLowerCase().split(' '); for (let i = 0; i < splitStr.length; i++) { // You do not need to check if i is larger than splitStr length, as your for does that for you // Assign it back to the array - splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1) + splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1); } // Directly return the joined string - return splitStr.join(' ') + return splitStr.join(' '); }, - - getValDb(keystr: string, serv: boolean, def?: any, table?: string, subkey?: any, id?: any, idmain?: any, specialField?: ISpecialField): any { - const globalStore = useGlobalStore() - const todos = useTodoStore() - const userStore = useUserStore() + getValDb( + keystr: string, + serv: boolean, + def?: any, + table?: string, + subkey?: any, + id?: any, + idmain?: any, + specialField?: ISpecialField + ): any { + const globalStore = useGlobalStore(); + const todos = useTodoStore(); + const userStore = useUserStore(); if (table === 'users') { if (keystr === 'profile') { // @ts-ignore - return userStore.my.profile[subkey] + return userStore.my.profile[subkey]; } else { // @ts-ignore - return userStore.my[keystr] + return userStore.my[keystr]; } } else if (table === 'todos') { // console.log('id', id, 'idmain', idmain) - const indcat = todos.categories.indexOf(idmain) - console.log('indcat', indcat) + const indcat = todos.categories.indexOf(idmain); + console.log('indcat', indcat); if (indcat >= 0) { - const myrec = todos.todos[indcat].find((rec: any) => rec._id === id) + const myrec = todos.todos[indcat].find((rec: any) => rec._id === id); // console.log('myrec', myrec) - let ris = null + let ris = null; if (myrec) { - ris = myrec[keystr] + ris = myrec[keystr]; } - console.log('ris', ris) - return ris + console.log('ris', ris); + return ris; } - return '' + return ''; } else { // console.log('keystr', keystr, 'serv', serv) - const ris = globalStore.getValueSettingsByKey(keystr, serv) + const ris = globalStore.getValueSettingsByKey(keystr, serv); // console.log('...ris', ris) if (ris === '') - if (def !== undefined) - return def - else - return '' - else - return ris + if (def !== undefined) return def; + else return ''; + else return ris; } - }, getkey(youtube: boolean, title: boolean, isnum: boolean) { - let mykey = 'MP4' - if (youtube) - mykey = 'YT' + let mykey = 'MP4'; + if (youtube) mykey = 'YT'; if (isnum) { - mykey += '_NUM' + mykey += '_NUM'; } else { - if (title) - mykey += '_TITLE_' - else - mykey += '_VIDEO_' + if (title) mykey += '_TITLE_'; + else mykey += '_VIDEO_'; } - return mykey + return mykey; }, heightgallvideo() { - const h = this.heightgallery(this.getValDb('YT_W', false) / this.getValDb('YT_H', false)) - return h + const h = this.heightgallery(this.getValDb('YT_W', false) / this.getValDb('YT_H', false)); + return h; }, getvideourl(index: number, youtube: boolean) { - const myvideo = this.getValDb(this.getkey(youtube, false, false) + index, false) + const myvideo = this.getValDb(this.getkey(youtube, false, false) + index, false); if (myvideo) - if (youtube) - return myvideo - else - return this.getpath(myvideo) - else - return '' + if (youtube) return myvideo; + else return this.getpath(myvideo); + else return ''; }, getvideonum(youtube: boolean) { - return this.getValDb(this.getkey(youtube, false, true), false) + return this.getValDb(this.getkey(youtube, false, true), false); }, getvideomp4yt(index: number) { - return [{ src: 'https://www.youtube.com/embed/' + this.getvideourl(index, true), type: 'video/mp4' }, - ] + return [{ src: 'https://www.youtube.com/embed/' + this.getvideourl(index, true), type: 'video/mp4' }]; }, getvideomp4src(index: number) { - return [{ src: this.getvideourl(index, false), type: 'video/mp4' }, - ] + return [{ src: this.getvideourl(index, false), type: 'video/mp4' }]; }, getvideoyt(index: number) { - return 'https://www.youtube.com/embed/' + this.getvideourl(index, true) + return 'https://www.youtube.com/embed/' + this.getvideourl(index, true); }, getvideobyidyoutube(key: string) { - return 'https://www.youtube.com/embed/' + key + return 'https://www.youtube.com/embed/' + key; }, getpath(myvideo: string) { - return 'video/' + func_tools.getLocale() + '/' + myvideo + return 'video/' + func_tools.getLocale() + '/' + myvideo; }, mygetarrValDb(keystr: string, serv: boolean) { - const globalStore = useGlobalStore() - const myval = globalStore.getValueSettingsByKey(keystr, serv) + const globalStore = useGlobalStore(); + const myval = globalStore.getValueSettingsByKey(keystr, serv); // console.log('AA: myval', myval) try { if (myval) { // console.log(' Entro') - const myrec = JSON.parse(myval) + const myrec = JSON.parse(myval); // console.log('*************** getarrValDb') // console.table(myrec) - return myrec + return myrec; } else { // console.log('NO MYVAL') - return [] + return []; } } catch (e) { - console.log('Errore: ', e) - return [] + console.log('Errore: ', e); + return []; } }, getvideotitle(index: number, youtube: boolean) { + const mykey = this.getkey(youtube, true, false) + index; + const ris = this.mygetarrValDb(mykey, false); - const mykey = this.getkey(youtube, true, false) + index - const ris = this.mygetarrValDb(mykey, false) - - return this.getelembylang(ris) + return this.getelembylang(ris); }, getvideoposter(index: number) { - return '' + return ''; }, clone(obj: any) { - if (null === obj || 'object' !== typeof obj) return obj - const copy: any = obj.constructor() + if (null === obj || 'object' !== typeof obj) return obj; + const copy: any = obj.constructor(); for (const attr in obj) { if (this.existProp(obj, attr)) { - copy[attr] = obj[attr] + copy[attr] = obj[attr]; } } - return copy + return copy; }, geticon(langin: string) { - if (langin === '') - return '' + if (langin === '') return ''; try { - const lang = langin.toUpperCase() + const lang = langin.toUpperCase(); - const arrlang = ['IT', 'ES', 'PT', 'BR', 'US', 'GB', 'UK', 'DE', 'FR', 'SI', 'MD', 'IE', 'KE', 'AU', 'ML', 'DO', - 'NG', 'SK', 'CH', 'CM', 'CO', 'CG', 'PE', 'MS', 'SM', 'HR', 'RO', 'VE', 'CL', 'PL', 'EG', 'AR', 'MX', 'SN', 'PK', 'AT', 'NP', - 'CU', 'MA', 'PH', 'BA', 'UA', 'BE', 'NL', 'CI', 'BF'] + const arrlang = [ + 'IT', + 'ES', + 'PT', + 'BR', + 'US', + 'GB', + 'UK', + 'DE', + 'FR', + 'SI', + 'MD', + 'IE', + 'KE', + 'AU', + 'ML', + 'DO', + 'NG', + 'SK', + 'CH', + 'CM', + 'CO', + 'CG', + 'PE', + 'MS', + 'SM', + 'HR', + 'RO', + 'VE', + 'CL', + 'PL', + 'EG', + 'AR', + 'MX', + 'SN', + 'PK', + 'AT', + 'NP', + 'CU', + 'MA', + 'PH', + 'BA', + 'UA', + 'BE', + 'NL', + 'CI', + 'BF', + ]; - const flag = arrlang.find((mylang) => mylang === lang) + const flag = arrlang.find((mylang) => mylang === lang); if (flag) { - return 'fa-flag-' + flag.toLowerCase() + return 'fa-flag-' + flag.toLowerCase(); } - return '' - + return ''; } catch (e) { - return '' + return ''; } }, removespaces(mystr: string) { - return mystr.replace(/\s+/g, '') + return mystr.replace(/\s+/g, ''); }, removeAt(mystr: string): string { - return mystr.replace(/@/g, '') + return mystr.replace(/@/g, ''); }, removespecial_chars(mystr: string) { - mystr = mystr.replace(/\s+/g, '') - mystr = mystr.replace(/\//g, '') - mystr = mystr.replace(/:/g, '') - mystr = mystr.replace(/,/g, '') - mystr = mystr.replace(/'/g, '') - mystr = mystr.replace(/&/g, '') - mystr = mystr.replace(/@/g, '') - mystr = mystr.replace(/\?/g, '') - mystr = mystr.replace(/#/g, '') - return mystr + mystr = mystr.replace(/\s+/g, ''); + mystr = mystr.replace(/\//g, ''); + mystr = mystr.replace(/:/g, ''); + mystr = mystr.replace(/,/g, ''); + mystr = mystr.replace(/'/g, ''); + mystr = mystr.replace(/&/g, ''); + mystr = mystr.replace(/@/g, ''); + mystr = mystr.replace(/\?/g, ''); + mystr = mystr.replace(/#/g, ''); + return mystr; }, removespaces_slash(mystr: string) { - mystr = mystr.replace(/\s+/g, '') - mystr = mystr.replace(/\//g, '') - mystr = mystr.replace(/,/g, '') - mystr = mystr.replace(/'/g, '') - return mystr + mystr = mystr.replace(/\s+/g, ''); + mystr = mystr.replace(/\//g, ''); + mystr = mystr.replace(/,/g, ''); + mystr = mystr.replace(/'/g, ''); + return mystr; }, copyStringToClipboard(myq: any, mystr: string, show: boolean) { //T_TOLTO copyToClipboard(mystr).then(() => { - let msg = t('dialog.copyclipboard') - if (show) - msg += ' \'' + mystr + '\'' - - this.showNotif(myq, msg) - }) + let msg = t('dialog.copyclipboard'); + if (show) msg += " '" + mystr + "'"; + this.showNotif(myq, msg); + }); }, copyToClip(myq: any, mystr: string, show: boolean) { - this.copyStringToClipboard(myq, mystr, show) + this.copyStringToClipboard(myq, mystr, show); }, copyStringToClipboardSilent(mystr: string) { - - copyToClipboard(mystr) - + copyToClipboard(mystr); }, getlinkhref(mylink: string, text: string) { if (mylink) { if (!mylink.startsWith('http')) { - mylink = 'https://' + mylink + mylink = 'https://' + mylink; } - return '' + text + '' + return '' + text + ''; } else { - return '' + return ''; } - }, getlinkEmailTo(myemail: string) { if (myemail) { - - return `${myemail}` + return `${myemail}`; } else { - return '' + return ''; } - }, getNationsByNationality(nat: string) { - if (!nat) - return '' + if (!nat) return ''; - nat = nat.toUpperCase() + nat = nat.toUpperCase(); if (nat === 'IT') { - return 'Italy' + return 'Italy'; } else if (nat === 'SI') { - return 'Slovenia' + return 'Slovenia'; } else if (nat === 'SK') { - return 'Slovakia' + return 'Slovakia'; } else if (nat === 'NG') { - return 'Nigeria' + return 'Nigeria'; } else if (nat === 'MD') { - return 'Moldova' + return 'Moldova'; } else if (nat === 'ES') { - return 'Spain' + return 'Spain'; } else if (nat === 'DE') { - return 'Germany' + return 'Germany'; } else if (nat === 'FR') { - return 'France' + return 'France'; } else if (nat === 'US') { - return 'United States' + return 'United States'; } else if (nat === 'CA') { - return 'Canada' + return 'Canada'; } else if (nat === 'MA') { - return 'Morocco' + return 'Morocco'; } else if (nat === 'LT') { - return 'Lithuania' + return 'Lithuania'; } else if (nat === 'HR') { - return 'Croatia' + return 'Croatia'; } else if (nat === 'HU') { - return 'Hungary' + return 'Hungary'; } else if (nat === 'CH') { - return 'Switzerland' + return 'Switzerland'; } else if (nat === 'CM') { - return 'Cameroon' + return 'Cameroon'; } else if (nat === 'CO') { - return 'Colombia' + return 'Colombia'; } else if (nat === 'PE') { - return 'Peru' + return 'Peru'; } else if (nat === 'PL') { - return 'Poland' + return 'Poland'; } else if (nat === 'SM') { - return 'San Marino' + return 'San Marino'; } else if (nat === 'PT') { - return 'Portugal' - } else if ((nat === 'UK') || (nat === 'GB')) { - return 'United Kingdom' + return 'Portugal'; + } else if (nat === 'UK' || nat === 'GB') { + return 'United Kingdom'; } else if (nat === 'UA') { - return 'Ukraine' + return 'Ukraine'; } else if (nat === 'RO') { - return 'Romania' + return 'Romania'; } else if (nat === 'VE') { - return 'Venezuela' + return 'Venezuela'; } else if (nat === 'CL') { - return 'Chile' + return 'Chile'; } else if (nat === 'EG') { - return 'Egypt' + return 'Egypt'; } else if (nat === 'BR') { - return 'Brazil' + return 'Brazil'; } else if (nat === 'CG') { - return 'Congo' + return 'Congo'; } else if (nat === 'AR') { - return 'Argentina' + return 'Argentina'; } else if (nat === 'MX') { - return 'Mexico' + return 'Mexico'; } else if (nat === 'SN') { - return 'Senegal' + return 'Senegal'; } else if (nat === 'PK') { - return 'Pakistan' + return 'Pakistan'; } else if (nat === 'AT') { - return 'Austria' + return 'Austria'; } else if (nat === 'NP') { - return 'Nepal' + return 'Nepal'; } else if (nat === 'CU') { - return 'Cuba' + return 'Cuba'; } else if (nat === 'PH') { - return 'Philippines' + return 'Philippines'; } else if (nat === 'BA') { - return 'Bosnia and Herzegovina' + return 'Bosnia and Herzegovina'; } else if (nat === 'BE') { - return 'Belgium' + return 'Belgium'; } else if (nat === 'NL') { - return 'Netherlands' + return 'Netherlands'; } else if (nat === 'MS') { - return 'Montserrat' + return 'Montserrat'; } else if (nat === 'CI') { - return 'Cote d\'Ivoire' + return "Cote d'Ivoire"; } else if (nat === 'BF') { - return 'Burkina Faso' + return 'Burkina Faso'; } else if (nat === 'IE') { - return 'Ireland' + return 'Ireland'; } else if (nat === 'KE') { - return 'Kenya' + return 'Kenya'; } else if (nat === 'AU') { - return 'Australia' + return 'Australia'; } else if (nat === 'ML') { - return 'Mali' + return 'Mali'; } else if (nat === 'DO') { - return 'Dominican Republic' + return 'Dominican Republic'; } }, getGroupById(myid: string) { - const globalStore = useGlobalStore() - const group = globalStore.groups.find((rec) => rec._id === myid) + const globalStore = useGlobalStore(); + const group = globalStore.groups.find((rec) => rec._id === myid); if (group) { - return group.descr + return group.descr; } - return '' + return ''; }, getLinkZoom() { - let id = '' - const globalStore = useGlobalStore() + let id = ''; + const globalStore = useGlobalStore(); if (globalStore.calzoom.length > 0) { // @ts-ignore - id = globalStore.calzoom.slice(-1)[0].id_conf_zoom.toString() + id = globalStore.calzoom.slice(-1)[0].id_conf_zoom.toString(); } else { - id = '0' + id = '0'; } - return 'https://zoom.us/j/' + id + return 'https://zoom.us/j/' + id; }, myprintf(val: string, params: any[]) { - params.forEach((par) => { - val = val.replace('{' + par.strin + '}', par.strout) - }) - return val + val = val.replace('{' + par.strin + '}', par.strout); + }); + return val; }, translate(params: string, options?: any) { - if (!params) - return '' + if (!params) return ''; - const msg = params.split('.') - const lang = toolsext.getLocale() + const msg = params.split('.'); + const lang = toolsext.getLocale(); // @ts-ignore - const stringa: string = messages[lang] + const stringa: string = messages[lang]; - let ris: any = stringa + let ris: any = stringa; if (ris) { msg.forEach((param) => { - ris = ris[param] - }) + ris = ris[param]; + }); if (options) { - ris = this.myprintf(ris, options) + ris = this.myprintf(ris, options); } - } else { - console.log('ERRORE IN TRANSLATE! ', params, ' NON ESISTE!') - return params + console.log('ERRORE IN TRANSLATE! ', params, ' NON ESISTE!'); + return params; } - return ris + return ris; }, isSel2Metodi(user: IUserFields) { if (user.profile.paymenttypes) { - return user.profile.paymenttypes.length > 1 + return user.profile.paymenttypes.length > 1; } - return false - + return false; }, getnumrequisiti(user: IUserFields) { - let req = 0 + let req = 0; - - req += user.verified_email ? 1 : 0 - req += user.profile.teleg_id > 0 ? 1 : 0 - req += this.isBitActive(user.profile.saw_and_accepted, shared_consts.Accepted.CHECK_READ_GUIDELINES.value) ? 1 : 0 - req += this.isBitActive(user.profile.saw_and_accepted, shared_consts.Accepted.CHECK_SEE_VIDEO_PRINCIPI.value) ? 1 : 0 + req += user.verified_email ? 1 : 0; + req += user.profile.teleg_id > 0 ? 1 : 0; + req += this.isBitActive(user.profile.saw_and_accepted, shared_consts.Accepted.CHECK_READ_GUIDELINES.value) ? 1 : 0; + req += this.isBitActive(user.profile.saw_and_accepted, shared_consts.Accepted.CHECK_SEE_VIDEO_PRINCIPI.value) + ? 1 + : 0; // req += user.profile.saw_zoom_presentation ? 1 : 0 // if (!!user.profile.my_dream) // req += user.profile.my_dream.length >= 10 ? 1 : 0 - req += this.isSel2Metodi(user) ? 1 : 0 + req += this.isSel2Metodi(user) ? 1 : 0; - return req + return req; }, Is7ReqOk(user: IUserFields) { - return this.getnumrequisiti(user) === 7 + return this.getnumrequisiti(user) === 7; }, getRiganave(riga: number) { - let ris = riga - 3 - if (ris <= 1) - ris = 1 + let ris = riga - 3; + if (ris <= 1) ris = 1; - return ris + return ris; }, getColnave(col: number) { - let ris = Math.ceil(col / (2 * 4)) - if (ris <= 1) - ris = 1 - return ris + let ris = Math.ceil(col / (2 * 4)); + if (ris <= 1) ris = 1; + return ris; }, getrigacolstr(mianave: any) { - return this.getRiganave(mianave.riga) + '.' + this.getColnave(mianave.col) + return this.getRiganave(mianave.riga) + '.' + this.getColnave(mianave.col); }, getlastnavestr(lastnave: any) { - return lastnave.riga + '.' + lastnave.col + return lastnave.riga + '.' + lastnave.col; }, getmaxcol(riga: number) { - - return Math.pow(2, riga - 1) + return Math.pow(2, riga - 1); }, getrigaNaveByPosiz(riga: number) { - let ris = riga + 3 - if (ris <= 1) - ris = 1 - return ris - + let ris = riga + 3; + if (ris <= 1) ris = 1; + return ris; }, getcolNaveByPosiz(col: number) { - let ris = Math.ceil(col * Math.pow(2, 3)) - if (ris <= 1) - ris = 1 - return ris + let ris = Math.ceil(col * Math.pow(2, 3)); + if (ris <= 1) ris = 1; + return ris; }, getfirstnaveSognatore(riga: number, col: number) { - const myriga = this.getrigaNaveByPosiz(riga) - const mycol = this.getcolNaveByPosiz(col) + const myriga = this.getrigaNaveByPosiz(riga); + const mycol = this.getcolNaveByPosiz(col); // console.log(`${riga}.${col} => ${myriga}.${mycol}`) - return { riga: myriga, col: mycol } + return { riga: myriga, col: mycol }; }, getnumnavi_finoa(naveorig: any, navedest: any, lastnave: any) { - let contaattuale = 0 - let contatot = 0 + let contaattuale = 0; + let contatot = 0; - const indrigaattuale = lastnave.riga - const indcolattuale = lastnave.col + const indrigaattuale = lastnave.riga; + const indcolattuale = lastnave.col; if (navedest.riga < indrigaattuale) { - return { perc: 100, totale: 0, contaattuale: 0 } + return { perc: 100, totale: 0, contaattuale: 0 }; } for (let indriga = naveorig.riga; indriga <= navedest.riga; indriga++) { - - let startcol = 0 + let startcol = 0; if (indriga === naveorig.riga) { - startcol = naveorig.col + startcol = naveorig.col; } - let endcol = this.getmaxcol(indriga) + let endcol = this.getmaxcol(indriga); if (indriga === navedest.riga) { - endcol = navedest.col + endcol = navedest.col; } if (indriga <= navedest.riga) { - contatot += (endcol - startcol) + contatot += endcol - startcol; } if (indriga < indrigaattuale) { - contaattuale += (endcol - startcol) + contaattuale += endcol - startcol; } else if (indriga === indrigaattuale) { - contaattuale += indcolattuale + contaattuale += indcolattuale; } } - let perc = 0 - if (contatot > 0) - perc = (contaattuale / contatot) * 100 + let perc = 0; + if (contatot > 0) perc = (contaattuale / contatot) * 100; - if (perc > 100) - perc = 100 + if (perc > 100) perc = 100; // console.log('naveorig', naveorig.riga, '.', naveorig.col, 'dest', navedest.riga, ',', navedest.col) // console.log('lastnave', lastnave.riga, '.', lastnave.col) // console.log('contaattuale', contaattuale, 'contatot', contatot, 'perc', perc) - return { perc, totale: contatot, contaattuale } + return { perc, totale: contatot, contaattuale }; }, isFacil() { - const userStore = useUserStore() + const userStore = useUserStore(); - return userStore.isFacilitatore || userStore.isAdmin + return userStore.isFacilitatore || userStore.isAdmin; }, sito_online(pertutti: boolean) { + const userStore = useUserStore(); - const userStore = useUserStore() - - let ris = true - const online = this.getValDb('SITO_ONLINE', false, true) - ris = userStore.isAdmin && !pertutti ? true : online + let ris = true; + const online = this.getValDb('SITO_ONLINE', false, true); + ris = userStore.isAdmin && !pertutti ? true : online; // console.log('sito_online', ris) - return ris + return ris; }, getsize() { if (this.isMobile()) { - return '0.85rem' + return '0.85rem'; } else { - return '1rem' + return '1rem'; } }, getsizesmall() { if (this.isMobile()) { - return '0.75rem' + return '0.75rem'; } else { - return '0.85rem' + return '0.85rem'; } }, convertiTagHTMLPerBOT(msg: string) { + msg = msg.replace(//g, ''); + msg = msg.replace(/<\/strong>/g, ''); - msg = msg.replace(//g, '') - msg = msg.replace(/<\/strong>/g, '') - - return msg + return msg; }, getlinkstd(link: string) { - let mylink = link + let mylink = link; if (link) { if (!link.startsWith('http')) { - mylink = 'https://' + link + mylink = 'https://' + link; } } - return mylink + return mylink; }, isselectPaypal() { - const userStore = useUserStore() + const userStore = useUserStore(); if (userStore.my.profile) { if (userStore.my.profile.paymenttypes) { if (userStore.my.profile.paymenttypes.includes({ key: 'paypal', label: 'paypal' })) { - return true + return true; } } - return false + return false; } }, isselectPayeer() { - const userStore = useUserStore() + const userStore = useUserStore(); if (userStore.my.profile) { if (userStore.my.profile.paymenttypes) { if (userStore.my.profile.paymenttypes.includes({ key: 'payeer', label: 'payeer' })) { - return true + return true; } } - return false + return false; } }, isselectRevolut() { - const userStore = useUserStore() + const userStore = useUserStore(); if (userStore.my.profile) { if (userStore.my.profile.paymenttypes) { if (userStore.my.profile.paymenttypes.includes({ key: 'revolut', label: 'revolut' })) { - return true + return true; } } - return false + return false; } }, isselectAdvCash() { - const userStore = useUserStore() + const userStore = useUserStore(); if (userStore.my.profile) { if (userStore.my.profile.paymenttypes) { if (userStore.my.profile.paymenttypes.includes({ key: 'advcash', label: 'advcash' })) { - return true + return true; } } - return false + return false; } }, getGroupList() { - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); // console.log('globalStore.groups', globalStore.groups) const mylist: any = { it: [], es: [], enUs: [], - } + }; - let myrec = {} + let myrec = {}; for (const mygroup of globalStore.groups) { myrec = { id: mygroup._id, label: mygroup.descr, value: mygroup._id, - } - mylist.it.push(myrec) - + }; + mylist.it.push(myrec); } - return mylist + return mylist; }, getRespList() { - // console.log('globalStore.groups', globalStore.groups) const mylist: any = { it: [], es: [], enUs: [], - } + }; - let myrec = {} + let myrec = {}; - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); for (const myresp of globalStore.resps) { myrec = { id: myresp._id, label: myresp.name + ' ' + myresp.surname, value: myresp.username, - } - mylist.it.push(myrec) - + }; + mylist.it.push(myrec); } - return mylist + return mylist; }, getWorkersList() { - // console.log('globalStore.groups', globalStore.groups) const mylist: any = { it: [], es: [], enUs: [], - } + }; - let myrec = {} + let myrec = {}; - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); for (const myresp of globalStore.workers) { myrec = { id: myresp._id, label: myresp.name + ' ' + myresp.surname, value: myresp.username, - } - mylist.it.push(myrec) - + }; + mylist.it.push(myrec); } - return mylist + return mylist; }, isLogged() { - const userStore = useUserStore() - const globalStore = useGlobalStore() - if (userStore) - return userStore.isLogged && !globalStore.serverError - else - return false + const userStore = useUserStore(); + const globalStore = useGlobalStore(); + if (userStore) return userStore.isLogged && !globalStore.serverError; + else return false; }, getUsername() { - const userStore = useUserStore() + const userStore = useUserStore(); try { - if (userStore) - return userStore.my.username - else - return false + if (userStore) return userStore.my.username; + else return false; } catch (e) { - return '' + return ''; } }, isUserOk() { - const userStore = useUserStore() - if (userStore) - return userStore.isUserOk() - else - return false + const userStore = useUserStore(); + if (userStore) return userStore.isUserOk(); + else return false; }, getProvincia() { - const userStore = useUserStore() - const globalStore = useGlobalStore() - const prov = userStore.my.profile.resid_province + const userStore = useUserStore(); + const globalStore = useGlobalStore(); + const prov = userStore.my.profile.resid_province; - return globalStore.getProvinceByProv(prov) + return globalStore.getProvinceByProv(prov); }, visualizzaHomeApp() { - return this.getProvincia() !== '' + return this.getProvincia() !== ''; }, getLinkBotTelegram(aportador_solidario: string, regexpire: string): string { - let mylink = '' - const sep = '-' + let mylink = ''; + const sep = '-'; if (this.isTest() && !import.meta.env.DEV) { - mylink = this.getValDb('TELEG_BOT_LINK_TEST', false) + mylink = this.getValDb('TELEG_BOT_LINK_TEST', false); } else { - mylink = this.getValDb('TELEG_BOT_LINK', false) + mylink = this.getValDb('TELEG_BOT_LINK', false); } - let add = '' + let add = ''; if (aportador_solidario) { - add = '?start=inv' + sep + aportador_solidario + sep + 'ex' + sep + regexpire + add = '?start=inv' + sep + aportador_solidario + sep + 'ex' + sep + regexpire; } - return mylink + add + return mylink + add; }, getBotName(): string { if (this.isTest() && !import.meta.env.DEV) { - return this.getValDb('TELEG_BOT_NAME', false) + return this.getValDb('TELEG_BOT_NAME', false); } else { - return this.getValDb('TELEG_BOT_NAME', false) + return this.getValDb('TELEG_BOT_NAME', false); } }, TelegVerificato(): boolean { - const userStore = useUserStore() - return userStore.my.profile ? userStore.my.profile.teleg_id > 0 || userStore.my.profile.teleg_id_old > 0 : false + const userStore = useUserStore(); + return userStore.my.profile ? userStore.my.profile.teleg_id > 0 || userStore.my.profile.teleg_id_old > 0 : false; }, isDebugOn(): boolean { - const globalStore = useGlobalStore() - const site = globalStore.site - return (site.confpages.enableDebugOn) + const globalStore = useGlobalStore(); + const site = globalStore.site; + return site.confpages.enableDebugOn; }, getDomainSite(): string { - const globalStore = useGlobalStore() - const site = globalStore.site + const globalStore = useGlobalStore(); + const site = globalStore.site; if (site) { return site.host ? site.host.replace(/^(https?:\/\/)/, '') : ''; } - return '' + return ''; }, isVerified(): boolean { - const globalStore = useGlobalStore() - const site = globalStore.site + const globalStore = useGlobalStore(); + const site = globalStore.site; if (site.confpages?.enableRegMultiChoice) { - return this.TelegVerificato() || this.isEmailVerified() + return this.TelegVerificato() || this.isEmailVerified(); } if (site.confpages.enabledRegNeedTelegram) { - return this.TelegVerificato() + return this.TelegVerificato(); } else { - return this.isEmailVerified() + return this.isEmailVerified(); } - }, Verificato() { - const userStore = useUserStore() - const globalStore = useGlobalStore() - return this.isVerified() + const userStore = useUserStore(); + const globalStore = useGlobalStore(); + return this.isVerified(); }, - isEmailVerified(): boolean { - const userStore = useUserStore() - return userStore.my.verified_email + const userStore = useUserStore(); + return userStore.my.verified_email; }, isEmailVerifiedByUser(userprofile: IUserFields): boolean { - return userprofile.verified_email + return userprofile.verified_email; }, isUsernameTelegOkByUser(userprofile: IUserFields): boolean { - return !!userprofile.profile.username_telegram + return !!userprofile.profile.username_telegram; }, getLinkUserTelegramByUser(userprofile: IUserFields) { - if (userprofile) { if (userprofile.profile?.username_telegram) { - return 'https://t.me/' + userprofile.profile.username_telegram + return 'https://t.me/' + userprofile.profile.username_telegram; } } else { - return '' + return ''; } }, TelegCode() { - const userStore = useUserStore() - if (userStore) - return userStore.my.profile.teleg_checkcode - else - return false + const userStore = useUserStore(); + if (userStore) return userStore.my.profile.teleg_checkcode; + else return false; }, formatDate(mydate: any) { - let d: Date + let d: Date; if (mydate !== void 0) { - d = new Date(mydate) + d = new Date(mydate); } else { - d = new Date() + d = new Date(); } - const month = '' + (d.getMonth() + 1) - const day = '' + d.getDate() - const year = d.getFullYear() + const month = '' + (d.getMonth() + 1); + const day = '' + d.getDate(); + const year = d.getFullYear(); - return [year, this.padTime(month), this.padTime(day)].join('-') + return [year, this.padTime(month), this.padTime(day)].join('-'); }, firstDayOfDate(mydate: any) { - let d: Date + let d: Date; if (mydate !== void 0) { - d = new Date(mydate) + d = new Date(mydate); } else { - d = new Date() + d = new Date(); } - const month = d.getMonth() - const day = 1 - const year = d.getFullYear() + const month = d.getMonth(); + const day = 1; + const year = d.getFullYear(); - return new Date(year, month, day) + return new Date(year, month, day); }, LastDayOfDate(mydate: any) { - let d: Date + let d: Date; if (mydate !== void 0) { - d = new Date(mydate) + d = new Date(mydate); } else { - d = new Date() + d = new Date(); } - let month = d.getMonth() - if (month === 11) - month = 0 - else - month++ - const year = d.getFullYear() + let month = d.getMonth(); + if (month === 11) month = 0; + else month++; + const year = d.getFullYear(); - return new Date(year, month, 0) + return new Date(year, month, 0); }, formatTime(mydate: any) { const d = mydate !== void 0 ? new Date(mydate) : new Date(), hours = '' + d.getHours(), - minutes = '' + d.getMinutes() + minutes = '' + d.getMinutes(); - return [this.padTime(hours), this.padTime(minutes)].join(':') + return [this.padTime(hours), this.padTime(minutes)].join(':'); }, colourNameToHex(colour: string) { const colours: any = { - 'aliceblue': '#f0f8ff', - 'antiquewhite': '#faebd7', - 'aqua': '#00ffff', - 'aquamarine': '#7fffd4', - 'azure': '#f0ffff', - 'beige': '#f5f5dc', - 'bisque': '#ffe4c4', - 'black': '#000000', - 'blanchedalmond': '#ffebcd', - 'blue': '#0000ff', + aliceblue: '#f0f8ff', + antiquewhite: '#faebd7', + aqua: '#00ffff', + aquamarine: '#7fffd4', + azure: '#f0ffff', + beige: '#f5f5dc', + bisque: '#ffe4c4', + black: '#000000', + blanchedalmond: '#ffebcd', + blue: '#0000ff', 'blue-3': '#90caf9', 'blue-4': '#64b5f6', 'amber-10': '#ff6f00', 'blue-6': '#2196f3', - 'blueviolet': '#8a2be2', - 'brown': '#a52a2a', - 'burlywood': '#deb887', - 'cadetblue': '#5f9ea0', - 'chartreuse': '#7fff00', - 'chocolate': '#d2691e', - 'coral': '#ff7f50', - 'cornflowerblue': '#6495ed', - 'cornsilk': '#fff8dc', - 'crimson': '#dc143c', - 'cyan': '#00ffff', - 'darkblue': '#00008b', - 'darkcyan': '#008b8b', - 'darkgoldenrod': '#b8860b', - 'darkgray': '#a9a9a9', - 'darkgreen': '#006400', - 'darkkhaki': '#bdb76b', - 'darkmagenta': '#8b008b', - 'darkolivegreen': '#556b2f', - 'darkorange': '#ff8c00', - 'darkorchid': '#9932cc', - 'darkred': '#8b0000', - 'darksalmon': '#e9967a', - 'darkseagreen': '#8fbc8f', - 'darkslateblue': '#483d8b', - 'darkslategray': '#2f4f4f', - 'darkturquoise': '#00ced1', - 'darkviolet': '#9400d3', - 'deeppink': '#ff1493', - 'deepskyblue': '#00bfff', - 'dimgray': '#696969', - 'dodgerblue': '#1e90ff', - 'firebrick': '#b22222', - 'floralwhite': '#fffaf0', - 'forestgreen': '#228b22', - 'fuchsia': '#ff00ff', - 'gainsboro': '#dcdcdc', - 'ghostwhite': '#f8f8ff', - 'gold': '#ffd700', - 'goldenrod': '#daa520', - 'gray': '#808080', - 'green': '#008000', + blueviolet: '#8a2be2', + brown: '#a52a2a', + burlywood: '#deb887', + cadetblue: '#5f9ea0', + chartreuse: '#7fff00', + chocolate: '#d2691e', + coral: '#ff7f50', + cornflowerblue: '#6495ed', + cornsilk: '#fff8dc', + crimson: '#dc143c', + cyan: '#00ffff', + darkblue: '#00008b', + darkcyan: '#008b8b', + darkgoldenrod: '#b8860b', + darkgray: '#a9a9a9', + darkgreen: '#006400', + darkkhaki: '#bdb76b', + darkmagenta: '#8b008b', + darkolivegreen: '#556b2f', + darkorange: '#ff8c00', + darkorchid: '#9932cc', + darkred: '#8b0000', + darksalmon: '#e9967a', + darkseagreen: '#8fbc8f', + darkslateblue: '#483d8b', + darkslategray: '#2f4f4f', + darkturquoise: '#00ced1', + darkviolet: '#9400d3', + deeppink: '#ff1493', + deepskyblue: '#00bfff', + dimgray: '#696969', + dodgerblue: '#1e90ff', + firebrick: '#b22222', + floralwhite: '#fffaf0', + forestgreen: '#228b22', + fuchsia: '#ff00ff', + gainsboro: '#dcdcdc', + ghostwhite: '#f8f8ff', + gold: '#ffd700', + goldenrod: '#daa520', + gray: '#808080', + green: '#008000', 'green-3': '#a5d6a7', 'green-4': '#81c784', 'green-6': '#4caf50', - 'greenyellow': '#adff2f', - 'honeydew': '#f0fff0', - 'hotpink': '#ff69b4', + greenyellow: '#adff2f', + honeydew: '#f0fff0', + hotpink: '#ff69b4', 'indianred ': '#cd5c5c', 'indigo-3': '#9fa8da', 'indigo-4': '#7986cb', 'indigo-6': '#3f51b5', - 'indigo': '#4b0082', - 'ivory': '#fffff0', - 'khaki': '#f0e68c', - 'lavender': '#e6e6fa', - 'lavenderblush': '#fff0f5', - 'lawngreen': '#7cfc00', - 'lemonchiffon': '#fffacd', - 'lightblue': '#add8e6', - 'lightcoral': '#f08080', - 'lightcyan': '#e0ffff', - 'lightgoldenrodyellow': '#fafad2', - 'lightgrey': '#d3d3d3', - 'lightgreen': '#90ee90', - 'lightpink': '#ffb6c1', - 'lightsalmon': '#ffa07a', - 'lightseagreen': '#20b2aa', - 'lightskyblue': '#87cefa', - 'lightslategray': '#778899', - 'lightsteelblue': '#b0c4de', - 'lightyellow': '#ffffe0', - 'lime': '#00ff00', + indigo: '#4b0082', + ivory: '#fffff0', + khaki: '#f0e68c', + lavender: '#e6e6fa', + lavenderblush: '#fff0f5', + lawngreen: '#7cfc00', + lemonchiffon: '#fffacd', + lightblue: '#add8e6', + lightcoral: '#f08080', + lightcyan: '#e0ffff', + lightgoldenrodyellow: '#fafad2', + lightgrey: '#d3d3d3', + lightgreen: '#90ee90', + lightpink: '#ffb6c1', + lightsalmon: '#ffa07a', + lightseagreen: '#20b2aa', + lightskyblue: '#87cefa', + lightslategray: '#778899', + lightsteelblue: '#b0c4de', + lightyellow: '#ffffe0', + lime: '#00ff00', 'lime-3': '#e6ee9c', 'lime-4': '#dce775', 'lime-6': '#cddc39', 'lime-8': '#afb42b', - 'limegreen': '#32cd32', - 'linen': '#faf0e6', - 'magenta': '#ff00ff', - 'maroon': '#800000', - 'mediumaquamarine': '#66cdaa', - 'mediumblue': '#0000cd', - 'mediumorchid': '#ba55d3', - 'mediumpurple': '#9370d8', - 'mediumseagreen': '#3cb371', - 'mediumslateblue': '#7b68ee', - 'mediumspringgreen': '#00fa9a', - 'mediumturquoise': '#48d1cc', - 'mediumvioletred': '#c71585', - 'midnightblue': '#191970', - 'mintcream': '#f5fffa', - 'mistyrose': '#ffe4e1', - 'moccasin': '#ffe4b5', - 'navajowhite': '#ffdead', - 'navy': '#000080', - 'oldlace': '#fdf5e6', - 'olive': '#808000', - 'olivedrab': '#6b8e23', - 'orange': '#ffa500', + limegreen: '#32cd32', + linen: '#faf0e6', + magenta: '#ff00ff', + maroon: '#800000', + mediumaquamarine: '#66cdaa', + mediumblue: '#0000cd', + mediumorchid: '#ba55d3', + mediumpurple: '#9370d8', + mediumseagreen: '#3cb371', + mediumslateblue: '#7b68ee', + mediumspringgreen: '#00fa9a', + mediumturquoise: '#48d1cc', + mediumvioletred: '#c71585', + midnightblue: '#191970', + mintcream: '#f5fffa', + mistyrose: '#ffe4e1', + moccasin: '#ffe4b5', + navajowhite: '#ffdead', + navy: '#000080', + oldlace: '#fdf5e6', + olive: '#808000', + olivedrab: '#6b8e23', + orange: '#ffa500', 'orange-3': '#ffcc80', 'orange-4': '#ffb74d', 'orange-6': '#ff9800', - 'orangered': '#ff4500', - 'orchid': '#da70d6', - 'palegoldenrod': '#eee8aa', - 'palegreen': '#98fb98', - 'paleturquoise': '#afeeee', - 'palevioletred': '#d87093', - 'papayawhip': '#ffefd5', - 'peachpuff': '#ffdab9', - 'peru': '#cd853f', - 'pink': '#ffc0cb', - 'plum': '#dda0dd', - 'powderblue': '#b0e0e6', - 'purple': '#800080', - 'rebeccapurple': '#663399', - 'red': '#ff0000', + orangered: '#ff4500', + orchid: '#da70d6', + palegoldenrod: '#eee8aa', + palegreen: '#98fb98', + paleturquoise: '#afeeee', + palevioletred: '#d87093', + papayawhip: '#ffefd5', + peachpuff: '#ffdab9', + peru: '#cd853f', + pink: '#ffc0cb', + plum: '#dda0dd', + powderblue: '#b0e0e6', + purple: '#800080', + rebeccapurple: '#663399', + red: '#ff0000', 'red-3': '#ef9a9a', 'red-4': '#e57373', 'red-6': '#f44336', - 'rosybrown': '#bc8f8f', - 'royalblue': '#4169e1', - 'saddlebrown': '#8b4513', - 'salmon': '#fa8072', - 'sandybrown': '#f4a460', - 'seagreen': '#2e8b57', - 'seashell': '#fff5ee', - 'sienna': '#a0522d', - 'silver': '#c0c0c0', - 'skyblue': '#87ceeb', - 'slateblue': '#6a5acd', - 'slategray': '#708090', - 'snow': '#fffafa', - 'springgreen': '#00ff7f', - 'steelblue': '#4682b4', - 'tan': '#d2b48c', - 'teal': '#008080', - 'thistle': '#d8bfd8', - 'tomato': '#ff6347', - 'turquoise': '#40e0d0', - 'violet': '#ee82ee', - 'wheat': '#f5deb3', - 'white': '#ffffff', - 'whitesmoke': '#f5f5f5', - 'yellow': '#ffff00', - 'yellowgreen': '#9acd32', - } + rosybrown: '#bc8f8f', + royalblue: '#4169e1', + saddlebrown: '#8b4513', + salmon: '#fa8072', + sandybrown: '#f4a460', + seagreen: '#2e8b57', + seashell: '#fff5ee', + sienna: '#a0522d', + silver: '#c0c0c0', + skyblue: '#87ceeb', + slateblue: '#6a5acd', + slategray: '#708090', + snow: '#fffafa', + springgreen: '#00ff7f', + steelblue: '#4682b4', + tan: '#d2b48c', + teal: '#008080', + thistle: '#d8bfd8', + tomato: '#ff6347', + turquoise: '#40e0d0', + violet: '#ee82ee', + wheat: '#f5deb3', + white: '#ffffff', + whitesmoke: '#f5f5f5', + yellow: '#ffff00', + yellowgreen: '#9acd32', + }; - const index: any = colour.toLowerCase() + const index: any = colour.toLowerCase(); - if (typeof colours[index] != 'undefined') - return colours[index] + if (typeof colours[index] != 'undefined') return colours[index]; - return false + return false; }, errorMsg(cosa: string, item: any) { try { if (!item.$error) { - return '' + return ''; } // console.log('errorMsg', cosa, item) //T_TOLTO if (item.email) { - if (item.email.$invalid) - return t('reg.err.email') + if (item.email.$invalid) return t('reg.err.email'); } if (item.minLength !== undefined) { if (item.minLength.$invalid) { - return t('reg.err.atleast') + ` ${item.minLength.$params.min} ` + t('reg.err.char') + return t('reg.err.atleast') + ` ${item.minLength.$params.min} ` + t('reg.err.char'); } } if (item.complexity !== undefined) { if (item.complexity.$invalid) { - return t('reg.err.complexity') + return t('reg.err.complexity'); } } if (item.complexityUser !== undefined) { if (item.complexityUser.$invalid) { - return t('reg.err.complexityUser') + return t('reg.err.complexityUser'); } } // if (!item.maxLength) { return t('reg.err.notmore') + ` ${item.$params.maxLength.max} ` + t('reg.err.char') } if (item.required !== undefined) { if (item.required.$invalid) { - return t('reg.err.required') + return t('reg.err.required'); } } @@ -5763,25 +5723,25 @@ export const tools = { // console.log(item); } else if (cosa === 'username') { if (item.registereduser.$invalid) { - return t('reg.err.duplicate_username') + return t('reg.err.duplicate_username'); } } else if (cosa === 'aportador_solidario') { // console.log(item); if (item.aportadorexist.$invalid) { // console.log('!item.aportadorexist !') - return t('reg.err.aportador_not_exist') + return t('reg.err.aportador_not_exist'); } - } else if ((cosa === 'name') || (cosa === 'surname')) { + } else if (cosa === 'name' || cosa === 'surname') { // console.log(item); } else if (cosa === 'repeatpassword') { if (item.matchText) { if (item.matchText.$invalid) { - return t('reg.err.sameaspassword') + return t('reg.err.sameaspassword'); } } } - return '' + return ''; } catch (error) { // console.log("ERR : " + error); } @@ -5789,132 +5749,133 @@ export const tools = { array_move(arr: any, old_index: number, new_index: number) { if (new_index >= arr.length) { - let k: any = new_index - arr.length + 1 + let k: any = new_index - arr.length + 1; while (k--) { - arr.push(undefined) + arr.push(undefined); } } - arr.splice(new_index, 0, arr.splice(old_index, 1)[0]) - return arr // for testing + arr.splice(new_index, 0, arr.splice(old_index, 1)[0]); + return arr; // for testing }, getColByLevel(level: number) { - let col = '' + let col = ''; if (level === 0) { - col = 'grey-5' + col = 'grey-5'; } else if (level === 1) { - col = 'red-5' + col = 'red-5'; } else if (level === 2) { - col = 'orange-5' + col = 'orange-5'; } else if (level === 3) { - col = 'yellow-5' + col = 'yellow-5'; } else if (level === 4) { - col = 'blue-5' + col = 'blue-5'; } else if (level === 5) { - col = 'green-5' + col = 'green-5'; } - return col + return col; }, baseurl(folder: string) { - return folder.substring(0, folder.lastIndexOf('/')) + return folder.substring(0, folder.lastIndexOf('/')); }, getLastItem(thePath: string) { - return thePath.substring(thePath.lastIndexOf('/') + 1) + return thePath.substring(thePath.lastIndexOf('/') + 1); }, async registeredemail(email: string) { - - const VALIDATE_USER_URL = this.getServerHost() + '/email/ck' + const VALIDATE_USER_URL = this.getServerHost() + '/email/ck'; const onSuccess = (res: AxiosResponse) => { - return res.status !== PayloadMessageTypes.statusfound - } + return res.status !== PayloadMessageTypes.statusfound; + }; - console.log('registeredemail', email) - return Axios.post(VALIDATE_USER_URL, { idapp: this.getEnv('VITE_APP_ID'), email, key: import.meta.env.VITE_PAO_APP_ID }) + console.log('registeredemail', email); + return Axios.post(VALIDATE_USER_URL, { + idapp: this.getEnv('VITE_APP_ID'), + email, + key: import.meta.env.VITE_PAO_APP_ID, + }) .then(onSuccess) .catch((err) => { - return true - }) - + return true; + }); }, async registeredusername(username: string) { - - console.log('registeredusername', username) - const VALIDATE_USER_URL = this.getServerHost() + '' + console.log('registeredusername', username); + const VALIDATE_USER_URL = this.getServerHost() + ''; const onSuccess = (res: AxiosResponse) => { - return res.status === PayloadMessageTypes.statusfound - } + return res.status === PayloadMessageTypes.statusfound; + }; return Axios.get(VALIDATE_USER_URL + '/users/' + this.getEnv('VITE_APP_ID') + '/' + username) .then(onSuccess) .catch((err) => { - return false - }) - + return false; + }); }, isEmail(email: string) { - const res = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ - return res.test(String(email).toLowerCase()) + const res = + /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return res.test(String(email).toLowerCase()); }, addToMyFriends($q: any, username: string, usernameDest: string) { - //T_TOLTO - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); $q.dialog({ message: t('db.domanda_addtofriend', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETFRIEND, null) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETFRIEND, null) .then((res: any) => { if (res) { - notifStore.updateNotification = true - userStore.my.profile.friends = [...userStore.my.profile.friends, res] - userStore.my.profile.req_friends = userStore.my.profile.req_friends.filter((rec: IFriends) => rec.username !== usernameDest) - this.showPositiveNotif($q, t('db.addedfriend')) + notifStore.updateNotification = true; + userStore.my.profile.friends = [...userStore.my.profile.friends, res]; + userStore.my.profile.req_friends = userStore.my.profile.req_friends.filter( + (rec: IFriends) => rec.username !== usernameDest + ); + this.showPositiveNotif($q, t('db.addedfriend')); } - }) - }) + }); + }); }, addToMyTrust($q: any, username: string, usernameDest: string, value: boolean) { - //T_TOLTO - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); $q.dialog({ message: t(value ? 'db.domanda_trusted' : 'db.domanda_reject', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETTRUST, value) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETTRUST, value) .then((res: any) => { if (res) { - userStore.my.profile.userstoverify = userStore.my.profile.userstoverify.filter((rec: any) => rec.username !== usernameDest) + userStore.my.profile.userstoverify = userStore.my.profile.userstoverify.filter( + (rec: any) => rec.username !== usernameDest + ); - if (value) - this.showPositiveNotif($q, t('db.enabled_to_app', { username: usernameDest })) - else - this.showNegativeNotif($q, t('db.rejected_to_app', { username: usernameDest })) + if (value) this.showPositiveNotif($q, t('db.enabled_to_app', { username: usernameDest })); + else this.showNegativeNotif($q, t('db.rejected_to_app', { username: usernameDest })); } - }) - }) + }); + }); }, removeFromMyFriends($q: any, username: string, usernameDest: string) { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO @@ -5922,936 +5883,973 @@ export const tools = { message: t('db.domanda_removefriend', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, null).then((res) => { - if (res) { - userStore.my.profile.friends = userStore.my.profile.friends.filter((rec: IFriends) => rec.username !== usernameDest) - this.showPositiveNotif($q, t('db.removedfriend')) - } - }) - }) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, null) + .then((res) => { + if (res) { + userStore.my.profile.friends = userStore.my.profile.friends.filter( + (rec: IFriends) => rec.username !== usernameDest + ); + this.showPositiveNotif($q, t('db.removedfriend')); + } + }); + }); }, addToMyHandShake($q: any, username: string, usernameDest: string) { //T_TOLTO - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); $q.dialog({ message: t('db.domanda_addtohandshake', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('handshake.strettadimano') + title: t('handshake.strettadimano'), }).onOk(() => { - - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETHANDSHAKE, null) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETHANDSHAKE, null) .then((res: any) => { if (res) { - notifStore.updateNotification = true - userStore.my.profile.handshake = res.myuser.profile.handshake - userStore.userprofile = res.userprofile - this.showPositiveNotif($q, t('db.addedhandshake')) + notifStore.updateNotification = true; + userStore.my.profile.handshake = res.myuser.profile.handshake; + userStore.userprofile = res.userprofile; + this.showPositiveNotif($q, t('db.addedhandshake')); } - }) - }) + }); + }); }, removeFromMyHandShake($q: any, username: string, usernameDest: string) { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_removehandshake', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE, null).then((res) => { - if (res) { - userStore.userprofile.profile.handshake = userStore.userprofile.profile.handshake.filter((rec: IFriends) => rec.username !== username) - this.showPositiveNotif($q, t('db.removedhandshake')) - } - }) - }) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE, null) + .then((res) => { + if (res) { + userStore.userprofile.profile.handshake = userStore.userprofile.profile.handshake.filter( + (rec: IFriends) => rec.username !== username + ); + this.showPositiveNotif($q, t('db.removedhandshake')); + } + }); + }); }, blockUser($q: any, username: string, usernameDest: string) { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_blockuser', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.BLOCK_USER, null).then((res: any) => { - if (res) { - userStore.my.profile.friends = userStore.my.profile.friends.filter((rec: IFriends) => rec.username !== usernameDest) - this.showPositiveNotif($q, t('db.blockedfriend')) - } - }) - }) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.BLOCK_USER, null) + .then((res: any) => { + if (res) { + userStore.my.profile.friends = userStore.my.profile.friends.filter( + (rec: IFriends) => rec.username !== usernameDest + ); + this.showPositiveNotif($q, t('db.blockedfriend')); + } + }); + }); }, unblockUser($q: any, username: string, usernameDest: string) { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_unblockuser', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.UNBLOCK_USER, null).then((res: any) => { - if (res) { - this.showPositiveNotif($q, t('db.unblockedfriend')) - } - }) - }) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.UNBLOCK_USER, null) + .then((res: any) => { + if (res) { + this.showPositiveNotif($q, t('db.unblockedfriend')); + } + }); + }); }, - reportUser($q: any, username: string, usernameDest: string) { // Segnala Profilo - const userStore = useUserStore() + reportUser($q: any, username: string, usernameDest: string) { + // Segnala Profilo + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_reportuser', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REPORT_USER, null).then((res: any) => { - if (res) { - this.showPositiveNotif($q, t('db.reporteduser')) - } - }) - }) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REPORT_USER, null) + .then((res: any) => { + if (res) { + this.showPositiveNotif($q, t('db.reporteduser')); + } + }); + }); }, refuseReqFriends($q: any, username: string, usernameDest: string) { - //T_TOLTO - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); $q.dialog({ message: t('db.domanda_revoke_friend', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, null).then((res) => { - if (res) { - notifStore.updateNotification = true - userStore.my.profile.req_friends = userStore.my.profile.req_friends.filter((user: IFriends) => user.username !== usernameDest) - this.showPositiveNotif($q, t('db.removedfriend')) - } - }) - }) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, null) + .then((res) => { + if (res) { + notifStore.updateNotification = true; + userStore.my.profile.req_friends = userStore.my.profile.req_friends.filter( + (user: IFriends) => user.username !== usernameDest + ); + this.showPositiveNotif($q, t('db.removedfriend')); + } + }); + }); }, updateMyData(res: any) { - const userStore = useUserStore() - const circuitStore = useCircuitStore() - const globalStore = useGlobalStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const circuitStore = useCircuitStore(); + const globalStore = useGlobalStore(); + const notifStore = useNotifStore(); // console.log('updateMyData: ', res) if (res && res.arrrecnotif) { - notifStore.updateArrRecNotifFromServer(res.arrrecnotif) + notifStore.updateArrRecNotifFromServer(res.arrrecnotif); } if (res && res.arrrecnotifcoins) { - notifStore.updateArrRecNotifCoinsFromServer(res.arrrecnotifcoins) + notifStore.updateArrRecNotifCoinsFromServer(res.arrrecnotifcoins); } if (res && res.userprofile) { // console.log('updateMyData', res.userprofile) - userStore.my.profile = res.userprofile + userStore.my.profile = res.userprofile; if (res.listcircuits) { - circuitStore.listcircuits = res.listcircuits + circuitStore.listcircuits = res.listcircuits; // console.log('circuitStore.listcircuits', circuitStore.listcircuits) } if (res.mygroups) { - globalStore.mygroups = res.mygroups + globalStore.mygroups = res.mygroups; } } }, addToMyCircuits($q: any, username: string, circuitname: string) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_addtocircuit', { username, circuitname }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.SET, true) - .then((res: any) => { - if (res && res.result) { - this.updateMyData(res) - notifStore.updateNotification = true - if (res.circuit) { - if (userStore.my.profile.mycircuits) - userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit] - else - userStore.my.profile.mycircuits = [res] - } - this.showPositiveNotif($q, t('db.addedcircuit', { circuitname })) + userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.SET, true).then((res: any) => { + if (res && res.result) { + this.updateMyData(res); + notifStore.updateNotification = true; + if (res.circuit) { + if (userStore.my.profile.mycircuits) + userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit]; + else userStore.my.profile.mycircuits = [res]; } - }) - }) + this.showPositiveNotif($q, t('db.addedcircuit', { circuitname })); + } + }); + }); }, addGroupToMyCircuits($q: any, groupname: string, circuitname: string) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_addgrouptocircuit', { groupname, circuitname }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - const extrarec = { groupname, - } + }; - userStore.setCircuitCmd($q, t, userStore.my.username, circuitname, shared_consts.CIRCUITCMD.SET, true, extrarec) + userStore + .setCircuitCmd($q, t, userStore.my.username, circuitname, shared_consts.CIRCUITCMD.SET, true, extrarec) .then((res: any) => { if (res && res.result) { - this.updateMyData(res) - notifStore.updateNotification = true + this.updateMyData(res); + notifStore.updateNotification = true; if (res.circuit) { if (userStore.my.profile.mycircuits) - userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit] - else - userStore.my.profile.mycircuits = [res] + userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit]; + else userStore.my.profile.mycircuits = [res]; } - this.showPositiveNotif($q, t('db.addedcircuit', { circuitname })) + this.showPositiveNotif($q, t('db.addedcircuit', { circuitname })); } - }) - }) + }); + }); }, addFidoToMyCircuits($q: any, username: string, circuitname: string) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_addfidotocircuit', { username, circuitname }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - const extrarec = { groupname: '', circuitnameDest: circuitname, - } + }; - userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.SETFIDO, true, extrarec) + userStore + .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.SETFIDO, true, extrarec) .then((res: any) => { if (res && res.result) { - this.updateMyData(res) - notifStore.updateNotification = true + this.updateMyData(res); + notifStore.updateNotification = true; if (res.circuit) { if (userStore.my.profile.mycircuits) - userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit] - else - userStore.my.profile.mycircuits = [res] + userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit]; + else userStore.my.profile.mycircuits = [res]; } - this.showPositiveNotif($q, t('db.addedfidocircuit', { circuitname })) + this.showPositiveNotif($q, t('db.addedfidocircuit', { circuitname })); } - }) - }) + }); + }); }, addFidoGroupToMyCircuits($q: any, groupname: string, circuitname: string) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_addgrouptocircuit', { groupname, circuitname }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - const extrarec = { groupname, - } + }; - userStore.setCircuitCmd($q, t, userStore.my.username, circuitname, shared_consts.CIRCUITCMD.SETFIDO, true, extrarec) + userStore + .setCircuitCmd($q, t, userStore.my.username, circuitname, shared_consts.CIRCUITCMD.SETFIDO, true, extrarec) .then((res: any) => { if (res && res.result) { - this.updateMyData(res) - notifStore.updateNotification = true + this.updateMyData(res); + notifStore.updateNotification = true; if (res.circuit) { if (userStore.my.profile.mycircuits) - userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit] - else - userStore.my.profile.mycircuits = [res] + userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit]; + else userStore.my.profile.mycircuits = [res]; } - this.showPositiveNotif($q, t('db.addedfidocircuit', { circuitname })) + this.showPositiveNotif($q, t('db.addedfidocircuit', { circuitname })); } - }) - }) + }); + }); }, addToMyGroups($q: any, username: string, groupnameDest: string) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_addtogroup', { username, groupname: groupnameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.SETGROUP, true) + userStore + .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.SETGROUP, true) .then((res: any) => { if (res) { - notifStore.updateNotification = true - if (userStore.my.profile.mygroups) - userStore.my.profile.mygroups = [...userStore.my.profile.mygroups, res] - else - userStore.my.profile.mygroups = [res] - this.showPositiveNotif($q, t('db.addedgroup')) + notifStore.updateNotification = true; + if (userStore.my.profile.mygroups) userStore.my.profile.mygroups = [...userStore.my.profile.mygroups, res]; + else userStore.my.profile.mygroups = [res]; + this.showPositiveNotif($q, t('db.addedgroup')); } - }) - }) + }); + }); }, - acceptCoins($q: any, username: string, notif: any) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO - notif.extrarec.notifId = notif._id - notif.extrarec.lastdr = notifStore.getLastDataRead(username) + notif.extrarec.notifId = notif._id; + notif.extrarec.lastdr = notifStore.getLastDataRead(username); - userStore.setCircuitCmd($q, t, username, notif.extrarec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT, 0, notif.extrarec) + userStore + .setCircuitCmd( + $q, + t, + username, + notif.extrarec.circuitname, + shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT, + 0, + notif.extrarec + ) .then((res: any) => { if (res) { - this.updateMyData(res) + this.updateMyData(res); if (res.cansend) { - console.log('useraccounts', userStore.my.profile.useraccounts) - this.showPositiveNotif($q, t('circuit.coins_accepted')) + console.log('useraccounts', userStore.my.profile.useraccounts); + this.showPositiveNotif($q, t('circuit.coins_accepted')); } else { - this.showNegativeNotif($q, res.errormsg) + this.showNegativeNotif($q, res.errormsg); } } - }) + }); }, refuseCoins($q: any, username: string, notif: any) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO - notif.extrarec.notifId = notif._id - notif.extrarec.lastdr = notifStore.getLastDataRead(username) - userStore.setCircuitCmd($q, t, username, notif.extrarec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_REFUSE, 0, notif.extrarec) + notif.extrarec.notifId = notif._id; + notif.extrarec.lastdr = notifStore.getLastDataRead(username); + userStore + .setCircuitCmd( + $q, + t, + username, + notif.extrarec.circuitname, + shared_consts.CIRCUITCMD.SENDCOINS_REFUSE, + 0, + notif.extrarec + ) .then((res: any) => { if (res && res.result) { - this.updateMyData(res) - this.showPositiveNotif($q, t('circuit.coins_refused')) + this.updateMyData(res); + this.showPositiveNotif($q, t('circuit.coins_refused')); } - }) + }); }, refuseReqGroup($q: any, username: string, groupnameDest: string) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_refuse_group', { username, groupname: groupnameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REFUSE_REQ_GROUP, null).then((res) => { - if (res) { - notifStore.updateNotification = true - if (username === userStore.my.username) { - userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IGroupShort) => rec.groupname !== groupnameDest) + userStore + .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REFUSE_REQ_GROUP, null) + .then((res) => { + if (res) { + notifStore.updateNotification = true; + if (username === userStore.my.username) { + userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter( + (rec: IGroupShort) => rec.groupname !== groupnameDest + ); + } + this.showPositiveNotif($q, t('db.refusedgroup', { username })); } - this.showPositiveNotif($q, t('db.refusedgroup', { username })) - } - }) - }) + }); + }); }, blockGroup($q: any, username: string, usernameDest: string) { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_blockgroup', { groupname: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { userStore.setGroupsCmd($q, t, username, usernameDest, shared_consts.GROUPSCMD.BLOCK_GROUP, null).then((res) => { if (res) { - userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter((rec: IMyGroup) => rec.groupname !== usernameDest) - this.showPositiveNotif($q, t('db.blockedgroup')) + userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter( + (rec: IMyGroup) => rec.groupname !== usernameDest + ); + this.showPositiveNotif($q, t('db.blockedgroup')); } - }) - }) + }); + }); }, removeFromMyGroups($q: any, username: string, groupnameDest: string, domanda: any = '') { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: domanda ? domanda : t('db.domanda_removegroup', { username }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP, null).then((res) => { - if (res) { - if (userStore.my.profile.mygroups) { - if (username === userStore.my.username) { - userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest) + userStore + .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP, null) + .then((res) => { + if (res) { + if (userStore.my.profile.mygroups) { + if (username === userStore.my.username) { + userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter( + (rec: IMyGroup) => rec.groupname !== groupnameDest + ); + } } + this.showPositiveNotif($q, t('db.removedgroup')); } - this.showPositiveNotif($q, t('db.removedgroup')) - } - }) - }) + }); + }); }, addtoAdminOfMyGroup($q: any, username: string, groupnameDest: string, domanda: any = '') { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: domanda ? domanda : t('db.domanda_addadminofmygroup', { username, groupnameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.ADDADMIN_OFMYGROUP, null).then((res) => { - if (res) { - const mygrp = userStore.my.profile.manage_mygroups.find((rec: IMyGroup) => rec.groupname === groupnameDest) - console.log('mygrp', mygrp) - if (mygrp && mygrp.admins) { - mygrp.admins = [...mygrp.admins, { username, date: new Date }] - console.log('mygrp.admins', mygrp.admins) - this.showPositiveNotif($q, t('db.addedtoadmin', { username })) + userStore + .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.ADDADMIN_OFMYGROUP, null) + .then((res) => { + if (res) { + const mygrp = userStore.my.profile.manage_mygroups.find((rec: IMyGroup) => rec.groupname === groupnameDest); + console.log('mygrp', mygrp); + if (mygrp && mygrp.admins) { + mygrp.admins = [...mygrp.admins, { username, date: new Date() }]; + console.log('mygrp.admins', mygrp.admins); + this.showPositiveNotif($q, t('db.addedtoadmin', { username })); + } } - } - }) - }) + }); + }); }, removeAdminOfMyGroup($q: any, username: string, groupnameDest: string, domanda: any = '') { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: domanda ? domanda : t('db.domanda_removeadminofmygroup', { username, groupnameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REMOVEADMIN_OFMYGROUP, null).then((res) => { - if (res) { - const mygrp = userStore.my.profile.manage_mygroups.find((rec: IMyGroup) => rec.groupname === groupnameDest) - console.log('mygrp', mygrp) - if (mygrp && mygrp.admins) { - mygrp.admins = mygrp.admins.filter((rec: any) => rec.username !== username) - console.log('mygrp.admins', mygrp.admins) - this.showPositiveNotif($q, t('db.removedtoadmin', { username })) + userStore + .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REMOVEADMIN_OFMYGROUP, null) + .then((res) => { + if (res) { + const mygrp = userStore.my.profile.manage_mygroups.find((rec: IMyGroup) => rec.groupname === groupnameDest); + console.log('mygrp', mygrp); + if (mygrp && mygrp.admins) { + mygrp.admins = mygrp.admins.filter((rec: any) => rec.username !== username); + console.log('mygrp.admins', mygrp.admins); + this.showPositiveNotif($q, t('db.removedtoadmin', { username })); + } } - } - }) - }) + }); + }); }, DeleteGroup($q: any, username: string, groupnameDest: string, domanda: any = '') { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: domanda ? domanda : t('db.domanda_remove_group', { groupname: groupnameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.DELETE_GROUP, null).then((res) => { if (res) { if (userStore.my.profile.mygroups) { - userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest) - this.showPositiveNotif($q, t('db.deletedgroup')) + userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter( + (rec: IMyGroup) => rec.groupname !== groupnameDest + ); + this.showPositiveNotif($q, t('db.deletedgroup')); } } - }) - }) + }); + }); }, setRequestFriendship($q: any, username: string, usernameDest: string, value: boolean) { - - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO - let msg = '' + let msg = ''; if (value) { - msg = t('db.domanda_ask_friend', { username: usernameDest }) + msg = t('db.domanda_ask_friend', { username: usernameDest }); } else { - msg = t('db.domanda_revoke_friend', { username: usernameDest }) + msg = t('db.domanda_revoke_friend', { username: usernameDest }); } $q.dialog({ message: msg, ok: { label: t('dialog.yes'), - push: true + push: true, }, cancel: { - label: t('dialog.cancel') + label: t('dialog.cancel'), }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REQFRIEND, value) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REQFRIEND, value) .then((res: any) => { if (res) { if (value) { // ADD to req Friends - userStore.my.profile.asked_friends.push(res) - this.showPositiveNotif($q, t('db.askedtofriend', { username: usernameDest })) + userStore.my.profile.asked_friends.push(res); + this.showPositiveNotif($q, t('db.askedtofriend', { username: usernameDest })); } else { // REMOVE to req Friends - userStore.my.profile.asked_friends = userStore.my.profile.asked_friends.filter((rec: IUserFields) => rec.username !== usernameDest) - this.showPositiveNotif($q, t('db.revoketofriend', { username: usernameDest })) + userStore.my.profile.asked_friends = userStore.my.profile.asked_friends.filter( + (rec: IUserFields) => rec.username !== usernameDest + ); + this.showPositiveNotif($q, t('db.revoketofriend', { username: usernameDest })); } - } else { - this.showNegativeNotif($q, t('db.recfailed')) + this.showNegativeNotif($q, t('db.recfailed')); } - }) - }) + }); + }); }, setHandShake($q: any, username: string, usernameDest: string, value: boolean) { //T_TOLTO - const userStore = useUserStore() + const userStore = useUserStore(); - let msg = '' + let msg = ''; if (value) { - msg = t('db.domanda_ask_handshake', { username: usernameDest }) + msg = t('db.domanda_ask_handshake', { username: usernameDest }); } else { - msg = t('db.domanda_revoke_handshake', { username: usernameDest }) + msg = t('db.domanda_revoke_handshake', { username: usernameDest }); } $q.dialog({ message: msg, ok: { label: t('dialog.yes'), - push: true + push: true, }, cancel: { - label: t('dialog.cancel') + label: t('dialog.cancel'), }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETHANDSHAKE, value) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETHANDSHAKE, value) .then((res: any) => { if (res) { if (value) { // ADD to req HandShake - this.showPositiveNotif($q, t('db.askedtohandshake', { username: usernameDest })) + this.showPositiveNotif($q, t('db.askedtohandshake', { username: usernameDest })); } else { // REMOVE to req HandShake - this.showPositiveNotif($q, t('db.revoketohandshake', { username: usernameDest })) + this.showPositiveNotif($q, t('db.revoketohandshake', { username: usernameDest })); } - } else { - this.showNegativeNotif($q, t('db.recfailed')) + this.showNegativeNotif($q, t('db.recfailed')); } - }) - }) + }); + }); }, SendMsgRisItalia($q: any, usernameDest: string) { - - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO - const username = userStore.my.username + const username = userStore.my.username; - userStore.setSendCmd($q, t, username, usernameDest, shared_consts.CallFunz.ENTRA_RIS_ITALIA, null) + userStore + .setSendCmd($q, t, username, usernameDest, shared_consts.CallFunz.ENTRA_RIS_ITALIA, null) .then((res: any) => { if (res && res.result) { - this.updateMyData(res) - this.showPositiveNotif($q, res.popupOnApp) + this.updateMyData(res); + this.showPositiveNotif($q, res.popupOnApp); } - }) + }); }, setRequestGroup($q: any, username: string, groupnameDest: string, value: boolean) { //T_TOLTO - const userStore = useUserStore() + const userStore = useUserStore(); - let msg = '' + let msg = ''; if (value) { - msg = t('db.domanda_ask_group', { groupname: groupnameDest }) + msg = t('db.domanda_ask_group', { groupname: groupnameDest }); } else { - msg = t('db.domanda_revoke_group', { groupname: groupnameDest }) + msg = t('db.domanda_revoke_group', { groupname: groupnameDest }); } $q.dialog({ message: msg, ok: { label: t('dialog.yes'), - push: true + push: true, }, cancel: { - label: t('dialog.cancel') + label: t('dialog.cancel'), }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REQGROUP, value) + userStore + .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REQGROUP, value) .then((res: any) => { if (res) { if (value) { // ADD to req Friends - userStore.my.profile.asked_groups.push(res) - this.showPositiveNotif($q, t('db.askedtogroup', { groupname: groupnameDest })) + userStore.my.profile.asked_groups.push(res); + this.showPositiveNotif($q, t('db.askedtogroup', { groupname: groupnameDest })); } else { // REMOVE to req Friends - userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IGroupShort) => rec.groupname !== groupnameDest) - this.showPositiveNotif($q, t('db.revoketogroup', { groupname: groupnameDest })) + userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter( + (rec: IGroupShort) => rec.groupname !== groupnameDest + ); + this.showPositiveNotif($q, t('db.revoketogroup', { groupname: groupnameDest })); } - } else { - this.showNegativeNotif($q, t('db.recfailed')) + this.showNegativeNotif($q, t('db.recfailed')); } - }) - }) + }); + }); }, cancelReqFriends($q: any, username: string, usernameDest: string) { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_cancel_req_friend', { username: usernameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND, null).then((res) => { - if (res) { - userStore.my.profile.asked_friends = userStore.my.profile.asked_friends.filter((rec: IUserFields) => rec.username !== usernameDest) - this.showPositiveNotif($q, t('db.cancel_req_friend')) - } - }) - }) + userStore + .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND, null) + .then((res) => { + if (res) { + userStore.my.profile.asked_friends = userStore.my.profile.asked_friends.filter( + (rec: IUserFields) => rec.username !== usernameDest + ); + this.showPositiveNotif($q, t('db.cancel_req_friend')); + } + }); + }); }, cancelReqGroups($q: any, username: string, groupnameDest: string) { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: t('db.domanda_cancel_req_group', { username, groupname: groupnameDest }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.CANCEL_REQ_GROUP, null).then((res) => { - if (res) { - if (username === userStore.my.username) { - userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IGroupShort) => rec.groupname !== groupnameDest) + userStore + .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.CANCEL_REQ_GROUP, null) + .then((res) => { + if (res) { + if (username === userStore.my.username) { + userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter( + (rec: IGroupShort) => rec.groupname !== groupnameDest + ); + } + this.showPositiveNotif($q, t('db.cancel_req_group')); } - this.showPositiveNotif($q, t('db.cancel_req_group')) - } - }) - }) + }); + }); }, CSVToArray(strData: any, strDelimiter: string) { // Check to see if the delimiter is defined. If not, // then default to comma. - strDelimiter = (strDelimiter || ',') + strDelimiter = strDelimiter || ','; // Create a regular expression to parse the CSV values. const objPattern = new RegExp( - ( - // Delimiters. - '(\\' + strDelimiter + '|\r?\\n|\\r|^)' + - + // Delimiters. + '(\\' + + strDelimiter + + '|\r?\\n|\\r|^)' + // Quoted fields. '(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|' + - // Standard fields. - '([^\"\\' + strDelimiter + '\\r\\n]*))' - ), + '([^\"\\' + + strDelimiter + + '\\r\\n]*))', 'gi' - ) - + ); // Create an array to hold our data. Give the array // a default empty first row. - const arrData: any = [[]] + const arrData: any = [[]]; // Create an array to hold our individual pattern // matching groups. - let arrMatches = null - + let arrMatches = null; // Keep looping over the regular expression matches // until we can no longer find a match. // eslint-disable-next-line no-cond-assign - while (arrMatches = objPattern.exec(strData)) { - + while ((arrMatches = objPattern.exec(strData))) { // Get the delimiter that was found. - const strMatchedDelimiter = arrMatches[1] + const strMatchedDelimiter = arrMatches[1]; // Check to see if the given delimiter has a length // (is not the start of string) and if it matches // field delimiter. If id does not, then we know // that this delimiter is a row delimiter. - if ( - strMatchedDelimiter.length && - strMatchedDelimiter !== strDelimiter - ) { + if (strMatchedDelimiter.length && strMatchedDelimiter !== strDelimiter) { // Since we have reached a new row of data, // add an empty row to our data array. - arrData.push([]) - + arrData.push([]); } - let strMatchedValue: any + let strMatchedValue: any; // Now that we have our delimiter out of the way, // let's check to see which kind of value we // captured (quoted or unquoted). if (arrMatches[2]) { - // We found a quoted value. When we capture // this value, unescape any double quotes. - strMatchedValue = arrMatches[2].replace( - new RegExp('\"\"', 'g'), - '\"' - ) - + strMatchedValue = arrMatches[2].replace(new RegExp('\"\"', 'g'), '\"'); } else { - // We found a non-quoted value. - strMatchedValue = arrMatches[3] - + strMatchedValue = arrMatches[3]; } - // Now that we have our value string, let's add // it to the data array. - arrData[arrData.length - 1].push(strMatchedValue) + arrData[arrData.length - 1].push(strMatchedValue); } // Return the parsed data. - return (arrData) + return arrData; }, getValue(myrow: any, field: string, subfield: string) { - let myvalue = '' + let myvalue = ''; if (subfield !== '') { if (myrow[field] === undefined) { - myrow[field] = {} - myvalue = '' + myrow[field] = {}; + myvalue = ''; } else { - myvalue = myrow[field][subfield] + myvalue = myrow[field][subfield]; } } else { - if (field !== '') - myvalue = myrow[field] + if (field !== '') myvalue = myrow[field]; else { // @ts-ignore - myvalue = myrow + myvalue = myrow; } } if (Array.isArray(myvalue)) { - return myvalue.length > 0 ? myvalue : '' + return myvalue.length > 0 ? myvalue : ''; } else { - return myvalue + return myvalue; } }, addslashes(str: string) { // eslint-disable-next-line no-control-regex - return (str + '').replace(/[\\"']/g, (m) => '\\' + m).replace(/\u0000/g, '\\0') + return (str + '').replace(/[\\"']/g, (m) => '\\' + m).replace(/\u0000/g, '\\0'); }, checkIfShowField(col: IColGridTable, tipovis: number, visulabel: boolean, valuePresent: any = '') { - - let check = (col.visible) + let check = col.visible; if (tipovis === this.TIPOVIS_NEW_RECORD) { - check = check && this.isBitActive(col.showWhen, costanti.showWhen.NewRec) + check = check && this.isBitActive(col.showWhen, costanti.showWhen.NewRec); } else if (tipovis === this.TIPOVIS_EDIT_RECORD) { - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); - check = check && this.isBitActive(col.showWhen, costanti.showWhen.InEdit) || (this.isAdmin() && globalStore.editOn) + check = + (check && this.isBitActive(col.showWhen, costanti.showWhen.InEdit)) || (this.isAdmin() && globalStore.editOn); } else if (tipovis === this.TIPOVIS_SHOW_RECORD) { if (this.isBitActive(col.showWhen, costanti.showWhen.InView_OnlyifExist)) { - check = check && valuePresent && valuePresent !== costanti.FILTER_NESSUNO + check = check && valuePresent && valuePresent !== costanti.FILTER_NESSUNO; } else { - check = check && this.isBitActive(col.showWhen, costanti.showWhen.InView) + check = check && this.isBitActive(col.showWhen, costanti.showWhen.InView); } } else if (tipovis === this.TIPOVIS_SHOW_INPAGE) { - check = check && this.isBitActive(col.showWhen, costanti.showWhen.InPage) + check = check && this.isBitActive(col.showWhen, costanti.showWhen.InPage); } if (col.onlyforAdmin) { - check = check && this.isAdmin() + check = check && this.isAdmin(); } - return check - + return check; // (!col.noShowView || (col.noShowView && isInModif)) || // (!visulabel && !col.showOnlyNewRec && !col.noShowView) }, iAmAdminGroup(groupname: string) { - const userStore = useUserStore() + const userStore = useUserStore(); - let risultato = false + let risultato = false; if (userStore.my.profile.manage_mygroups) { const ris = userStore.my.profile.manage_mygroups.find((grp: IMyGroup) => { if (grp.groupname === groupname) { - return true + return true; } - }) + }); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username) - risultato = !!isadmin + const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username); + risultato = !!isadmin; } - } - return risultato - + return risultato; }, setRequestCircuit($q: any, username: string, circuitname: string, value: boolean, groupname?: string) { - - const userStore = useUserStore() - const circuitStore = useCircuitStore() + const userStore = useUserStore(); + const circuitStore = useCircuitStore(); //T_TOLTO - userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REQ, value, { groupname }) + userStore + .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REQ, value, { groupname }) .then((res: any) => { if (res) { if (value) { + const mycircuit = circuitStore.getCircuitByName(circuitname); - const mycircuit = circuitStore.getCircuitByName(circuitname) - - let msg = t('circuit.already_entered', { circuitname }) + let msg = t('circuit.already_entered', { circuitname }); if (mycircuit?.askManagerToEnter) { - msg = t('circuit.askedto', { circuitname }) + msg = t('circuit.askedto', { circuitname }); } // ADD to req - userStore.my.profile.asked_circuits.push(res.circuit) - this.showPositiveNotif($q, msg) + userStore.my.profile.asked_circuits.push(res.circuit); + this.showPositiveNotif($q, msg); } else { // REMOVE to req - userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname) - this.showPositiveNotif($q, t('circuit.revoketo', { circuitname })) + userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter( + (rec: ICircuit) => rec.name !== circuitname + ); + this.showPositiveNotif($q, t('circuit.revoketo', { circuitname })); } - this.updateMyData(res) + this.updateMyData(res); } else { - this.showNegativeNotif($q, t('db.recfailed')) + this.showNegativeNotif($q, t('db.recfailed')); } - }) + }); }, getDestStrByExtraRec(extrarec: any) { - return extrarec.groupdest ? extrarec.groupdest : (extrarec.contoComDest ? extrarec.contoComDest : extrarec.dest) + return extrarec.groupdest ? extrarec.groupdest : extrarec.contoComDest ? extrarec.contoComDest : extrarec.dest; }, getOrigStrBySendNotif(extrarec: any) { - return extrarec.grouporig ? extrarec.grouporig : (extrarec.contoComOrig ? extrarec.contoComOrig : extrarec.sender) + return extrarec.grouporig ? extrarec.grouporig : extrarec.contoComOrig ? extrarec.contoComOrig : extrarec.sender; }, async sendCoinsByCircuit($q: any, $router: any, circuit: ICircuit, sendcoinrec: ISendCoin) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO - const username = userStore.my.username + const username = userStore.my.username; - const orig = sendcoinrec.grouporig ? sendcoinrec.grouporig : (sendcoinrec.contoComOrig ? sendcoinrec.contoComOrig : '') - const dest = sendcoinrec.groupdest ? sendcoinrec.groupdest : (sendcoinrec.contoComDest ? sendcoinrec.contoComDest : sendcoinrec.dest) + const orig = sendcoinrec.grouporig + ? sendcoinrec.grouporig + : sendcoinrec.contoComOrig + ? sendcoinrec.contoComOrig + : ''; + const dest = sendcoinrec.groupdest + ? sendcoinrec.groupdest + : sendcoinrec.contoComDest + ? sendcoinrec.contoComDest + : sendcoinrec.dest; - let msg = '' + let msg = ''; if (orig) { - msg = t('circuit.question_sendcoinsto_from', { coin: circuit.symbol, from: orig, dest, qty: sendcoinrec.qty }) + msg = t('circuit.question_sendcoinsto_from', { coin: circuit.symbol, from: orig, dest, qty: sendcoinrec.qty }); } else { - msg = t('circuit.question_sendcoinsto', { coin: circuit.symbol, dest, qty: sendcoinrec.qty }) + msg = t('circuit.question_sendcoinsto', { coin: circuit.symbol, dest, qty: sendcoinrec.qty }); } - return $q.dialog({ - message: msg, - ok: { - label: t('dialog.yes'), - push: true - }, - cancel: { - label: t('dialog.cancel') - }, - title: t('db.domanda') - }).onOk(() => { - - return userStore.setCircuitCmd($q, t, username, sendcoinrec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_REQ, true, sendcoinrec) - .then((res: any) => { - console.log('setCircuitCmd ', res) - if (res && res.cansend) { - if (res.useraccounts && res.useraccounts.length > 0) { - userStore.my.profile.useraccounts = res.useraccounts + return $q + .dialog({ + message: msg, + ok: { + label: t('dialog.yes'), + push: true, + }, + cancel: { + label: t('dialog.cancel'), + }, + title: t('db.domanda'), + }) + .onOk(() => { + return userStore + .setCircuitCmd( + $q, + t, + username, + sendcoinrec.circuitname, + shared_consts.CIRCUITCMD.SENDCOINS_REQ, + true, + sendcoinrec + ) + .then((res: any) => { + console.log('setCircuitCmd ', res); + if (res && res.cansend) { + if (res.useraccounts && res.useraccounts.length > 0) { + userStore.my.profile.useraccounts = res.useraccounts; + } + $router.push('/circuits'); + this.showPositiveNotif( + $q, + t('circuit.coins_sent', { qty: sendcoinrec.qty, symbol: circuit.symbol, dest }) + ); + //this.showPositiveNotif($q, t('circuit.coins_sendrequest_sent')) + } else { + this.showNegativeNotif($q, res.errormsg); } - $router.push('/circuits') - this.showPositiveNotif($q, t('circuit.coins_sent', { qty: sendcoinrec.qty, symbol: circuit.symbol, dest })) - //this.showPositiveNotif($q, t('circuit.coins_sendrequest_sent')) - } else { - this.showNegativeNotif($q, res.errormsg) - } - notifStore.updateNotification = true - this.updateMyData(res) - }) - }) + notifStore.updateNotification = true; + this.updateMyData(res); + }); + }); /* return await new Promise((resolve, reject) => { resolve(false) @@ -6860,162 +6858,167 @@ export const tools = { }, cancelReqCircuit($q: any, username: string, circuitname: string, groupname?: string) { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: t('circuit.domanda_cancel_req', { username, circuitname }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.CANCEL_REQ, null, { groupname }).then((res) => { - if (res && res.result) { - if (username === userStore.my.username) { - userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname) + userStore + .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.CANCEL_REQ, null, { groupname }) + .then((res) => { + if (res && res.result) { + if (username === userStore.my.username) { + userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter( + (rec: ICircuit) => rec.name !== circuitname + ); + } + this.updateMyData(res); + this.showPositiveNotif($q, t('circuit.cancel_req', { circuitname })); } - this.updateMyData(res) - this.showPositiveNotif($q, t('circuit.cancel_req', { circuitname })) - } - }) - }) + }); + }); }, refuseReqCircuit($q: any, username: string, circuitname: string, groupname?: string) { - - const userStore = useUserStore() - const notifStore = useNotifStore() + const userStore = useUserStore(); + const notifStore = useNotifStore(); //T_TOLTO $q.dialog({ message: t('circuit.domanda_refuse_circuit', { username, circuitname }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REFUSE_REQ, null, { groupname }).then((res) => { - if (res && res.result) { - notifStore.updateNotification = true - if (username === userStore.my.username) { - userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname) + userStore + .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REFUSE_REQ, null, { groupname }) + .then((res) => { + if (res && res.result) { + notifStore.updateNotification = true; + if (username === userStore.my.username) { + userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter( + (rec: ICircuit) => rec.name !== circuitname + ); + } + this.showPositiveNotif($q, t('circuit.refusedcircuit', { username })); + this.updateMyData(res); } - this.showPositiveNotif($q, t('circuit.refusedcircuit', { username })) - this.updateMyData(res) - } - }) - }) + }); + }); }, removeFromMyCircuits($q: any, username: string, circuitname: string, groupname?: string, domanda: any = '') { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: domanda ? domanda : t('circuit.domanda_remove', { username }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - - userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST, null, { groupname }).then((res) => { - if (res && res.result) { - if (userStore.my.profile.mycircuits && username === userStore.my.username) { - userStore.my.profile.mycircuits = userStore.my.profile.mycircuits.filter((rec: IMyCircuit) => rec.circuitname !== circuitname) + userStore + .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST, null, { groupname }) + .then((res) => { + if (res && res.result) { + if (userStore.my.profile.mycircuits && username === userStore.my.username) { + userStore.my.profile.mycircuits = userStore.my.profile.mycircuits.filter( + (rec: IMyCircuit) => rec.circuitname !== circuitname + ); + } + this.showPositiveNotif($q, t('circuit.removed')); + this.updateMyData(res); } - this.showPositiveNotif($q, t('circuit.removed')) - this.updateMyData(res) - } - }) - }) + }); + }); }, gestiscoAlmeno1Circuito() { try { - const userStore = useUserStore() + const userStore = useUserStore(); - return userStore.my.profile.manage_mycircuits ? userStore.my.profile.manage_mycircuits.length > 0 : false + return userStore.my.profile.manage_mycircuits ? userStore.my.profile.manage_mycircuits.length > 0 : false; } catch (e) { - return false + return false; } - }, addtoAdminOfCircuit($q: any, username: string, circuitname: string, domanda: any = '') { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: domanda ? domanda : t('circuit.domanda_addadminofcircuit', { username, circuitname }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.ADDADMIN, null).then((res) => { if (res && res.result) { - const mycircuit = userStore.my.profile.manage_mycircuits.find((rec: ICircuit) => rec.name === circuitname) - console.log('mycircuit', mycircuit) + const mycircuit = userStore.my.profile.manage_mycircuits.find((rec: ICircuit) => rec.name === circuitname); + console.log('mycircuit', mycircuit); if (mycircuit && mycircuit.admins) { - mycircuit.admins = [...mycircuit.admins, { username, date: new Date }] - console.log('mycircuit.admins', mycircuit.admins) - this.showPositiveNotif($q, t('db.addedtoadmin', { username })) + mycircuit.admins = [...mycircuit.admins, { username, date: new Date() }]; + console.log('mycircuit.admins', mycircuit.admins); + this.showPositiveNotif($q, t('db.addedtoadmin', { username })); } - this.updateMyData(res) + this.updateMyData(res); } - }) - }) + }); + }); }, removeAdminOfCircuit($q: any, username: string, circuitname: string, domanda: any = '') { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: domanda ? domanda : t('circuit.domanda_removeadminofcircuit', { username, circuitname }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVEADMIN, null).then((res) => { if (res && res.result) { - const mygrp = userStore.my.profile.manage_mycircuits.find((rec: ICircuit) => rec.name === circuitname) - console.log('mygrp', mygrp) + const mygrp = userStore.my.profile.manage_mycircuits.find((rec: ICircuit) => rec.name === circuitname); + console.log('mygrp', mygrp); if (mygrp && mygrp.admins) { - mygrp.admins = mygrp.admins.filter((rec: any) => rec.username !== username) - console.log('mygrp.admins', mygrp.admins) - this.showPositiveNotif($q, t('db.removedtoadmin', { username })) + mygrp.admins = mygrp.admins.filter((rec: any) => rec.username !== username); + console.log('mygrp.admins', mygrp.admins); + this.showPositiveNotif($q, t('db.removedtoadmin', { username })); } - this.updateMyData(res) + this.updateMyData(res); } - }) - }) + }); + }); }, DeleteCircuit($q: any, username: string, circuitname: string, domanda: any = '') { - const userStore = useUserStore() + const userStore = useUserStore(); //T_TOLTO $q.dialog({ message: domanda ? domanda : t('circuit.domanda_removecircuit', { circuitname }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, - title: t('db.domanda') + title: t('db.domanda'), }).onOk(() => { - userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.DELETE, null).then((res) => { if (res && res.result) { if (userStore.my.profile.manage_mycircuits) { - userStore.my.profile.manage_mycircuits = userStore.my.profile.manage_mycircuits.filter((rec: ICircuit) => rec.name !== circuitname) - this.showPositiveNotif($q, t('circuit.deleted', { circuitname })) + userStore.my.profile.manage_mycircuits = userStore.my.profile.manage_mycircuits.filter( + (rec: ICircuit) => rec.name !== circuitname + ); + this.showPositiveNotif($q, t('circuit.deleted', { circuitname })); } - this.updateMyData(res) + this.updateMyData(res); } - }) - }) + }); + }); }, - iCanShowCircuitsMember(circuit: ICircuit) { // ++Todo: Posso vedere i membri dei Circuiti ??? @@ -7024,439 +7027,418 @@ export const tools = { return this.iAmPartOfThisGroup(grp) } */ - return true - + return true; }, iAmAdminCircuit(circuitname: string) { - const userStore = useUserStore() + const userStore = useUserStore(); - let risultato = false + let risultato = false; if (userStore.isAdmin) { - return true + return true; } if (userStore.my.profile.manage_mycircuits) { const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => { if (circuit.name === circuitname) { - return true + return true; } - }) + }); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username) - risultato = !!isadmin + const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username); + risultato = !!isadmin; } - } - return risultato - + return risultato; }, iCanSendCoinsSuperUserCircuit(circuitname: string) { - const userStore = useUserStore() + const userStore = useUserStore(); - let risultato = false + 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 + return true; } - }) + }); if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username) - risultato = !!isadmin + const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username); + risultato = !!isadmin; } - } - return risultato - + return risultato; }, iAmPartOfThisGroup(grp: IMyGroup) { - const userStore = useUserStore() - return userStore.my.profile.mygroups.findIndex((rec: IMyGroup) => rec.groupname === grp.groupname) >= 0 + const userStore = useUserStore(); + return userStore.my.profile.mygroups.findIndex((rec: IMyGroup) => rec.groupname === grp.groupname) >= 0; }, iCanShowGroupsMember(grp: IMyGroup) { - if (grp && grp.visibility.includes(shared_consts.Visibility_Group.PRIVATE)) { // Only if I am part of this group - return this.iAmPartOfThisGroup(grp) + return this.iAmPartOfThisGroup(grp); } - return true - + return true; }, iCanShowAnnunci(grp: IMyGroup) { - if (grp && grp.visibility.includes(shared_consts.Visibility_Group.HIDDEN)) { // Only if I am part of this group - return this.iAmPartOfThisGroup(grp) + return this.iAmPartOfThisGroup(grp); } - return true - + return true; }, iAmTheCreatorOfTheGroup(groupname: string) { - const userStore = useUserStore() + const userStore = useUserStore(); - const risultato = false + const risultato = false; if (userStore.my.profile.manage_mygroups) { const ris = userStore.my.profile.manage_mygroups.find((grp: IMyGroup) => { if (grp.groupname === groupname) { - return true + return true; } - }) + }); // console.log('ris', ris) - return (ris && ris.createdBy === userStore.my.username) - + return ris && ris.createdBy === userStore.my.username; } - return risultato - + return risultato; }, isUserTheCreatorOfTheGroup(groupname: string, username: string) { - const userStore = useUserStore() + const userStore = useUserStore(); - const risultato = false + const risultato = false; if (userStore.my.profile.manage_mygroups) { const ris = userStore.my.profile.manage_mygroups.find((grp: IMyGroup) => { if (grp.groupname === groupname) { - return true + return true; } - }) + }); // console.log('ris', ris) - return (ris && ris.createdBy === username) - + return ris && ris.createdBy === username; } - return risultato - + return risultato; }, isUserAdminGroup(groupname: string, username: string, real?: boolean) { - const userStore = useUserStore() + const userStore = useUserStore(); - if (!real && (userStore.my.username === username && userStore.isAdmin)) { - return true + if (!real && userStore.my.username === username && userStore.isAdmin) { + return true; } - let risultato = false + let risultato = false; if (userStore.my.profile.manage_mygroups) { const ris = userStore.my.profile.manage_mygroups.find((grp: IMyGroup) => { if (grp.groupname === groupname) { - return true + return true; } - }) + }); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === username) - risultato = !!isadmin + const isadmin = ris.admins.find((user: IFriends) => user.username === username); + risultato = !!isadmin; } - } - return risultato - + return risultato; }, iAmTheCreatorOfTheCircuit(name: string) { - const userStore = useUserStore() + const userStore = useUserStore(); - const risultato = false + const risultato = false; if (userStore.my.profile.manage_mycircuits) { const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => { if (circuit.name === name) { - return true + return true; } - }) + }); // console.log('ris', ris) - return (ris && ris.createdBy === userStore.my.username) - + return ris && ris.createdBy === userStore.my.username; } - return risultato - + return risultato; }, isUserTheCreatorOfTheCircuit(name: string, username: string) { - const userStore = useUserStore() + const userStore = useUserStore(); if (userStore.my.username === username && userStore.isAdmin) { - return true + return true; } - const risultato = false + const risultato = false; if (userStore.my.profile.manage_mycircuits) { const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => { if (circuit.name === name) { - return true + return true; } - }) + }); // console.log('ris', ris) - return (ris && ris.createdBy === username) - + return ris && ris.createdBy === username; } - return risultato - + return risultato; }, isUserAdminCircuit(name: string, username: string, real?: boolean) { - const userStore = useUserStore() + const userStore = useUserStore(); - if (!real && (userStore.my.username === username && userStore.isAdmin)) { - return true + if (!real && userStore.my.username === username && userStore.isAdmin) { + return true; } - let risultato = false + let risultato = false; if (userStore.my.profile.manage_mycircuits) { const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => { if (circuit.name === name) { - return true + return true; } - }) + }); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === username) - risultato = !!isadmin + const isadmin = ris.admins.find((user: IFriends) => user.username === username); + risultato = !!isadmin; } - } - return risultato - + return risultato; }, getGroupsWhereIAmTheAdminOfTheCircuit(name: string, username: string) { - const userStore = useUserStore() + const userStore = useUserStore(); - const arr: any[] = [] + const arr: any[] = []; - let risultato = false + let risultato = false; if (userStore.my.profile.manage_mycircuits) { const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => { if (circuit.name === name) { - return true + return true; } - }) + }); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === username) - risultato = !!isadmin + const isadmin = ris.admins.find((user: IFriends) => user.username === username); + risultato = !!isadmin; } - } - return arr - + return arr; }, setCmd($q: any, cmd: number, username: string, value: any, dest: string) { //T_TOLTO - console.log('setcmd', cmd) + console.log('setcmd', cmd); if (cmd === shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP) { - this.removeFromMyGroups($q, username, dest, t('db.domanda_exit_fromgroup', { username })) + this.removeFromMyGroups($q, username, dest, t('db.domanda_exit_fromgroup', { username })); } else if (cmd === shared_consts.GROUPSCMD.DELETE_GROUP) { - this.DeleteGroup($q, username, dest) + this.DeleteGroup($q, username, dest); } else if (cmd === shared_consts.GROUPSCMD.BLOCK_GROUP) { - this.blockGroup($q, username, dest) + this.blockGroup($q, username, dest); } else if (cmd === shared_consts.GROUPSCMD.SETGROUP) { - this.addToMyGroups($q, username, dest) + this.addToMyGroups($q, username, dest); } else if (cmd === shared_consts.GROUPSCMD.ADDADMIN_OFMYGROUP) { - this.addtoAdminOfMyGroup($q, username, dest) + this.addtoAdminOfMyGroup($q, username, dest); } else if (cmd === shared_consts.GROUPSCMD.REMOVEADMIN_OFMYGROUP) { - this.removeAdminOfMyGroup($q, username, dest) + this.removeAdminOfMyGroup($q, username, dest); } else if (cmd === shared_consts.GROUPSCMD.REQGROUP) { - this.setRequestGroup($q, username, dest, value) + this.setRequestGroup($q, username, dest, value); } else if (cmd === shared_consts.GROUPSCMD.REFUSE_REQ_GROUP) { - this.refuseReqGroup($q, username, dest) + this.refuseReqGroup($q, username, dest); } else if (cmd === shared_consts.GROUPSCMD.CANCEL_REQ_GROUP) { - this.cancelReqGroups($q, username, dest) + this.cancelReqGroups($q, username, dest); } else if (cmd === shared_consts.FRIENDSCMD.BLOCK_USER) { - this.blockUser($q, username, dest) + this.blockUser($q, username, dest); } else if (cmd === shared_consts.FRIENDSCMD.SETFRIEND) { - this.addToMyFriends($q, username, dest) + this.addToMyFriends($q, username, dest); } else if (cmd === shared_consts.FRIENDSCMD.SETTRUST) { - this.addToMyTrust($q, username, dest, value) + this.addToMyTrust($q, username, dest, value); } else if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) { - this.setRequestFriendship($q, username, dest, value) + this.setRequestFriendship($q, username, dest, value); } else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS) { - this.removeFromMyFriends($q, username, dest) + this.removeFromMyFriends($q, username, dest); } else if (cmd === shared_consts.FRIENDSCMD.REFUSE_REQ_FRIEND) { - this.refuseReqFriends($q, username, dest) + this.refuseReqFriends($q, username, dest); } else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND) { - this.cancelReqFriends($q, username, dest) + this.cancelReqFriends($q, username, dest); } else if (cmd === shared_consts.FRIENDSCMD.SETHANDSHAKE) { - this.addToMyHandShake($q, username, dest) + this.addToMyHandShake($q, username, dest); } else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE) { - this.removeFromMyHandShake($q, username, dest) + this.removeFromMyHandShake($q, username, dest); } else if (cmd === shared_consts.CIRCUITCMD.SET) { - this.addToMyCircuits($q, username, dest) + this.addToMyCircuits($q, username, dest); } else if (cmd === shared_consts.CIRCUITCMD.REQ) { - this.setRequestCircuit($q, username, dest, value) + this.setRequestCircuit($q, username, dest, value); } else if (cmd === shared_consts.CIRCUITCMD.CANCEL_REQ) { - this.cancelReqCircuit($q, username, dest) + this.cancelReqCircuit($q, username, dest); } else if (cmd === shared_consts.CIRCUITCMD.REFUSE_REQ) { - this.refuseReqCircuit($q, username, dest) + this.refuseReqCircuit($q, username, dest); } else if (cmd === shared_consts.CIRCUITCMD.DELETE) { - this.DeleteCircuit($q, username, dest) + this.DeleteCircuit($q, username, dest); } else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) { - this.addtoAdminOfCircuit($q, username, dest) + this.addtoAdminOfCircuit($q, username, dest); } else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) { - this.removeAdminOfCircuit($q, username, dest) + this.removeAdminOfCircuit($q, username, dest); } else if (cmd === shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST) { - this.removeFromMyCircuits($q, username, dest) + this.removeFromMyCircuits($q, username, dest); } }, isCallable(anything: any) { - return typeof anything === 'function' + return typeof anything === 'function'; }, getValueByFunzOrVal(value: any, keyfunz: any) { try { if (typeof keyfunz === 'function') { - return keyfunz(value) + return keyfunz(value); } else { - return value[keyfunz] + return value[keyfunz]; } } catch (e) { - return '' + return ''; } }, getValueByRemoteField(col: IColGridTable, row: any) { if (col) { if (col.remote_table && col.remote_key && col.remote_field) { + const myarrremote = row[col.remote_table]; - const myarrremote = row[col.remote_table] - - const myarr: any = [] + const myarr: any = []; if (myarrremote) { for (const myrec of myarrremote) { - const myval = myrec[col.remote_field] - myarr.push(myval) + const myval = myrec[col.remote_field]; + myarr.push(myval); } } - console.log('myarrremote', myarrremote) + console.log('myarrremote', myarrremote); // console.log('myarr', myarr) - return myarr ? myarr.join(' - ') : '' - + return myarr ? myarr.join(' - ') : ''; } } - return '' - + return ''; }, isArray(val: any) { - return Array.isArray(val) + return Array.isArray(val); }, isTelegOk() { - const userStore = useUserStore() - return userStore.isTelegOk() + const userStore = useUserStore(); + return userStore.isTelegOk(); }, isUsernameTelegOk() { - const userStore = useUserStore() - return userStore.isUsernameTelegOk() + const userStore = useUserStore(); + return userStore.isUsernameTelegOk(); }, notFinishReg() { - return !this.isUserOk() + return !this.isUserOk(); }, getParamsByTable(table: string) { - const obj = { prop_colkey: '', col_title: '', col_footer: '', col_tabfooter: '', - } + }; if (table === toolsext.TABMYSKILLS) { - obj.prop_colkey = 'idSkill' - obj.col_title = 'descr' - obj.col_footer = 'idCity' - obj.col_tabfooter = 'mycities' + obj.prop_colkey = 'idSkill'; + obj.col_title = 'descr'; + obj.col_footer = 'idCity'; + obj.col_tabfooter = 'mycities'; } else if (table === toolsext.TABMYBACHECAS) { - obj.prop_colkey = 'idSkill' - obj.col_title = 'descr' - obj.col_footer = 'idCity' - obj.col_tabfooter = 'mycities' + obj.prop_colkey = 'idSkill'; + obj.col_title = 'descr'; + obj.col_footer = 'idCity'; + obj.col_tabfooter = 'mycities'; } else if (table === toolsext.TABMYHOSPS) { - obj.prop_colkey = 'descr' - obj.col_title = 'descr' - obj.col_footer = 'idCity' - obj.col_tabfooter = 'mycities' + obj.prop_colkey = 'descr'; + obj.col_title = 'descr'; + obj.col_footer = 'idCity'; + obj.col_tabfooter = 'mycities'; } else if (table === 'cities') { - obj.prop_colkey = '_id' - obj.col_title = 'comune' - obj.col_footer = 'comune' - obj.col_tabfooter = 'mycities' + obj.prop_colkey = '_id'; + obj.col_title = 'comune'; + obj.col_footer = 'comune'; + obj.col_tabfooter = 'mycities'; } - return obj - + return obj; }, getCitySel() { - const objcity = this.getCookie(this.COOK_SEARCH + 'cities', { _id: 0 }) - let defcity: any = [] + const objcity = this.getCookie(this.COOK_SEARCH + 'cities', { _id: 0 }); + let defcity: any = []; if (objcity && objcity._id > 0) { - defcity = [objcity._id] + defcity = [objcity._id]; } else { - return [] + return []; } - return defcity + return defcity; }, getSelectionByTable(table: string, mydef: any, convertint: any = false) { - - const arrtable = ['sectors', 'statusSkills', 'contribtypes', 'adtypes', 'sectorgoods', 'otherfilters', 'shippings', 'pub_to_share'] - const arrmultisel_tab = ['skills', 'goods'] + const arrtable = [ + 'sectors', + 'statusSkills', + 'contribtypes', + 'adtypes', + 'sectorgoods', + 'otherfilters', + 'shippings', + 'pub_to_share', + ]; + const arrmultisel_tab = ['skills', 'goods']; const arrmultisel = [ { table: 'skills', join: 'sectors' }, - { table: 'goods', join: 'sectorgoods' } - ] + { table: 'goods', join: 'sectorgoods' }, + ]; - let ris = mydef + let ris = mydef; if (arrtable.includes(table)) { - ris = this.getCookie(this.COOK_SEARCH + table, mydef, convertint) + ris = this.getCookie(this.COOK_SEARCH + table, mydef, convertint); } else if (arrmultisel_tab.includes(table)) { - const rec = arrmultisel.find((rec) => rec.table === table) + const rec = arrmultisel.find((rec) => rec.table === table); if (rec) { - ris = this.getCookie(this.COOK_SEARCH + table + '_' + this.getCookie(this.COOK_SEARCH + rec.join, 0), mydef) + ris = this.getCookie(this.COOK_SEARCH + table + '_' + this.getCookie(this.COOK_SEARCH + rec.join, 0), mydef); } } if (ris.toString() === costanti.FILTER_TUTTI.toString()) { - ris = '' + ris = ''; } - return ris + return ris; }, getdefaultnewrec_MySkill(extrarec: any): any { - return { idSector: this.getSelectionByTable('sectors', 0, true), idSkill: this.getSelectionByTable('skills', 0, true), @@ -7472,7 +7454,7 @@ export const tools = { website: '', descr: '', groupname: extrarec && extrarec.groupname ? extrarec.groupname : '', - } + }; }, getdefaultnewrec_MyGoods(extrarec: any): any { @@ -7502,7 +7484,7 @@ export const tools = { website: '', descr: '', groupname: extrarec && extrarec.groupname ? extrarec.groupname : '', - } + }; }, getdefaultnewrec_MyGroup(): any { @@ -7515,14 +7497,21 @@ export const tools = { blocked: false, website: '', link_telegram: '', - } + }; }, getdefaultnewrec_Catalog(): any { return { title: '', active: true, idCollana: '', - } + }; + }, + + getdefaultnewrec_RaccoltaCataloghi(): any { + return { + title: '', + active: true, + }; }, getdefaultnewrec_Circuit(): any { @@ -7546,7 +7535,7 @@ export const tools = { valuta_per_euro: 1, totTransato: 0, totCircolante: 0, - } + }; }, getDateTomorrowByTime(ora: number) { @@ -7554,10 +7543,9 @@ export const tools = { dateTimeStart.setDate(dateTimeStart.getDate() + 1); // Avanza al giorno successivo dateTimeStart.setHours(ora, 0, 0, 0); - return dateTimeStart + return dateTimeStart; }, - getdefaultnewrec_MyBacheca(extrarec: any): any { return { idSector: this.getSelectionByTable('sectors', 0, true), @@ -7582,8 +7570,7 @@ export const tools = { //**ADDFIELD_MYBACHECAS website: '', descr: '', - - } + }; }, getdefaultnewrec_MyHosp(extrarec: any): any { @@ -7600,24 +7587,22 @@ export const tools = { note: '', website: '', groupname: extrarec && extrarec.groupname ? extrarec.groupname : '', - - } + }; }, - getFullFileName(arrimage: IImgGallery[], table: string, username: string, groupname: string) { // console.log('arrimage', arrimage) if (shared_consts.TABLES_DIRECTORY_A_PARTE.includes(table)) { - return this.getDirUpload() + `${table}/` + groupname + '/' + arrimage[0]?.imagefile + return this.getDirUpload() + `${table}/` + groupname + '/' + arrimage[0]?.imagefile; } else if (shared_consts.TABLES_DIRECTORY_SINGLE_IMG.includes(table)) { - return this.getDirUpload() + `${table}/` + groupname + '/' + arrimage[0]?.imagefile + return this.getDirUpload() + `${table}/` + groupname + '/' + arrimage[0]?.imagefile; } else { // console.log('username', username, 'table', table) if (arrimage && arrimage.length > 0) { - return this.getDirUpload() + `profile/${username}/${table}/` + arrimage[0].imagefile + return this.getDirUpload() + `profile/${username}/${table}/` + arrimage[0]?.imagefile; } else { - return '' + return ''; } } }, @@ -7625,14 +7610,14 @@ export const tools = { // console.log('arrimage', arrimage) if (shared_consts.TABLES_IMAGEFILE_SINGOLO.includes(table)) { - return this.getDirUpload() + `products/` + imagefile + return this.getDirUpload() + `products/` + imagefile; } - return imagefile + return imagefile; }, canModifyThisRec(rec: any, tablesel: string) { // console.log('rec', rec) - const userStore = useUserStore() + const userStore = useUserStore(); //if (this.isTest() && (userStore.isAdmin || userStore.isManager)) // if ((userStore.isAdmin || userStore.isManager)) @@ -7640,119 +7625,130 @@ export const tools = { if (shared_consts.TABLES_PER_EDITORI.includes(tablesel)) { if (userStore.isCommerciale || userStore.isEditor || userStore.isGrafico || userStore.isAdmin) { - return true + return true; } } if (shared_consts.TABLES_WITH_ADMINS.includes(tablesel)) { - if (userStore.isAdmin) - return true + if (userStore.isAdmin) return true; // is Admin ? if (rec.admins) { - const trovato = rec.admins.find((myuser: any) => myuser.username === userStore.my.username) + const trovato = rec.admins.find((myuser: any) => myuser.username === userStore.my.username); if (trovato) { - return !!trovato + return !!trovato; } } - - } if (this.existProp(rec, 'userId')) { - const userId = rec.userId + const userId = rec.userId; if (userId === userStore.my._id) { // E' il mio, quindi modificalo - return true + return true; } else { - return false + return false; } } else { - return false + return false; } }, getToByCol(col: IColGridTable, table: string, rec: any) { - return this.getPathByTableAndRec(table, rec) + return this.getPathByTableAndRec(table, rec); }, getPathByGroup(grp: any) { - return '/' + shared_consts.getDirectoryByTable(shared_consts.TABLES_MYGROUPS) + '/' + grp.groupname + return '/' + shared_consts.getDirectoryByTable(shared_consts.TABLES_MYGROUPS) + '/' + grp.groupname; }, getPathByCircuit(circuit: any, table: string) { - return '/' + shared_consts.getDirectoryByTable(table) + '/' + circuit.path + return '/' + shared_consts.getDirectoryByTable(table) + '/' + circuit.path; }, getPathByTable(table: string, pagename: string) { - return '/' + shared_consts.getDirectoryByTable(table) + '/' + pagename + return '/' + shared_consts.getDirectoryByTable(table) + '/' + pagename; }, getPathByTableAndRec(table: string, rec: any) { - if (shared_consts.TABLES_REC_ID.includes(table)) { - return '/' + shared_consts.getDirectoryByTable(table) + '/' + rec['_id'] + return '/' + shared_consts.getDirectoryByTable(table) + '/' + rec['_id']; } else if (table === toolsext.TABMYGROUPS) { - return this.getPathByGroup(rec) + return this.getPathByGroup(rec); } else if (table === toolsext.TABCIRCUITS) { - return this.getPathByCircuit(rec, table) + return this.getPathByCircuit(rec, table); } - return '' + return ''; }, getAportadorSolidario() { - const userStore = useUserStore() - return userStore.my ? userStore.my.aportador_solidario : '' + const userStore = useUserStore(); + return userStore.my ? userStore.my.aportador_solidario : ''; }, getLinkProfileAportador() { - return '/my/' + this.getAportadorSolidario() + return '/my/' + this.getAportadorSolidario(); }, getLinkTelegramAportador(username_telegram_aportador: string) { - return this.getHttpForTelegram(username_telegram_aportador) + return this.getHttpForTelegram(username_telegram_aportador); }, openrighttoolbar() { - const globalStore = useGlobalStore() - globalStore.rightDrawerOpen = true + const globalStore = useGlobalStore(); + globalStore.rightDrawerOpen = true; }, getbackgroundGradient(color: string, degree: number) { if (color !== '-1') { - const mycol = this.colourNameToHex(color) - const arrcol = color.split('-') - const newcol = arrcol[0] + '-4' - const mycolchiaro = this.colourNameToHex(newcol) + const mycol = this.colourNameToHex(color); + const arrcol = color.split('-'); + const newcol = arrcol[0] + '-4'; + const mycolchiaro = this.colourNameToHex(newcol); - return 'background: ' + mycol + - ' background: -webkit-linear-gradient(' + degree + 'deg, ' + mycol + ', ' + mycolchiaro + ') !important; ' + - ' background: linear-gradient(' + degree + 'deg, ' + mycol + ', ' + mycolchiaro + ') !important;' + return ( + 'background: ' + + mycol + + ' background: -webkit-linear-gradient(' + + degree + + 'deg, ' + + mycol + + ', ' + + mycolchiaro + + ') !important; ' + + ' background: linear-gradient(' + + degree + + 'deg, ' + + mycol + + ', ' + + mycolchiaro + + ') !important;' + ); } else { - return '' + return ''; } }, getCurrentUrl() { - return window.location.pathname + return window.location.pathname; }, getFullCurrentUrl() { - return window.location.href + return window.location.href; }, isCurrentUrlSignUp() { - return window.location.pathname.indexOf('signup') >= 0 + return window.location.pathname.indexOf('signup') >= 0; }, async sendMsgTelegram($q: any, $t: any, mydata: IMsgGlobParam, showmsgsent: boolean) { - const userStore = useUserStore() + const userStore = useUserStore(); - return userStore.sendMsgToBotTelegram($q, $t, mydata, showmsgsent) + return userStore.sendMsgToBotTelegram($q, $t, mydata, showmsgsent); }, async sendMsgTelegramCmd($q: any, $t: any, cmd: number, showmsgsent: boolean, text?: string, title?: string) { - const userStore = useUserStore() + const userStore = useUserStore(); const mydata: IMsgGlobParam = { typemsg: 0, @@ -7760,26 +7756,26 @@ export const tools = { cmd, content: text, title, - } + }; - if ((cmd === shared_consts.CmdToSend.SHARE_MSGREG) || (cmd === shared_consts.CmdToSend.SHARE_TEXT)) { - mydata.typemsg = shared_consts.TypeMsg.SEND_TO_MYSELF + if (cmd === shared_consts.CmdToSend.SHARE_MSGREG || cmd === shared_consts.CmdToSend.SHARE_TEXT) { + mydata.typemsg = shared_consts.TypeMsg.SEND_TO_MYSELF; // if yourself , don't need to say I send to me - showmsgsent = false + showmsgsent = false; } if (cmd === shared_consts.CmdToSend.SHARE_MSGREG) { - const link = userStore.getRefLink(userStore.my.username) - this.copyStringToClipboard($q, link, true) + const link = userStore.getRefLink(userStore.my.username); + this.copyStringToClipboard($q, link, true); } - return await this.sendMsgTelegram($q, $t, mydata, showmsgsent) + return await this.sendMsgTelegram($q, $t, mydata, showmsgsent); }, async sendMsgAnnuncioToTelegramCmd($q: any, $t: any, tablerec: string, idrec: string) { - const userStore = useUserStore() + const userStore = useUserStore(); - const showmsgsent = false + const showmsgsent = false; const mydata: IMsgGlobParam = { typemsg: shared_consts.TypeMsg.SEND_TO_MYSELF, @@ -7788,202 +7784,207 @@ export const tools = { tablerec, idrec, idapp: this.appid(), - } + }; // this.copyStringToClipboard($q, link, true) - return await this.sendMsgTelegram($q, $t, mydata, showmsgsent) + return await this.sendMsgTelegram($q, $t, mydata, showmsgsent); }, getFieldSearchByTable(mytable: string, tablejoin: string, field: string) { - let ris = field + let ris = field; if (mytable === 'users') { if (tablejoin === 'cities') { - ris = 'profile.born_city_id' + ris = 'profile.born_city_id'; } if (tablejoin === 'provinces') { - ris = 'profile.resid_province' + ris = 'profile.resid_province'; } if (tablejoin === 'cards') { - ris = 'profile.resid_card' + ris = 'profile.resid_card'; } if (tablejoin === 'regions') { - ris = 'mycities.reg' + ris = 'mycities.reg'; } if (tablejoin === 'circuits') { - ris = 'mycircuits.circuitname' + ris = 'mycircuits.circuitname'; } } - return ris + return ris; }, getConfSiteOptionEnabled(option: number): any { - - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); if (globalStore.site) { if (this.existProp(globalStore.site.confsite, 'options')) { - return this.isBitActive(globalStore.site.confsite.options, option) + return this.isBitActive(globalStore.site.confsite.options, option); } } - return false + return false; }, isLangEnabled(lang: number): any { - - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); if (globalStore.site) { - const exist = this.existProp(globalStore.site.confpages, 'lang') + const exist = this.existProp(globalStore.site.confpages, 'lang'); if (exist) { - return this.isBitActive(globalStore.site.confpages.lang, lang) + return this.isBitActive(globalStore.site.confpages.lang, lang); } else if (!exist || globalStore.site.confpages.lang === 0) { if (lang === costanti.Lang.IT) { - return true + return true; } } } - return false + return false; }, getAskToVerifyReg(): boolean { - return this.getConfSiteOptionEnabled(shared_consts.ConfSite.Need_Aportador_On_DataReg_To_Verify_Reg) + return this.getConfSiteOptionEnabled(shared_consts.ConfSite.Need_Aportador_On_DataReg_To_Verify_Reg); }, async loadGroupsByUsername(username: string) { - const userStore = useUserStore() + const userStore = useUserStore(); // Carica il profilo di quest'utente if (username) { await userStore.loadGroups(username).then((ris) => { - console.log('loadGroupsByUsername ', ris) + console.log('loadGroupsByUsername ', ris); if (ris) { - userStore.my.profile.mygroups = ris.mygroups ? ris.mygroups : [] - userStore.my.profile.list_usersgroup = ris.listUsersGroup ? ris.listUsersGroup : [] - userStore.groups = ris.listgroups ? ris.listgroups : [] - userStore.my.profile.asked_groups = ris.listSentRequestGroups ? ris.listSentRequestGroups : [] - userStore.my.profile.refused_groups = ris.listRefusedGroups ? ris.listRefusedGroups : [] - return [{ userId: userStore.my._id }] + userStore.my.profile.mygroups = ris.mygroups ? ris.mygroups : []; + userStore.my.profile.list_usersgroup = ris.listUsersGroup ? ris.listUsersGroup : []; + userStore.groups = ris.listgroups ? ris.listgroups : []; + userStore.my.profile.asked_groups = ris.listSentRequestGroups ? ris.listSentRequestGroups : []; + userStore.my.profile.refused_groups = ris.listRefusedGroups ? ris.listRefusedGroups : []; + return [{ userId: userStore.my._id }]; } - }) - + }); } - return [] + return []; }, async loadCircuits(nummovTodownload: number) { - const userStore = useUserStore() - const circuitStore = useCircuitStore() + const userStore = useUserStore(); + const circuitStore = useCircuitStore(); // Carica il profilo di quest'utente await userStore.loadCircuits(nummovTodownload).then((ris) => { // console.log('ris', ris) if (ris) { - - circuitStore.listcircuits = ris.listcircuits ? ris.listcircuits : [] + circuitStore.listcircuits = ris.listcircuits ? ris.listcircuits : []; // to Refresh Data User Accounts: - userStore.my.profile.mycircuits = ris.mycircuits ? ris.mycircuits : [] + userStore.my.profile.mycircuits = ris.mycircuits ? ris.mycircuits : []; // Others not loaded at the beginning: - userStore.my.profile.asked_circuits = ris.asked_circuits ? ris.asked_circuits : [] - userStore.my.profile.refused_circuits = ris.refused_circuits ? ris.refused_circuits : [] - userStore.my.profile.last_my_transactions = ris.last_my_transactions ? ris.last_my_transactions : [] - return [{ userId: userStore.my._id }] + userStore.my.profile.asked_circuits = ris.asked_circuits ? ris.asked_circuits : []; + userStore.my.profile.refused_circuits = ris.refused_circuits ? ris.refused_circuits : []; + userStore.my.profile.last_my_transactions = ris.last_my_transactions ? ris.last_my_transactions : []; + return [{ userId: userStore.my._id }]; } - }) + }); - return [] + return []; }, async loadAccounts() { - const userStore = useUserStore() - const circuitStore = useCircuitStore() + const userStore = useUserStore(); + const circuitStore = useCircuitStore(); // Carica il profilo di quest'utente await userStore.loadAllAccounts().then((ris) => { // console.log('ris', ris) if (ris) { - - circuitStore.listaccounts = ris.listaccounts ? ris.listaccounts : [] - return true + circuitStore.listaccounts = ris.listaccounts ? ris.listaccounts : []; + return true; } - }) + }); - return false + return false; }, async loadrecProfile() { - - const userStore = useUserStore() - const globalStore = useGlobalStore() + const userStore = useUserStore(); + const globalStore = useGlobalStore(); const params: any = { table: 'exp', - userId: userStore.my._id - } + userId: userStore.my._id, + }; - console.log('loadrecProfile', params) - - return await globalStore.loadExp(params) + console.log('loadrecProfile', params); + return await globalStore.loadExp(params); }, async exportListaEmail() { - - const myrec = await this.loadrecProfile() + const myrec = await this.loadrecProfile(); // console.log('myrec', myrec) - const sep = ';' + const sep = ';'; - let mystr = '' + let mystr = ''; - mystr += 'username' + sep + 'username_telegram' + sep + 'nome_telegram' + sep + 'cognome_telegram' + sep + 'email' + sep + 'verificato_telegram' + sep + 'verificato_invitante' + '\n' - let index = 1 + mystr += + 'username' + + sep + + 'username_telegram' + + sep + + 'nome_telegram' + + sep + + 'cognome_telegram' + + sep + + 'email' + + sep + + 'verificato_telegram' + + sep + + 'verificato_invitante' + + '\n'; + let index = 1; for (const rec of myrec) { - mystr += rec.username + sep - mystr += rec.profile.username_telegram + sep - mystr += rec.profile.firstname_telegram ? rec.profile.firstname_telegram + sep : sep - mystr += rec.profile.lastname_telegram ? rec.profile.lastname_telegram + sep : sep - mystr += rec.email + sep - mystr += ((rec.profile.teleg_id) ? 'SI' : 'NO') + sep - mystr += ((rec.verified_by_aportador) ? 'SI' : 'NO') + sep - mystr += '\n' - index++ + mystr += rec.username + sep; + mystr += rec.profile.username_telegram + sep; + mystr += rec.profile.firstname_telegram ? rec.profile.firstname_telegram + sep : sep; + mystr += rec.profile.lastname_telegram ? rec.profile.lastname_telegram + sep : sep; + mystr += rec.email + sep; + mystr += (rec.profile.teleg_id ? 'SI' : 'NO') + sep; + mystr += (rec.verified_by_aportador ? 'SI' : 'NO') + sep; + mystr += '\n'; + index++; } // this.copyStringToClipboard(this, mystr, false) - return mystr + return mystr; }, get_SI_NO(myvalue: boolean) { - return myvalue ? 'SI' : 'NO' + return myvalue ? 'SI' : 'NO'; }, getvalueAll(myval: string | Date) { - const mydate = new Date(myval) + const mydate = new Date(myval); if (mydate instanceof Date && !isNaN(mydate.valueOf())) { - return this.getstrDateTime(mydate) + return this.getstrDateTime(mydate); } else { - return myval + return myval; } - }, updateQueryStringParameter(uri: string, key: string, value: string) { - const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i') - const separator = uri.indexOf('?') !== -1 ? '&' : '?' + const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i'); + const separator = uri.indexOf('?') !== -1 ? '&' : '?'; if (uri.match(re)) { - return uri.replace(re, '$1' + key + '=' + value + '$2') + return uri.replace(re, '$1' + key + '=' + value + '$2'); } else { - return uri + separator + key + '=' + value + return uri + separator + key + '=' + value; } }, @@ -7996,51 +7997,40 @@ export const tools = { return config[name]*/ try { - let myenv = name ? import.meta.env[name] : '' + let myenv = name ? import.meta.env[name] : ''; // console.log('--- ENV: ', name, myenv) - return myenv + return myenv; } catch (e) { - return '' + return ''; } }, getArrSector(table: string, rec: any) { - if (table === toolsext.TABMYGOODS) - return rec.sectorGood - else if ((table === toolsext.TABMYBACHECAS) || (table === toolsext.TABMYSKILLS)) - return rec.sector - else if (table === toolsext.TABMYGROUPS) - return [{ descr: rec.sector }] - else if (table === toolsext.TABMYHOSPS) - return [] - - + if (table === toolsext.TABMYGOODS) return rec.sectorGood; + else if (table === toolsext.TABMYBACHECAS || table === toolsext.TABMYSKILLS) return rec.sector; + else if (table === toolsext.TABMYGROUPS) return [{ descr: rec.sector }]; + else if (table === toolsext.TABMYHOSPS) return []; }, getArrSubSector(table: string, rec: any) { - if (table === toolsext.TABMYGOODS) - return rec.recGood - else if ((table === toolsext.TABMYBACHECAS) || (table === toolsext.TABMYSKILLS) || (table === toolsext.TABATTIVITA)) - return rec.recSkill - else if (table === toolsext.TABMYGROUPS) - return [] - else if (table === toolsext.TABMYHOSPS) - return [] - - + if (table === toolsext.TABMYGOODS) return rec.recGood; + else if (table === toolsext.TABMYBACHECAS || table === toolsext.TABMYSKILLS || table === toolsext.TABATTIVITA) + return rec.recSkill; + else if (table === toolsext.TABMYGROUPS) return []; + else if (table === toolsext.TABMYHOSPS) return []; }, findCommonElements(arr1: any, arr2: any) { - return arr1.some((item: any) => arr2.includes(item)) + return arr1.some((item: any) => arr2.includes(item)); }, // Function to return common elements between two arrays getCommon(arr1: any[], arr2: any[], field1: string, field2: string): any[] { // Assicurati che gli array non siano null o undefined if (!Array.isArray(arr1) || !Array.isArray(arr2)) { - console.error("Entrambi gli input devono essere array."); + console.error('Entrambi gli input devono essere array.'); return []; } @@ -8049,7 +8039,8 @@ export const tools = { arr2.sort((a, b) => (a[field2] > b[field2] ? 1 : a[field2] < b[field2] ? -1 : 0)); const common: any[] = []; // Array per contenere gli elementi comuni - let i = 0, j = 0; // Indici per iterare sugli array + let i = 0, + j = 0; // Indici per iterare sugli array // Itera finché non si esaurisce uno dei due array while (i < arr1.length && j < arr2.length) { @@ -8077,7 +8068,7 @@ export const tools = { getCommonAllRecord(arr1: any[], arr2: any[], field: string): any[] { // Assicurati che gli array non siano null o undefined if (!Array.isArray(arr1) || !Array.isArray(arr2)) { - console.error("Entrambi gli input devono essere array."); + console.error('Entrambi gli input devono essere array.'); return []; } @@ -8086,7 +8077,8 @@ export const tools = { arr2.sort((a, b) => (a[field] > b[field] ? 1 : a[field] < b[field] ? -1 : 0)); const common: any[] = []; // Array per contenere gli oggetti comuni - let i = 0, j = 0; // Indici per iterare sugli array + let i = 0, + j = 0; // Indici per iterare sugli array // Itera finché non si esaurisce uno dei due array while (i < arr1.length && j < arr2.length) { @@ -8110,357 +8102,340 @@ export const tools = { }, isTypeByRecMov(rec: IMovVisu) { - - let type = costanti.TypeMov.Nessuno + let type = costanti.TypeMov.Nessuno; if (rec && (rec.userfrom || rec.userto || rec.groupfrom || rec.groupto)) { - const userStore = useUserStore() + const userStore = useUserStore(); if (rec.userfrom && userStore.my.username === rec.userfrom.username) { - type = costanti.TypeMov.Uscita + type = costanti.TypeMov.Uscita; } else if (rec.userto && userStore.my.username === rec.userto.username) { - type = costanti.TypeMov.Entrata + type = costanti.TypeMov.Entrata; } else if (rec.groupfrom && this.isUserAdminGroup(rec.groupfrom.groupname, userStore.my.username)) { - type = costanti.TypeMov.Uscita + type = costanti.TypeMov.Uscita; } else if (rec.groupto && this.isUserAdminGroup(rec.groupto.groupname, userStore.my.username)) { - type = costanti.TypeMov.Entrata + type = costanti.TypeMov.Entrata; } } - return type + return type; }, isEntrataByRecMov(rec: IMovVisu) { - - return this.isTypeByRecMov(rec) === costanti.TypeMov.Entrata + return this.isTypeByRecMov(rec) === costanti.TypeMov.Entrata; }, isUscitaByRecMov(rec: IMovVisu) { - - return this.isTypeByRecMov(rec) === costanti.TypeMov.Uscita + return this.isTypeByRecMov(rec) === costanti.TypeMov.Uscita; }, getSymbolByCircuit(circuit: any) { try { if (circuit.symbol) { - return circuit.symbol + return circuit.symbol; } else if (this.existProp(circuit, 'circuitfrom') && circuit.circuitfrom.symbol) { - return circuit.circuitfrom.symbol + return circuit.circuitfrom.symbol; } else if (this.existProp(circuit.extrarec, 'symbol')) { - return circuit.extrarec.symbol + return circuit.extrarec.symbol; } else { - return '' + return ''; } } catch (e) { - return '' + return ''; } }, getColorByCircuit(circuit: any) { if (circuit && circuit.color) { - return circuit.color + return circuit.color; } else { - return '' + return ''; } }, roundDec2(mynum: number): number { - return (Math.round(mynum * 100) / 100) + return Math.round(mynum * 100) / 100; }, getheightgallery() { if (this.isMobile()) { if (Screen.height < 700) { - return '400px' + return '400px'; } else { - return '500px' + return '500px'; } - } else { if (Screen.width < 1200) { - return '500px' + return '500px'; } else { - return '600px' + return '600px'; } } - }, getTitleGall(table: string) { if (shared_consts.TABLEFORUSERS.includes(table)) { - return 'Profilo' + return 'Profilo'; } else { - return fieldsTable.getTitleImgByTable(table) + return fieldsTable.getTitleImgByTable(table); } }, getDirectoryGall(myrow: any, table: string, path: string) { - const userStore = useUserStore() + const userStore = useUserStore(); // console.log('getDirectoryGall', myrow) - let ris = '' + let ris = ''; try { - let username = this.existProp(myrow, 'username') ? myrow['username'] : '' - const userId = this.existProp(myrow, 'userId') ? myrow['userId'] : '' - const id = this.existProp(myrow, '_id') ? myrow['_id'] : '' + let username = this.existProp(myrow, 'username') ? myrow['username'] : ''; + const userId = this.existProp(myrow, 'userId') ? myrow['userId'] : ''; + const id = this.existProp(myrow, '_id') ? myrow['_id'] : ''; if (username === '') { - if (userId === userStore.my._id) - username = userStore.my.username + if (userId === userStore.my._id) username = userStore.my.username; } if (username === '') { - username = userStore.my.username + username = userStore.my.username; } if (shared_consts.TABLEFORUSERS.includes(table)) { - ris = 'profile/' + username + '/' + table + ris = 'profile/' + username + '/' + table; } else if (table === 'users') { - ris = 'profile/' + userStore.my.username + ris = 'profile/' + userStore.my.username; } else if (table === 'mygroups') { - if (this.existProp(myrow, 'groupname')) - ris = 'mygroups/' + myrow['groupname'] + if (this.existProp(myrow, 'groupname')) ris = 'mygroups/' + myrow['groupname']; } else if (table === 'circuits') { - if (this.existProp(myrow, 'path')) - ris = 'circuits/' + myrow['path'] + if (this.existProp(myrow, 'path')) ris = 'circuits/' + myrow['path']; } else if (table === 'catalogs') { - ris = 'catalogs/' + id + ris = 'catalogs/' + id; + } else if (table === 'raccoltacataloghis') { + ris = 'raccoltacatalogs/' + id; } else if (!!myrow && !!myrow.directory) { - ris = myrow.directory + ris = myrow.directory; } else if (table === 'myelems') { - ris = 'pages/' + (path ? path : myrow.path) + ris = 'pages/' + (path ? path : myrow.path); } else if (table === 'listcards') { - ris = 'pages/' + (path ? path : myrow.path) + ris = 'pages/' + (path ? path : myrow.path); } else if (table === 'imgcards') { - ris = 'pages/' + path + ris = 'pages/' + path; } else if (table === 'productInfos') { - ris = path + ris = path; } else if (table === 'imgs') { - ris = path + ris = path; } else { - ris = table + ris = table; } - } catch (e) { - console.error('err getDirectoryGall', e) + console.error('err getDirectoryGall', e); } // console.log('getDirectoryGall', ris, 'mypath', path, 'myrow', myrow) - return ris + return ris; }, getImgFileByFilename(elem: IMyElem, filename: string) { - return this.getDirUpload() + 'pages/' + elem.path + '/' + filename + return this.getDirUpload() + 'pages/' + elem.path + '/' + filename; }, getImgFileByElem(elem: IMyElem, reccard?: IMyCard, path?: string) { if (elem) { - - let addtourl = '' + let addtourl = ''; if (elem && elem.vers_img) { - addtourl = '?v=' + elem.vers_img + addtourl = '?v=' + elem.vers_img; } - const mypath = (path ? path : elem.path) + const mypath = path ? path : elem.path; if (elem.type === shared_consts.ELEMTYPE.CARD) { if (reccard?.imagefile) { if (reccard.vers_img) { - addtourl = '?v=' + reccard.vers_img + addtourl = '?v=' + reccard.vers_img; } - return this.getDirUpload() + 'pages/' + mypath + '/' + reccard.imagefile + addtourl - } else - return '' + return this.getDirUpload() + 'pages/' + mypath + '/' + reccard.imagefile + addtourl; + } else return ''; } else if (elem.type === shared_consts.ELEMTYPE.IMAGE) { - return this.getDirUpload() + 'pages/' + mypath + '/' + elem.container + addtourl + return this.getDirUpload() + 'pages/' + mypath + '/' + elem.container + addtourl; } else if (elem.type === shared_consts.ELEMTYPE.QRCODE) { - return this.getDirUpload() + 'pages/' + mypath + '/' + elem.image + addtourl + return this.getDirUpload() + 'pages/' + mypath + '/' + elem.image + addtourl; } else { - return this.getDirUpload() + 'pages/' + mypath + '/' + elem.image + addtourl + return this.getDirUpload() + 'pages/' + mypath + '/' + elem.image + addtourl; } } }, getGenerateVersionImage() { - return 100000 + Math.round(Math.random() * 899999) + return 100000 + Math.round(Math.random() * 899999); }, findFirstElemInCommon(arr1: ILabelValueStr[], arr2: string[]) { for (let i = 0; i < arr1.length; i++) { for (let j = 0; j < arr2.length; j++) { if (arr1[i].value == arr2[j] && arr1[i].value !== '') { - return arr1[i].value + return arr1[i].value; } } } - return '' + return ''; }, updateFonts(newval?: string) { - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); if (newval) { - if (globalStore.site && globalStore.site.confpages) - globalStore.site.confpages.font = newval + if (globalStore.site && globalStore.site.confpages) globalStore.site.confpages.font = newval; } for (const myfont of shared_consts.FontsInstalled) { - document.body.classList.remove(myfont.value.toString()) + document.body.classList.remove(myfont.value.toString()); } if (globalStore.site?.confpages && globalStore.site.confpages.font) { - document.body.classList.add(globalStore.site.confpages.font) + document.body.classList.add(globalStore.site.confpages.font); } }, getClassAnim(myanim: IAnim) { - if (!myanim) - return '' + if (!myanim) return ''; - let mycl = '' + let mycl = ''; if (myanim) - mycl = (myanim.name ? myanim.name : '') + - ' ' + (myanim.clduration ? myanim.clduration : '') + - ' ' + (myanim.cldelay ? myanim.cldelay : '') + - ' ' + (myanim.timingtype ? myanim.timingtype : '') - else - mycl = '' + mycl = + (myanim.name ? myanim.name : '') + + ' ' + + (myanim.clduration ? myanim.clduration : '') + + ' ' + + (myanim.cldelay ? myanim.cldelay : '') + + ' ' + + (myanim.timingtype ? myanim.timingtype : ''); + else mycl = ''; - if (mycl) - return 'animate__animated ' + mycl - else - return '' + if (mycl) return 'animate__animated ' + mycl; + else return ''; }, - getLabelFooterByRow(row: any, field: string, tablesel: string) { if (field) { - - const mycol = fieldsTable.getColByTable(tablesel, field) + const mycol = fieldsTable.getColByTable(tablesel, field); if (mycol) { - console.log('remote_table = ', mycol.remote_table, 'remote_key', mycol.remote_key) - console.log('ROW', row) - return this.getValueByRemoteField(mycol, row) + console.log('remote_table = ', mycol.remote_table, 'remote_key', mycol.remote_key); + console.log('ROW', row); + return this.getValueByRemoteField(mycol, row); } } - return '' + return ''; }, getNameToShow(user: IUserFields, col: any = null, options = null): string { - const userStore = useUserStore() + const userStore = useUserStore(); - const name = userStore.getNameToShow(user, col, options) + const name = userStore.getNameToShow(user, col, options); - return name + return name; }, getUserNameOnlyIfToShow(user: IUserFields, col: any = null, options = null): string { - const userStore = useUserStore() + const userStore = useUserStore(); - const name = userStore.getUserNameOnlyIfToShow(user, col, options) + const name = userStore.getUserNameOnlyIfToShow(user, col, options); - return name + return name; }, isEmailNoMicroZozz(myemail: string) { - - return myemail.search(/hotmail/i) !== -1 - || myemail.search(/outlook/i) !== -1 - || myemail.search(/live.it/i) !== -1 - || myemail.search(/live.com/i) !== -1 - || myemail.search(/microsoft/i) !== -1 + return ( + myemail.search(/hotmail/i) !== -1 || + myemail.search(/outlook/i) !== -1 || + myemail.search(/live.it/i) !== -1 || + myemail.search(/live.com/i) !== -1 || + myemail.search(/microsoft/i) !== -1 + ); }, // || myemail.search(/yahoo/i) !== -1 getoptionsMainCards(only: boolean) { - const myarr = [] - const obj = { label: '', value: '', icon: '', color: '' } + const myarr = []; + const obj = { label: '', value: '', icon: '', color: '' }; for (let i = 0; i < costanti.MAINCARDS.length; i++) { - const rec: any = costanti.MAINCARDS[i] + const rec: any = costanti.MAINCARDS[i]; if (rec.table && rec.showinoptions) { - obj.label = rec.title - obj.value = rec.table - obj.icon = rec.icon - obj.color = rec.color - myarr.push({ ...obj }) + obj.label = rec.title; + obj.value = rec.table; + obj.icon = rec.icon; + obj.color = rec.color; + myarr.push({ ...obj }); } } - return myarr + return myarr; }, checkApp() { - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); // console.log('checkApp (homescreen=', globalStore.homescreen) try { - let displayMode = 'browser' - const mqStandAlone = '(display-mode: standalone)' + let displayMode = 'browser'; + const mqStandAlone = '(display-mode: standalone)'; // @ts-ignore - if (((navigator && (navigator.standalone))) || - (window.matchMedia(mqStandAlone).matches)) { + if ((navigator && navigator.standalone) || window.matchMedia(mqStandAlone).matches) { // console.log('navigator.standalone') - displayMode = 'standalone' + displayMode = 'standalone'; } // prova altro 2 // console.log('displayMode = ', displayMode) - globalStore.isAppRunning = displayMode === 'standalone' || globalStore.homescreen + globalStore.isAppRunning = displayMode === 'standalone' || globalStore.homescreen; } catch (e) { - console.log('error navigator.standalone ?!', e) + console.log('error navigator.standalone ?!', e); } - }, initprompt() { - try { // console.log('initprompt') - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); window.addEventListener('beforeinstallprompt', (event) => { - event.preventDefault() - console.log('beforeinstallprompt !') + event.preventDefault(); + console.log('beforeinstallprompt !'); // Stash the event so it can be triggered later. - globalStore.deferredPrompt = event - }) + globalStore.deferredPrompt = event; + }); } catch (e) { - console.error('err', e) + console.error('err', e); } }, isDevelop() { - return import.meta.env.DEV + return import.meta.env.DEV; }, getIndMainCardsByTable(table: string) { for (let i = 0; i < costanti.MAINCARDS.length; i++) { - if (costanti.MAINCARDS[i].table === table) - return i + if (costanti.MAINCARDS[i].table === table) return i; } - return -1 + return -1; }, getStrByParamTypeAccount(paramTypeAccount: string): string { - const myrec = costanti.ParamTypeAccountStr.find((rec: any) => rec.value === paramTypeAccount) - return myrec ? translate(myrec.labeltrans) : '' + const myrec = costanti.ParamTypeAccountStr.find((rec: any) => rec.value === paramTypeAccount); + return myrec ? translate(myrec.labeltrans) : ''; }, getTypeByParamTypeAccount(paramTypeAccount: string): number { - const myrec = costanti.ParamTypeAccountStr.find((rec: any) => rec.value === paramTypeAccount) - return myrec ? myrec.type : 0 + const myrec = costanti.ParamTypeAccountStr.find((rec: any) => rec.value === paramTypeAccount); + return myrec ? myrec.type : 0; }, getFieldByParamTypeAccount(paramTypeAccount: string): string { - const myrec = costanti.ParamTypeAccountStr.find((rec: any) => rec.value === paramTypeAccount) - return myrec ? myrec.field : '' + const myrec = costanti.ParamTypeAccountStr.find((rec: any) => rec.value === paramTypeAccount); + return myrec ? myrec.field : ''; }, getNomeUtenteByRecUser(user: IUserFields) { - return user.name ? user.name + ' ' + (user.surname ? user.surname : '') : user.username + return user.name ? user.name + ' ' + (user.surname ? user.surname : '') : user.username; }, getNomeUtenteEUsernameByRecUser(user: IUserFields) { - if (user.name) - return user.name + ' ' + user.surname + ' (' + user.username + ')' - else - return user.username + if (user.name) return user.name + ' ' + user.surname + ' (' + user.username + ')'; + else return user.username; }, updateLink(link: string) { - const userStore = useUserStore() + const userStore = useUserStore(); /*if (link === '/circuits') { let path = userStore.my.profile.last_circuitpath @@ -8469,155 +8444,151 @@ export const tools = { } return link }*/ - return link + return link; }, async addToTemporaryReceiverRIS(t: any) { - const userStore = useUserStore() + const userStore = useUserStore(); - const username = userStore.my.username - - return await userStore.setUserReceiveRIS(username, '') - .then((data) => { - if (data.code === serv_constants.RIS_CODE_OK) { - return { msg: t('circuit.coins_requestedris', { username }), ris: true } - } else { - return { msg: t('db.recfailed'), ris: false } - } - - }) + const username = userStore.my.username; + return await userStore.setUserReceiveRIS(username, '').then((data) => { + if (data.code === serv_constants.RIS_CODE_OK) { + return { msg: t('circuit.coins_requestedris', { username }), ris: true }; + } else { + return { msg: t('db.recfailed'), ris: false }; + } + }); }, async addToTemporaryLinkReg(t: any) { - const userStore = useUserStore() + const userStore = useUserStore(); - const username = userStore.my.username - - return await userStore.seListLinkReg(username, '') - .then((data) => { - if (data.code === serv_constants.RIS_CODE_OK) { - return { msg: t('circuit.listlinkreg', { username }), ris: true } - } else { - return { msg: t('db.recfailed'), ris: false } - } - - }) + const username = userStore.my.username; + return await userStore.seListLinkReg(username, '').then((data) => { + if (data.code === serv_constants.RIS_CODE_OK) { + return { msg: t('circuit.listlinkreg', { username }), ris: true }; + } else { + return { msg: t('db.recfailed'), ris: false }; + } + }); }, async receiveRisGroup(groupname: string, $q: any, t: any) { - const userStore = useUserStore() + const userStore = useUserStore(); await userStore.setUserReceiveRIS('', groupname).then((data) => { if (data.code === serv_constants.RIS_CODE_OK) { - this.showPositiveNotif($q, t('circuit.coins_requestedrisgroup', { groupname }), 6000) + this.showPositiveNotif($q, t('circuit.coins_requestedrisgroup', { groupname }), 6000); } else { - this.showNegativeNotif($q, t('db.recfailed')) + this.showNegativeNotif($q, t('db.recfailed')); } - - }) - + }); }, getPagination(table: string): IPagination { - return { sortBy: 'desc', descending: true, page: 1, rowsNumber: 0, rowsPerPage: 10 } + return { sortBy: 'desc', descending: true, page: 1, rowsNumber: 0, rowsPerPage: 10 }; }, getNumTabByTable(table: string) { - const myrec = shared_consts.MYTABS.find((rec: any) => rec.table === table) - return myrec ? myrec.id : -1 + const myrec = shared_consts.MYTABS.find((rec: any) => rec.table === table); + return myrec ? myrec.id : -1; }, removeItemOnce(arr: any, value: any) { - const index = arr.indexOf(value) + const index = arr.indexOf(value); if (index > -1) { - arr.splice(index, 1) + arr.splice(index, 1); } return arr; }, indexOfObject(arr: any, obj: any) { - let l = arr.length, i, k, ok; + let l = arr.length, + i, + k, + ok; for (let i = 0; i < l; i++) { ok = true; - for (k in obj) if (this.existProp(obj, k)) { - if (arr[i][k] !== obj[k]) { - ok = false; - break; + for (k in obj) + if (this.existProp(obj, k)) { + if (arr[i][k] !== obj[k]) { + ok = false; + break; + } } - } if (ok) return i; } return -1; // no match }, removeIObjectOnce(arr: any, obj: IBookmark | IFavorite) { - const index = this.indexOfObject(arr, obj) + const index = this.indexOfObject(arr, obj); if (index > -1) { - arr.splice(index, 1) + arr.splice(index, 1); } return arr; }, optionsTable(table: string) { - if (shared_consts.TABLES_FAVORITE_BOOKMARK.includes(table)) - return shared_consts.OPTIONS_ADD_COUNT_FAVORITE + if (shared_consts.TABLES_FAVORITE_BOOKMARK.includes(table)) return shared_consts.OPTIONS_ADD_COUNT_FAVORITE; - return 0 + return 0; }, getdefaultnewrec(table: string, extrarec?: any): any { if (table === toolsext.TABMYSKILLS) { - return this.getdefaultnewrec_MySkill(extrarec) + return this.getdefaultnewrec_MySkill(extrarec); } else if (table === toolsext.TABMYBACHECAS) { - return this.getdefaultnewrec_MyBacheca(extrarec) + return this.getdefaultnewrec_MyBacheca(extrarec); } else if (table === toolsext.TABMYHOSPS) { - return this.getdefaultnewrec_MyHosp(extrarec) + return this.getdefaultnewrec_MyHosp(extrarec); } else if (table === toolsext.TABMYGOODS) { - return this.getdefaultnewrec_MyGoods(extrarec) + return this.getdefaultnewrec_MyGoods(extrarec); } else if (table === toolsext.TABMYGROUPS) { - return this.getdefaultnewrec_MyGroup() + return this.getdefaultnewrec_MyGroup(); } else if (table === toolsext.TABCIRCUITS) { - return this.getdefaultnewrec_Circuit() + return this.getdefaultnewrec_Circuit(); } else if (table === toolsext.TABCATALOGS) { - return this.getdefaultnewrec_Catalog() + return this.getdefaultnewrec_Catalog(); + } else if (table === toolsext.TABRACCOLTA_CATALOGHI) { + return this.getdefaultnewrec_RaccoltaCataloghi(); } - return {} + return {}; }, getNomeTabellaStrByTable(table: string, rec: any) { - let str = '' - let nome = '' + let str = ''; + let nome = ''; if (table === toolsext.TABMYBACHECAS) { - nome = rec ? rec.descr : '' - str = 'l\'Evento "' + nome + '"' + nome = rec ? rec.descr : ''; + str = 'l\'Evento "' + nome + '"'; } else if (table === toolsext.TABMYSKILLS) { - nome = rec ? rec.descr : '' - str = 'il Servizio "' + nome + '"' + nome = rec ? rec.descr : ''; + str = 'il Servizio "' + nome + '"'; } else if (table === toolsext.TABMYGOODS) { - nome = rec ? rec.descr : '' - str = 'il Bene "' + nome + '"' + nome = rec ? rec.descr : ''; + str = 'il Bene "' + nome + '"'; } else if (table === toolsext.TABMYHOSPS) { - nome = rec ? rec.descr : '' - str = 'l\'Ospitalità "' + nome + '"' + nome = rec ? rec.descr : ''; + str = 'l\'Ospitalità "' + nome + '"'; } if (!str) { - str = 'il record selezionato' + str = 'il record selezionato'; } - return str + return str; }, extraparams(table: string, extra?: any) { if (table === toolsext.TABMYGROUPS) { - - const lk_tab = 'mygroups' - const lk_LF = 'userId' - const lk_FF = '_id' - const lk_as = 'group' - const af_objId_tab = 'myId' + const lk_tab = 'mygroups'; + const lk_LF = 'userId'; + const lk_FF = '_id'; + const lk_as = 'group'; + const af_objId_tab = 'myId'; return { lookup1: { @@ -8649,15 +8620,13 @@ export const tools = { lk_as: 'mycities', af_objId_tab: '', }, - } - + }; } else if (table === toolsext.TABCIRCUITS) { - - const lk_tab = 'cities' - const lk_LF = 'idCity' - const lk_FF = '_id' - const lk_as = 'mycities' - const af_objId_tab = '' + const lk_tab = 'cities'; + const lk_LF = 'idCity'; + const lk_FF = '_id'; + const lk_as = 'mycities'; + const af_objId_tab = ''; return { lookup1: { @@ -8668,8 +8637,7 @@ export const tools = { af_objId_tab, lk_proj: shared_consts.getProjectByTable(table, {}), }, - } - + }; } else if (table === toolsext.TABMYGOODS) { return { lookup1: { @@ -8711,7 +8679,7 @@ export const tools = { unwind: true, noarray: true, }, - } + }; } else if (table === toolsext.TABMYBACHECAS) { return { lookup1: { @@ -8753,13 +8721,12 @@ export const tools = { unwind: true, noarray: true, }, - } - + }; } else if (table === toolsext.TABMYHOSPS) { - const obj2: any = {} + const obj2: any = {}; if (extra && extra.myrecfiltertoggle.value === this.FILTER_ALL) { - obj2['visibile'] = true + obj2['visibile'] = true; } return { @@ -8788,12 +8755,11 @@ export const tools = { unwind: true, noarray: true, }, - } - + }; } else if (table === toolsext.TABCATALOGS) { - return { - - } + return {}; + } else if (table === toolsext.TABRACCOLTA_CATALOGHI) { + return {}; } else { return { // Servizi @@ -8835,59 +8801,70 @@ export const tools = { unwind: true, noarray: true, }, - } + }; } }, getNumPartecipantes(myrec: any) { if (myrec && myrec.mybookings && myrec.mybookings.length > 0) { - return myrec.mybookings.reduce((accum: any, currval: any) => accum + (currval.booked ? 0 : currval.numpeople), 0) + return myrec.mybookings.reduce((accum: any, currval: any) => accum + (currval.booked ? 0 : currval.numpeople), 0); } - return 0 + return 0; }, getUnitsMeasure(unit: number, short: boolean, weight?: number) { - let unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === unit) - let mystr = '' + let unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === unit); + let mystr = ''; if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.CHILI && weight && weight < 1) { - unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === shared_consts.UNITS_OF_MEASURE.GRAMMI) + unitrec = shared_consts.Units_Of_Measure_ListBox.find( + (rec: any) => rec.value === shared_consts.UNITS_OF_MEASURE.GRAMMI + ); } if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.LITRI && weight && weight < 1) { - unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === shared_consts.UNITS_OF_MEASURE.MILLILITRI) + unitrec = shared_consts.Units_Of_Measure_ListBox.find( + (rec: any) => rec.value === shared_consts.UNITS_OF_MEASURE.MILLILITRI + ); } - mystr = unitrec ? (short ? unitrec.short : unitrec.label) : '' - return mystr + mystr = unitrec ? (short ? unitrec.short : unitrec.label) : ''; + return mystr; }, - getWeightByUnit(unit: number, short: boolean, weight: number | undefined) { - const unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === unit) + const unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === unit); if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.CHILI && weight && weight < 1) { - return weight * 1000 + return weight * 1000; } if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.LITRI && weight && weight < 1) { - return weight * 1000 + return weight * 1000; } - return weight + return weight; }, - getWeightTotalByOrder(order: IOrder) { - return (order.product && order.product.productInfo && order.product.productInfo.weight ? order.product.productInfo.weight : 1) * (order.quantitypreordered | 0 + order.quantity | 0) + return ( + (order.product && order.product.productInfo && order.product.productInfo.weight + ? order.product.productInfo.weight + : 1) * + (order.quantitypreordered | (0 + order.quantity) | 0) + ); }, isPartecipero(myrec: any) { - const userStore = useUserStore() + const userStore = useUserStore(); if (myrec && myrec.mybookings && myrec.mybookings.length > 0) { - const isconfirmed = true - return myrec.mybookings.find((bookedevent: any) => (bookedevent.id_bookedevent === myrec._id) && (bookedevent.userId === userStore.my._id) && ((isconfirmed && bookedevent.booked) || (!isconfirmed))) + const isconfirmed = true; + return myrec.mybookings.find( + (bookedevent: any) => + bookedevent.id_bookedevent === myrec._id && + bookedevent.userId === userStore.my._id && + ((isconfirmed && bookedevent.booked) || !isconfirmed) + ); } - return 0 + return 0; }, convertPriceEurToValue(inputString: string): string { - if (inputString === '') - return '0'; + if (inputString === '') return '0'; // Rimuovi il simbolo della valuta (€) e sostituisci la virgola con un punto return inputString.replace(/[^\d.,]/g, '').replace(',', '.'); }, @@ -8900,7 +8877,6 @@ export const tools = { return jsonString.replace(/"/g, "'"); }, - removeFileExtension(filename: string) { // Trova l'ultima occorrenza del punto nel nome del file const lastDotIndex = filename.lastIndexOf('.'); @@ -8916,7 +8892,7 @@ export const tools = { }, removeescape(inputString: string): string { - return inputString.replace('\\', '').replace(/"/g, '') + return inputString.replace('\\', '').replace(/"/g, ''); }, removeTrailingBr(str: string) { @@ -8925,7 +8901,9 @@ export const tools = { }, removeescape_e_acapo(inputString: string): string { - return this.removeTrailingBr(inputString.replace('\\', '').replace(/"/g, '').replace(/\r\n/g, '
').replace(/\r/g, '
')) + return this.removeTrailingBr( + inputString.replace('\\', '').replace(/"/g, '').replace(/\r\n/g, '
').replace(/\r/g, '
') + ); }, isObjectEmpty(obj: any) { @@ -8952,14 +8930,13 @@ export const tools = { const hours = Math.floor((countdownInSeconds % (60 * 60 * 24)) / (60 * 60)); const minutes = Math.floor((countdownInSeconds % (60 * 60)) / 60); - const gg = days > 0 ? 'giorni' : '' - const strgg = gg ? `${days} giorni` : '' + const gg = days > 0 ? 'giorni' : ''; + const strgg = gg ? `${days} giorni` : ''; - return (`${strgg} ${this.pad(hours)}h ${this.pad(minutes)}m`); + return `${strgg} ${this.pad(hours)}h ${this.pad(minutes)}m`; } else { return ''; } - }, getCountDownWithSeconds(mydate: Date) { @@ -8978,29 +8955,26 @@ export const tools = { const minutes = Math.floor((countdownInSeconds % (60 * 60)) / 60); const seconds = countdownInSeconds % 60; - const gg = days > 0 ? 'giorni' : '' - const strgg = gg ? `${days} giorni` : '' + const gg = days > 0 ? 'giorni' : ''; + const strgg = gg ? `${days} giorni` : ''; - return (`${strgg} ${this.pad(hours)}:${this.pad(minutes)}:${this.pad(seconds)}`); + return `${strgg} ${this.pad(hours)}:${this.pad(minutes)}:${this.pad(seconds)}`; } else { return ''; } - }, calcperc(val1: number, valmax: number): number { - if (valmax > 0) - return (val1 / valmax * 100) - else - return 0 + if (valmax > 0) return (val1 / valmax) * 100; + else return 0; }, getHost() { - return this.getUrlSite() + return this.getUrlSite(); }, generateURL(mylink: string, value: string): string { - const site = this.getUrlSite() + const site = this.getUrlSite(); return mylink.replace('{site}', site).replace('{value}', value); }, @@ -9014,46 +8988,45 @@ export const tools = { }, openUrl(url: string) { - - url = url.replace('{link_chat_territoriale}', this.getLinkChatTerritoriale()) + url = url.replace('{link_chat_territoriale}', this.getLinkChatTerritoriale()); window.open(url, '_blank'); - }, getText(mystr: string) { - - mystr = mystr.replace('{miaprovincia}', this.getProvincia()) + mystr = mystr.replace('{miaprovincia}', this.getProvincia()); if (mystr.includes('{titolo_prov_riso}')) { - let titleprovincia = translate('dashboard.link_gruppo_telegram') - titleprovincia = titleprovincia.replace('{prov}', this.getProvincia()) + let titleprovincia = translate('dashboard.link_gruppo_telegram'); + titleprovincia = titleprovincia.replace('{prov}', this.getProvincia()); - mystr = mystr.replace('{titolo_prov_riso}', titleprovincia) + mystr = mystr.replace('{titolo_prov_riso}', titleprovincia); } - return mystr + return mystr; }, getCircuitYourProvince() { - - const circuitStore = useCircuitStore() - const userStore = useUserStore() + const circuitStore = useCircuitStore(); + const userStore = useUserStore(); try { - return circuitStore.getCircuitByProvinceAndCard(userStore.my.profile.resid_province, userStore.my.profile.resid_card) + return circuitStore.getCircuitByProvinceAndCard( + userStore.my.profile.resid_province, + userStore.my.profile.resid_card + ); } catch (e) { - return null + return null; } }, getLinkChatTerritoriale() { - const circ = this.getCircuitYourProvince() - return circ ? circ.link_group : '' + const circ = this.getCircuitYourProvince(); + return circ ? circ.link_group : ''; }, getNomeCircuitoChatTerritoriale() { - const circ = this.getCircuitYourProvince() - return circ ? circ.name : '' + const circ = this.getCircuitYourProvince(); + return circ ? circ.name : ''; }, rimuoviAtPrimoCarattere(stringa: string) { @@ -9066,10 +9039,10 @@ export const tools = { getInvitante() { try { - const invitante = this.getCookie(this.APORTADOR_SOLIDARIO, '') - return invitante ? invitante : '' + const invitante = this.getCookie(this.APORTADOR_SOLIDARIO, ''); + return invitante ? invitante : ''; } catch (e) { - return '' + return ''; } }, @@ -9077,7 +9050,7 @@ export const tools = { try { return str.includes('/'); } catch (e) { - return '' + return ''; } }, @@ -9088,76 +9061,68 @@ export const tools = { disponibStr(quantita: any) { if (!quantita) { // Disponibilità non pervenuta, non scrivere niente - return '' + return ''; } - quantita = parseInt(quantita) - let ris = '' + quantita = parseInt(quantita); + let ris = ''; if (quantita < 0) { - ris = 'Disponibile per il Pre-Ordine' + ris = 'Disponibile per il Pre-Ordine'; } else if (quantita === 0) { - ris = 'Terminato!' - } else if ((quantita > 0) && (quantita <= 3)) { - if (quantita === 1) - ris = 'Ultimo pezzo !' - else - ris = 'Ultimi ' + quantita + ' pezzi' - } else if ((quantita > 3) && (quantita <= 10)) { - ris = 'Media' + ris = 'Terminato!'; + } else if (quantita > 0 && quantita <= 3) { + if (quantita === 1) ris = 'Ultimo pezzo !'; + else ris = 'Ultimi ' + quantita + ' pezzi'; + } else if (quantita > 3 && quantita <= 10) { + ris = 'Media'; } else { - ris = 'Alta' + ris = 'Alta'; } - return ris - + return ris; }, colordisponib(quantita: any) { if (!quantita) { // Disponibilità non pervenuta, non scrivere niente - return 'gray' + return 'gray'; } - quantita = parseInt(quantita) - let color = '' + quantita = parseInt(quantita); + let color = ''; if (quantita < 0) { - color = 'blue' + color = 'blue'; } else if (quantita === 0) { - color = 'gray' - } else if ((quantita > 0) && (quantita <= 3)) { - color = 'red' - } else if ((quantita > 3) && (quantita <= 10)) { - color = 'orange' + color = 'gray'; + } else if (quantita > 0 && quantita <= 3) { + color = 'red'; + } else if (quantita > 3 && quantita <= 10) { + color = 'orange'; } else if (quantita > 10) { - color = 'green' + color = 'green'; } - return color + return color; }, getIconByVersione(versione: number) { - let str = '' - if (versione === shared_consts.PRODUCTTYPE.NUOVO) - str = 'fas fa-book' + let str = ''; + if (versione === shared_consts.PRODUCTTYPE.NUOVO) str = 'fas fa-book'; else if (versione === shared_consts.PRODUCTTYPE.USATO) // Versione Libro usato - str = 'fas fa-book-open' - else if (versione === shared_consts.PRODUCTTYPE.DOWNLOAD) - str = 'fas fa-file-download' - else if (versione === shared_consts.PRODUCTTYPE.DVD) - str = 'fas fa-film' - else if (versione === shared_consts.PRODUCTTYPE.PDF) - str = 'fas fa-file-pdf' + str = 'fas fa-book-open'; + else if (versione === shared_consts.PRODUCTTYPE.DOWNLOAD) str = 'fas fa-file-download'; + else if (versione === shared_consts.PRODUCTTYPE.DVD) str = 'fas fa-film'; + else if (versione === shared_consts.PRODUCTTYPE.PDF) str = 'fas fa-file-pdf'; else if (versione === shared_consts.PRODUCTTYPE.EPUB) // Libro elettronico EPUB - str = 'fas fa-book-open-reader' - else if (versione === shared_consts.PRODUCTTYPE.STREAMING) - str = 'fas fa-stream' + str = 'fas fa-book-open-reader'; + else if (versione === shared_consts.PRODUCTTYPE.STREAMING) str = 'fas fa-stream'; - return str + return str; }, // get the integer part, no round, of a decimal number getIntPart(number: number) { - return Math.trunc(number) + return Math.trunc(number); }, // get the last 2 digit fraction part, of a decimal number @@ -9166,70 +9131,67 @@ export const tools = { return parts.length > 1 ? parts[1] : '00'; }, arrotonda2Dec(number: any): string { - let num = '' - if (!number) - return '' + let num = ''; + if (!number) return ''; try { - if (number) - num = number.toFixed(2) + if (number) num = number.toFixed(2); } catch (e) { - return number + return number; } - return num + return num; }, getRecordByField(field: any, record: any) { - let mioval = '' + let mioval = ''; if (field) { - const arrfields = field.split('.') + const arrfields = field.split('.'); if (arrfields && arrfields.length > 0) { try { - mioval = record[arrfields[0]][arrfields[1]] + mioval = record[arrfields[0]][arrfields[1]]; } catch (e) { - return '' + return ''; } } else { - mioval = record[field] + mioval = record[field]; } } - return mioval + return mioval; }, setRecordByField(field: any, record: any, value: any) { - const mioval = '' + const mioval = ''; if (field) { if (typeof field === 'function') { // Se field è una funzione, chiamala per ottenere il campo - const fieldValue = field(record) - record[fieldValue] = value + const fieldValue = field(record); + record[fieldValue] = value; } else { - const arrfields = field.split('.') + const arrfields = field.split('.'); if (arrfields && arrfields.length > 1) { try { - record[arrfields[0]][arrfields[1]] = value + record[arrfields[0]][arrfields[1]] = value; } catch (e) { - return record + return record; } } else { - record[field] = value + record[field] = value; } } } - return record + return record; }, getRecByVersioneProd(versione: number) { - - return shared_consts.VERSIONI_PRODOTTO.find((rec: any) => rec.value === versione) + return shared_consts.VERSIONI_PRODOTTO.find((rec: any) => rec.value === versione); }, numtostr(value: number): string { try { - value = Math.round(value) - return value.toLocaleString('it-IT') + value = Math.round(value); + return value.toLocaleString('it-IT'); } catch (e) { - return '' + return ''; } }, @@ -9241,94 +9203,87 @@ export const tools = { // Controlla se la conversione è un numero valido if (isNaN(numberValue)) { // console.error('Valore non valido:', stringValue); - return 0 + return 0; } // Usa toFixed per creare un numero con 6 decimali return parseFloat(numberValue.toFixed(6)); } catch (error) { console.error('Errore durante la conversione:', error); - return 0 + return 0; } }, getLabelAddrec(ind: any) { - return (ind >= 0) ? translate('grid.newrecord') + ` ` + costanti.MAINCARDS[ind].strsingolo : '' + return ind >= 0 ? translate('grid.newrecord') + ` ` + costanti.MAINCARDS[ind].strsingolo : ''; }, getCoordinatesToShow(coordinate_gps: any) { - if (coordinate_gps) { if (coordinate_gps.coordinates) { - const lng = coordinate_gps.coordinates[0] - const lat = coordinate_gps.coordinates[1] - return `Coordinate: ${lng}, Lat: ${lat}` + const lng = coordinate_gps.coordinates[0]; + const lat = coordinate_gps.coordinates[1]; + return `Coordinate: ${lng}, Lat: ${lat}`; } } }, getHostPuntamento(arrDNS: any, tofind: string, paramsulServer: string, type: string): any { - let checkDomain = '' - let color = 'red' - let ok = false + let checkDomain = ''; + let color = 'red'; + let ok = false; try { if (arrDNS) { - const indrec = arrDNS.findIndex((rec: any) => rec.name === tofind && rec.type === type) + const indrec = arrDNS.findIndex((rec: any) => rec.name === tofind && rec.type === type); if (indrec >= 0) { - checkDomain = tofind + ' -> ' + arrDNS[indrec].content - const giusto = (paramsulServer === arrDNS[indrec].content) - color = giusto ? 'green' : 'red' + checkDomain = tofind + ' -> ' + arrDNS[indrec].content; + const giusto = paramsulServer === arrDNS[indrec].content; + color = giusto ? 'green' : 'red'; if (!giusto) { - checkDomain += ' (al posto di -> ' + paramsulServer + ')' + checkDomain += ' (al posto di -> ' + paramsulServer + ')'; } else { - ok = true + ok = true; } } else { - checkDomain = tofind + ' N/A' + checkDomain = tofind + ' N/A'; } } - } catch (e) { - console.log('Error: ', e) + console.log('Error: ', e); } - return { text: '' + checkDomain + '
', ok } - + return { text: '' + checkDomain + '
', ok }; }, checkIfICanAddNewRecord() { - // Attualmente se sei loggato puoi inserire Record - return this.isLogged() && this.isUserOk() + return this.isLogged() && this.isUserOk(); }, getsrcimg(gallerylist: any, dir: string) { - // console.log('getsrcimg', gallerylist) - let addtourl = '' + let addtourl = ''; if (!gallerylist) { return '/images/noimg.png'; } if (gallerylist && gallerylist.vers_img) { - addtourl = '?v=' + gallerylist.vers_img + addtourl = '?v=' + gallerylist.vers_img; } if (gallerylist && !gallerylist.imagefile) { return '/images/noimg.png'; } if (gallerylist) { - if (this.getextfile(gallerylist.imagefile) === 'pdf') - return '/images/images/pdf.jpg' + if (this.getextfile(gallerylist.imagefile) === 'pdf') return '/images/images/pdf.jpg'; else { if (this.contieneSlash(gallerylist.imagefile)) { - return gallerylist.imagefile + addtourl + return gallerylist.imagefile + addtourl; } else { - return this.getDirUpload() + dir + '/' + gallerylist.imagefile + addtourl + return this.getDirUpload() + dir + '/' + gallerylist.imagefile + addtourl; } } - } else { return '/images/noimg.png'; } @@ -9336,9 +9291,9 @@ export const tools = { getImgFileToSaveByFilename(filename_o_rec: any) { if (filename_o_rec && filename_o_rec.imagefile) { - return filename_o_rec.imagefile + return filename_o_rec.imagefile; } else { - return filename_o_rec + return filename_o_rec; } }, @@ -9361,52 +9316,60 @@ export const tools = { */ /****** 0d5e5048-6331-423d-9a49-1a7416c2612a *******/ - async saveInDBForTypes($q: any, mykey: string, newval: any, type: any, serv: boolean, table?: string, mysubkey?: string, id?: any, indrec?: number, mysubsubkey?: string, specialField?: ISpecialField) { + async saveInDBForTypes( + $q: any, + mykey: string, + newval: any, + type: any, + serv: boolean, + table?: string, + mysubkey?: string, + id?: any, + indrec?: number, + mysubsubkey?: string, + specialField?: ISpecialField + ) { + const { setValDb, getValDb } = MixinBase(); - const { setValDb, getValDb } = MixinBase() - - let eseguito = false + let eseguito = false; // if (table === 'myelems') { if (type === costanti.FieldType.image && newval.imagefile) { + let myval = newval.imagefile; + await setValDb($q, mykey, myval, type, serv, table, mysubkey, id, indrec, mysubsubkey, specialField); + myval = newval.vers_img; + const mykey2 = 'vers_img'; + await setValDb($q, mykey2, myval, type, serv, table, mysubkey, id, indrec, mysubsubkey, specialField); - let myval = newval.imagefile - await setValDb($q, mykey, myval, type, serv, table, mysubkey, id, indrec, mysubsubkey, specialField) - myval = newval.vers_img - const mykey2 = 'vers_img' - await setValDb($q, mykey2, myval, type, serv, table, mysubkey, id, indrec, mysubsubkey, specialField) - - eseguito = true + eseguito = true; } // } if (!eseguito) { - // if (newval !== valinitial) { - await setValDb($q, mykey, newval, type, serv, table, mysubkey, id, indrec, mysubsubkey, specialField) + await setValDb($q, mykey, newval, type, serv, table, mysubkey, id, indrec, mysubsubkey, specialField); // } } - return eseguito - + return eseguito; }, updateEditOn(value: boolean) { - const globalStore = useGlobalStore() + const globalStore = useGlobalStore(); - globalStore.editOn = value + globalStore.editOn = value; const pageKey = window.location.pathname; - const mykey = 'edn_' + pageKey + const mykey = 'edn_' + pageKey; // console.log('mykey', mykey) if (this.getCookie(mykey) === '1' && !value) { - this.setCookie(mykey, '0') + this.setCookie(mykey, '0'); } if (this.getCookie(mykey) !== '1' && value) { - this.setCookie(mykey, '1') + this.setCookie(mykey, '1'); } }, @@ -9417,80 +9380,76 @@ export const tools = { }, getStringaConto_NonUsata(mov: IMovQuery) { + let mystr = ''; + let mystrfrom = ''; + let mystrto = ''; - let mystr = '' - let mystrfrom = '' - let mystrto = '' - - let tipocontofrom = shared_consts.AccountType.USER - let tipocontoto = shared_consts.AccountType.USER + let tipocontofrom = shared_consts.AccountType.USER; + let tipocontoto = shared_consts.AccountType.USER; if (mov.contocomfrom && mov.contocomfrom.name) { - mystrfrom += mov.contocomfrom.name + ' ' - tipocontofrom = shared_consts.AccountType.COMMUNITY_ACCOUNT + mystrfrom += mov.contocomfrom.name + ' '; + tipocontofrom = shared_consts.AccountType.COMMUNITY_ACCOUNT; } if (mov.groupfrom) { - mystrfrom += mov.groupfrom.groupname + ' ' - tipocontofrom = shared_consts.AccountType.CONTO_DI_GRUPPO + mystrfrom += mov.groupfrom.groupname + ' '; + tipocontofrom = shared_consts.AccountType.CONTO_DI_GRUPPO; } if (mov.userfrom) { - mystrfrom += mov.userfrom.username + ' ' + mystrfrom += mov.userfrom.username + ' '; } if (mov.contocomto && mov.contocomto.name) { - mystrto += mov.contocomto.name + ' ' - tipocontoto = shared_consts.AccountType.COMMUNITY_ACCOUNT + mystrto += mov.contocomto.name + ' '; + tipocontoto = shared_consts.AccountType.COMMUNITY_ACCOUNT; } if (mov.groupto) { - mystrto += mov.groupto.groupname + ' ' - tipocontoto = shared_consts.AccountType.CONTO_DI_GRUPPO + mystrto += mov.groupto.groupname + ' '; + tipocontoto = shared_consts.AccountType.CONTO_DI_GRUPPO; } if (mov.userto) { - mystrto += mov.userto.username + ' ' + mystrto += mov.userto.username + ' '; } - mystr = t('movement.from') + mystrfrom + ' ' + t('movement.to') + mystrto + mystr = t('movement.from') + mystrfrom + ' ' + t('movement.to') + mystrto; - return { str: mystr.trim(), tipocontofrom, tipocontoto } + return { str: mystr.trim(), tipocontofrom, tipocontoto }; }, getUsernameOrGroupOrContoComByMov(mov: IMovQuery, from: boolean) { - - let mystrfrom = '' - let mystrto = '' + let mystrfrom = ''; + let mystrto = ''; if (from) { if (mov.contocomfrom && mov.contocomfrom.name) { - mystrfrom = mov.contocomfrom.name + mystrfrom = mov.contocomfrom.name; } if (mov.groupfrom) { - mystrfrom = mov.groupfrom.groupname + mystrfrom = mov.groupfrom.groupname; } if (mov.userfrom) { - mystrfrom = mov.userfrom.username + mystrfrom = mov.userfrom.username; } - return mystrfrom + return mystrfrom; } else { - if (mov.contocomto && mov.contocomto.name) { - mystrto = mov.contocomto.name + mystrto = mov.contocomto.name; } if (mov.groupto) { - mystrto = mov.groupto.groupname + mystrto = mov.groupto.groupname; } if (mov.userto) { - mystrto = mov.userto.username + mystrto = mov.userto.username; } - return mystrto + return mystrto; } - }, getTitleAnnuncio(table: string) { - const rec = costanti.MAINCARDS.find((rec: any) => rec.showinoptions && rec.table === table) - return rec ? rec.strsingolo : '' + const rec = costanti.MAINCARDS.find((rec: any) => rec.showinoptions && rec.table === table); + return rec ? rec.strsingolo : ''; }, getMainUrl(fullUrl: string) { @@ -9503,33 +9462,34 @@ export const tools = { return mainUrl; } catch (error) { - console.error("URL non valido:", error); + console.error('URL non valido:', error); return null; } }, getGradientByColors(col1: string, col2: string, col3: string): string { - let mystr = '' + let mystr = ''; if (col1) { - mystr = `background: linear-gradient(${col1}` + mystr = `background: linear-gradient(${col1}`; } if (col2) { - mystr += `, ${col2}` + mystr += `, ${col2}`; } if (col3) { - mystr += `, ${col3}` + mystr += `, ${col3}`; } - mystr += ') !important;' - - return mystr + mystr += ') !important;'; + return mystr; }, isNumeric(value: any) { // Controlla se il valore è un numero e non è NaN (Not-a-Number) - return typeof value === 'number' && !isNaN(value) || - typeof value === 'string' && value.trim() !== '' && !isNaN(Number(value)); + return ( + (typeof value === 'number' && !isNaN(value)) || + (typeof value === 'string' && value.trim() !== '' && !isNaN(Number(value))) + ); }, strToVal(mystr: string, abs: boolean = false): number | null { @@ -9537,14 +9497,14 @@ export const tools = { if (this.isNumeric(mystr)) { let num = parseFloat(mystr); if (num) { - num = Math.abs(num) + num = Math.abs(num); } - return num + return num; } else { - return null + return null; } } catch (e) { - return null + return null; } }, @@ -9556,63 +9516,63 @@ export const tools = { if (!rec) { rec = { width: '', - height: '' - } + height: '', + }; } - return rec + return rec; }, resetRecIMyScheda(rec?: IMyScheda): IMyScheda { - rec.testo_right_attaccato = tools.resetIText(rec?.testo_right_attaccato) - rec.testo_right = tools.resetIText(rec?.testo_right) - rec.testo_bottom = tools.resetIText(rec?.testo_bottom) + rec.testo_right_attaccato = tools.resetIText(rec?.testo_right_attaccato); + rec.testo_right = tools.resetIText(rec?.testo_right); + rec.testo_bottom = tools.resetIText(rec?.testo_bottom); - rec.dimensioni = { pagina: null, riga: null, scheda_prodotto: {}, immagine_prodotto: {} } - rec.dimensioni.pagina = tools.resetRecIPagina({}) - rec.testo_right_attaccato = tools.resetIText({}) - rec.testo_right = tools.resetIText({}) - rec.testo_bottom = tools.resetIText({}) + rec.dimensioni = { pagina: null, riga: null, scheda_prodotto: {}, immagine_prodotto: {} }; + rec.dimensioni.pagina = tools.resetRecIPagina({}); + rec.testo_right_attaccato = tools.resetIText({}); + rec.testo_right = tools.resetIText({}); + rec.testo_bottom = tools.resetIText({}); - return rec + return rec; }, resetIBorder(rec: IBorder | null) { if (!rec) { - rec = {} - rec.top = '' - rec.bottom = '' - rec.left = '' - rec.right = '' + rec = {}; + rec.top = ''; + rec.bottom = ''; + rec.left = ''; + rec.right = ''; } - return rec + return rec; }, resetIImg(rec: IImg | null) { if (!rec) { - rec = {} + rec = {}; - rec.imagefile = '' - rec.fit = '' + rec.imagefile = ''; + rec.fit = ''; } - return rec + return rec; }, resetIText(rec: IText | null) { if (!rec) { - rec = {} + rec = {}; - rec.contenuto = '' - rec.maxlength = 0 + rec.contenuto = ''; + rec.maxlength = 0; rec.font = { line_height: 1, posiz_text: 0, perc_text: '50%', name: '', size: '14px', - } + }; } if (!rec.font) { @@ -9622,18 +9582,17 @@ export const tools = { perc_text: '50%', name: '', size: '14px', - } + }; } if (!rec.size) { - rec.size = this.resetISize(rec.size) + rec.size = this.resetISize(rec.size); } - return rec + return rec; }, resetRecIDimensioni(rec: IDimensioni | null) { - - let myrec: IDimensioni = {} + let myrec: IDimensioni = {}; if (!rec) { myrec = { @@ -9642,55 +9601,51 @@ export const tools = { padding: {}, imgsfondo: {}, text_html: {}, - } + }; } else { - myrec = rec + myrec = rec; } - myrec.size = this.resetISize(myrec.size) - myrec.margini = this.resetIBorder(myrec.margini) - myrec.padding = this.resetIBorder(myrec.padding) - myrec.imgsfondo = this.resetIImg(myrec.imgsfondo) - myrec.text_html = this.resetIText(myrec.text_html) + myrec.size = this.resetISize(myrec.size); + myrec.margini = this.resetIBorder(myrec.margini); + myrec.padding = this.resetIBorder(myrec.padding); + myrec.imgsfondo = this.resetIImg(myrec.imgsfondo); + myrec.text_html = this.resetIText(myrec.text_html); - return myrec + return myrec; }, resetRecIPagina(rec: IPagina | null) { - - let myrec: IPagina = {} + let myrec: IPagina = {}; if (!rec) { - const dimensioni: IDimensioni = this.resetRecIDimensioni(null) + const dimensioni: IDimensioni = this.resetRecIDimensioni(null); myrec = { dimensioni, testo_up: this.resetIText(null), testo_down: this.resetIText(null), - } + }; } if (!myrec.dimensioni) { - myrec.dimensioni = this.resetRecIDimensioni(null) + myrec.dimensioni = this.resetRecIDimensioni(null); } if (!myrec.testo_title) { - myrec.testo_title = this.resetIText(null) + myrec.testo_title = this.resetIText(null); } if (!myrec.testo_up) { - myrec.testo_up = this.resetIText(null) + myrec.testo_up = this.resetIText(null); } if (!myrec.testo_down) { - myrec.testo_down = this.resetIText(null) + myrec.testo_down = this.resetIText(null); } - - - return myrec + return myrec; }, resetRecIAreaDiStampa(rec: IAreaDiStampa | null) { - - let myrec: IAreaDiStampa = {} + let myrec: IAreaDiStampa = {}; if (!rec) { myrec = { @@ -9701,14 +9656,14 @@ export const tools = { format: [210, 297], scale: 1, scalecanvas: 2, - } + }; } else { - myrec = rec + myrec = rec; } - myrec.margini = this.resetIBorder(myrec.margini) + myrec.margini = this.resetIBorder(myrec.margini); - return myrec + return myrec; }, adjustSize(optcatalogo: IOptCatalogo, mysize: any, add: number = 0) { @@ -9724,22 +9679,22 @@ export const tools = { let size = numericalValue; // Inizializza size con il valore numerico if (add > 0) { - size += add + size += add; } if (optcatalogo.printable && optcatalogo.areadistampa?.scale && optcatalogo.areadistampa?.scale > 0) { size = size * optcatalogo.areadistampa?.scale; // Applicare la scala se necessaria } - const strfinale = `${size}${unit}` + const strfinale = `${size}${unit}`; // console.log('mysize', mysize, ' => ', strfinale) return strfinale; // Restituisce il valore con il suffisso } catch (e) { - return mysize + return mysize; } }, - getValueAndSuffix(myvalue: any): { value: number, suffix: string } { + getValueAndSuffix(myvalue: any): { value: number; suffix: string } { if (!myvalue) { return { value: 0, suffix: '' }; } @@ -9755,16 +9710,18 @@ export const tools = { // Converte un XML in un oggetto JavaScript let obj: any = {}; - if (xml.nodeType === 1) { // Elemento + if (xml.nodeType === 1) { + // Elemento // Se ha attributi, aggiungili all'oggetto if (xml.attributes.length > 0) { - obj["@attributes"] = {} + obj['@attributes'] = {}; for (let j = 0; j < xml.attributes.length; j++) { const attribute = xml.attributes.item(j); - obj["@attributes"][attribute.nodeName] = attribute.nodeValue; + obj['@attributes'][attribute.nodeName] = attribute.nodeValue; } } - } else if (xml.nodeType === 3) { // Testo + } else if (xml.nodeType === 3) { + // Testo obj = xml.nodeValue; } @@ -9773,12 +9730,12 @@ export const tools = { for (let i = 0; i < xml.childNodes.length; i++) { const item = xml.childNodes.item(i); const nodeName = item.nodeName; - if (typeof (obj[nodeName]) === "undefined") { + if (typeof obj[nodeName] === 'undefined') { obj[nodeName] = this.xmlToJson(item); } else { - if (typeof (obj[nodeName]) === "object") { + if (typeof obj[nodeName] === 'object') { // Se l'elemento esiste già, trasformalo in un array - if (typeof (obj[nodeName].push) === "undefined") { + if (typeof obj[nodeName].push === 'undefined') { const old = obj[nodeName]; obj[nodeName] = []; obj[nodeName].push(old); @@ -9791,30 +9748,27 @@ export const tools = { } } } - return obj + return obj; }, // Esempio di utilizzo convertXMLStringToJSON(xmlString: string): any { const parser = new DOMParser(); - const xmlDoc = parser.parseFromString(xmlString, "application/xml"); + const xmlDoc = parser.parseFromString(xmlString, 'application/xml'); const jsonResult = this.xmlToJson(xmlDoc); return jsonResult; }, getScale(optcatalogo: IOptCatalogo): number | undefined { - if (optcatalogo.printable && optcatalogo.generazionePDFInCorso) - return optcatalogo.areadistampa?.scale_printable - else - return optcatalogo.areadistampa!.scale + if (optcatalogo.printable && optcatalogo.generazionePDFInCorso) return optcatalogo.areadistampa?.scale_printable; + else return optcatalogo.areadistampa!.scale; }, getMainLink(url: string): string { try { - // Se l'URL non ha un protocollo, aggiunge "https://" - const baseprotocol = this.getProtocol() + const baseprotocol = this.getProtocol(); const formattedUrl = url.startsWith('http://') || url.startsWith('https://') ? url : `${baseprotocol}${url}`; // Crea un nuovo oggetto URL a partire dall'input @@ -9829,7 +9783,7 @@ export const tools = { // Ricostruisce il link principale return `${protocol}//${host}`; } catch (error) { - console.error('Errore durante l\'elaborazione dell\'URL:', error, 'url=', url); + console.error("Errore durante l'elaborazione dell'URL:", error, 'url=', url); return ''; } }, @@ -9839,161 +9793,213 @@ export const tools = { }, isUtente() { - const userStore = useUserStore() + const userStore = useUserStore(); - return (!userStore.isEditor && !userStore.isCommerciale && !userStore.isAdmin && !userStore.isManager & !userStore.isGrafico) + return ( + !userStore.isEditor && + !userStore.isCommerciale && + !userStore.isAdmin && + !userStore.isManager & !userStore.isGrafico + ); + }, + + getsearchList_RaccoltaCataloghi() { + const lista = [ + { + visible: !this.isUtente(), + label: 'Dettagli', + table: 'finto_racc_dettagli', + key: 'dettagli', + bool: true, + notinsearch: true, // non usarlo nella ricerca filtro + type: costanti.FieldType.boolean, + value: this.isUtente() + ? false + : this.getCookieBool( + this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_racc_dettagli' + costanti.FILTER_SEP + 'dettagli', + true + ), + keycookie: '', + addall: true, + arrvalue: [], + filter: null, + useinput: false, + icon: 'fas fa-info-circle', + }, + ]; + return lista; }, getsearchList_Cataloghi(isCatalogoGenerale: boolean) { const lista = [ { - visible: !this.isUtente(), - label: 'Editore', - table: 'lista_editori', - key: 'referenti', - type: costanti.FieldType.select, - value: this.isUtente() ? costanti.FILTER_TUTTI : this.getCookie(this.COOK_SEARCH + costanti.FILTER_SEP + shared_consts.TABLES_LISTA_EDITORI + costanti.FILTER_SEP + 'referente', costanti.FILTER_TUTTI), - keycookie: '', - addall: true, - arrvalue: [], - filter: null, - useinput: false, - icon: 'fas fa-user' - }, - { - table: 'finto_active', - visible: !this.isUtente(), - label: 'Pubblicati OnLine', - key: 'active', - type: costanti.FieldType.boolean, - value: this.isUtente() ? true: this.getCookieBool(this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_active' + costanti.FILTER_SEP + 'active', true), - bool: true, - keycookie: '', - addall: true, - arrvalue: [], - filter: null, - useinput: false, - icon: 'fas fa-globe' - }, - { - table: 'finto_isCatalogoGenerale', - visible: !this.isUtente(), - label: 'Solo Catalogo Generale', - key: 'isCatalogoGenerale', - type: costanti.FieldType.boolean, - value: this.isUtente() ? isCatalogoGenerale: this.getCookieBool(this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_isCatalogoGenerale' + costanti.FILTER_SEP + 'isCatalogoGenerale', isCatalogoGenerale), - bool: true, - keycookie: '', - addall: true, - arrvalue: [], - filter: null, - useinput: false, - icon: 'fas fa-bookmark' - }, - { - visible: !this.isUtente(), - label: 'Dettagli', - table: 'finto_dettagli', - key: 'dettagli', - bool: true, - notinsearch: true, // non usarlo nella ricerca filtro - type: costanti.FieldType.boolean, - value: this.isUtente() ? false: this.getCookieBool(this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_dettagli' + costanti.FILTER_SEP + 'dettagli', true), - keycookie: '', - addall: true, - arrvalue: [], - filter: null, - useinput: false, - icon: 'fas fa-info-circle' - }, - ] + visible: !this.isUtente(), + label: 'Editore', + table: 'lista_editori', + key: 'referenti', + type: costanti.FieldType.select, + value: this.isUtente() + ? costanti.FILTER_TUTTI + : this.getCookie( + this.COOK_SEARCH + + costanti.FILTER_SEP + + shared_consts.TABLES_LISTA_EDITORI + + costanti.FILTER_SEP + + 'referente', + costanti.FILTER_TUTTI + ), + keycookie: '', + addall: true, + arrvalue: [], + filter: null, + useinput: false, + icon: 'fas fa-user', + }, + { + table: 'finto_active', + visible: !this.isUtente(), + label: 'Pubblicati OnLine', + key: 'active', + type: costanti.FieldType.boolean, + value: this.isUtente() + ? true + : this.getCookieBool( + this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_active' + costanti.FILTER_SEP + 'active', + true + ), + bool: true, + keycookie: '', + addall: true, + arrvalue: [], + filter: null, + useinput: false, + icon: 'fas fa-globe', + }, + { + table: 'finto_isCatalogoGenerale', + visible: !this.isUtente(), + label: 'Solo Catalogo Generale', + key: 'isCatalogoGenerale', + type: costanti.FieldType.boolean, + value: this.isUtente() + ? isCatalogoGenerale + : this.getCookieBool( + this.COOK_SEARCH + + costanti.FILTER_SEP + + 'finto_isCatalogoGenerale' + + costanti.FILTER_SEP + + 'isCatalogoGenerale', + isCatalogoGenerale + ), + bool: true, + keycookie: '', + addall: true, + arrvalue: [], + filter: null, + useinput: false, + icon: 'fas fa-bookmark', + }, + { + visible: !this.isUtente(), + label: 'Dettagli', + table: 'finto_dettagli', + key: 'dettagli', + bool: true, + notinsearch: true, // non usarlo nella ricerca filtro + type: costanti.FieldType.boolean, + value: this.isUtente() + ? false + : this.getCookieBool( + this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_dettagli' + costanti.FILTER_SEP + 'dettagli', + true + ), + keycookie: '', + addall: true, + arrvalue: [], + filter: null, + useinput: false, + icon: 'fas fa-info-circle', + }, + ]; - console.log('getsearchList_Cataloghi', lista) - - return lista + // console.log('getsearchList_Cataloghi', lista); + return lista; }, existProp(obj: any, prop: string) { - return obj ? Object.prototype.hasOwnProperty.call(obj, prop) : false + return obj ? Object.prototype.hasOwnProperty.call(obj, prop) : false; }, getProp(obj: any, prop: string) { - return obj ? obj[prop] : null + return obj ? obj[prop] : null; }, getDirUpload() { - const senzaBarra = false - return senzaBarra ? costanti.DIR_UPLOAD : '/' + costanti.DIR_UPLOAD + const senzaBarra = false; + return senzaBarra ? costanti.DIR_UPLOAD : '/' + costanti.DIR_UPLOAD; }, getProtocol() { // estrai il protocollo da VITE_APP_URL - const url = import.meta.env.VITE_APP_URL - const protocol = url.startsWith('http://') ? 'http://' : url.startsWith('https://') ? 'https://' : '' - return protocol + const url = import.meta.env.VITE_APP_URL; + const protocol = url.startsWith('http://') ? 'http://' : url.startsWith('https://') ? 'https://' : ''; + return protocol; }, isRisoApp() { - return this.appid() === tools.IDAPP_RISO + return this.appid() === tools.IDAPP_RISO; }, isValueNotEmpty(value: any) { // Verifica se `value` è un oggetto non vuoto o un valore valido - return ( - value !== null && - typeof value === "object" && - Object.keys(value).length > 0 - ); + return value !== null && typeof value === 'object' && Object.keys(value).length > 0; }, formatCatProds(catprods: ICatProd[] | undefined | null): string { if (!catprods || !Array.isArray(catprods)) { - return ""; + return ''; } // Estrai il nome e il cognome di ogni autore e uniscili con ', ' return catprods - .map((catprod) => `${catprod.name ?? ""}`.trim()) + .map((catprod) => `${catprod.name ?? ''}`.trim()) .filter((name) => name.length > 0) // Filtra eventuali nomi vuoti - .join(", "); + .join(', '); }, formatCollane(collane: string[] | string): string { if (!collane) { - return ""; + return ''; } - const products = useProducts() + const products = useProducts(); if (Array.isArray(collane)) { // Estrai le collane e uniscile con ', ' return collane .map((idcollana) => { - const reccoll: ICollana | undefined = products.collane!.find((coll: ICollana) => coll._id === idcollana) - return reccoll ? `${reccoll.title ?? ""}`.trim() : "" + const reccoll: ICollana | undefined = products.collane!.find((coll: ICollana) => coll._id === idcollana); + return reccoll ? `${reccoll.title ?? ''}`.trim() : ''; }) .filter((name) => name.length > 0) // Filtra eventuali nomi vuoti - .join(", "); + .join(', '); } else { - const reccoll: ICollana | undefined = products.collane!.find((coll: ICollana) => coll._id === collane) - return reccoll ? `${reccoll.title}` : '' - + const reccoll: ICollana | undefined = products.collane!.find((coll: ICollana) => coll._id === collane); + return reccoll ? `${reccoll.title}` : ''; } }, isDateValid(mydate: Date) { try { return ( - mydate instanceof Date && - isFinite(mydate.getTime()) && - mydate.toISOString().split("T")[0] !== "1970-01-01" - ) + mydate instanceof Date && isFinite(mydate.getTime()) && mydate.toISOString().split('T')[0] !== '1970-01-01' + ); } catch { - return false + return false; } }, - getDescrQuantitàByQuantity(quantity: number) : string { + getDescrQuantitàByQuantity(quantity: number): string { if (quantity <= 1) { return 'Non disponibile'; } else if (quantity > 1 && quantity <= 10) { @@ -10003,9 +10009,14 @@ export const tools = { } else { return 'Buona'; } - }, + addstrCookie(table): string { + let addstr = '_' + table; + return addstr; + }, + + // FINE ! // getLocale() { @@ -10015,4 +10026,4 @@ export const tools = { // return navigator.userLanguages || navigator.language || navigator.browserLanguages || 'it-IT' // } // } -} +}; diff --git a/src/store/Modules/toolsext.ts b/src/store/Modules/toolsext.ts index 9e28812e..f89a386a 100755 --- a/src/store/Modules/toolsext.ts +++ b/src/store/Modules/toolsext.ts @@ -84,6 +84,7 @@ export const toolsext = { TABNEWSLETTER: 'newstosent', TABGALLERY: 'gallery', TABCATALOGS: 'catalogs', + TABRACCOLTA_CATALOGHI: 'raccoltacataloghis', TABMAILINGLIST: 'mailinglist', TABGROUPS: 'groups', TABMYPAGE: 'mypages', diff --git a/src/store/Products.ts b/src/store/Products.ts index da2bfa41..d08c1ab5 100755 --- a/src/store/Products.ts +++ b/src/store/Products.ts @@ -898,6 +898,7 @@ export const useProducts = defineStore('Products', { return ris }, + async loadOrders() { // console.log('loadOrders') diff --git a/src/store/globalStore.ts b/src/store/globalStore.ts index d5b09afc..8144675e 100644 --- a/src/store/globalStore.ts +++ b/src/store/globalStore.ts @@ -432,6 +432,7 @@ export const useGlobalStore = defineStore('GlobalStore', { else if (table === 'mypages_id') ris = state.mypage; else if (table === toolsext.TABMYELEMS) ris = state.myelems; else if (table === toolsext.TABCATALOGS) ris = catalogStore.catalogs!; + else if (table === toolsext.TABRACCOLTA_CATALOGHI) ris = catalogStore.raccoltacataloghis!; else if (table === toolsext.TABCALZOOM) ris = state.calzoom; else if (table === 'producers') ris = state.producers; else if (table === 'storehouses') ris = state.storehouses; @@ -1852,6 +1853,7 @@ export const useGlobalStore = defineStore('GlobalStore', { circuitStore.listaccounts = res.data.listaccounts ? res.data.listaccounts : []; catalogStore.catalogs = res.data.catalogs; + catalogStore.raccoltacataloghis = res.data.raccoltacataloghis; this.settings = res.data.settings ? [...res.data.settings] : []; this.disciplines = res.data.disciplines ? [...res.data.disciplines] : []; @@ -2466,6 +2468,21 @@ export const useGlobalStore = defineStore('GlobalStore', { areadistampa: tools.resetRecIAreaDiStampa(null), }; }, + createRaccoltaCataloghiVuoto(): IOptCatalogo { + return { + productTypes: [0], + excludeproductTypes: [], + idTipologie: [], + formato: [], + Categoria: [], + editore: [], + pdf: false, + dimensioni_def: { + pagina: tools.resetRecIDimensioni(null), + }, + areadistampa: tools.resetRecIAreaDiStampa(null), + }; + }, async prepareAddNewElem(order: any, $q: any, t: any, myelem: any, newtype: any) { const newrec: IMyElem = { @@ -2487,6 +2504,8 @@ export const useGlobalStore = defineStore('GlobalStore', { newrec.catalogo = this.createCatalogoVuoto(); } else if (newrec.type === shared_consts.ELEMTYPE.CATALOGO) { newrec.catalogo = this.createCatalogoVuoto(); + } else if (newrec.type === shared_consts.ELEMTYPE.RACCOLTA) { + newrec.catalogo = this.createRaccoltaCataloghiVuoto(); } const mynewrec = await this.addNewElem($q, t, newrec); @@ -2528,6 +2547,15 @@ export const useGlobalStore = defineStore('GlobalStore', { return false; }); }, + async execJoinPDF(paramquery: any) { + return Api.SendReq('/admin/join-pdf', 'POST', paramquery) + .then((res) => { + return res.data; + }) + .catch((error) => { + return false; + }); + }, async execOnlinePDF(paramquery: any) { return Api.SendReq('/admin/online-pdf', 'POST', paramquery) .then((res) => { @@ -2824,6 +2852,11 @@ export const useGlobalStore = defineStore('GlobalStore', { const prec_lista_prodotti = mytablerec![index].lista_prodotti; mytablerec![index] = { ...mytablerec[index], ...resdata.rec }; mytablerec![index].lista_prodotti = prec_lista_prodotti; + } else if (datain.table === 'raccoltacataloghis') { + // salva lista_cataloghi + const prec_lista_cataloghi = mytablerec![index].lista_cataloghi; + mytablerec![index] = { ...mytablerec[index], ...resdata.rec }; + mytablerec![index].lista_cataloghi = prec_lista_cataloghi; } else { mytablerec![index] = { ...mytablerec[index], ...resdata.rec }; console.log('Aggiorna il record mantenendo reattività'); diff --git a/src/views/ecommerce/catalogo/catalogo.ts b/src/views/ecommerce/catalogo/catalogo.ts index cffa1dc3..3c7a1c97 100755 --- a/src/views/ecommerce/catalogo/catalogo.ts +++ b/src/views/ecommerce/catalogo/catalogo.ts @@ -1702,15 +1702,18 @@ export default defineComponent({ } } - function addProductToList(element: IProduct) { + function addProductToList(element: IProduct, where: string) { // console.log('addProductToList', element) if (element) { // add this record to lista_prodotti - if (getCatalogoByMyPage.value && !getCatalogoByMyPage.value.lista_prodotti.some((p) => p._id === element._id)) { + if (getCatalogoByMyPage.value && !getCatalogoByMyPage.value.lista_prodotti?.some((p) => p._id === element._id)) { // inserire il record in cima - const arr = getCatalogoByMyPage.value.lista_prodotti; - arr.unshift(element); + const arr = getCatalogoByMyPage.value.lista_prodotti || []; + if (where === shared_consts.WHERE_INSERT.ONTOP) + arr.unshift(element); + else if (where === shared_consts.WHERE_INSERT.ONBOTTOM) + arr.push(element) updateProducts(arr); @@ -1944,9 +1947,9 @@ export default defineComponent({ const ris = await globalStore.execOnlinePDF({ id_catalog: catalog._id, stampa: false }); if (ris) { - if (ris.catalog?.pdf_online) { - catalog.pdf_online = ris.catalog.pdf_online; - catalog.data_online = ris.catalog.data_online; + if (ris.record?.pdf_online) { + catalog.pdf_online = ris.record.pdf_online; + catalog.data_online = ris.record.data_online; } $q.notify({ color: 'positive', @@ -1969,9 +1972,9 @@ export default defineComponent({ const ris = await globalStore.execOnlinePDF({ id_catalog: catalog._id, stampa: true }); if (ris) { - if (ris.catalog.pdf_online_stampa) { - catalog.pdf_online_stampa = ris.catalog.pdf_online_stampa; - catalog.data_online_stampa = ris.catalog.data_online_stampa; + if (ris.record.pdf_online_stampa) { + catalog.pdf_online_stampa = ris.record.pdf_online_stampa; + catalog.data_online_stampa = ris.record.data_online_stampa; } $q.notify({ color: 'positive', diff --git a/src/views/ecommerce/catalogo/catalogo.vue b/src/views/ecommerce/catalogo/catalogo.vue index b5b15a9a..42e9d206 100755 --- a/src/views/ecommerce/catalogo/catalogo.vue +++ b/src/views/ecommerce/catalogo/catalogo.vue @@ -231,6 +231,7 @@ :lista_prodotti="lista_prodotti" @update:lista_prodotti="updateProducts" :optcatalogo="optcatalogo" + table="products" @rigenera="generaListaLibri()" /> @@ -1072,6 +1073,7 @@ @close="addnewProd = false" nameLinkTemplate="SEARCH_Prima" :empty="true" + table="catalogs" > diff --git a/src/views/ecommerce/raccoltacataloghi/index.ts b/src/views/ecommerce/raccoltacataloghi/index.ts new file mode 100755 index 00000000..310db24e --- /dev/null +++ b/src/views/ecommerce/raccoltacataloghi/index.ts @@ -0,0 +1 @@ +export {default as RaccoltaCataloghi} from './raccoltacataloghi.vue' diff --git a/src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.scss b/src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.scss new file mode 100755 index 00000000..a85711d1 --- /dev/null +++ b/src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.scss @@ -0,0 +1,166 @@ +$heightBtn: 100%; +$colore_titolo_libro: rgb(210, 12, 12); + +body { + line-height: 1.2 !important; +} + +.card .product-image { + height: 300px; +} + +.container { + margin-top: 4px; + margin-bottom: 4px; +} + +.prod_trov { + font-style: italic; + color: grey; +} + +.fixed-group { + position: fixed; + top: 0; + left: 0; + width: 100%; + background-color: #ffffff; + /* Customize the background color as needed */ + z-index: 1000; + /* Adjust the z-index to ensure it's above other elements */ + transition: all 1s ease; +} + + +.category-title { + font-weight: bold; + font-size: 1.1rem; + margin-bottom: 0.5rem; + margin-top: 0.5rem; + color: black; + text-align: center; + +} + +.fixed-width { + width: var(--width) !important; + /* Usa una variabile CSS */ +} + +.fixed-height { + height: var(--height) !important; + /* Usa una variabile CSS */ +} + +.break { + flex-basis: 100%; + height: 0; +} + +.book-title { + font-family: 'DINPro-Condensed-Bold', sans-serif; + color: $colore_titolo_libro; + text-transform: uppercase; + margin-top: calc(5 * var(--scalecatalog) * 1px); + margin-bottom: calc(5 * var(--scalecatalog) * 1px); + font-size: calc(18 * var(--scalecatalog) * 1px); + line-height: 100%; + font-weight: bold; +} + +.book-author { + font-family: 'DINPro-Condensed-Regular', sans-serif; + font-size: calc(16 * var(--scalecatalog) * 1px); +} + +.book-descr { + font-family: 'DINPro-Condensed-Bold-Italic', sans-serif; + font-size: calc(16 * var(--scalecatalog) * 1px); +} + +.book-details { + font-family: 'DINPro-Condensed-Regular', sans-serif; + margin-bottom: calc(5 * var(--scalecatalog) * 1px); + font-size: calc(16 * var(--scalecatalog) * 1px); + text-align: left !important; + + &.big { + font-size: calc(22 * var(--scalecatalog) * 1px); + } +} + + +.book-descr-estesa { + font-family: 'AGaramondPro-Regular', sans-serif; + font-size: calc(15 * var(--scalecatalog) * 1px); + text-align: justify; + word-wrap: break-word; +} + +.book-link { + font-style: italic; + font-size: calc(14 * var(--scalecatalog) * 1px); +} + +.book-novita { + font-size: calc(20 * var(--scalecatalog) * 1px); +} + + +.book-text-up { + font-family: 'DINPro', sans-serif; + margin-bottom: calc(5 * var(--scalecatalog) * 1px); + font-size: calc(20 * var(--scalecatalog) * 1px); + height: calc(380 * var(--scalecatalog) * 1px); + line-height: 130%; +} + +.book-text-down { + font-family: 'DINPro', sans-serif; + margin-bottom: calc(5 * var(--scalecatalog) * 1px); +} + +.book-pagina-title { + font-family: 'DINPro', sans-serif; + margin-top: calc(20 * var(--scalecatalog) * 1px); + margin-bottom: calc(5 * var(--scalecatalog) * 1px); + font-size: calc(35 * var(--scalecatalog) * 1px); + height: calc(100 * var(--scalecatalog) * 1px); +} + +.categories { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 8px; + padding: 12px; + border-radius: 24px; + background-color: #e6f0ff; +} + +.category { + font-family: 'Segoe UI', Arial, sans-serif; + font-size: 0.95rem; + padding: 8px 16px; + background-color: white; + color: #2c3e50; + border: 1px solid #b0c4de; + border-radius: 20px; + cursor: pointer; + transition: all 0.2s ease-in-out; + user-select: none; +} + +.category:hover { + background-color: #dbe9ff; + color: #1a3f8a; + border-color: #89aef0; +} + +.category_sel { + background-color: #5c8ef4 !important; + color: white !important; + font-weight: 600; + border-color: #5c8ef4 !important; + box-shadow: 0 0 0 2px rgba(92, 142, 244, 0.3); +} diff --git a/src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.ts b/src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.ts new file mode 100755 index 00000000..e0570a36 --- /dev/null +++ b/src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.ts @@ -0,0 +1,430 @@ +import type { PropType } from 'vue'; +import { defineComponent, onMounted, ref, watch, computed, onBeforeUnmount, nextTick } from 'vue'; +import { tools } from '@tools'; +import { useUserStore } from '@store/UserStore'; +import { useRouter } from 'vue-router'; +import { useGlobalStore } from '@store/globalStore'; +import { useProducts } from '@store/Products'; +import { useI18n } from 'vue-i18n'; +import { toolsext } from '@store/Modules/toolsext'; +import { useQuasar } from 'quasar'; +import { costanti } from '@costanti'; + +import { shared_consts } from '@src/common/shared_vuejs'; +import { CProductCard } from '@src/components/CProductCard'; + +import { CMyDialog } from '@src/components/CMyDialog'; +import { CMySelect } from '@src/components/CMySelect'; +import { CMyValueDb } from '@src/components/CMyValueDb'; +import { CProductTable } from '@src/components/CProductTable'; +import { CSearchProduct } from '@src/components/CSearchProduct'; +import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard'; +import { CSelectUserActive } from '@src/components/CSelectUserActive'; + +import html2pdf from 'html2pdf.js'; +import { PDFDocument } from 'pdf-lib'; +import { saveAs } from 'file-saver'; + +import type { + IOptCatalogo, + IDimensioni, + IFilterCatalogo, + IProdView, + IProduct, + ISearchList, + ICatalog, + IImg, + IText, + ICollana, + IOptRigenera, + IOpAndOr, +} from 'model'; +import { IMyPage } from 'model'; + +import { fieldsTable } from '@store/Modules/fieldsTable'; +import { useCatalogStore } from '@src/store/CatalogStore'; + +export default defineComponent({ + name: 'RaccoltaCataloghi', + components: { + CContainerCatalogoCard, + CProductCard, + CSelectUserActive, + CMySelect, + CProductTable, + CSearchProduct, + CMyDialog, + CMyValueDb, + }, + emits: ['update:modelValue', 'updateCatalogo'], + props: { + modelValue: { + type: Object as PropType, + required: true, + }, + idPage: { + type: String, + required: false, + default: '', + }, + }, + setup(props, { emit }) { + const userStore = useUserStore(); + const globalStore = useGlobalStore(); + const productStore = useProducts(); + const router = useRouter(); + const $q = useQuasar(); + const { t } = useI18n(); + + const rigeneraLibri = ref(false); + + const search = ref(''); + const optauthors = ref([]); + + const loadpage = ref(false) + + const pdfContent = ref(null); + const addnewProd = ref(false); + + const widthpdf = ref('8.88'); + const heightpdf = ref('12.31'); + const compressionepdf = ref('prepress'); + + const optcatalogo = ref({ ...props.modelValue }); + + const getRaccoltaCataloghiByMyPage = computed(() => { + return catalogStore.raccoltacataloghis?.find((raccolta: IRaccoltaCatalogo) => raccolta.idPageAssigned === props.idPage); + }); + + + const lista_cataloghi = computed(() => { + const arr = catalogStore.raccoltacataloghis?.find( + (raccolta: IRaccoltaCatalogo) => raccolta.idPageAssigned === props.idPage + ); + return arr?.lista_cataloghi; + }); + + const ispageCatalogata = computed(() => { + return !!getRaccoltaCataloghiByMyPage.value; + }); + + const mycolumns = ref([]); + + const catalogStore = useCatalogStore(); + + const tabraccolta = ref('lista'); + + const searchList = ref([] as ISearchList[]); + + const numRecLoaded = ref(0); + + // Create a ref for the component to fix + const componentToFixRef = ref(null); + + const isFixed = ref(false); + + watch( + () => tabraccolta.value, + () => { + tools.setCookie('RACC_TAB_CAT', tabraccolta.value); + } + ); + + const labelcombo = computed(() => (item: any) => { + let lab = item.label; + if (item.showcount) lab += ' (' + valoriopt.value(item, false, false).length + ')'; + return lab; + }); + + const arrLoaded = computed(() => { + if (arrCataloghi.value && numRecLoaded.value) return arrCataloghi.value.slice(0, numRecLoaded.value); + else { + return []; + } + }); + + function getTitoloRaccolta(): string { + const trovatoraccolta = getRaccoltaCataloghiByMyPage.value; + + return trovatoraccolta ? trovatoraccolta.title : 'Raccolta'; + } + + function getSfondoImgCatalogo(scheda?: IMyScheda | null, mypage?: IDimensioni): IImg { + const trovatoraccolta = getRaccoltaCataloghiByMyPage.value; + + let imagefile = ''; + let fit = 'contain'; + + if (trovatoraccolta) { + // Poi cerca se c'è l'immagine di sfondo + const recimg = trovatoraccolta.img_bordata!; + if (!imagefile && recimg) { + imagefile = recimg.imagefile!; + fit = recimg.fit! || 'contain'; + imagefile = imagefile + ? `url(${tools.getDirUpload() + shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG) + '/' + trovatoraccolta._id + '/' + imagefile})` + : ''; + } + } + if (!imagefile) { + let myimg = costanti.CATALOGHI.PAG_SFONDO_DEFAULT; + // Se non c'è un immagine di sfondo, allora prende quella di default + imagefile = `url(${tools.getDirUpload() + shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG) + '/' + myimg})`; + } + + if (!imagefile && mypage) { + imagefile = mypage.imgsfondo!.imagefile!; + imagefile = imagefile ? `url(${tools.getDirUpload() + costanti.DIR_CATALOGO + imagefile})` : ''; + fit = mypage.imgsfondo!.fit!; + } + + return { imagefile, fit }; + } + + function salvaListaRaccolte(ricarica: boolean) { + // Estrai solo gli ID dei prodotti filtrati + const myarr = [...getRaccoltaCataloghiByMyPage.value.lista_cataloghi]; + const catalogoIds = myarr.map((catalog) => (catalog._id ? catalog._id : null)).filter((id) => id !== null); + + let mydata = { + lista_cataloghi: catalogoIds, + }; + + // Salva gli ID dei prodotti nel catalogo + tools.saveFieldToServer($q, 'raccoltacataloghis', getRaccoltaCataloghiByMyPage.value._id, mydata, true, false); + + } + + async function mounted() { + // console.log('mounted Catalogo') + + if (getRaccoltaCataloghiByMyPage.value) { + tabraccolta.value = tools.getCookie('RACC_TAB_CAT', 'lista'); + } else { + tabraccolta.value = 'lista'; + } + + loadpage.value = false; + // await productStore.loadProducts(true); + + mycolumns.value = fieldsTable.getArrColsByTable('raccoltacataloghis'); + + // Inizializza + loadpage.value = true; + + calcArrCataloghi(); + } + + function calcArrCataloghi() {} + + function loaddata() { + numRecLoaded.value = 20; + } + + function naviga(path: string) { + router.push(path); + } + + function updateRaccolta(arr: any) { + if (getRaccoltaCataloghiByMyPage.value) { + getRaccoltaCataloghiByMyPage.value.lista_cataloghi = [...arr]; + + salvaListaRaccolte(true); + } + } + + function addCatalogToList(element: ICatalog, where: string) { + // console.log('addCatalogToList', element) + + if (element) { + // add this record to lista_cataloghi + if ( + getRaccoltaCataloghiByMyPage.value && + element._id && !getRaccoltaCataloghiByMyPage.value.lista_cataloghi?.some((p) => p?._id === element._id) + ) { + // inserire il record in cima + const arr = getRaccoltaCataloghiByMyPage.value.lista_cataloghi || []; + if (where === shared_consts.WHERE_INSERT.ONTOP) + arr.unshift(element); + else if (where === shared_consts.WHERE_INSERT.ONBOTTOM) + arr.push(element) + + updateRaccolta(arr); + + addnewProd.value = false; + } + } + } + + function clickaddNewBook() { + addnewProd.value = true; + } + + function toggleDebug() { + optcatalogo.value.indebug = !optcatalogo.value.indebug; + } + + const preparePDF = (stampa: boolean) => { + + let addstr = stampa ? ' per la STAMPA' : '' + $q.dialog({ + message: `Generare il PDF ${addstr}?`, + ok: { + label: t('dialog.yes'), + push: true, + }, + cancel: { + label: t('dialog.cancel'), + }, + title: 'Generazione PDF', + }).onOk(async () => { + generaPDF(stampa); + }); + }; + + async function saveRaccolta() { + const raccolta = getRaccoltaCataloghiByMyPage.value + const mydata = { + table: 'raccoltacataloghis', + data: raccolta, + }; + + await globalStore.saveTable(mydata); + } + + + async function generaPDF(stampa: boolean) { + $q.loading.show({ + message: 'Generazione della Raccolta Catalogo in PDF in corso ...', + }); + + try { + const options = { + id_raccolta: getRaccoltaCataloghiByMyPage.value._id, + stampa, + metti_online: false, + dir_out: '/upload/raccolte/', + } + const ris = await globalStore.execJoinPDF({options}); + + if (ris) { + const raccolta = getRaccoltaCataloghiByMyPage.value; + if (!stampa && ris.raccolta.pdf_generato) { + raccolta.pdf_generato = ris.raccolta.pdf_generato; + raccolta.data_generato = tools.getDateNow(); + } + if (stampa && ris.raccolta.pdf_generato_stampa) { + raccolta.pdf_generato_stampa = ris.raccolta.pdf_generato_stampa; + raccolta.data_generato_stampa = tools.getDateNow(); + } + + await saveRaccolta(); + } + + $q.loading.hide(); + $q.notify({ + color: 'positive', + message: 'PDF generato con successo!', + icon: 'check', + }); + } catch (error) { + $q.loading.hide(); + $q.notify({ + color: 'negative', + message: 'Errore nella generazione del PDF', + icon: 'error', + }); + console.error('Errore nella generazione del PDF:', error); + } + } + + const pubblicaPDF = async () => { + const raccolta = getRaccoltaCataloghiByMyPage.value; + + const ris = await globalStore.execOnlinePDF({ id_raccolta: raccolta._id, stampa: false }); + + if (ris) { + if (ris.record?.pdf_online) { + raccolta.pdf_online = ris.record.pdf_online; + raccolta.data_online = ris.record.data_online; + } + + $q.notify({ + color: 'positive', + message: 'PDF inviato ONLINE!', + icon: 'check', + }); + } else { + $q.loading.hide(); + $q.notify({ + color: 'negative', + message: "Errore nell'invio del PDF OnLine", + icon: 'error', + }); + } + }; + + const pubblicaPDFStampa = async () => { + const raccolta = getRaccoltaCataloghiByMyPage.value; + + const ris = await globalStore.execOnlinePDF({ id_raccolta: raccolta._id, stampa: true }); + + if (ris) { + if (ris.record.pdf_online_stampa) { + raccolta.pdf_online_stampa = ris.record.pdf_online_stampa; + raccolta.data_online_stampa = ris.record.data_online_stampa; + } + + await saveRaccolta(); + + $q.notify({ + color: 'positive', + message: 'PDF STAMPA inviato ONLINE!', + icon: 'check', + }); + } else { + $q.loading.hide(); + $q.notify({ + color: 'negative', + message: "Errore nell'invio del PDF STAMPA OnLine", + icon: 'error', + }); + } + + } + + onMounted(mounted); + + return { + userStore, + costanti, + tools, + toolsext, + search, + shared_consts, + productStore, + t, + componentToFixRef, + isFixed, + numRecLoaded, + arrLoaded, + mycolumns, + tabraccolta, + naviga, + getTitoloRaccolta, + lista_cataloghi, + updateRaccolta, + clickaddNewBook, + addCatalogToList, + addnewProd, + rigeneraLibri, + getRaccoltaCataloghiByMyPage, + preparePDF, + pubblicaPDF, + pubblicaPDFStampa, + loadpage, + ispageCatalogata, + optcatalogo, + }; + }, +}); diff --git a/src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.vue b/src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.vue new file mode 100755 index 00000000..f2b4e04e --- /dev/null +++ b/src/views/ecommerce/raccoltacataloghi/raccoltacataloghi.vue @@ -0,0 +1,184 @@ + + + + + diff --git a/tsconfig.json b/tsconfig.json index ccace68d..1e1615b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "resolveJsonModule": true, "moduleDetection": "force", "isolatedModules": true, - "module": "preserve", + "module": "ESNext", "noEmit": true, "lib": [ "esnext", @@ -159,7 +159,8 @@ "include": [ "./**/*.d.ts", "./**/*", - ".eslintrc.js" + ".eslintrc.js", + "src/**/*", ], "exclude": [ "./dist",