diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index 1b2ca847..ff664085 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -2500,6 +2500,7 @@ export const shared_consts = { SCHEDA_PRODOTTO: { CMD_NONE: 0, CMD_MODIFICA: 1, + CMD_SCHEDA: 2, }, VISU_SEARCHPROD_MODE: { diff --git a/src/components/CProductTable/CProductTable.scss b/src/components/CProductTable/CProductTable.scss index 076a8fad..0762c35e 100755 --- a/src/components/CProductTable/CProductTable.scss +++ b/src/components/CProductTable/CProductTable.scss @@ -20,4 +20,15 @@ vertical-align: middle; } + + .custom-flat-button { + border: 1px solid #0078D4; /* Colore del bordo */ + background-color: transparent; /* Rendi il background trasparente */ + color: #0078D4; /* Colore dell'icona e del testo */ + } + + .custom-flat-button:hover { + background-color: rgba(0, 120, 212, 0.1); /* Aggiungi un colore di hover, se desideri */ + border-color: #005A8C; /* Colore del bordo al passaggio del mouse */ + } \ No newline at end of file diff --git a/src/components/CProductTable/CProductTable.ts b/src/components/CProductTable/CProductTable.ts index a03384ca..40faf5a5 100755 --- a/src/components/CProductTable/CProductTable.ts +++ b/src/components/CProductTable/CProductTable.ts @@ -1,9 +1,18 @@ -import { PropType, computed, defineComponent, onMounted, ref, watch } from 'vue'; +import { + PropType, + computed, + defineComponent, + onMounted, + ref, + watch, +} from 'vue'; import draggable from 'vuedraggable'; import { tools } from '@tools'; -import { useRouter } from 'vue-router' +import { useQuasar } from 'quasar'; + +import { useRouter } from 'vue-router'; import { useGlobalStore } from '@src/store/globalStore'; import { useProducts } from '@src/store/productStore'; @@ -58,12 +67,14 @@ export default defineComponent({ // Copia locale della lista_prodotti per manipolazione interna const internalProducts = ref([...(props.lista_prodotti || [])]); - const productStore = useProducts() + const productStore = useProducts(); - const $router = useRouter() + const $router = useRouter(); const { t } = useI18n(); + const $q = useQuasar(); + const globalStore = useGlobalStore(); const products = useProducts(); @@ -117,7 +128,24 @@ export default defineComponent({ // Colonne della tabella const allColumns_Raccolta = ref([ - { name: 'pos', label: 'Ind', field: 'pos', align: 'left', style: 'width: 50px', notsortable: true }, + { + name: 'pos', + label: 'Ind', + field: 'pos', + align: 'left', + style: 'width: 50px', + notsortable: true, + }, + { + name: 'edit', + label: 'Mod', + field: '', + align: 'left', + style: 'width: 50px', + edit: true, + noexp: true, + notsortable: true, + }, { name: 'drag', label: 'Ord', @@ -128,16 +156,63 @@ export default defineComponent({ noexp: true, notsortable: true, }, - { name: 'image', label: 'Foto', field: 'image', align: 'center', 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: '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', @@ -150,7 +225,24 @@ export default defineComponent({ ]); const allColumns_Catalog = ref([ - { name: 'pos', label: 'Ind', field: 'pos', align: 'left', style: 'width: 50px', notsortable: true }, + { + name: 'pos', + label: 'Ind', + field: 'pos', + align: 'left', + style: 'width: 50px', + notsortable: true, + }, + { + name: 'edit', + label: 'Mod', + field: '', + align: 'left', + style: 'width: 50px', + edit: true, + noexp: true, + notsortable: true, + }, { name: 'drag', label: 'Ord', @@ -161,37 +253,156 @@ export default defineComponent({ noexp: true, notsortable: true, }, - { name: 'validato', label: 'Val', field: 'validato', align: 'left', style: '' }, - { name: 'scraped', label: 'Estratto', field: 'scraped', align: 'left', style: '' }, - { name: 'image', label: 'Foto', field: 'image', align: 'center', noexp: true, notsortable: true }, + { + name: 'validato', + label: 'Val', + field: 'validato', + align: 'left', + style: '', + }, + { + name: 'scraped', + label: 'Estratto', + field: 'scraped', + align: 'left', + style: '', + }, + { + name: 'scraped_error', + label: 'Err estrazione', + field: 'scraped_error', + 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: '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: '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: '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: '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: '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: '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', @@ -210,7 +421,9 @@ export default defineComponent({ if (props.table === shared_consts.TABLES_CATALOG) { selectedColumns.value = selectedColumns_Catalogs.value; } else { - selectedColumns.value = tools.isUtente() ? selectedColumns_Utenti.value : selectedColumns_Editori.value; + selectedColumns.value = tools.isUtente() + ? selectedColumns_Utenti.value + : selectedColumns_Editori.value; } addstr.value = tools.addstrCookie(props.table); @@ -295,7 +508,10 @@ export default defineComponent({ switch (field.field) { case 'image': return element.productInfo?.imagefile - ? tools.getFullFileNameByImageFile('productInfos', element.productInfo?.imagefile) + ? tools.getFullFileNameByImageFile( + 'productInfos', + element.productInfo?.imagefile + ) : element.productInfo?.image_link; case 'name': @@ -318,12 +534,19 @@ export default defineComponent({ return element.scraped === true ? 'SI' : ''; + case 'scraped_error': + return element.scraped_error === true + ? 'ERR' + : ''; case 'isbn': return element.isbn; case 'trafiletto': - return element.productInfo?.descr_trafiletto_catalogo?.length > 100 ? 'SI' : 'NO'; + return element.productInfo?.descr_trafiletto_catalogo?.length > + 100 + ? 'SI' + : 'NO'; case 'catprods': return tools.formatCatProds(element.productInfo?.catprods); @@ -332,19 +555,27 @@ export default defineComponent({ return element.arrvariazioni?.[0]?.edizione; case 'casaeditrice': - return products.getCasaEditriceByIdPublisher(element.productInfo?.idPublisher); + return products.getCasaEditriceByIdPublisher( + element.productInfo?.idPublisher + ); case 'idCollana': return tools.formatCollane(element.productInfo?.idCollana); case 'stato': - return products.getDescrStatiProdottoByIdStatoProdotto(element.productInfo?.idStatoProdotto || ''); + return products.getDescrStatiProdottoByIdStatoProdotto( + element.productInfo?.idStatoProdotto || '' + ); case 'tipologia': - return products.getDescrByIdTipologia(element.arrvariazioni?.[0]?.idTipologia || ''); + return products.getDescrByIdTipologia( + element.arrvariazioni?.[0]?.idTipologia || '' + ); case 'tipoformato': - return products.getDescrByIdTipoFormato(element.arrvariazioni?.[0]?.idTipoFormato || ''); + return products.getDescrByIdTipoFormato( + element.arrvariazioni?.[0]?.idTipoFormato || '' + ); case 'date_pub': return tools.getstrDate(element.productInfo?.date_pub); @@ -353,7 +584,9 @@ export default defineComponent({ return element.price ? '€ ' + element.price.toFixed(2) : ''; case 'prezzo_sconto': - return element.sale_price ? '€ ' + element.sale_price.toFixed(2) : ''; + return element.sale_price + ? '€ ' + element.sale_price.toFixed(2) + : ''; case 'rank3M': return element.productInfo?.rank3M; @@ -386,7 +619,10 @@ export default defineComponent({ return tools.getstrDate(element.productInfo?.dataUltimoOrdine); case 'quantity': - if (tools.isUtente()) return tools.getDescrQuantitàByQuantity(element.arrvariazioni?.[0]?.quantita); + if (tools.isUtente()) + return tools.getDescrQuantitàByQuantity( + element.arrvariazioni?.[0]?.quantita + ); else return element.arrvariazioni?.[0]?.quantita; default: @@ -403,7 +639,9 @@ export default defineComponent({ 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)) { @@ -420,7 +658,9 @@ export default defineComponent({ case 'validato': if (element.validaprod?.esito === costanti.VALIDATO.SI) { return 'bg-green'; - } else if (element.validaprod?.esito === costanti.VALIDATO.TO_RESOLV) { + } else if ( + element.validaprod?.esito === costanti.VALIDATO.TO_RESOLV + ) { return 'bg-red'; } else { return 'bg-grey'; @@ -514,6 +754,7 @@ export default defineComponent({ : [ 'pos', 'drag', + 'edit', 'validato', 'image', 'name', @@ -547,7 +788,9 @@ export default defineComponent({ ] ); const selectedColumns_Catalogs = ref( - cookieValue.length > 0 ? cookieValue : ['pos', 'drag', 'image', 'title', 'pdf_generato', 'actions'] + cookieValue.length > 0 + ? cookieValue + : ['pos', 'drag', 'image', 'title', 'pdf_generato', 'actions'] ); const selectedColumns = ref([]); @@ -564,7 +807,8 @@ export default defineComponent({ } const ok = allColumns.value.some((col) => col.name === column) && - (!props.optcatalogo.showListaArgomenti || (props.optcatalogo.showListaArgomenti && !column.edit)); + (!props.optcatalogo.showListaArgomenti || + (props.optcatalogo.showListaArgomenti && !column.edit)); return selectedColumns.value.includes(column) && ok; }; @@ -575,13 +819,32 @@ export default defineComponent({ // 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 + return $q + .dialog({ + message: t('scheda.removeProduct'), + html: true, + ok: { + label: t('dialog.yes'), + push: false, + }, + title: '', + cancel: true, + persistent: false, + }) + .onOk(() => { + internalProducts.value = internalProducts.value.filter( + (p: any) => p._id !== product._id + ); + emit('update:lista_prodotti', internalProducts.value); // Notifica il parent del cambiamento + }); }; // 8. Salvataggio delle colonne selezionate in un cookie const saveSelectedColumns = () => { - tools.setCookie(addstr.value + '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 @@ -688,11 +951,12 @@ export default defineComponent({ 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 - ); + field_updated_fromGM.value = + await globalStore.getGM_FieldOf_T_Web_Articoli( + selProd.value.productInfo.sku!, + field, + shared_consts.CmdQueryMs.GET + ); loading.value = false; } } @@ -707,32 +971,40 @@ export default defineComponent({ sortAttribute.value = sortAttributeToSort; sortDirection.value = 1; } - internalProducts.value = internalProducts.value.sort((a: any, b: any) => { - const aVal = getFieldValue(a, { field: sortAttributeToSort }); - const bVal = getFieldValue(b, { field: sortAttributeToSort }); - if (aVal instanceof Date && bVal instanceof Date) { - return sortDirection.value === 1 ? aVal.getTime() - bVal.getTime() : bVal.getTime() - aVal.getTime(); + internalProducts.value = internalProducts.value.sort( + (a: any, b: any) => { + const aVal = getFieldValue(a, { field: sortAttributeToSort }); + const bVal = getFieldValue(b, { field: sortAttributeToSort }); + 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}$/) + ) { + 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(); + } + if (typeof aVal === 'number' && typeof bVal === 'number') { + return sortDirection.value === 1 ? aVal - bVal : bVal - aVal; + } + 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)); } - 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(); - } - if (typeof aVal === 'number' && typeof bVal === 'number') { - return sortDirection.value === 1 ? aVal - bVal : bVal - aVal; - } - 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)); - }); + ); } }; @@ -772,7 +1044,9 @@ export default defineComponent({ .join('|'), ...internalProducts.value.map((product: any) => { return selectedColumns.value - .filter((col) => !allColumns.value.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' @@ -783,7 +1057,8 @@ export default defineComponent({ }), ].join('\r\n'); - const filename = 'prodotti_' + new Date().toISOString().slice(0, 10) + '.csv'; + const filename = + 'prodotti_' + new Date().toISOString().slice(0, 10) + '.csv'; const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }); const link = document.createElement('a'); const url = URL.createObjectURL(blob); @@ -798,7 +1073,10 @@ export default defineComponent({ } function isSortable(field: string): boolean { - return allColumns && !allColumns.value.find((col) => col.name === field)?.notsortable; + return ( + allColumns && + !allColumns.value.find((col) => col.name === field)?.notsortable + ); } function getImageByElement(element) { diff --git a/src/components/CProductTable/CProductTable.vue b/src/components/CProductTable/CProductTable.vue index 22d409f0..add24a48 100755 --- a/src/components/CProductTable/CProductTable.vue +++ b/src/components/CProductTable/CProductTable.vue @@ -47,12 +47,16 @@ v-if="isColumnVisible(col.name)" :key="col.name" @click="isSortable(col.name) ? sortTable(col.name) : ''" - :style="{ 'background-color': sortAttribute === col.name ? 'yellow' : '' }" + :style="{ + 'background-color': sortAttribute === col.name ? 'yellow' : '', + }" > {{ col.label }} - {{ - // put index in the first column - internalProducts.indexOf(element) + 1 - }} +
+ {{ + // put index in the first column + internalProducts.indexOf(element) + 1 + }} + +
+ + + + + - +
- + - - Modifica + + Scheda @@ -157,7 +196,11 @@ > - + Elimina diff --git a/src/components/CSchedaProdotto/CSchedaProdotto.ts b/src/components/CSchedaProdotto/CSchedaProdotto.ts index 0c24a8cb..fed33f6d 100755 --- a/src/components/CSchedaProdotto/CSchedaProdotto.ts +++ b/src/components/CSchedaProdotto/CSchedaProdotto.ts @@ -270,6 +270,18 @@ export default defineComponent({ dense: true, showall: true, }, + { + editOn: true, + label: 'Imagefile', + table: 'productinfos', + id: myproduct.value.productInfo._id, // ID dinamico, da sostituire con il valore reale + rec: myproduct.value.productInfo, // Oggetto dinamico, da sostituire con il valore reale + mykey: 'imagefile', + debounce: '1000', + type: costanti.FieldType.string, + dense: true, + showall: true, + }, ]; return arrlist; @@ -310,17 +322,6 @@ export default defineComponent({ type: costanti.FieldType.string, dense: true, }, - /*{ - editOn: true, - label: "Pagine", - table: "arrvariazioni", - id: myproduct.value._id, - rec: myproduct.value, - mykey: "data_verifica", - debounce: "0", - type: costanti.FieldType.date, - dense: true, - },*/ { editOn: false, label: 'Pubblicazione', @@ -478,7 +479,18 @@ export default defineComponent({ table: 'products', id: myproduct.value._id, rec: myproduct.value, - mykey: 'scraped', + mykey: 'scraped_date', + debounce: '1000', + type: costanti.FieldType.data, + dense: true, + }, + { + editOn: false, + label: 'Err Scraped', + table: 'products', + id: myproduct.value._id, + rec: myproduct.value, + mykey: 'scraped_error', debounce: '1000', type: costanti.FieldType.boolean, dense: true, @@ -611,6 +623,8 @@ export default defineComponent({ .then((dataupdated) => { if (dataupdated) { tools.showPositiveNotif($q, t('dbgm.scrapingOkUpdated')); + } else { + tools.showNeutralNotif($q, t('dbgm.scrapingNotUpdated')); } return dataupdated; }) diff --git a/src/model/Products.ts b/src/model/Products.ts index 0ea38203..6055a3ce 100755 --- a/src/model/Products.ts +++ b/src/model/Products.ts @@ -99,6 +99,7 @@ export interface IVariazione { eta?: string validaprod?: IValidaProd scraped?: boolean + scraped_error?: boolean } export interface IAuthor { diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js index b794bb45..847e5823 100755 --- a/src/statics/lang/it.js +++ b/src/statics/lang/it.js @@ -2068,12 +2068,14 @@ const msg_it = { scheda: { isPagIntro: 'Pagina Introduttiva', + removeProduct: 'Rimuovere il titolo selezionato dalla lista?', }, dbgm: { updateLocalDb_OK: 'Dati Aggiornati in locale', updateLocalDb_ERROR: 'Errore aggiornamento singolo libro', scrapingOkUpdated: 'Dati Aggiornati prelevando dal Web', + scrapingNotUpdated: 'Dati non aggiorrnati (o non trovati!)', }, queryai: { diff --git a/src/store/Modules/fieldsTable.ts b/src/store/Modules/fieldsTable.ts index cc831342..81489e6a 100755 --- a/src/store/Modules/fieldsTable.ts +++ b/src/store/Modules/fieldsTable.ts @@ -2842,6 +2842,7 @@ export const colTableProducts = [ AddCol({ name: 'canBeBuyOnline', label_trans: 'products.canBeBuyOnline', fieldtype: costanti.FieldType.boolean }), AddCol({ name: 'validaprod', label_trans: 'products.validaprod', fieldtype: costanti.FieldType.verifica }), AddCol({ name: 'scraped', label_trans: 'products.scraped', fieldtype: costanti.FieldType.boolean }), + AddCol({ name: 'scraped_error', label_trans: 'products.scraped_error', fieldtype: costanti.FieldType.boolean }), AddCol(DeleteRec), AddCol(DuplicateRec), ] diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index 0f10f507..b2b6218c 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -56,7 +56,15 @@ 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 { + copyToClipboard, + date, + Screen, + useQuasar, + colors, + Cookies, + scroll, +} from 'quasar'; const { getScrollTarget, setVerticalScrollPosition } = scroll; import { func_tools, toolsext } from '@store/Modules/toolsext'; @@ -2294,7 +2302,12 @@ export const tools = { return index >= 0 && index < myarr.length; }, - async swapGeneralElem(nametable: string, myarr: any, itemdragend: any, listFieldsToChange: any) { + async swapGeneralElem( + nametable: string, + myarr: any, + itemdragend: any, + listFieldsToChange: any + ) { const arrprec = [...myarr]; if (itemdragend.field === 'priority') { @@ -2306,7 +2319,10 @@ export const tools = { itemdragend.atfirst, itemdragend.idelemtochange ); - itemdragend.oldIndex = this.getIndexById(myarr, itemdragend.idelemtochange); + itemdragend.oldIndex = this.getIndexById( + myarr, + itemdragend.idelemtochange + ); console.log('swapElems PRIORITY', itemdragend); } @@ -2315,12 +2331,26 @@ export const tools = { 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)) { + 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]); + myarr.splice( + itemdragend.newIndex, + 0, + myarr.splice(itemdragend.oldIndex, 1)[0] + ); console.log(' DOPO!', this.logga_arrproj(myarr)); // Ora inverti gli indici @@ -2377,7 +2407,12 @@ export const tools = { if (findelem !== myarr[i].pos) { myarr[i].modified = true; - await ApiTables.table_ModifyRecord(nametable, myarr[i], listFieldsToChange, 'pos'); + await ApiTables.table_ModifyRecord( + nametable, + myarr[i], + listFieldsToChange, + 'pos' + ); } } } @@ -2395,7 +2430,12 @@ export const tools = { if (findelem !== myarr[i].pos) { myarr[i].modified = true; - await ApiTables.table_ModifyRecord(nametable, myarr[i], listFieldsToChange, 'pos'); + await ApiTables.table_ModifyRecord( + nametable, + myarr[i], + listFieldsToChange, + 'pos' + ); } } } @@ -2439,14 +2479,23 @@ export const tools = { //T_TOLTO console.log('askfornotification', $q); - this.showNotif($q, t('notification.waitingconfirm'), { color: 'positive', icon: 'notifications' }); + this.showNotif($q, t('notification.waitingconfirm'), { + color: 'positive', + icon: 'notifications', + }); Notification.requestPermission((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(); } @@ -2480,7 +2529,9 @@ export const tools = { getaltimg(dir: string, file: string, alt?: string): string { const myimage = dir + file; - const myrec = static_data.preLoadImages.find((rec) => rec.imgname === myimage); + const myrec = static_data.preLoadImages.find( + (rec) => rec.imgname === myimage + ); if (myrec) return myrec ? myrec.alt : 'my image'; return alt || ''; }, @@ -2489,7 +2540,10 @@ export const tools = { 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 }; }, @@ -2571,7 +2625,12 @@ export const tools = { return myarr.find((elem: any) => elem.id_prev === id); }, - getLastFirstElemPriority(myarr: any, priority: number, atfirst: boolean, escludiId: string) { + getLastFirstElemPriority( + myarr: any, + priority: number, + atfirst: boolean, + escludiId: string + ) { if (myarr === null) { return -1; } @@ -2581,7 +2640,10 @@ export const tools = { console.log('priority', priority); for (let indrec = 0; indrec < myarr.length; indrec++) { - if (myarr[indrec].priority === priority && myarr[indrec]._id !== escludiId) { + if ( + myarr[indrec].priority === priority && + myarr[indrec]._id !== escludiId + ) { trovato = true; if (atfirst) { return indrec - 1; @@ -2638,7 +2700,8 @@ export const tools = { let arr: any = []; const projects = useProjectStore(); const todos = useTodoStore(); - if (nametable === 'projects') arr = projects.projs_dacompletare(cat, tipoproj); + 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; @@ -2700,7 +2763,13 @@ export const tools = { return visu; }, - executefunc(mythisq: any, table: string, func: number, par: IParamDialog, mythis?: any) { + executefunc( + mythisq: any, + table: string, + func: number, + par: IParamDialog, + mythis?: any + ) { const globalStore = useGlobalStore(); const calendarStore = useCalendarStore(); //T_TOLTO @@ -2714,7 +2783,10 @@ export const tools = { }) .then((ris: any) => { if (ris) { - this.showPositiveNotif(mythisq, t('cal.canceledbooking') + ' "' + par.param3 + '"'); + this.showPositiveNotif( + mythisq, + t('cal.canceledbooking') + ' "' + par.param3 + '"' + ); } else { this.showNegativeNotif(mythisq, t('cal.cancelederrorbooking')); } @@ -2724,8 +2796,13 @@ export const tools = { 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')); } @@ -2758,8 +2835,19 @@ export const tools = { }) .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, {}); + 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) { @@ -2816,12 +2904,20 @@ export const tools = { 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.fieldsvalue = { + made_gift: false, + riga: par.param1.riga, + col: par.param1.col, + }; mydatatosave.unset = { date_made_gift: 1, received_gift: 1 }; } } @@ -2845,7 +2941,14 @@ export const tools = { } }, - async saveFieldToServer(mythisq: any, table: string, id: any, mydata: any, notif = true, aggiornainmem = true) { + async saveFieldToServer( + mythisq: any, + table: string, + id: any, + mydata: any, + notif = true, + aggiornainmem = true + ) { const mydatatosave = { id, table, @@ -2903,18 +3006,36 @@ export const tools = { }, 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); }, - showNotif(q: any, msg: string, data?: INotify | null, time?: number, group?: any) { + showNotif( + q: any, + msg: string, + data?: INotify | null, + time?: number, + group?: any + ) { let myicon = data ? data.icon : 'ion-add'; if (!myicon) { myicon = 'ion-add'; @@ -2977,19 +3098,39 @@ export const tools = { ) { mylang = 'enUs'; } - if (mylang.toLowerCase() === 'es' || mylang.toLowerCase() === 'es-es' || mylang.toLowerCase() === 'eses') { + if ( + mylang.toLowerCase() === 'es' || + mylang.toLowerCase() === 'es-es' || + mylang.toLowerCase() === 'eses' + ) { mylang = 'es'; } - if (mylang.toLowerCase() === 'pt' || mylang.toLowerCase() === 'pt-pt' || mylang.toLowerCase() === 'ptpt') { + if ( + mylang.toLowerCase() === 'pt' || + mylang.toLowerCase() === 'pt-pt' || + mylang.toLowerCase() === 'ptpt' + ) { mylang = 'pt'; } - if (mylang.toLowerCase() === 'fr' || mylang.toLowerCase() === 'fr-fr' || mylang.toLowerCase() === 'frfr') { + if ( + mylang.toLowerCase() === 'fr' || + mylang.toLowerCase() === 'fr-fr' || + mylang.toLowerCase() === 'frfr' + ) { mylang = 'fr'; } - if (mylang.toLowerCase() === 'it' || mylang.toLowerCase() === 'it-it' || mylang.toLowerCase() === 'itit') { + if ( + mylang.toLowerCase() === 'it' || + mylang.toLowerCase() === 'it-it' || + mylang.toLowerCase() === 'itit' + ) { mylang = 'it'; } - if (mylang.toLowerCase() === 'si' || mylang.toLowerCase() === 'si-si' || mylang.toLowerCase() === 'sisi') { + if ( + mylang.toLowerCase() === 'si' || + mylang.toLowerCase() === 'si-si' || + mylang.toLowerCase() === 'sisi' + ) { mylang = 'si'; } @@ -3094,7 +3235,11 @@ export const tools = { } 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); @@ -3144,8 +3289,12 @@ export const tools = { return 'red'; } }, - hasManyDays(mydatestart: Date | number | string | undefined, mydateend: Date | number | string | undefined) { - if (mydateend) return this.getstrDate(mydatestart) !== this.getstrDate(mydateend); + hasManyDays( + mydatestart: Date | number | string | undefined, + mydateend: Date | number | string | undefined + ) { + if (mydateend) + return this.getstrDate(mydatestart) !== this.getstrDate(mydateend); else return false; }, @@ -3259,7 +3408,8 @@ export const tools = { 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')}`; + if (mytimestamp) + return `${dayofweek} ${date.formatDate(mytimestamp, 'DD/MM/YYYY')}`; return ''; }, @@ -3289,13 +3439,16 @@ export const tools = { getstrShortDate(mydate: Date | number | string | undefined) { try { - const DateFormatter = new Intl.DateTimeFormat(toolsext.getLocale() || void 0, { - weekday: 'long', - day: 'numeric', - month: 'short', - year: 'numeric', - // timeZone: 'UTC' - }); + const DateFormatter = new Intl.DateTimeFormat( + toolsext.getLocale() || void 0, + { + weekday: 'long', + day: 'numeric', + month: 'short', + year: 'numeric', + // timeZone: 'UTC' + } + ); try { if (DateFormatter) { // @ts-ignore @@ -3311,12 +3464,15 @@ export const tools = { } }, getstrVeryShortDate(mydate: Date | number | string | undefined) { - const DateFormatter = new Intl.DateTimeFormat(toolsext.getLocale() || void 0, { - weekday: 'short', - day: 'numeric', - month: 'short', - // timeZone: 'UTC' - }); + const DateFormatter = new Intl.DateTimeFormat( + toolsext.getLocale() || void 0, + { + weekday: 'short', + day: 'numeric', + month: 'short', + // timeZone: 'UTC' + } + ); try { if (DateFormatter) { // @ts-ignore @@ -3330,11 +3486,14 @@ export const tools = { }, getstrVeryVeryShortDate(mydate: Date) { - const DateFormatter = new Intl.DateTimeFormat(toolsext.getLocale() || void 0, { - weekday: 'long', - day: 'numeric', - // timeZone: 'UTC' - }); + const DateFormatter = new Intl.DateTimeFormat( + toolsext.getLocale() || void 0, + { + weekday: 'long', + day: 'numeric', + // timeZone: 'UTC' + } + ); try { if (DateFormatter) { const date1 = new Date(mydate); @@ -3346,10 +3505,18 @@ export const tools = { } }, - getstrDateTimeEvent($t: any, myevent: IEvents, withhtml: boolean, acapo: boolean = false) { + getstrDateTimeEvent( + $t: any, + myevent: IEvents, + withhtml: boolean, + acapo: boolean = false + ) { let mystr = ''; // is same day? - if (this.getstrDate(myevent.dateTimeStart) === this.getstrDate(myevent.dateTimeEnd)) { + if ( + this.getstrDate(myevent.dateTimeStart) === + this.getstrDate(myevent.dateTimeEnd) + ) { if (withhtml) { mystr += `${this.getstrDateLong(myevent.dateTimeStart)} ${$t('cal.starttime')} ${this.getstrTime(myevent.dateTimeStart)} @@ -3391,7 +3558,10 @@ export const tools = { getstrDateTimeEventSimple(myevent: IEvents) { let mystr = ''; // is same day? - if (this.getstrShortDate(myevent.dateTimeStart) === this.getstrShortDate(myevent.dateTimeEnd)) { + if ( + this.getstrShortDate(myevent.dateTimeStart) === + this.getstrShortDate(myevent.dateTimeEnd) + ) { mystr = `${this.getstrShortDate(myevent.dateTimeStart)} - ${this.getstrTime(myevent.dateTimeStart)}`; } else { @@ -3404,7 +3574,10 @@ export const tools = { getstrDateTimeEventShort(myevent: IEvents) { let mystr = ''; // is same day? - if (this.getstrShortDate(myevent.dateTimeStart) === this.getstrShortDate(myevent.dateTimeEnd)) { + if ( + this.getstrShortDate(myevent.dateTimeStart) === + this.getstrShortDate(myevent.dateTimeEnd) + ) { mystr = `${this.getstrVeryShortDate(myevent.dateTimeStart)} h. ${this.getstrTime(myevent.dateTimeStart)}`; } else { @@ -3460,9 +3633,12 @@ export const tools = { return ''; }, - getstrDateMonthWeekTimeShort(mytimestamp: Date | number | string | undefined) { + getstrDateMonthWeekTimeShort( + mytimestamp: Date | number | string | undefined + ) { // console.log('getstrDate', mytimestamp) - if (mytimestamp) return `${this.getDayOfWeek(mytimestamp)} ${date.formatDate(mytimestamp, 'DD MMM - HH:mm')}`; + if (mytimestamp) + return `${this.getDayOfWeek(mytimestamp)} ${date.formatDate(mytimestamp, 'DD MMM - HH:mm')}`; return ''; }, @@ -3599,16 +3775,74 @@ export const tools = { const mylang = toolsext.getLocale(); const myday: any = { - it: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'], - enUs: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], - fr: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'], - es: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'], - 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'], + it: [ + 'Domenica', + 'Lunedì', + 'Martedì', + 'Mercoledì', + 'Giovedì', + 'Venerdì', + 'Sabato', + ], + enUs: [ + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday', + ], + fr: [ + 'Dimanche', + 'Lundi', + 'Mardi', + 'Mercredi', + 'Jeudi', + 'Vendredi', + 'Samedi', + ], + es: [ + 'Domingo', + 'Lunes', + 'Martes', + 'Miércoles', + 'Jueves', + 'Viernes', + 'Sábado', + ], + 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) { @@ -3671,8 +3905,16 @@ export const tools = { tag: 'confirm-notification', 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' }, + { + action: 'confirm', + title: 'Okay', + icon: '/myicons/app-icon-96x96.png', + }, + { + action: 'cancel', + title: 'Cancel', + icon: '/myicons/app-icon-96x96.png', + }, ], }; @@ -3710,7 +3952,11 @@ export const tools = { tag: 'confirm-notification', renotify: true, // if it's already sent, will Vibrate anyway actions: [ - { action: 'confirm', title: t('dialog.ok'), icon: '/images/android-chrome-192x192.png' }, + { + action: 'confirm', + title: t('dialog.ok'), + icon: '/images/android-chrome-192x192.png', + }, // { action: 'cancel', title: 'Cancel', icon: '/statics/images/android-chrome-192x192.png', } ], }; @@ -3895,7 +4141,10 @@ export const tools = { isUserOnline(user: IUserFields, col: any = null) { try { const dateonline = this.addDays(this.getDateNow(), -1); - return user.lasttimeonline && new Date(user.lasttimeonline).getTime() > dateonline.getTime(); + return ( + user.lasttimeonline && + new Date(user.lasttimeonline).getTime() > dateonline.getTime() + ); } catch (e) { return false; } @@ -3911,7 +4160,11 @@ export const tools = { 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; } @@ -3922,32 +4175,37 @@ export const tools = { }, 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]]; } }, 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]]; } }, 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]]; } }, 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]]; } }, 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]]; } @@ -3956,7 +4214,8 @@ export const tools = { } }, 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]]; } @@ -4089,7 +4348,13 @@ export const tools = { return arr[0] + '//' + arr[2]; }, - SignIncheckErrors(mythisq: any, $router: Router, route: any, riscode: any, ispageLogin?: boolean) { + SignIncheckErrors( + mythisq: any, + $router: Router, + route: any, + riscode: any, + ispageLogin?: boolean + ) { console.log('SignIncheckErrors: ', riscode); //T_TOLTO @@ -4098,7 +4363,10 @@ export const tools = { 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('/'); @@ -4114,7 +4382,10 @@ export const tools = { // console.log('HIDE...') mythisq.loading.hide(); }, 500); - this.showNotif(mythisq, t('login.errato'), { color: 'negative', icon: 'notifications' }); + this.showNotif(mythisq, t('login.errato'), { + color: 'negative', + icon: 'notifications', + }); // iswaitingforRes = false if (ispageLogin) { globalStore.rightDrawerOpen = true; @@ -4132,7 +4403,10 @@ export const tools = { // console.log('HIDE...') mythisq.loading.hide(); }, 500); - this.showNotif(mythisq, t('login.subaccount'), { color: 'negative', icon: 'notifications' }); + this.showNotif(mythisq, t('login.subaccount'), { + color: 'negative', + icon: 'notifications', + }); // mythis.iswaitingforRes = false if (ispageLogin) { globalStore.rightDrawerOpen = true; @@ -4140,12 +4414,21 @@ export const tools = { } }); } 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' }); + 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) { @@ -4166,13 +4449,27 @@ export const tools = { 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); - } 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_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 + ); } }, @@ -4188,9 +4485,15 @@ export const tools = { } else if (riscode === serv_constants.RIS_CODE_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')); } else if (riscode === serv_constants.RIS_CODE_USERNAME_ALREADY_EXIST) { @@ -4209,7 +4512,9 @@ export const tools = { }) */ this.showNotif( mythisq, - t('components.authentication.email_verification.reg_ok', { botname: this.getBotName() }), + t('components.authentication.email_verification.reg_ok', { + botname: this.getBotName(), + }), { color: 'green', textColor: 'black', @@ -4217,10 +4522,16 @@ export const tools = { ); } else if (riscode === serv_constants.RIS_ISCRIZIONE_OK) { $router.replace('/'); - this.showNotif(mythisq, t('components.authentication.iscrizione_ok', { botname: this.getBotName() }), { - color: 'green', - textColor: 'black', - }); + this.showNotif( + mythisq, + t('components.authentication.iscrizione_ok', { + botname: this.getBotName(), + }), + { + color: 'green', + textColor: 'black', + } + ); } else { this.showNotif(mythisq, 'Errore num ' + riscode); } @@ -4250,12 +4561,20 @@ export const tools = { } return s; }, - CancelBookingEvent(mythisq: any, eventparam: IEvents, bookeventid: string, notify: boolean) { + 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('cal.cancelbooking') + + ' ' + + this.gettextevent(eventparam) + + '?', translate('dialog.yes'), translate('dialog.no'), '', @@ -4303,7 +4622,14 @@ export const tools = { } ); }, - ActionRecTable(mythisq: any, action: number, table: string, id: string, item: any, askaction: any) { + ActionRecTable( + mythisq: any, + action: number, + table: string, + id: string, + item: any, + askaction: any + ) { // console.log('ActionRecTable', id) return this.askConfirm( mythisq, @@ -4361,7 +4687,12 @@ export const tools = { } }, - getheightbywidth(mythis: any, mywidth: string, myheight: string, maxwidth: string) { + 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)); @@ -4428,7 +4759,12 @@ export const tools = { return parseFloat(myval); }, - getCookie(mytok: any, def?: any, convertint: any = false, convertbool: any = false) { + getCookie( + mytok: any, + def?: any, + convertint: any = false, + convertbool: any = false + ) { const ris = Cookies.get(mytok); // console.log('getCookie', mytok, ris) if (ris === 'null') return def; @@ -4561,7 +4897,10 @@ export const tools = { }, getWssUrl(): string | URL { const myurl = import.meta.env.VITE_APP_URL; - if (myurl) return myurl.replace(/(https?:\/\/[^:]+):\d+/, `$1:3000`).replace(/^http/, 'wss'); + if (myurl) + return myurl + .replace(/(https?:\/\/[^:]+):\d+/, `$1:3000`) + .replace(/^http/, 'wss'); else return ''; }, getheaders() { @@ -4592,7 +4931,10 @@ export const tools = { }, isChristmasHoliday() { const now = new Date(); - return (now.getMonth() === 11 && now.getDate() > 20) || (now.getMonth() === 0 && now.getDate() < 8); + return ( + (now.getMonth() === 11 && now.getDate() > 20) || + (now.getMonth() === 0 && now.getDate() < 8) + ); }, CapitalizeAllWords(str: string | undefined) { @@ -4601,7 +4943,8 @@ export const tools = { 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(' '); @@ -4671,12 +5014,17 @@ export const tools = { }, heightgallvideo() { - const h = this.heightgallery(this.getValDb('YT_W', false) / this.getValDb('YT_H', false)); + 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); @@ -4688,7 +5036,12 @@ export const tools = { }, 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' }]; @@ -5049,8 +5402,16 @@ export const tools = { 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) + 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 @@ -5208,7 +5569,12 @@ export const tools = { const userStore = useUserStore(); if (userStore.my.profile) { if (userStore.my.profile.paymenttypes) { - if (userStore.my.profile.paymenttypes.includes({ key: 'paypal', label: 'paypal' })) { + if ( + userStore.my.profile.paymenttypes.includes({ + key: 'paypal', + label: 'paypal', + }) + ) { return true; } } @@ -5221,7 +5587,12 @@ export const tools = { const userStore = useUserStore(); if (userStore.my.profile) { if (userStore.my.profile.paymenttypes) { - if (userStore.my.profile.paymenttypes.includes({ key: 'payeer', label: 'payeer' })) { + if ( + userStore.my.profile.paymenttypes.includes({ + key: 'payeer', + label: 'payeer', + }) + ) { return true; } } @@ -5234,7 +5605,12 @@ export const tools = { const userStore = useUserStore(); if (userStore.my.profile) { if (userStore.my.profile.paymenttypes) { - if (userStore.my.profile.paymenttypes.includes({ key: 'revolut', label: 'revolut' })) { + if ( + userStore.my.profile.paymenttypes.includes({ + key: 'revolut', + label: 'revolut', + }) + ) { return true; } } @@ -5247,7 +5623,12 @@ export const tools = { const userStore = useUserStore(); if (userStore.my.profile) { if (userStore.my.profile.paymenttypes) { - if (userStore.my.profile.paymenttypes.includes({ key: 'advcash', label: 'advcash' })) { + if ( + userStore.my.profile.paymenttypes.includes({ + key: 'advcash', + label: 'advcash', + }) + ) { return true; } } @@ -5373,7 +5754,8 @@ export const tools = { } 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; @@ -5389,7 +5771,10 @@ export const tools = { TelegVerificato(): boolean { const userStore = useUserStore(); - return userStore.my.profile ? userStore.my.profile.teleg_id > 0 || userStore.my.profile.teleg_id_old > 0 : false; + return userStore.my.profile + ? userStore.my.profile.teleg_id > 0 || + userStore.my.profile.teleg_id_old > 0 + : false; }, isDebugOn(): boolean { @@ -5696,7 +6081,11 @@ export const tools = { 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) { @@ -5810,7 +6199,13 @@ export const tools = { return res.status === PayloadMessageTypes.statusfound; }; - return Axios.get(VALIDATE_USER_URL + '/users/' + this.getEnv('VITE_APP_ID') + '/' + username) + return Axios.get( + VALIDATE_USER_URL + + '/users/' + + this.getEnv('VITE_APP_ID') + + '/' + + username + ) .then(onSuccess) .catch((err) => { return false; @@ -5834,41 +6229,75 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETFRIEND, null) + .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 - ); + 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) { + addToMyTrust( + $q: any, + username: string, + usernameDest: string, + value: boolean + ) { //T_TOLTO const userStore = useUserStore(); const notifStore = useNotifStore(); $q.dialog({ - message: t(value ? 'db.domanda_trusted' : 'db.domanda_reject', { username: usernameDest }), + 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'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETTRUST, value) + .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 }) + ); } }); }); @@ -5886,7 +6315,14 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, null) + .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( @@ -5910,7 +6346,14 @@ export const tools = { title: t('handshake.strettadimano'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETHANDSHAKE, null) + .setFriendsCmd( + $q, + t, + username, + usernameDest, + shared_consts.FRIENDSCMD.SETHANDSHAKE, + null + ) .then((res: any) => { if (res) { notifStore.updateNotification = true; @@ -5933,12 +6376,20 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE, null) + .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 - ); + userStore.userprofile.profile.handshake = + userStore.userprofile.profile.handshake.filter( + (rec: IFriends) => rec.username !== username + ); this.showPositiveNotif($q, t('db.removedhandshake')); } }); @@ -5955,7 +6406,14 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.BLOCK_USER, null) + .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( @@ -5977,7 +6435,14 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.UNBLOCK_USER, null) + .setFriendsCmd( + $q, + t, + username, + usernameDest, + shared_consts.FRIENDSCMD.UNBLOCK_USER, + null + ) .then((res: any) => { if (res) { this.showPositiveNotif($q, t('db.unblockedfriend')); @@ -5997,7 +6462,14 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REPORT_USER, null) + .setFriendsCmd( + $q, + t, + username, + usernameDest, + shared_consts.FRIENDSCMD.REPORT_USER, + null + ) .then((res: any) => { if (res) { this.showPositiveNotif($q, t('db.reporteduser')); @@ -6017,13 +6489,21 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, null) + .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 - ); + userStore.my.profile.req_friends = + userStore.my.profile.req_friends.filter( + (user: IFriends) => user.username !== usernameDest + ); this.showPositiveNotif($q, t('db.removedfriend')); } }); @@ -6069,18 +6549,30 @@ export const tools = { cancel: { label: t('dialog.cancel') }, 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]; + 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 })); } - this.showPositiveNotif($q, t('db.addedcircuit', { circuitname })); - } - }); + }); }); }, @@ -6099,14 +6591,25 @@ export const tools = { }; userStore - .setCircuitCmd($q, t, userStore.my.username, circuitname, shared_consts.CIRCUITCMD.SET, true, extrarec) + .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; if (res.circuit) { if (userStore.my.profile.mycircuits) - userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit]; + userStore.my.profile.mycircuits = [ + ...userStore.my.profile.mycircuits, + res.circuit, + ]; else userStore.my.profile.mycircuits = [res]; } this.showPositiveNotif($q, t('db.addedcircuit', { circuitname })); @@ -6131,17 +6634,31 @@ export const tools = { }; userStore - .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.SETFIDO, true, extrarec) + .setCircuitCmd( + $q, + t, + username, + circuitname, + shared_consts.CIRCUITCMD.SETFIDO, + true, + extrarec + ) .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]; + 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 }) + ); } }); }); @@ -6162,17 +6679,31 @@ export const tools = { }; userStore - .setCircuitCmd($q, t, userStore.my.username, circuitname, shared_consts.CIRCUITCMD.SETFIDO, true, extrarec) + .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; if (res.circuit) { if (userStore.my.profile.mycircuits) - userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit]; + 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 }) + ); } }); }); @@ -6183,17 +6714,31 @@ export const tools = { const notifStore = useNotifStore(); //T_TOLTO $q.dialog({ - message: t('db.domanda_addtogroup', { username, groupname: groupnameDest }), + message: t('db.domanda_addtogroup', { + username, + groupname: groupnameDest, + }), ok: { label: t('dialog.yes'), push: true }, cancel: { label: t('dialog.cancel') }, title: t('db.domanda'), }).onOk(() => { userStore - .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.SETGROUP, true) + .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]; + 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')); } @@ -6262,20 +6807,31 @@ export const tools = { const notifStore = useNotifStore(); //T_TOLTO $q.dialog({ - message: t('db.domanda_refuse_group', { username, groupname: groupnameDest }), + 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'), }).onOk(() => { userStore - .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REFUSE_REQ_GROUP, null) + .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.my.profile.asked_groups = + userStore.my.profile.asked_groups.filter( + (rec: IGroupShort) => rec.groupname !== groupnameDest + ); } this.showPositiveNotif($q, t('db.refusedgroup', { username })); } @@ -6293,18 +6849,33 @@ export const tools = { cancel: { label: t('dialog.cancel') }, 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 + .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')); + } + }); }); }, - removeFromMyGroups($q: any, username: string, groupnameDest: string, domanda: any = '') { + removeFromMyGroups( + $q: any, + username: string, + groupnameDest: string, + domanda: any = '' + ) { const userStore = useUserStore(); //T_TOLTO @@ -6315,14 +6886,22 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP, null) + .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.my.profile.mygroups = + userStore.my.profile.mygroups.filter( + (rec: IMyGroup) => rec.groupname !== groupnameDest + ); } } this.showPositiveNotif($q, t('db.removedgroup')); @@ -6331,21 +6910,37 @@ export const tools = { }); }, - addtoAdminOfMyGroup($q: any, username: string, groupnameDest: string, domanda: any = '') { + addtoAdminOfMyGroup( + $q: any, + username: string, + groupnameDest: string, + domanda: any = '' + ) { const userStore = useUserStore(); //T_TOLTO $q.dialog({ - message: domanda ? domanda : t('db.domanda_addadminofmygroup', { username, groupnameDest }), + 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'), }).onOk(() => { userStore - .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.ADDADMIN_OFMYGROUP, null) + .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); + 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() }]; @@ -6357,24 +6952,42 @@ export const tools = { }); }, - removeAdminOfMyGroup($q: any, username: string, groupnameDest: string, domanda: any = '') { + removeAdminOfMyGroup( + $q: any, + username: string, + groupnameDest: string, + domanda: any = '' + ) { const userStore = useUserStore(); //T_TOLTO $q.dialog({ - message: domanda ? domanda : t('db.domanda_removeadminofmygroup', { username, groupnameDest }), + 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'), }).onOk(() => { userStore - .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REMOVEADMIN_OFMYGROUP, null) + .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); + 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); + mygrp.admins = mygrp.admins.filter( + (rec: any) => rec.username !== username + ); console.log('mygrp.admins', mygrp.admins); this.showPositiveNotif($q, t('db.removedtoadmin', { username })); } @@ -6383,30 +6996,52 @@ export const tools = { }); }, - DeleteGroup($q: any, username: string, groupnameDest: string, domanda: any = '') { + DeleteGroup( + $q: any, + username: string, + groupnameDest: string, + domanda: any = '' + ) { const userStore = useUserStore(); //T_TOLTO $q.dialog({ - message: domanda ? domanda : t('db.domanda_remove_group', { groupname: groupnameDest }), + 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'), }).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 + .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')); + } } - } - }); + }); }); }, - setRequestFriendship($q: any, username: string, usernameDest: string, value: boolean) { + setRequestFriendship( + $q: any, + username: string, + usernameDest: string, + value: boolean + ) { const userStore = useUserStore(); //T_TOLTO @@ -6429,19 +7064,33 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REQFRIEND, value) + .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 })); + 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 + userStore.my.profile.asked_friends = + userStore.my.profile.asked_friends.filter( + (rec: IUserFields) => rec.username !== usernameDest + ); + this.showPositiveNotif( + $q, + t('db.revoketofriend', { username: usernameDest }) ); - this.showPositiveNotif($q, t('db.revoketofriend', { username: usernameDest })); } } else { this.showNegativeNotif($q, t('db.recfailed')); @@ -6450,7 +7099,12 @@ export const tools = { }); }, - setHandShake($q: any, username: string, usernameDest: string, value: boolean) { + setHandShake( + $q: any, + username: string, + usernameDest: string, + value: boolean + ) { //T_TOLTO const userStore = useUserStore(); @@ -6474,15 +7128,28 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETHANDSHAKE, value) + .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')); @@ -6498,7 +7165,14 @@ export const tools = { const username = userStore.my.username; userStore - .setSendCmd($q, t, username, usernameDest, shared_consts.CallFunz.ENTRA_RIS_ITALIA, null) + .setSendCmd( + $q, + t, + username, + usernameDest, + shared_consts.CallFunz.ENTRA_RIS_ITALIA, + null + ) .then((res: any) => { if (res && res.result) { this.updateMyData(res); @@ -6507,7 +7181,12 @@ export const tools = { }); }, - setRequestGroup($q: any, username: string, groupnameDest: string, value: boolean) { + setRequestGroup( + $q: any, + username: string, + groupnameDest: string, + value: boolean + ) { //T_TOLTO const userStore = useUserStore(); @@ -6531,19 +7210,33 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REQGROUP, value) + .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 })); + 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 + userStore.my.profile.asked_groups = + userStore.my.profile.asked_groups.filter( + (rec: IGroupShort) => rec.groupname !== groupnameDest + ); + this.showPositiveNotif( + $q, + t('db.revoketogroup', { groupname: groupnameDest }) ); - this.showPositiveNotif($q, t('db.revoketogroup', { groupname: groupnameDest })); } } else { this.showNegativeNotif($q, t('db.recfailed')); @@ -6561,12 +7254,20 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND, null) + .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 - ); + userStore.my.profile.asked_friends = + userStore.my.profile.asked_friends.filter( + (rec: IUserFields) => rec.username !== usernameDest + ); this.showPositiveNotif($q, t('db.cancel_req_friend')); } }); @@ -6576,19 +7277,30 @@ export const tools = { const userStore = useUserStore(); //T_TOLTO $q.dialog({ - message: t('db.domanda_cancel_req_group', { username, groupname: groupnameDest }), + 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'), }).onOk(() => { userStore - .setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.CANCEL_REQ_GROUP, null) + .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.my.profile.asked_groups = + userStore.my.profile.asked_groups.filter( + (rec: IGroupShort) => rec.groupname !== groupnameDest + ); } this.showPositiveNotif($q, t('db.cancel_req_group')); } @@ -6687,10 +7399,17 @@ export const tools = { }, 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 = '') { + checkIfShowField( + col: IColGridTable, + tipovis: number, + visulabel: boolean, + valuePresent: any = '' + ) { let check = col.visible; if (tipovis === this.TIPOVIS_NEW_RECORD) { @@ -6699,12 +7418,17 @@ export const tools = { const globalStore = useGlobalStore(); check = - (check && this.isBitActive(col.showWhen, costanti.showWhen.InEdit)) || (this.isAdmin() && globalStore.editOn); + (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; + if ( + this.isBitActive(col.showWhen, costanti.showWhen.InView_OnlyifExist) + ) { + 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); @@ -6733,20 +7457,36 @@ export const tools = { }); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username); + const isadmin = ris.admins.find( + (user: IFriends) => user.username === userStore.my.username + ); risultato = !!isadmin; } } return risultato; }, - setRequestCircuit($q: any, username: string, circuitname: string, value: boolean, groupname?: string) { + setRequestCircuit( + $q: any, + username: string, + circuitname: string, + value: boolean, + groupname?: string + ) { const userStore = useUserStore(); const circuitStore = useCircuitStore(); //T_TOLTO userStore - .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REQ, value, { groupname }) + .setCircuitCmd( + $q, + t, + username, + circuitname, + shared_consts.CIRCUITCMD.REQ, + value, + { groupname } + ) .then((res: any) => { if (res) { if (value) { @@ -6762,9 +7502,10 @@ export const tools = { this.showPositiveNotif($q, msg); } else { // REMOVE to req - userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter( - (rec: ICircuit) => rec.name !== circuitname - ); + userStore.my.profile.asked_circuits = + userStore.my.profile.asked_circuits.filter( + (rec: ICircuit) => rec.name !== circuitname + ); this.showPositiveNotif($q, t('circuit.revoketo', { circuitname })); } @@ -6776,14 +7517,27 @@ export const tools = { }, 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) { + async sendCoinsByCircuit( + $q: any, + $router: any, + circuit: ICircuit, + sendcoinrec: ISendCoin + ) { const userStore = useUserStore(); const notifStore = useNotifStore(); //T_TOLTO @@ -6803,9 +7557,18 @@ export const tools = { 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 @@ -6840,7 +7603,11 @@ export const tools = { $router.push('/circuits'); this.showPositiveNotif( $q, - t('circuit.coins_sent', { qty: sendcoinrec.qty, symbol: circuit.symbol, dest }) + t('circuit.coins_sent', { + qty: sendcoinrec.qty, + symbol: circuit.symbol, + dest, + }) ); //this.showPositiveNotif($q, t('circuit.coins_sendrequest_sent')) } else { @@ -6857,7 +7624,12 @@ export const tools = { */ }, - cancelReqCircuit($q: any, username: string, circuitname: string, groupname?: string) { + cancelReqCircuit( + $q: any, + username: string, + circuitname: string, + groupname?: string + ) { const userStore = useUserStore(); //T_TOLTO $q.dialog({ @@ -6867,22 +7639,39 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.CANCEL_REQ, null, { groupname }) + .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.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.showPositiveNotif( + $q, + t('circuit.cancel_req', { circuitname }) + ); } }); }); }, - refuseReqCircuit($q: any, username: string, circuitname: string, groupname?: string) { + refuseReqCircuit( + $q: any, + username: string, + circuitname: string, + groupname?: string + ) { const userStore = useUserStore(); const notifStore = useNotifStore(); //T_TOLTO @@ -6893,23 +7682,41 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REFUSE_REQ, null, { groupname }) + .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.my.profile.asked_circuits = + userStore.my.profile.asked_circuits.filter( + (rec: ICircuit) => rec.name !== circuitname + ); } - this.showPositiveNotif($q, t('circuit.refusedcircuit', { username })); + this.showPositiveNotif( + $q, + t('circuit.refusedcircuit', { username }) + ); this.updateMyData(res); } }); }); }, - removeFromMyCircuits($q: any, username: string, circuitname: string, groupname?: string, domanda: any = '') { + removeFromMyCircuits( + $q: any, + username: string, + circuitname: string, + groupname?: string, + domanda: any = '' + ) { const userStore = useUserStore(); //T_TOLTO @@ -6920,13 +7727,25 @@ export const tools = { title: t('db.domanda'), }).onOk(() => { userStore - .setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST, null, { groupname }) + .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 - ); + 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); @@ -6939,83 +7758,143 @@ export const tools = { try { 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; } }, - addtoAdminOfCircuit($q: any, username: string, circuitname: string, domanda: any = '') { + addtoAdminOfCircuit( + $q: any, + username: string, + circuitname: string, + domanda: any = '' + ) { const userStore = useUserStore(); //T_TOLTO $q.dialog({ - message: domanda ? domanda : t('circuit.domanda_addadminofcircuit', { username, circuitname }), + 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'), }).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); - 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 })); - } - this.updateMyData(res); - } - }); - }); - }, - - removeAdminOfCircuit($q: any, username: string, circuitname: string, domanda: any = '') { - 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'), - }).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); - 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 })); - } - this.updateMyData(res); - } - }); - }); - }, - - DeleteCircuit($q: any, username: string, circuitname: string, domanda: any = '') { - 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'), - }).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 + 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 ); - this.showPositiveNotif($q, t('circuit.deleted', { 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 })); + } + this.updateMyData(res); } - this.updateMyData(res); - } - }); + }); + }); + }, + + removeAdminOfCircuit( + $q: any, + username: string, + circuitname: string, + domanda: any = '' + ) { + 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'), + }).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); + 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 })); + } + this.updateMyData(res); + } + }); + }); + }, + + DeleteCircuit( + $q: any, + username: string, + circuitname: string, + domanda: any = '' + ) { + 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'), + }).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 })); + } + this.updateMyData(res); + } + }); }); }, @@ -7040,14 +7919,18 @@ export const tools = { } if (userStore.my.profile.manage_mycircuits) { - const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => { - if (circuit.name === circuitname) { - return true; + const ris = userStore.my.profile.manage_mycircuits.find( + (circuit: ICircuit) => { + if (circuit.name === circuitname) { + return true; + } } - }); + ); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username); + const isadmin = ris.admins.find( + (user: IFriends) => user.username === userStore.my.username + ); risultato = !!isadmin; } } @@ -7061,13 +7944,17 @@ export const tools = { 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; + const ris = userStore.my.profile.manage_mycircuits.find( + (circuit: ICircuit) => { + if (circuit.name === circuitname) { + return true; + } } - }); + ); if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username); + const isadmin = ris.admins.find( + (user: IFriends) => user.username === userStore.my.username + ); risultato = !!isadmin; } } @@ -7077,11 +7964,18 @@ export const tools = { iAmPartOfThisGroup(grp: IMyGroup) { const userStore = useUserStore(); - return userStore.my.profile.mygroups.findIndex((rec: IMyGroup) => rec.groupname === grp.groupname) >= 0; + 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)) { + if ( + grp && + grp.visibility.includes(shared_consts.Visibility_Group.PRIVATE) + ) { // Only if I am part of this group return this.iAmPartOfThisGroup(grp); } @@ -7150,7 +8044,9 @@ export const tools = { }); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === username); + const isadmin = ris.admins.find( + (user: IFriends) => user.username === username + ); risultato = !!isadmin; } } @@ -7163,11 +8059,13 @@ export const tools = { 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; + const ris = userStore.my.profile.manage_mycircuits.find( + (circuit: ICircuit) => { + if (circuit.name === name) { + return true; + } } - }); + ); // console.log('ris', ris) return ris && ris.createdBy === userStore.my.username; } @@ -7185,11 +8083,13 @@ export const tools = { 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; + const ris = userStore.my.profile.manage_mycircuits.find( + (circuit: ICircuit) => { + if (circuit.name === name) { + return true; + } } - }); + ); // console.log('ris', ris) return ris && ris.createdBy === username; } @@ -7207,14 +8107,18 @@ export const tools = { 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; + const ris = userStore.my.profile.manage_mycircuits.find( + (circuit: ICircuit) => { + if (circuit.name === name) { + return true; + } } - }); + ); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === username); + const isadmin = ris.admins.find( + (user: IFriends) => user.username === username + ); risultato = !!isadmin; } } @@ -7230,14 +8134,18 @@ export const tools = { 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; + const ris = userStore.my.profile.manage_mycircuits.find( + (circuit: ICircuit) => { + if (circuit.name === name) { + return true; + } } - }); + ); // console.log('ris', ris) if (ris && ris.admins) { - const isadmin = ris.admins.find((user: IFriends) => user.username === username); + const isadmin = ris.admins.find( + (user: IFriends) => user.username === username + ); risultato = !!isadmin; } } @@ -7249,7 +8157,12 @@ export const tools = { //T_TOLTO 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); } else if (cmd === shared_consts.GROUPSCMD.BLOCK_GROUP) { @@ -7427,7 +8340,13 @@ export const tools = { } else if (arrmultisel_tab.includes(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 + ); } } @@ -7447,7 +8366,11 @@ export const tools = { idCity: this.getCitySel(), NumLevel: 0, adType: this.getSelectionByTable('adtypes', costanti.AdType.OFFRO), - pub_to_share: this.getSelectionByTable('pub_to_share', shared_consts.PUBTOSHARE.ALL, true), + pub_to_share: this.getSelectionByTable( + 'pub_to_share', + shared_consts.PUBTOSHARE.ALL, + true + ), photos: [], note: '', //**ADDFIELD_MYSKILL @@ -7477,7 +8400,11 @@ export const tools = { adType: this.getSelectionByTable('adtypes', costanti.AdType.OFFRO), idShipping: this.getSelectionByTable('shippings', []), otherfilters: this.getSelectionByTable('otherfilters', []), - pub_to_share: this.getSelectionByTable('pub_to_share', shared_consts.PUBTOSHARE.ALL, true), + pub_to_share: this.getSelectionByTable( + 'pub_to_share', + shared_consts.PUBTOSHARE.ALL, + true + ), photos: [], note: '', //**ADDFIELD_MYSKILL @@ -7530,8 +8457,10 @@ export const tools = { qta_max_default: 200, fido_scoperto_default_grp: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP, qta_max_default_grp: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_GRP, - fido_scoperto_default_contocom: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO, - qta_max_default_contocom: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO, + fido_scoperto_default_contocom: + shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO, + qta_max_default_contocom: + shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO, valuta_per_euro: 1, totTransato: 0, totCircolante: 0, @@ -7557,7 +8486,11 @@ export const tools = { idCity: this.getCitySel(), NumLevel: 0, adType: this.getSelectionByTable('adtypes', costanti.AdType.OFFRO), - pub_to_share: this.getSelectionByTable('pub_to_share', shared_consts.PUBTOSHARE.ALL, true), + pub_to_share: this.getSelectionByTable( + 'pub_to_share', + shared_consts.PUBTOSHARE.ALL, + true + ), photos: [], note: '', organisedBy: this.getSelectionByTable('organisedBy', ''), @@ -7581,7 +8514,11 @@ export const tools = { idContribType: this.getSelectionByTable('contribtypes', []), accomodation: [], idCity: this.getCitySel(), - pub_to_share: this.getSelectionByTable('pub_to_share', shared_consts.PUBTOSHARE.ALL, true), + pub_to_share: this.getSelectionByTable( + 'pub_to_share', + shared_consts.PUBTOSHARE.ALL, + true + ), photos: [], descr: '', note: '', @@ -7590,17 +8527,38 @@ export const tools = { }; }, - getFullFileName(arrimage: IImgGallery[], table: string, username: string, groupname: string) { + 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 ''; } @@ -7626,7 +8584,12 @@ export const tools = { // return true if (shared_consts.TABLES_PER_EDITORI.includes(tablesel)) { - if (userStore.isCommerciale || userStore.isEditor || userStore.isGrafico || userStore.isAdmin) { + if ( + userStore.isCommerciale || + userStore.isEditor || + userStore.isGrafico || + userStore.isAdmin + ) { return true; } } @@ -7636,7 +8599,9 @@ export const tools = { // 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; } @@ -7661,7 +8626,12 @@ export const tools = { }, 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) { @@ -7743,13 +8713,25 @@ export const tools = { return window.location.pathname.indexOf('signup') >= 0; }, - async sendMsgTelegram($q: any, $t: any, mydata: IMsgGlobParam, showmsgsent: boolean) { + async sendMsgTelegram( + $q: any, + $t: any, + mydata: IMsgGlobParam, + showmsgsent: boolean + ) { const userStore = useUserStore(); return userStore.sendMsgToBotTelegram($q, $t, mydata, showmsgsent); }, - async sendMsgTelegramCmd($q: any, $t: any, cmd: number, showmsgsent: boolean, text?: string, title?: string) { + async sendMsgTelegramCmd( + $q: any, + $t: any, + cmd: number, + showmsgsent: boolean, + text?: string, + title?: string + ) { const userStore = useUserStore(); const mydata: IMsgGlobParam = { @@ -7760,7 +8742,10 @@ export const tools = { title, }; - if (cmd === shared_consts.CmdToSend.SHARE_MSGREG || cmd === shared_consts.CmdToSend.SHARE_TEXT) { + 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; @@ -7774,7 +8759,12 @@ export const tools = { return await this.sendMsgTelegram($q, $t, mydata, showmsgsent); }, - async sendMsgAnnuncioToTelegramCmd($q: any, $t: any, tablerec: string, idrec: string) { + async sendMsgAnnuncioToTelegramCmd( + $q: any, + $t: any, + tablerec: string, + idrec: string + ) { const userStore = useUserStore(); const showmsgsent = false; @@ -7846,7 +8836,9 @@ export const tools = { }, 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) { @@ -7858,10 +8850,16 @@ export const tools = { console.log('loadGroupsByUsername ', ris); if (ris) { userStore.my.profile.mygroups = ris.mygroups ? ris.mygroups : []; - userStore.my.profile.list_usersgroup = ris.listUsersGroup ? ris.listUsersGroup : []; + 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 : []; + userStore.my.profile.asked_groups = ris.listSentRequestGroups + ? ris.listSentRequestGroups + : []; + userStore.my.profile.refused_groups = ris.listRefusedGroups + ? ris.listRefusedGroups + : []; return [{ userId: userStore.my._id }]; } }); @@ -7885,9 +8883,15 @@ export const tools = { // 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 : []; + 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 }]; } }); @@ -7953,8 +8957,12 @@ export const tools = { 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.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; @@ -8011,14 +9019,19 @@ export const tools = { 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.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) + 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 []; @@ -8037,8 +9050,12 @@ export const tools = { } // Ordina entrambi gli array in base ai campi specificati - arr1.sort((a, b) => (a[field1] > b[field1] ? 1 : a[field1] < b[field1] ? -1 : 0)); - arr2.sort((a, b) => (a[field2] > b[field2] ? 1 : a[field2] < b[field2] ? -1 : 0)); + arr1.sort((a, b) => + a[field1] > b[field1] ? 1 : a[field1] < b[field1] ? -1 : 0 + ); + 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, @@ -8075,8 +9092,12 @@ export const tools = { } // Ordina entrambi gli array in base al campo specificato - arr1.sort((a, b) => (a[field] > b[field] ? 1 : a[field] < b[field] ? -1 : 0)); - arr2.sort((a, b) => (a[field] > b[field] ? 1 : a[field] < b[field] ? -1 : 0)); + arr1.sort((a, b) => + a[field] > b[field] ? 1 : a[field] < b[field] ? -1 : 0 + ); + 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, @@ -8111,9 +9132,15 @@ export const tools = { type = costanti.TypeMov.Uscita; } else if (rec.userto && userStore.my.username === rec.userto.username) { type = costanti.TypeMov.Entrata; - } else if (rec.groupfrom && this.isUserAdminGroup(rec.groupfrom.groupname, userStore.my.username)) { + } else if ( + rec.groupfrom && + this.isUserAdminGroup(rec.groupfrom.groupname, userStore.my.username) + ) { type = costanti.TypeMov.Uscita; - } else if (rec.groupto && this.isUserAdminGroup(rec.groupto.groupname, userStore.my.username)) { + } else if ( + rec.groupto && + this.isUserAdminGroup(rec.groupto.groupname, userStore.my.username) + ) { type = costanti.TypeMov.Entrata; } } @@ -8132,7 +9159,10 @@ export const tools = { try { if (circuit.symbol) { return circuit.symbol; - } else if (this.existProp(circuit, 'circuitfrom') && circuit.circuitfrom.symbol) { + } else if ( + this.existProp(circuit, 'circuitfrom') && + circuit.circuitfrom.symbol + ) { return circuit.circuitfrom.symbol; } else if (this.existProp(circuit.extrarec, 'symbol')) { return circuit.extrarec.symbol; @@ -8200,7 +9230,8 @@ export const tools = { } else if (table === 'users') { 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']; } else if (table === 'catalogs') { @@ -8248,14 +9279,32 @@ export const tools = { addtourl = '?v=' + reccard.vers_img; } - return this.getDirUpload() + 'pages/' + mypath + '/' + reccard.imagefile + addtourl; + 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 + ); } } }, @@ -8280,7 +9329,8 @@ export const tools = { 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) { @@ -8315,7 +9365,12 @@ export const tools = { if (field) { const mycol = fieldsTable.getColByTable(tablesel, field); if (mycol) { - console.log('remote_table = ', mycol.remote_table, 'remote_key', mycol.remote_key); + console.log( + 'remote_table = ', + mycol.remote_table, + 'remote_key', + mycol.remote_key + ); console.log('ROW', row); return this.getValueByRemoteField(mycol, row); } @@ -8331,7 +9386,11 @@ export const tools = { return name; }, - getUserNameOnlyIfToShow(user: IUserFields, col: any = null, options = null): string { + getUserNameOnlyIfToShow( + user: IUserFields, + col: any = null, + options = null + ): string { const userStore = useUserStore(); const name = userStore.getUserNameOnlyIfToShow(user, col, options); @@ -8374,14 +9433,18 @@ export const tools = { 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'; } // 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); } @@ -8416,25 +9479,34 @@ export const tools = { }, getStrByParamTypeAccount(paramTypeAccount: string): string { - const myrec = costanti.ParamTypeAccountStr.find((rec: any) => rec.value === paramTypeAccount); + 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); + 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); + 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 + ')'; + if (user.name) + return user.name + ' ' + user.surname + ' (' + user.username + ')'; else return user.username; }, @@ -8458,7 +9530,10 @@ export const tools = { return await userStore.setUserReceiveRIS(username, '').then((data) => { if (data.code === serv_constants.RIS_CODE_OK) { - return { msg: t('circuit.coins_requestedris', { username }), ris: true }; + return { + msg: t('circuit.coins_requestedris', { username }), + ris: true, + }; } else { return { msg: t('db.recfailed'), ris: false }; } @@ -8484,7 +9559,11 @@ export const tools = { 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')); } @@ -8492,7 +9571,13 @@ export const tools = { }, 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) { @@ -8536,7 +9621,8 @@ export const tools = { }, 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; }, @@ -8811,20 +9897,36 @@ export const tools = { 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; }, getUnitsMeasure(unit: number, short: boolean, weight?: number) { - let unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === unit); + 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) { + 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 ); } - if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.LITRI && weight && weight < 1) { + 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 ); @@ -8834,11 +9936,23 @@ export const tools = { }, getWeightByUnit(unit: number, short: boolean, weight: number | undefined) { - 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) { + 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; } - if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.LITRI && weight && weight < 1) { + if ( + unitrec && + unitrec.value === shared_consts.UNITS_OF_MEASURE.LITRI && + weight && + weight < 1 + ) { return weight * 1000; } return weight; @@ -8846,7 +9960,9 @@ export const tools = { getWeightTotalByOrder(order: IOrder) { return ( - (order.product && order.product.productInfo && order.product.productInfo.weight + (order.product && + order.product.productInfo && + order.product.productInfo.weight ? order.product.productInfo.weight : 1) * (order.quantitypreordered | (0 + order.quantity) | 0) @@ -8906,7 +10022,11 @@ export const tools = { removeescape_e_acapo(inputString: string): string { return this.removeTrailingBr( - inputString.replace('\\', '').replace(/"/g, '').replace(/\r\n/g, '
').replace(/\r/g, '
') + inputString + .replace('\\', '') + .replace(/"/g, '') + .replace(/\r\n/g, '
') + .replace(/\r/g, '
') ); }, @@ -8931,7 +10051,9 @@ export const tools = { const countdownInSeconds = Math.floor(countdown / 1000); const days = Math.floor(countdownInSeconds / (60 * 60 * 24)); - const hours = Math.floor((countdownInSeconds % (60 * 60 * 24)) / (60 * 60)); + const hours = Math.floor( + (countdownInSeconds % (60 * 60 * 24)) / (60 * 60) + ); const minutes = Math.floor((countdownInSeconds % (60 * 60)) / 60); const gg = days > 0 ? 'giorni' : ''; @@ -8955,7 +10077,9 @@ export const tools = { const countdownInSeconds = Math.floor(countdown / 1000); const days = Math.floor(countdownInSeconds / (60 * 60 * 24)); - const hours = Math.floor((countdownInSeconds % (60 * 60 * 24)) / (60 * 60)); + const hours = Math.floor( + (countdownInSeconds % (60 * 60 * 24)) / (60 * 60) + ); const minutes = Math.floor((countdownInSeconds % (60 * 60)) / 60); const seconds = countdownInSeconds % 60; @@ -8992,7 +10116,10 @@ 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'); }, @@ -9113,13 +10240,16 @@ export const tools = { 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.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.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'; + else if (versione === shared_consts.PRODUCTTYPE.STREAMING) + str = 'fas fa-stream'; return str; }, @@ -9187,7 +10317,9 @@ export const tools = { }, 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 { @@ -9219,7 +10351,9 @@ export const tools = { }, 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) { @@ -9232,19 +10366,27 @@ export const tools = { } }, - getHostPuntamento(arrDNS: any, tofind: string, paramsulServer: string, type: string): any { + getHostPuntamento( + arrDNS: any, + tofind: string, + paramsulServer: string, + type: string + ): any { 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'; if (!giusto) { - checkDomain += ' (al posto di -> ' + paramsulServer + ')'; + checkDomain += + ' (al posto di -> ' + paramsulServer + ')'; } else { ok = true; } @@ -9256,7 +10398,11 @@ export const tools = { console.log('Error: ', e); } - return { text: '' + checkDomain + '
', ok }; + return { + text: + '' + checkDomain + '
', + ok, + }; }, checkIfICanAddNewRecord() { @@ -9280,12 +10426,15 @@ export const tools = { 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; } else { - return this.getDirUpload() + dir + '/' + gallerylist.imagefile + addtourl; + return ( + this.getDirUpload() + dir + '/' + gallerylist.imagefile + addtourl + ); } } } else { @@ -9340,10 +10489,34 @@ export const tools = { // 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); + 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); + await setValDb( + $q, + mykey2, + myval, + type, + serv, + table, + mysubkey, + id, + indrec, + mysubsubkey, + specialField + ); eseguito = true; } @@ -9351,7 +10524,19 @@ export const tools = { 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 + ); // } } @@ -9377,7 +10562,11 @@ export const tools = { } }, - replaceStringCaseInsensitive(originalString: string, searchString: string, replaceString: string) { + replaceStringCaseInsensitive( + originalString: string, + searchString: string, + replaceString: string + ) { // Crea una regex con il flag 'i' per la ricerca case-insensitive const regex = new RegExp(searchString, 'gi'); // 'g' per global, 'i' per case-insensitive return originalString.replace(regex, replaceString); @@ -9452,7 +10641,9 @@ export const tools = { }, getTitleAnnuncio(table: string) { - const rec = costanti.MAINCARDS.find((rec: any) => rec.showinoptions && rec.table === table); + const rec = costanti.MAINCARDS.find( + (rec: any) => rec.showinoptions && rec.table === table + ); return rec ? rec.strsingolo : ''; }, @@ -9492,7 +10683,9 @@ export const tools = { // 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))) + (typeof value === 'string' && + value.trim() !== '' && + !isNaN(Number(value))) ); }, @@ -9532,7 +10725,12 @@ export const tools = { 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: null, + riga: null, + scheda_prodotto: {}, + immagine_prodotto: {}, + }; rec.dimensioni.pagina = tools.resetRecIPagina({}); rec.testo_right_attaccato = tools.resetIText({}); rec.testo_right = tools.resetIText({}); @@ -9686,7 +10884,11 @@ export const tools = { size += add; } - if (optcatalogo.printable && optcatalogo.areadistampa?.scale && optcatalogo.areadistampa?.scale > 0) { + if ( + optcatalogo.printable && + optcatalogo.areadistampa?.scale && + optcatalogo.areadistampa?.scale > 0 + ) { size = size * optcatalogo.areadistampa?.scale; // Applicare la scala se necessaria } @@ -9765,7 +10967,8 @@ export const tools = { }, getScale(optcatalogo: IOptCatalogo): number | undefined { - if (optcatalogo.printable && optcatalogo.generazionePDFInCorso) return optcatalogo.areadistampa?.scale_printable; + if (optcatalogo.printable && optcatalogo.generazionePDFInCorso) + return optcatalogo.areadistampa?.scale_printable; else return optcatalogo.areadistampa!.scale; }, @@ -9773,13 +10976,17 @@ export const tools = { try { // Se l'URL non ha un protocollo, aggiunge "https://" const baseprotocol = this.getProtocol(); - const formattedUrl = url.startsWith('http://') || url.startsWith('https://') ? url : `${baseprotocol}${url}`; + const formattedUrl = + url.startsWith('http://') || url.startsWith('https://') + ? url + : `${baseprotocol}${url}`; // Crea un nuovo oggetto URL a partire dall'input const parsedUrl = new URL(formattedUrl); // Se non c'è https nella url, aggiungilo - const protocol = parsedUrl.protocol === 'http:' ? 'https:' : parsedUrl.protocol; + const protocol = + parsedUrl.protocol === 'http:' ? 'https:' : parsedUrl.protocol; // Estrae solo l'host const host = parsedUrl ? parsedUrl.host : ''; @@ -9787,7 +10994,12 @@ 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 ''; } }, @@ -9820,7 +11032,11 @@ export const tools = { value: this.isUtente() ? false : this.getCookieBool( - this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_racc_dettagli' + costanti.FILTER_SEP + 'dettagli', + this.COOK_SEARCH + + costanti.FILTER_SEP + + 'finto_racc_dettagli' + + costanti.FILTER_SEP + + 'dettagli', true ), keycookie: '', @@ -9868,7 +11084,11 @@ export const tools = { value: this.isUtente() ? true : this.getCookieBool( - this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_active' + costanti.FILTER_SEP + 'active', + this.COOK_SEARCH + + costanti.FILTER_SEP + + 'finto_active' + + costanti.FILTER_SEP + + 'active', true ), bool: true, @@ -9914,7 +11134,11 @@ export const tools = { value: this.isUtente() ? false : this.getCookieBool( - this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_dettagli' + costanti.FILTER_SEP + 'dettagli', + this.COOK_SEARCH + + costanti.FILTER_SEP + + 'finto_dettagli' + + costanti.FILTER_SEP + + 'dettagli', true ), keycookie: '', @@ -9947,7 +11171,11 @@ export const tools = { 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://' : ''; + const protocol = url.startsWith('http://') + ? 'http://' + : url.startsWith('https://') + ? 'https://' + : ''; return protocol; }, @@ -9957,7 +11185,11 @@ export const tools = { 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 { @@ -9982,13 +11214,17 @@ export const tools = { // Estrai le collane e uniscile con ', ' return collane .map((idcollana) => { - const reccoll: ICollana | undefined = products.collane!.find((coll: ICollana) => coll._id === idcollana); + 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(', '); } else { - const reccoll: ICollana | undefined = products.collane!.find((coll: ICollana) => coll._id === collane); + const reccoll: ICollana | undefined = products.collane!.find( + (coll: ICollana) => coll._id === collane + ); return reccoll ? `${reccoll.title}` : ''; } }, @@ -9996,7 +11232,9 @@ export const tools = { 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; @@ -10023,12 +11261,16 @@ export const tools = { generateHtmlTableFromObject(obj: object) { if (!obj || typeof obj !== 'object') return ''; - let html = ''; + let html = + '
'; html += ''; for (const [key, value] of Object.entries(obj)) { // Se il valore è un oggetto o array, lo converto in JSON stringa - const displayValue = value && typeof value === 'object' ? JSON.stringify(value) : String(value); + const displayValue = + value && typeof value === 'object' + ? JSON.stringify(value) + : String(value); html += ``; } @@ -10037,7 +11279,19 @@ export const tools = { return html; }, + createAndDownloadCSVFromData(csvContent: string, filename: string) { + const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }); + const link = document.createElement('a'); + const url = URL.createObjectURL(blob); + link.setAttribute('href', url); + link.setAttribute('download', filename); + link.style.visibility = 'hidden'; + + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }, // FINE ! diff --git a/src/store/UserStore.ts b/src/store/UserStore.ts index 171a704f..05dc8a1b 100755 --- a/src/store/UserStore.ts +++ b/src/store/UserStore.ts @@ -1050,9 +1050,11 @@ export const useUserStore = defineStore('UserStore', { }, async execDbOp(paramquery: any) { + // come faccio a ricevere un file da node.js ? return Api.SendReq('/users/dbop', 'POST', paramquery, false, false, 0, 5000, null, null, {timeout: 300000}) .then((res) => { + return res.data }).catch((error) => { return false diff --git a/src/views/admin/dbop/dbop.ts b/src/views/admin/dbop/dbop.ts index 745908fb..885a8552 100755 --- a/src/views/admin/dbop/dbop.ts +++ b/src/views/admin/dbop/dbop.ts @@ -77,6 +77,7 @@ export default defineComponent({ const risfunz = await userStore.execDbOp({ mydata }) + $q.loading.hide() await globalStore.loadSite() diff --git a/src/views/admin/dbopmacro/dbopmacro.ts b/src/views/admin/dbopmacro/dbopmacro.ts index 1857e27b..469d3d14 100755 --- a/src/views/admin/dbopmacro/dbopmacro.ts +++ b/src/views/admin/dbopmacro/dbopmacro.ts @@ -78,6 +78,11 @@ export default defineComponent({ const risfunz = await userStore.execDbOp({ mydata }) + if (options?.generateCSV) { + const today = new Date() + tools.createAndDownloadCSVFromData(risfunz.data.mystr.data, `${options?.filename}_${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`) + } + $q.loading.hide() await globalStore.loadSite() diff --git a/src/views/admin/dbopmacro/dbopmacro.vue b/src/views/admin/dbopmacro/dbopmacro.vue index 34b66350..ba8eca40 100755 --- a/src/views/admin/dbopmacro/dbopmacro.vue +++ b/src/views/admin/dbopmacro/dbopmacro.vue @@ -68,9 +68,24 @@ @click="EseguiFunz('removeProductInfoWithoutDateUpdatedFromGM')" > + + +
ChiaveValore
${key}${displayValue}