From 5d8e38fea6aca729c63dc1538a826ae3ef9aa1e7 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Tue, 12 Aug 2025 19:43:36 +0200 Subject: [PATCH] galleria prodotto --- src/components/CGallery/CGallery.ts | 357 +++++---- src/components/CGallery/CGallery.vue | 2 +- src/components/CMyDimensioni/CMyDimensioni.ts | 2 +- .../CMyDimensioni/CMyDimensioni.vue | 2 +- src/components/CMyEditElem/CMyEditElem.ts | 4 +- src/components/CMyEditElem/CMyEditElem.vue | 12 +- src/components/CMyPopupEdit/CMyPopupEdit.ts | 735 ++++++++++-------- src/components/CMyPopupEdit/CMyPopupEdit.vue | 107 ++- .../CMyProfileTutorial/CMyProfileTutorial.vue | 2 +- src/components/CProductCard/CProductCard.vue | 4 +- .../admin/productInfos/productInfos.ts | 4 +- .../admin/productInfos/productInfos.vue | 2 +- .../productInfosComplete.scss | 0 .../productInfosComplete.ts | 24 + .../productInfosComplete.vue | 28 + src/rootgen/admin/products/products.ts | 3 +- src/rootgen/admin/products/products.vue | 2 +- src/router/routesECommerce.ts | 12 +- src/store/Api/Instance.ts | 2 +- src/store/Api/index.ts | 10 +- src/store/Modules/costanti.ts | 3 +- src/store/Modules/fieldsTable.ts | 47 +- src/store/Modules/tools.ts | 4 +- src/views/user/editprofile/editprofile.vue | 2 +- src/views/user/profile/profile.vue | 2 +- 25 files changed, 848 insertions(+), 524 deletions(-) create mode 100755 src/rootgen/admin/productInfosComplete/productInfosComplete.scss create mode 100755 src/rootgen/admin/productInfosComplete/productInfosComplete.ts create mode 100755 src/rootgen/admin/productInfosComplete/productInfosComplete.vue diff --git a/src/components/CGallery/CGallery.ts b/src/components/CGallery/CGallery.ts index 2c813e8c..291dc78d 100755 --- a/src/components/CGallery/CGallery.ts +++ b/src/components/CGallery/CGallery.ts @@ -1,15 +1,18 @@ import type { PropType } from 'vue'; -import { defineComponent, ref, watch, onMounted, computed } from 'vue' -import { useI18n } from 'vue-i18n' -import { useUserStore } from '@store/UserStore' -import { useQuasar } from 'quasar' +import { defineComponent, ref, watch, onMounted, computed } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useUserStore } from '@store/UserStore'; +import { useQuasar } from 'quasar'; import type { IImgGallery } from 'model'; -import { IGallery } from 'model' -import { CMyPage } from '@src/components/CMyPage' -import { tools } from '@tools' -import { useGlobalStore } from '@store/globalStore' -import { costanti } from '@costanti' +import { IGallery } from 'model'; +import { CMyPage } from '@src/components/CMyPage'; +import { tools } from '@tools'; +import { useGlobalStore } from '@store/globalStore'; +import { costanti } from '@costanti'; import { shared_consts } from 'app/src/common/shared_vuejs'; +import { Api } from 'app/src/store/Api'; +import axios from 'app/src/boot/axios'; +import { toolsext } from 'app/src/store/Modules/toolsext'; export default defineComponent({ name: 'CGallery', @@ -57,6 +60,11 @@ export default defineComponent({ required: false, default: false, }, + fieldtype: { + type: Number, + required: false, + default: 0, + }, imgGall: { type: Object as PropType, required: true, @@ -65,174 +73,182 @@ export default defineComponent({ emits: ['showandsave'], components: { CMyPage }, setup(props, { emit }) { - const $q = useQuasar() - const { t } = useI18n() - const userStore = useUserStore() - const globalStore = useGlobalStore() + const $q = useQuasar(); + const { t } = useI18n(); + const userStore = useUserStore(); + const globalStore = useGlobalStore(); - const displayGall = ref(false) + const displayGall = ref(false); - const gallerylist = ref([]) - const maximizedToggle = ref(true) + const gallerylist = ref([]); + const maximizedToggle = ref(true); - const fullscreen = ref(false) - const fullscreensrc = ref('') + const fullscreen = ref(false); + const fullscreensrc = ref(''); - const uploadOptions = ref({ // qui definisci le opzioni da passare + const upl = ref(); + + const uploadOptions = ref({ + // qui definisci le opzioni da passare quality: 'original', // esempio di opzione di qualità - resize: true // opzione per abilitare il ridimensionamento - }) + resize: true, // opzione per abilitare il ridimensionamento + }); function isValid(myobj: any): boolean { - return (myobj && typeof myobj !== 'string' && typeof myobj !== 'undefined') + return myobj && typeof myobj !== 'string' && typeof myobj !== 'undefined'; } const isListImgValid = computed(() => { - const arr = getlistimages() + const arr = getlistimages(); if (arr && tools.isArray(arr)) { - return arr.length > 0 + return arr.length > 0; } else { - return !!arr + return !!arr; } - }) + }); - watch(() => props.imgGall, (newval, oldval) => { - if (isValid(props.imgGall)) { - // @ts-ignore - gallerylist.value = props.imgGall + watch( + () => props.imgGall, + (newval, oldval) => { + if (isValid(props.imgGall)) { + // @ts-ignore + gallerylist.value = props.imgGall; + } } - }) + ); function created() { // console.log('created cgallery') if (isValid(props.imgGall)) { // @ts-ignore - let myarr: any = props.imgGall - gallerylist.value = [] + let myarr: any = props.imgGall; + gallerylist.value = []; if (Array.isArray(myarr)) { myarr.forEach((pic: any) => { - if (pic.imagefile) { - gallerylist.value.push(pic) + if (pic?.imagefile) { + gallerylist.value.push(pic); + } else { + gallerylist.value.push(pic); } - }) + }); } } else { - gallerylist.value = [ - ] + gallerylist.value = []; } uploadOptions.value = { quality: props.quality, resize: props.resize, - } + }; } function getnumimages() { - if (gallerylist.value) - return gallerylist.value.length - else - return 0 + if (gallerylist.value) return gallerylist.value.length; + else return 0; } function getlistimages() { if (gallerylist.value) // return gallerylist.value.slice().sort((a: any, b: any) => a.order! - b.order!) //return gallerylist.value.filter(filename => !filename) - return gallerylist.value - else - return null + return gallerylist.value; + else return null; } function onDragStart(e: any) { - console.log('onDragStart') - e.dataTransfer.setData('text', e.target.id) - e.dataTransfer.dropEffect = 'move' + console.log('onDragStart'); + e.dataTransfer.setData('text', e.target.id); + e.dataTransfer.dropEffect = 'move'; } function onDragEnter(e: any) { if (props.canModify) { // don't drop on other draggables if (e.target.draggable !== true) { - e.target.classList.add('drag-enter') + e.target.classList.add('drag-enter'); } } } function onDragLeave(e: any) { if (props.canModify) { - e.target.classList.remove('drag-enter') + e.target.classList.remove('drag-enter'); } } function onDragOver(e: any) { if (props.canModify) { - e.preventDefault() + e.preventDefault(); } } function onDrop(e: any) { if (props.canModify) { - console.log('onDrop', e) - e.preventDefault() + console.log('onDrop', e); + e.preventDefault(); // don't drop on other draggables if (e.target.draggable === true) { - return + return; } if (gallerylist.value) { - - const draggedId = e.dataTransfer.getData('text') - let dragout = '' + const draggedId = e.dataTransfer.getData('text'); + let dragout = ''; try { - dragout = e.target.parentNode.parentNode.parentNode.id + dragout = e.target.parentNode.parentNode.parentNode.id; } catch (err) { - dragout = '' + dragout = ''; } - const draggedEl = document.getElementById(draggedId) - console.log('draggedId', draggedId, 'draggedEl', draggedEl) - console.log('dragout', dragout) + const draggedEl = document.getElementById(draggedId); + console.log('draggedId', draggedId, 'draggedEl', draggedEl); + console.log('dragout', dragout); // check if original parent node if (draggedEl) { if (draggedEl.parentNode === e.target) { - e.target.classList.remove('drag-enter') - return + e.target.classList.remove('drag-enter'); + return; } } - const myindexIn = gallerylist.value.findIndex((rec: any) => rec._id === draggedId) - const myrecIn: IImgGallery = gallerylist.value[myindexIn] + const myindexIn = gallerylist.value.findIndex( + (rec: any) => rec._id === draggedId + ); + const myrecIn: IImgGallery = gallerylist.value[myindexIn]; - let myrecOut: IImgGallery - const myindexout = gallerylist.value.findIndex((rec: any) => rec._id === dragout) - myrecOut = gallerylist.value[myindexout] + let myrecOut: IImgGallery; + const myindexout = gallerylist.value.findIndex( + (rec: any) => rec._id === dragout + ); + myrecOut = gallerylist.value[myindexout]; - if (myindexIn === myindexout) - return + if (myindexIn === myindexout) return; - - tools.array_move(gallerylist.value, myindexIn, myindexout) + tools.array_move(gallerylist.value, myindexIn, myindexout); // make the exchange // draggedEl.parentNode.removeChild(draggedEl) // e.target.appendChild(draggedEl) - e.target.classList.remove('drag-enter') + e.target.classList.remove('drag-enter'); - save() + save(); } } } function getclass() { - return (props.edit || displayGall.value) ? (props.isInModif ? 'my-card-gallery' : 'my-card-gallery-noModif') : 'my-card-gallery-view' + ' text-center' + return props.edit || displayGall.value + ? props.isInModif + ? 'my-card-gallery' + : 'my-card-gallery-noModif' + : 'my-card-gallery-view' + ' text-center'; } function getclimg() { - let mycl = (props.edit || displayGall.value) ? 'myimg' : 'myimg-view' - if (props.canModify && props.edit) - mycl = mycl + ' myimg-modify' - return mycl + let mycl = props.edit || displayGall.value ? 'myimg' : 'myimg-view'; + if (props.canModify && props.edit) mycl = mycl + ' myimg-modify'; + return mycl; } /*function getlastord() { @@ -248,79 +264,81 @@ export default defineComponent({ }*/ function uploaded(info: any) { - console.log('uploaded', info) + console.log('uploaded', info); - let vers_img = tools.getGenerateVersionImage() + let vers_img = tools.getGenerateVersionImage(); if (gallerylist.value) { - console.log('vers_img', vers_img) + console.log('vers_img', vers_img); if (props.single && info.files) { - console.log('gallerylist.value[0]', info.files[0].name) + console.log('gallerylist.value[0]', info.files[0].name); if (info.files[0].name.imagefile) { - gallerylist.value[0] = info.files[0].name + gallerylist.value[0] = info.files[0].name; } else { - gallerylist.value[0] = { imagefile: info.files[0].name, vers_img } + gallerylist.value[0] = { imagefile: info.files[0].name, vers_img, fieldtype: props.fieldtype }; } - } else { for (const file of info.files) { if (file.name.imagefile) { - gallerylist.value.push(file.name) + gallerylist.value.push(file.name); } else { - gallerylist.value.push({ imagefile: file.name, vers_img }) + gallerylist.value.push({ imagefile: file.name, vers_img, fieldtype: props.fieldtype }); } } } - save() + save(); - console.log('CGALLERY gallerylist', gallerylist.value) + console.log('CGALLERY gallerylist', gallerylist.value); } } function apri() { - displayGall.value = true + displayGall.value = true; } function deleted(rec: any) { - console.log('deleted', rec.imagefile) + console.log('deleted', rec.imagefile); // console.table(mylistimages) if (gallerylist.value) { - const index = gallerylist.value.findIndex((elem: any) => elem.imagefile === rec.imagefile) + const index = gallerylist.value.findIndex( + (elem: any) => elem.imagefile === rec.imagefile + ); if (index > -1) { - gallerylist.value.splice(index, 1) + gallerylist.value.splice(index, 1); } - gallerylist.value = gallerylist.value.filter((elem: any) => typeof elem.imagefile === 'string' && elem.imagefile) + gallerylist.value = gallerylist.value.filter( + (elem: any) => typeof elem.imagefile === 'string' && elem.imagefile + ); // mylistimages = mylistimages.pop((elem) => elem.imagefile !== rec.imagefile) // console.table(mylistimages) - console.log('single', props.single) + console.log('single', props.single); - save() + save(); } } function getfullname(rec: any) { if (rec) { - return tools.getDirUpload() + props.directory + '/' + rec.imagefile + return tools.getDirUpload() + props.directory + '/' + rec.imagefile; } else { - return props.imagebak + return props.imagebak; } - } function copytoclipboard(rec: any) { - const filename = getfullname(rec) - tools.copyStringToClipboard($q, filename, true) + const filename = getfullname(rec); + tools.copyStringToClipboard($q, filename, true); } function deleteFile(rec: any) { - console.log('deleteFile....') - const filename = getfullname(rec) - const filenamerel = filename.replace(/^.*[\\\/]/, '') + console.log('deleteFile....'); + const filename = getfullname(rec); + const filenamerel = filename.replace(/^.*[\\\/]/, ''); $q.dialog({ message: 'Eliminare il file ' + filenamerel + '?', @@ -333,91 +351,134 @@ export default defineComponent({ cancel: true, persistent: false, }).onOk(async () => { - // Delete File on server: - const ris = await globalStore.DeleteFile({ filename }) + const ris = await globalStore.DeleteFile({ filename }); // console.log('ris', ris) //if (ris) - deleted(rec) - }) + deleted(rec); + }); } function save() { - console.log('CGallery save', gallerylist.value) + console.log('CGallery save', gallerylist.value); if (gallerylist.value.length > 0) { if (!props.single) { - emit('showandsave', gallerylist.value) + emit('showandsave', gallerylist.value); } else { - emit('showandsave', gallerylist.value[0]) + emit('showandsave', gallerylist.value[0]); } } else { - emit('showandsave', !props.single ? [] : '') + emit('showandsave', !props.single ? [] : ''); } } function close() { - return '' + return ''; } function getrealdirectory() { - if (props.directory == 'productinfos') - return 'products' - else - return props.directory + if (props.directory == 'productinfos') return 'products'; + else return props.directory; } function getParamDir() { - return tools.escapeslash(getrealdirectory()) + return tools.escapeslash(getrealdirectory()); } function getUrl() { - const myurl = tools.geturlupload() + getParamDir() - console.log('myurl', myurl) - return myurl + const myurl = tools.geturlupload() + getParamDir(); + console.log('myurl', myurl); + return myurl; } function ImgFullScreen(mygallery: IImgGallery) { - fullscreen.value = true - fullscreensrc.value = getfullname(mygallery) + fullscreen.value = true; + fullscreensrc.value = getfullname(mygallery); } function onRejected(rejectedEntries: any) { // Notify plugin needs to be installed // https://quasar.dev/quasar-plugins/notify#Installation - console.log('rejectedEntries', rejectedEntries) + console.log('rejectedEntries', rejectedEntries); $q.notify({ type: 'negative', - message: 'La Dimensione massima dell\'immagine è di 2 MB' - }) + message: "La Dimensione massima dell'immagine è di 2 MB", + }); } function getFileTypeStr() { - let tipo = '' - if (props.filetype === shared_consts.FILETYPE.IMG) - tipo = 'Immagine' - else if (props.filetype === shared_consts.FILETYPE.PDF) - tipo = 'PDF' + let tipo = ''; + if (props.filetype === shared_consts.FILETYPE.IMG) tipo = 'Immagine'; + else if (props.filetype === shared_consts.FILETYPE.PDF) tipo = 'PDF'; - return tipo + return tipo; } function getAccept() { - let tipo = '' - if (props.filetype === shared_consts.FILETYPE.IMG) - tipo = 'image/*' - else if (props.filetype === shared_consts.FILETYPE.PDF) - tipo = 'application/pdf' + let tipo = ''; + if (props.filetype === shared_consts.FILETYPE.IMG) tipo = 'image/*'; + else if (props.filetype === shared_consts.FILETYPE.PDF) tipo = 'application/pdf'; - return tipo + return tipo; } function isPDF() { - return props.filetype === shared_consts.FILETYPE.PDF + return props.filetype === shared_consts.FILETYPE.PDF; } function isIMG() { - return props.filetype === shared_consts.FILETYPE.IMG + return props.filetype === shared_consts.FILETYPE.IMG; } + const uploadFactory = async (files: readonly File[]) => { + const userStore = useUserStore(); + const url = getUrl(); - onMounted(created) + const buildFormData = () => { + const fd = new FormData(); + // "file" è il fieldName atteso dal backend (adegua se diverso) + files.forEach((f) => fd.append('file', f, f.name)); + // opzionale: passaggio di options come nel tuo backend + fd.append('options', JSON.stringify({ quality: 'original' })); + return fd; + }; + + const sendOnce = async () => { + return Api.SendReq(url, 'POST', buildFormData()); + }; + + try { + await sendOnce(); + } catch (err: any) { + const status = err?.response?.status; + try { + // usa la tua logica centralizzata + Api.checkTokenScaduto( + status, + /*evitaloop*/ false, + url, + 'POST', + null, + /*setAuthToken*/ true + ); + if (ret !== null) { + // token aggiornato -> ritenta UNA volta + await sendOnce(); + } else { + throw err; + } + } catch (err2: any) { + // se l’handler segnala re-login, mostra messaggio e rilancia + const mystatus = err2?.status || err2?.code; + if (mystatus === toolsext.ERR_RETRY_LOGIN) { + $q.notify({ + type: 'warning', + message: 'Sessione scaduta. Effettua nuovamente il login.', + }); + } + throw err2; + } + } + }; + + onMounted(created); return { getlistimages, @@ -453,6 +514,8 @@ export default defineComponent({ shared_consts, isIMG, isPDF, - } - } -}) + upl, + uploadFactory, + }; + }, +}); diff --git a/src/components/CGallery/CGallery.vue b/src/components/CGallery/CGallery.vue index 4163363b..348265d3 100755 --- a/src/components/CGallery/CGallery.vue +++ b/src/components/CGallery/CGallery.vue @@ -322,7 +322,7 @@ :src="tools.getsrcimg(mygallery, getrealdirectory())" :class="getclimg()" @click="ImgFullScreen(mygallery)" - :alt="mygallery.alt" + :alt="mygallery?.alt" >
diff --git a/src/components/CMyEditElem/CMyEditElem.ts b/src/components/CMyEditElem/CMyEditElem.ts index 701f8850..eb42d53f 100755 --- a/src/components/CMyEditElem/CMyEditElem.ts +++ b/src/components/CMyEditElem/CMyEditElem.ts @@ -553,9 +553,9 @@ export default defineComponent({ const iscatalogo = costanti.CATALOGO_FIELDS.includes(col.name); const isscheda = costanti.SCHEDA_FIELDS.includes(col.name); - const isIImg = costanti.IMG_FIELDS.includes(col.name) && col.fieldtype === costanti.FieldType.image; + const isIImg = costanti.IMG_FIELDS.includes(col.name) && col.fieldtype === costanti.FieldType.imagerec; - if (col.fieldtype === costanti.FieldType.image) { + if (col.fieldtype === costanti.FieldType.imagerec) { if (iscatalogo) { myel.value.catalogo[col.name] = newval.imagefile; //console.log('SALVATO IN', col.name, newval.imagefile, 'RIS', myel.value.catalogo[col.name]) diff --git a/src/components/CMyEditElem/CMyEditElem.vue b/src/components/CMyEditElem/CMyEditElem.vue index 832053ab..67d1fd19 100755 --- a/src/components/CMyEditElem/CMyEditElem.vue +++ b/src/components/CMyEditElem/CMyEditElem.vue @@ -711,7 +711,7 @@ @update:model-value="modifElem" :canEdit="true" :canModify="true" - :fieldtype="costanti.FieldType.image" + :fieldtype="costanti.FieldType.imagerec" > @@ -760,7 +760,7 @@ @update:model-value="modifElem" :canEdit="true" :canModify="true" - :fieldtype="costanti.FieldType.image" + :fieldtype="costanti.FieldType.imagerec" >
@@ -947,7 +947,7 @@ @update:model-value="modifElem" :canEdit="true" :canModify="true" - :fieldtype="costanti.FieldType.image" + :fieldtype="costanti.FieldType.imagerec" >
@@ -1036,7 +1036,7 @@ @update:model-value="modifElem" :canEdit="true" :canModify="true" - :fieldtype="costanti.FieldType.image" + :fieldtype="costanti.FieldType.imagerec" >
diff --git a/src/components/CMyPopupEdit/CMyPopupEdit.ts b/src/components/CMyPopupEdit/CMyPopupEdit.ts index fecef970..65568626 100755 --- a/src/components/CMyPopupEdit/CMyPopupEdit.ts +++ b/src/components/CMyPopupEdit/CMyPopupEdit.ts @@ -1,40 +1,46 @@ import type { PropType } from 'vue'; -import { defineComponent, onMounted, onBeforeMount, ref, toRef, watch, computed } from 'vue' -import { useI18n } from 'vue-i18n' -import { useUserStore } from '@store/UserStore' -import { useGlobalStore } from '@store/globalStore' -import { useQuasar } from 'quasar' -import type { IColGridTable, IImgGallery, ISpecialField } from 'model' -import { CMyChipList } from '../CMyChipList' -import { CDate } from '../CDate' -import { CDateTime } from '../CDateTime' -import { CLabel } from '../CLabel' -import { CMyToggleList } from '../CMyToggleList' -import { CMySelect } from '../CMySelect' -import { CCurrencyValue } from '../CCurrencyValue' -import { CMapEditAddressByCoord } from '../CMapEditAddressByCoord' -import { CInput } from '../CInput' -import { CMyEditor } from '../CMyEditor' -import { CMyEditorAI } from '../CMyEditorAI' -import { CGallery } from '../CGallery' -import { CPickColor } from '../CPickColor' -import { CSelectImage } from '../CSelectImage' -import { CAccomodation } from '../CAccomodation' -import { tools } from '@tools' -import { costanti } from '@costanti' - +import { + defineComponent, + onMounted, + onBeforeMount, + ref, + toRef, + watch, + computed, +} from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useUserStore } from '@store/UserStore'; +import { useGlobalStore } from '@store/globalStore'; +import { useQuasar } from 'quasar'; +import type { IColGridTable, IImgGallery, ISpecialField } from 'model'; +import { CMyChipList } from '../CMyChipList'; +import { CDate } from '../CDate'; +import { CDateTime } from '../CDateTime'; +import { CLabel } from '../CLabel'; +import { CMyToggleList } from '../CMyToggleList'; +import { CMySelect } from '../CMySelect'; +import { CCurrencyValue } from '../CCurrencyValue'; +import { CMapEditAddressByCoord } from '../CMapEditAddressByCoord'; +import { CInput } from '../CInput'; +import { CMyEditor } from '../CMyEditor'; +import { CMyEditorAI } from '../CMyEditorAI'; +import { CGallery } from '../CGallery'; +import { CPickColor } from '../CPickColor'; +import { CSelectImage } from '../CSelectImage'; +import { CAccomodation } from '../CAccomodation'; +import { tools } from '@tools'; +import { costanti } from '@costanti'; // @ts-ignore // import VueTelInput from 'vue3-tel-input' // import 'vue3-tel-input/dist/vue3-tel-input.css' -import { fieldsTable } from '@store/Modules/fieldsTable' -import MixinBase from '@src/mixins/mixin-base' -import MixinUsers from '@src/mixins/mixin-users' -import { toolsext } from '@store/Modules/toolsext' -import { shared_consts } from '@src/common/shared_vuejs' -import { useRouter } from 'vue-router' - +import { fieldsTable } from '@store/Modules/fieldsTable'; +import MixinBase from '@src/mixins/mixin-base'; +import MixinUsers from '@src/mixins/mixin-users'; +import { toolsext } from '@store/Modules/toolsext'; +import { shared_consts } from '@src/common/shared_vuejs'; +import { useRouter } from 'vue-router'; export default defineComponent({ name: 'CMyPopupEdit', @@ -221,84 +227,105 @@ export default defineComponent({ }, }, components: { - CMyChipList, CDateTime, CDate, CMyToggleList, CMySelect, CMyEditor, CGallery, CMyEditorAI, - CCurrencyValue, CLabel, CAccomodation, CSelectImage, CMapEditAddressByCoord, CInput, + CMyChipList, + CDateTime, + CDate, + CMyToggleList, + CMySelect, + CMyEditor, + CGallery, + CMyEditorAI, + CCurrencyValue, + CLabel, + CAccomodation, + CSelectImage, + CMapEditAddressByCoord, + CInput, CPickColor, }, setup(props, { emit }) { - const $q = useQuasar() - const { t } = useI18n() - const userStore = useUserStore() - const globalStore = useGlobalStore() + const $q = useQuasar(); + const { t } = useI18n(); + const userStore = useUserStore(); + const globalStore = useGlobalStore(); - const myvalue = ref(null as any) - const myvalueprec = ref('false') - const countryname = ref('') - const visueditor = ref(false) - const visuhtml = ref(false) - const showeditor = ref(false) + const myvalue = ref(null as any); + const myvalueprec = ref('false'); + const countryname = ref(''); + const visueditor = ref(false); + const visuhtml = ref(false); + const showeditor = ref(false); - const hoverPreview = ref(false) + const hoverPreview = ref(false); - const myImgGall = ref([{}] as IImgGallery[]) + const myImgGall = ref([{}] as IImgGallery[]); - const $router = useRouter() + const $router = useRouter(); - const loaded = ref(false) + const loaded = ref(false); const myColor = ref('#FF00AA55'); // Colore con trasparenza iniziale - const popupEditRef = ref(null) + const popupEditRef = ref(null); const colorPicker = ref(null); - const addstrrequired = ref('') + const addstrrequired = ref(''); const col = ref({ name: 'test', fieldtype: 0, - showWhen: costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView, + showWhen: + costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView, visible: true, maxlength: props.mycol ? props.mycol.maxlength : 0, - minlength: props.mycol ? props.mycol.minlength : undefined - }) + minlength: props.mycol ? props.mycol.minlength : undefined, + }); const copyToClipboard = (text) => { - navigator.clipboard.writeText(text) + navigator.clipboard + .writeText(text) .then(() => { $q.notify({ message: 'Testo copiato negli appunti!', color: 'positive', icon: 'check', - position: 'top' + position: 'top', }); }) - .catch(err => { + .catch((err) => { console.error('Errore durante la copia:', err); $q.notify({ message: 'Errore nella copia', color: 'negative', icon: 'error', - position: 'top' + position: 'top', }); }); }; - const { setValDb, getValDb } = MixinBase() - const { getMyUsername } = MixinUsers() + const { setValDb, getValDb } = MixinBase(); + const { getMyUsername } = MixinUsers(); - const myrealrow = toRef(props, 'row') + const myrealrow = toRef(props, 'row'); - watch(() => props.row, (newval, oldval) => { - refresh() - }) + watch( + () => props.row, + (newval, oldval) => { + refresh(); + } + ); - watch(() => props.rec, (newval, oldval) => { - refresh() - }, { deep: true }) + watch( + () => props.rec, + (newval, oldval) => { + refresh(); + }, + { deep: true } + ); - const myrow = ref(null) - const mypath = ref('') + const myrow = ref(null); + const mypath = ref(''); /* const myrow = computed(() => { return props.rec && props.isrec ? props.rec : props.row @@ -308,48 +335,68 @@ export default defineComponent({ // console.log('crea', isFieldDb(), 'props.mycol', props.mycol) if (props.mycol && props.mycol.name && props.mycol.name !== 'test') { - col.value = { ...props.mycol } + col.value = { ...props.mycol }; } else { if (col.value.name === 'test') { - col.value.name = props.field + col.value.name = props.field; if (props.subfield) { - col.value.name += '.' + props.subfield + col.value.name += '.' + props.subfield; } } - col.value.jointable = props.jointable - if (props.filter) - col.value.filter = props.filter - col.value.fieldtype = props.type + col.value.jointable = props.jointable; + if (props.filter) col.value.filter = props.filter; + col.value.fieldtype = props.type; - if (props.type === costanti.FieldType.image) { - myImgGall.value = [{ - _id: '', - imagefile: myvalue.value, - vers_img: 1, - alt: 'img', - }] + if (props.type === costanti.FieldType.imagerec) { + myImgGall.value = [ + { + _id: '', + imagefile: myvalue.value, + vers_img: 1, + alt: 'img', + }, + ]; + } else if (props.type === costanti.FieldType.imgfile_sfuso) { + myImgGall.value = [ + { + _id: '', + imagefile: myvalue.value, + vers_img: 1, + alt: 'img', + }, + ]; } else if (props.type === costanti.FieldType.imgcard) { - myImgGall.value = [myvalue.value] + myImgGall.value = [myvalue.value]; } // console.log('* col', col.value); } if (props.type) { - col.value.fieldtype = props.type + col.value.fieldtype = props.type; } if (props.isrec) { } else { if (isFieldDb()) { - myvalue.value = getValDb(props.field, props.serv, '', props.table, props.subfield, props.id, props.idmain, props.indrec, props.mysubsubkey, props.specialField) + myvalue.value = getValDb( + props.field, + props.serv, + '', + props.table, + props.subfield, + props.id, + props.idmain, + props.indrec, + props.mysubsubkey, + props.specialField + ); } else { - if (props.mycol && props.mycol.name) - col.value = { ...props.mycol } + if (props.mycol && props.mycol.name) col.value = { ...props.mycol }; } } - addstrrequired.value = col.value.required ? '* ' : '' + addstrrequired.value = col.value.required ? '* ' : ''; // console.log('popupedit myvalue.value: ', myvalue.value) @@ -357,52 +404,55 @@ export default defineComponent({ // let obj = tools.getParamsByTable(props.table) // console.log('OBJ:', obj) if (true) { - // console.log(' CAMPO', props.field + '.' + props.subfield) - const myval = tools.getLabelFooterByRow(myrow.value, props.field + '.' + props.subfield, props.table) - if (myval) - myvalue.value = myval + const myval = tools.getLabelFooterByRow( + myrow.value, + props.field + '.' + props.subfield, + props.table + ); + if (myval) myvalue.value = myval; // console.log(' RECORD INPUT', myrow.value) // console.log(' VALORE OUTPUT: ', myvalue.value) } } if (props.path) { - mypath.value = props.path + mypath.value = props.path; } else { if (tools.existProp(col.value, 'path')) - mypath.value = col.value.path ? col.value.path : '' + mypath.value = col.value.path ? col.value.path : ''; } // console.log('CMyFieldDb crea', myvalue) } - watch(() => props.id, (newval, oldval) => { - crea() - }) - + watch( + () => props.id, + (newval, oldval) => { + crea(); + } + ); function isFieldDb() { // return props.type !== 0 - return props.fielddb + return props.fielddb; } function isviewfield() { - return props.view === 'field' + return props.view === 'field'; } function changeval(newval: any) { // console.log('changeval update:row', newval) if (!props.isrec) { - emit('update:row', props.row) + emit('update:row', props.row); } - if (props.isInModif) - OpenEdit() + if (props.isInModif) OpenEdit(); } function getrealval(newval: any) { if (col.value.fieldtype === costanti.FieldType.hours) { - newval = newval.value + newval = newval.value; } } @@ -410,75 +460,78 @@ export default defineComponent({ // console.log('addNewValue', value, col.value) if (col.value.allowNewValue && col.value.jointable) { - const myrec: any = {} + const myrec: any = {}; - const mylabel = fieldsTable.getLabelByTable(col.value.jointable) - myrec[mylabel] = value + const mylabel = fieldsTable.getLabelByTable(col.value.jointable); + myrec[mylabel] = value; if (col.value.filter_field && props.value_extra) { - myrec[col.value.filter_field] = props.value_extra + myrec[col.value.filter_field] = props.value_extra; } // console.log('value_extra', props.value_extra) if (props.table) { - return await globalStore.saveNewRecord(col.value.jointable, myrec) + return await globalStore.saveNewRecord(col.value.jointable, myrec); } } - return null + return null; } function changeValRecCoordAddr(newval: any) { // console.log('changeValRecCoordAddr', newval, 'myrow', myrow.value[col.value.name]) if (!myrow.value[col.value.name]) { - myrow.value[col.value.name] = {} + myrow.value[col.value.name] = {}; } if (newval.coordinates && newval.coordinates.lat) { - newval.coordinates.lat = tools.convertToDecimal6(newval.coordinates.lat) - newval.coordinates.lng = tools.convertToDecimal6(newval.coordinates.lng) + newval.coordinates.lat = tools.convertToDecimal6(newval.coordinates.lat); + newval.coordinates.lng = tools.convertToDecimal6(newval.coordinates.lng); } // console.log('newval...', newval) - return changevalRecOrig(newval) + return changevalRecOrig(newval); } function changevalRec(newval: any) { - return changevalRecOrig(newval, props.subfield) + return changevalRecOrig(newval, props.subfield); } function changevalRecOrig(newval: any, subcol: string = '') { - // console.log('changevalRec', newval) + console.log('changevalRec', newval) // if (!props.insertMode || (props.insertMode && col.value.fieldtype !== costanti.FieldType.multioption)) { if (col.value && col.value.allowchar === costanti.ALLOWCHAR_CODE) { - newval = tools.removespaces_slash(newval) + newval = tools.removespaces_slash(newval); } if (col.value.fieldtype === costanti.FieldType.username_telegram) { - newval = tools.removeatIniziale(newval) + newval = tools.removeatIniziale(newval); } // console.log('popuppedit: changevalRec', newval, 'COLName', col.value.name) // console.log('row', props.row, 'col', props.mycol, 'newval', newval) // console.log('row[col.value.name]', props.row[col.value.name]) - if (props.type === costanti.FieldType.image) { + if (props.type === costanti.FieldType.imagerec) { // console.log('image', newval) } + if (props.type === costanti.FieldType.imgfile_sfuso) { + newval = newval?.imagefile + } + if (props.notAllowAtChar) { - newval = tools.rimuoviAtPrimoCarattere(newval) + newval = tools.rimuoviAtPrimoCarattere(newval); } if (subcol) { - const arrcol = col.value.name.split('.') + const arrcol = col.value.name.split('.'); if (arrcol.length > 0) { - const primo = arrcol[0] - let sec = null - if (arrcol.length > 1) - sec = arrcol[1] + const primo = arrcol[0]; + let sec = null; + if (arrcol.length > 1) sec = arrcol[1]; if (sec) { if (!myrow.value[primo]) { - myrow.value[primo] = {} + myrow.value[primo] = {}; } - myrow.value[primo][sec] = newval + myrow.value[primo][sec] = newval; } else { - myrow.value[primo] = newval + myrow.value[primo] = newval; } /*if (!myrow.value[col.value.name]) { myrow.value[col.value.name] = {} @@ -487,64 +540,61 @@ export default defineComponent({ // console.log('myrow.value[col.value.name]', myrow.value[col.value.name]) } } else { - myrow.value[col.value.name] = newval + myrow.value[col.value.name] = newval; } // console.log('changevalRec update:row', myrow.value) // emit('update:row', myrow.value) - emit('update_col', col.value.name, newval) - if (props.isInModif) - OpenEdit() + emit('update_col', col.value.name, newval); + if (props.isInModif) OpenEdit(); - emit('save', newval) + emit('save', newval); // } } function changevalRecHours(newval: any) { if (col.value.fieldtype === costanti.FieldType.hours) { - newval = newval.value + newval = newval.value; } - changevalRec(newval) + changevalRec(newval); - myvalue.value = newval + myvalue.value = newval; } function updatedata() { - mounted() + mounted(); } function mounted() { //console.log('mounted CMyPopupEdit') - myrow.value = props.rec && props.isrec ? { ...props.rec } : { ...props.row } + myrow.value = props.rec && props.isrec ? { ...props.rec } : { ...props.row }; // console.log('myrow', myrow.value?.arrvariazioni?.[0]) try { - // console.log('mounted', 'isFieldDb()', myrow.value, 'sub', props.subfield, 'field', props.field) if (isFieldDb() && !props.isrec) { // console.log(' . none...') } else { if (props.subfield !== '') { if (myrow.value[props.field] === undefined) { - myrow.value[props.field] = {} - myvalue.value = '' + myrow.value[props.field] = {}; + myvalue.value = ''; } else { - myvalue.value = myrow.value[props.field][props.subfield] + myvalue.value = myrow.value[props.field][props.subfield]; } } else { - let miorecord = myrow.value + let miorecord = myrow.value; if (props.table === 'arrvariazioni') { - miorecord = myrow.value.arrvariazioni[0] + miorecord = myrow.value.arrvariazioni[0]; } - if (props.field !== '') - myvalue.value = miorecord[props.field] + if (props.field !== '') myvalue.value = miorecord[props.field]; else { // @ts-ignore - myvalue.value = myrow.value + myvalue.value = myrow.value; } } // console.log('props.field', props.field, 'props.subfield', props.subfield, 'myvalue: ', myvalue) @@ -555,76 +605,76 @@ export default defineComponent({ esito: costanti.VALIDATO.NO, username: '', note: '', - } + }; } - } catch (e) { + } catch (e) { } - } // console.log('popupedit: myvalue.value', myvalue.value) // console.log('myvalue.value', myvalue.value) - myvalueprec.value = myvalue.value + myvalueprec.value = myvalue.value; - - crea() + crea(); if (!loaded.value) { - if (col.value.fieldtype === costanti.FieldType.listimages) { if (myvalue.value === '' || myvalue.value === undefined) { // console.log('set default myvalue.value ') myvalue.value = { title: 'Galleria', directory: 'none', - list: [] - } + list: [], + }; } } else if (col.value.fieldtype === costanti.FieldType.listobj) { if (myvalue.value === '' || myvalue.value === undefined) { // console.log('set default myvalue.value ') - myvalue.value = [{ - type: 0, // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) - location: 0, // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto - num: 0, - }] + myvalue.value = [ + { + type: 0, // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) + location: 0, // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto + num: 0, + }, + ]; } } else if (col.value.fieldtype === costanti.FieldType.coordinates) { if (myvalue.value === '' || myvalue.value === undefined) { // console.log('set default myvalue.value ') myvalue.value = { address: '', - coordinates: [0, 0] - } + coordinates: [0, 0], + }; } if (!myvalue.value.address) { - myvalue.value.address = '' + myvalue.value.address = ''; } if (!myvalue.value.coordinates) { - myvalue.value.coordinates = [0, 0] + myvalue.value.coordinates = [0, 0]; } } } - loaded.value = true + loaded.value = true; + + console.log('MOUNTED - myvalue.value', myvalue.value) // console.log('myvalueprec', myvalueprec) } function refresh() { - mounted() + mounted(); } - function OpenEdit() { // console.log('OpenEdit') - emit('show') + emit('show'); } function OpenEditDateToday() { // console.log('OpenEdit') - myvalue.value = new Date() - emit('show') + myvalue.value = new Date(); + emit('show'); } /*function getval() { @@ -648,129 +698,148 @@ export default defineComponent({ }*/ async function SaveValueInt(newVal: any, valinitial: any) { - - console.log('SaveValueInt', newVal, valinitial) + console.log('SaveValueInt', newVal, valinitial); if (col.value.fieldtype === costanti.FieldType.verifica) { - newVal.username = userStore.my.username - newVal.data = tools.getDateNow() + newVal.username = userStore.my.username; + newVal.data = tools.getDateNow(); } if (props.tablesel) { if (true) { - - const mystrcol = '_id' + const mystrcol = '_id'; const mycol = fieldsTable.getColByTable(props.tablesel, mystrcol); if (mycol) { - if (newVal) - newVal = newVal[mystrcol] + if (newVal) newVal = newVal[mystrcol]; } } } if (props.notAllowAtChar) { - newVal = tools.rimuoviAtPrimoCarattere(newVal) - myvalue.value = newVal + newVal = tools.rimuoviAtPrimoCarattere(newVal); + myvalue.value = newVal; } - console.log('newVal', newVal) + console.log('newVal', newVal); if (isFieldDb()) { - await savefield(newVal, valinitial, $q) + await savefield(newVal, valinitial, $q); } else { // Update value in table memory if (props.subfield !== '') { - if (myrow.value[props.field] === undefined) - myrow.value[props.field] = {} - myrow.value[props.field][props.subfield] = newVal + if (myrow.value[props.field] === undefined) myrow.value[props.field] = {}; + myrow.value[props.field][props.subfield] = newVal; } else { - if (props.field !== '') - myrow.value[props.field] = newVal + if (props.field !== '') myrow.value[props.field] = newVal; else { if (!props.isrec) { // @ts-ignore - myrealrow.value = newVal + myrealrow.value = newVal; } - } } } - console.log('SaveValueInt', newVal, valinitial) + console.log('SaveValueInt', newVal, valinitial); - emit('save', newVal, valinitial) + emit('save', newVal, valinitial); } - async function savefield(value: any, initialval: any, myq: any) { if (!props.insertMode) { - myvalue.value = value - return tools.saveInDBForTypes(myq, props.field, myvalue.value, props.type, props.serv, props.table, props.subfield, props.id, props.indrec, props.mysubsubkey, props.specialField) + myvalue.value = value; + return tools.saveInDBForTypes( + myq, + props.field, + myvalue.value, + props.type, + props.serv, + props.table, + props.subfield, + props.id, + props.indrec, + props.mysubsubkey, + props.specialField + ); } } - function annulla(val: any) { - emit('annulla', true) + emit('annulla', true); } function savefieldboolean(value: any) { - if (myvalue.value === undefined) - myvalue.value = 'true' - else - myvalue.value = value + if (myvalue.value === undefined) myvalue.value = 'true'; + else myvalue.value = value; - tools.saveInDBForTypes($q, props.field, myvalue, props.type, props.serv, props.table, props.subfield, props.id, props.indrec, props.mysubsubkey, props.specialField) + tools.saveInDBForTypes( + $q, + props.field, + myvalue, + props.type, + props.serv, + props.table, + props.subfield, + props.id, + props.indrec, + props.mysubsubkey, + props.specialField + ); } - function Savedb(newVal: any, valinitial: any) { // console.log('Savedb', newVal) if (col.value.fieldtype === costanti.FieldType.boolean) { // console.log('myvalue', myvalue, newVal, myvalueprec) if (myvalueprec.value === undefined) { - newVal = true - myvalueprec.value = myvalue.value - myvalue.value = newVal - + newVal = true; + myvalueprec.value = myvalue.value; + myvalue.value = newVal; } // console.log('DOPO myvalue', myvalue, newVal, myvalueprec) } - console.log('Savedb: type', col.value.fieldtype) + console.log('Savedb: type', col.value.fieldtype); - if (col.value.fieldtype === costanti.FieldType.image) { - console.log('newVal.imagefile', newVal) - if (newVal === ''){ - myvalue.value = '' + if (col.value.fieldtype === costanti.FieldType.imagerec) { + console.log('newVal.imagefile', newVal); + if (newVal === '') { + myvalue.value = ''; } else { - myvalue.value = newVal + myvalue.value = newVal; } // myvalue.value = tools.getImgFileToSaveByFilename(newVal) + } else if (col.value.fieldtype === costanti.FieldType.imgfile_sfuso) { + console.log('newVal.imagefile', newVal); + if (newVal === '') { + myvalue.value = ''; + } else { + myvalue.value = newVal.imagefile; + newVal = tools.getDirUpload() + mypath.value + myvalue.value + } } else if (col.value.fieldtype === costanti.FieldType.imgcard) { - console.log('newVal.imagefile', newVal) - myvalue.value = newVal + console.log('newVal.imagefile', newVal); + myvalue.value = newVal; } else if (col.value.fieldtype === costanti.FieldType.image_and_filename) { - newVal = tools.getDirUpload() + mypath.value + newVal - console.log('newVal.imagefile', newVal) - myvalue.value = newVal + newVal = tools.getDirUpload() + mypath.value + newVal; + console.log('newVal.imagefile', newVal); + myvalue.value = newVal; } if (col.value.fieldtype === costanti.FieldType.listobj) { - myvalue.value.accomodation = newVal + myvalue.value.accomodation = newVal; } - // console.log('Savedb', newVal) + console.log('Savedb', newVal) - emit('showandsave', props.row, props.mycol, newVal, valinitial) - visueditor.value = false + emit('showandsave', props.row, props.mycol, newVal, valinitial); + visueditor.value = false; } function visuValByType(val: any, col: IColGridTable, row: any) { - if (col === undefined || row === undefined) - return + if (col === undefined || row === undefined) return; // let val = '' // if (col.subfield !== '') { @@ -784,187 +853,192 @@ export default defineComponent({ // if (col.fieldtype === costanti.FieldType.date) { if (val === undefined) { - return '[]' + return '[]'; } else { - return tools.getstrDateTime(val) + return tools.getstrDateTime(val); } } else if (col.fieldtype === costanti.FieldType.onlydate) { if (val === undefined) { - return '[]' + return '[]'; } else { - return tools.getstrDate(val) + return tools.getstrDate(val); } } else if (col.fieldtype === costanti.FieldType.boolean) { - return (val) ? t('dialog.yes') : t('dialog.no') + return val ? t('dialog.yes') : t('dialog.no'); } else if (col.fieldtype === costanti.FieldType.binary) { - if (val === undefined) - return '[---]' - else - return globalStore.getArrStrByValueBinary(col, val) - } else if ((col.fieldtype === costanti.FieldType.select) || (col.fieldtype === costanti.FieldType.option)) { - if (val === undefined) - return '[---]' - else - return globalStore.getValueByTable(col, val) - } else if ((col.fieldtype === costanti.FieldType.nationality) || (col.fieldtype === costanti.FieldType.select_by_server) || (col.fieldtype === costanti.FieldType.multiselect_by_server)) { - if (!val) - return '[---]' - else - return val + if (val === undefined) return '[---]'; + else return globalStore.getArrStrByValueBinary(col, val); + } else if ( + col.fieldtype === costanti.FieldType.select || + col.fieldtype === costanti.FieldType.option + ) { + if (val === undefined) return '[---]'; + else return globalStore.getValueByTable(col, val); + } else if ( + col.fieldtype === costanti.FieldType.nationality || + col.fieldtype === costanti.FieldType.select_by_server || + col.fieldtype === costanti.FieldType.multiselect_by_server + ) { + if (!val) return '[---]'; + else return val; } else if (col.fieldtype === costanti.FieldType.intcode) { - if (!val) - return '[---]' - else - return val + if (!val) return '[---]'; + else return val; } else if (col.fieldtype === costanti.FieldType.multiselect) { - if (val === undefined) - return '[---]' - else - return globalStore.getMultiValueByTable(col, val) + if (val === undefined) return '[---]'; + else return globalStore.getMultiValueByTable(col, val); } else if (col.fieldtype === costanti.FieldType.multioption) { - if (val === undefined) - return '[---]' - else - return globalStore.getMultiValueByTable(col, val) + if (val === undefined) return '[---]'; + else return globalStore.getMultiValueByTable(col, val); } else if (col.fieldtype === costanti.FieldType.password) { - if (val === undefined) - return '[---]' - else - return '***************' + if (val === undefined) return '[---]'; + else return '***************'; } else { if (val === undefined || val === null) { if (props.canEdit) - return ' (' + t('reg.select') + ') ' - else - return '' + return ' (' + t('reg.select') + ') '; + else return ''; } else if (val === '') { if (props.canEdit) - return ' (' + t('reg.select') + ') ' - else - return '' + return ' (' + t('reg.select') + ') '; + else return ''; } else { - let mystr = '' - let mylink = '' + let mystr = ''; + let mylink = ''; - if (col.link) - mylink = col.link.replace(col.name, val) + if (col.link) mylink = col.link.replace(col.name, val); if (col.tipovisu === costanti.TipoVisu.LINK && col.link) { - return "" + val + '' + return "" + val + ''; } else if (col.tipovisu === costanti.TipoVisu.BUTTON && col.link) { - return '' + return ''; } - if (props.showall) { - return val + return val; } else { - mystr = tools.firstchars(val, tools.MAX_CHARACTERS) + mystr = tools.firstchars(val, tools.MAX_CHARACTERS); } if (val) { - if (val.length > tools.MAX_CHARACTERS) - mystr += '...' + if (val.length > tools.MAX_CHARACTERS) mystr += '...'; } else { - return val + return val; } - return mystr + return mystr; } } } function getclassCol(mycol: any) { if (mycol) { - let myclstr = (mycol.disable || isviewfield()) ? '' : (props.canEdit ? 'colmodif' : '') - myclstr += ((mycol.fieldtype === costanti.FieldType.date) || (mycol.fieldtype === costanti.FieldType.onlydate)) ? ' coldate flex flex-container' : '' + let myclstr = + mycol.disable || isviewfield() ? '' : props.canEdit ? 'colmodif' : ''; + myclstr += + mycol.fieldtype === costanti.FieldType.date || + mycol.fieldtype === costanti.FieldType.onlydate + ? ' coldate flex flex-container' + : ''; - return myclstr + return myclstr; } else { - return '' + return ''; } } function mycl() { if (props.disable) { - return 'cldisable' + return 'cldisable'; } } - function selectcountry({ name, iso2, dialCode }: { name: string, iso2: string, dialCode: string }) { + function selectcountry({ + name, + iso2, + dialCode, + }: { + name: string; + iso2: string; + dialCode: string; + }) { // console.log(name, iso2, dialCode) - myvalueprec.value = myvalue.value - myvalue.value = iso2 - countryname.value = name + myvalueprec.value = myvalue.value; + myvalue.value = iso2; + countryname.value = name; } function intcode_change(coderec: any) { - myvalueprec.value = myvalue.value - myvalue.value = '+' + coderec.dialCode + myvalueprec.value = myvalue.value; + myvalue.value = '+' + coderec.dialCode; } function onInput(phone: any, phoneObject: any, input: any) { if (phoneObject?.formatted) { - myvalue.value = phoneObject.formatted + myvalue.value = phoneObject.formatted; } } - function uploaded(info: any) { - if (info.files) { if (info.files[0].name.imagefile) { - myvalue.value = tools.geturlrelativeprofile() + '/' + getMyUsername() + '/' + info.files[0].name.imagefile + myvalue.value = + tools.geturlrelativeprofile() + + '/' + + getMyUsername() + + '/' + + info.files[0].name.imagefile; } else { - myvalue.value = tools.geturlrelativeprofile() + '/' + getMyUsername() + '/' + info.files[0].name + myvalue.value = + tools.geturlrelativeprofile() + + '/' + + getMyUsername() + + '/' + + info.files[0].name; } - console.log('uploaded', myvalue.value) - savefield(myvalue.value, '', $q) + console.log('uploaded', myvalue.value); + savefield(myvalue.value, '', $q); } // info.files[0].name } - function removephoto() { - myvalue.value = '' - SaveValueInt(myvalue.value, '') + myvalue.value = ''; + SaveValueInt(myvalue.value, ''); } function noPopupeditByCol(mycol: IColGridTable) { - return (mycol.fieldtype !== costanti.FieldType.html - && mycol.fieldtype !== costanti.FieldType.image - && mycol.fieldtype !== costanti.FieldType.imgcard - && mycol.fieldtype !== costanti.FieldType.listimages - && mycol.fieldtype !== costanti.FieldType.listobj - && mycol.fieldtype !== costanti.FieldType.number - ) + return ( + mycol.fieldtype !== costanti.FieldType.html && + mycol.fieldtype !== costanti.FieldType.imagerec && + mycol.fieldtype !== costanti.FieldType.imgfile_sfuso && + mycol.fieldtype !== costanti.FieldType.imgcard && + mycol.fieldtype !== costanti.FieldType.listimages && + mycol.fieldtype !== costanti.FieldType.listobj && + mycol.fieldtype !== costanti.FieldType.number + ); } function getTitleEditor(col: IColGridTable, row: any) { - - let title = '' + let title = ''; if (col.field_extra1) { try { - title = tools.getValue(row, col.field_extra1, col.subfield_extra1) - } catch (e) { - } + title = tools.getValue(row, col.field_extra1, col.subfield_extra1); + } catch (e) {} } - return title - + return title; } function gotoPage(link: string) { - $router.push(link) + $router.push(link); } function nameKeydown(e: any, col: any) { if (col.fieldtype === costanti.FieldType.username_telegram) { - if (!/^[a-z0-9_]*$/i.test(e.key)) { - e.preventDefault(); - } - + if (!/^[a-z0-9_]*$/i.test(e.key)) { + e.preventDefault(); + } } else { if (col.allowchar === costanti.ALLOWCHAR_CODE) { - if (/^\W$/.test(e.key)) { e.preventDefault(); } @@ -974,27 +1048,27 @@ export default defineComponent({ function handleCancel() { // Gestisci la chiusura del q-popup-edit - console.log("Chiusura di q-popup-edit"); + console.log('Chiusura di q-popup-edit'); } function handleKeydown(event) { // Interrompi la propagazione del tasto ESC - if (event.key === "Escape") { + if (event.key === 'Escape') { event.stopPropagation(); - console.log("Tasto ESC intercettato e bloccato"); + console.log('Tasto ESC intercettato e bloccato'); popupEditRef.value.hide(); } } function updateValidazione(esito: any) { - myvalue.value.esito = esito - myvalue.value.data = tools.getDateNow() - myvalue.value.username = userStore.my.username - changevalRec(myvalue.value) - Savedb(myvalue.value, '') + myvalue.value.esito = esito; + myvalue.value.data = tools.getDateNow(); + myvalue.value.username = userStore.my.username; + changevalRec(myvalue.value); + Savedb(myvalue.value, ''); } - onBeforeMount(mounted) + onBeforeMount(mounted); function handleShowAndSave(payload: any) { Savedb(payload); @@ -1057,7 +1131,6 @@ export default defineComponent({ colorPicker, myColor, hoverPreview, - } - } -}) - + }; + }, +}); diff --git a/src/components/CMyPopupEdit/CMyPopupEdit.vue b/src/components/CMyPopupEdit/CMyPopupEdit.vue index f09c4eb4..1e533232 100755 --- a/src/components/CMyPopupEdit/CMyPopupEdit.vue +++ b/src/components/CMyPopupEdit/CMyPopupEdit.vue @@ -564,7 +564,7 @@
@@ -727,6 +727,77 @@ ? [myvalue] : [{ imagefile: myvalue, vers_img: 1 }] " + :fieldtype="col.fieldtype" + :edit="isviewfield()" + :canModify="canModify" + :isInModif="isInModif" + :single="true" + @update:imgGall="changevalRec" + @showandsave="Savedb" + > + +
+
+
+ + +
+
+ + +
+ +
+
+
+
+ {{ t('reg.photo') }} + + +
+
+
+
+ {{ t('reg.photo') }} + -->
diff --git a/src/components/CProductCard/CProductCard.vue b/src/components/CProductCard/CProductCard.vue index 70402874..1953188e 100755 --- a/src/components/CProductCard/CProductCard.vue +++ b/src/components/CProductCard/CProductCard.vue @@ -456,7 +456,7 @@ mykey="imagefile" debounce="1000" @save="updateproductmodif" - :type="costanti.FieldType.image" + :type="costanti.FieldType.imagerec" >
@@ -472,7 +472,7 @@ @update:model-value="modifElem" :canEdit="true" :canModify="true" - :fieldtype="costanti.FieldType.image" + :fieldtype="costanti.FieldType.imagerec" > --> diff --git a/src/rootgen/admin/productInfos/productInfos.ts b/src/rootgen/admin/productInfos/productInfos.ts index 7bfb7529..cbedf40b 100755 --- a/src/rootgen/admin/productInfos/productInfos.ts +++ b/src/rootgen/admin/productInfos/productInfos.ts @@ -6,7 +6,7 @@ import { CMyPage } from '@src/components/CMyPage' import { CTitleBanner } from '@src/components/CTitleBanner' import { CGridTableRec } from '@src/components/CGridTableRec' -import { colTableProductInfos } from '@src/store/Modules/fieldsTable' +import { colTableProductInfosShort } from '@src/store/Modules/fieldsTable' import MixinMetaTags from '@src/mixins/mixin-metatags' export default defineComponent({ @@ -17,7 +17,7 @@ export default defineComponent({ const { setmeta } = MixinMetaTags() return { - colTableProductInfos, + colTableProductInfosShort, setmeta, } } diff --git a/src/rootgen/admin/productInfos/productInfos.vue b/src/rootgen/admin/productInfos/productInfos.vue index 2eab6493..7c342f56 100755 --- a/src/rootgen/admin/productInfos/productInfos.vue +++ b/src/rootgen/admin/productInfos/productInfos.vue @@ -13,7 +13,7 @@
diff --git a/src/rootgen/admin/productInfosComplete/productInfosComplete.scss b/src/rootgen/admin/productInfosComplete/productInfosComplete.scss new file mode 100755 index 00000000..e69de29b diff --git a/src/rootgen/admin/productInfosComplete/productInfosComplete.ts b/src/rootgen/admin/productInfosComplete/productInfosComplete.ts new file mode 100755 index 00000000..3caddb8b --- /dev/null +++ b/src/rootgen/admin/productInfosComplete/productInfosComplete.ts @@ -0,0 +1,24 @@ +import { defineComponent } from 'vue' + +import { CImgText } from '../../../components/CImgText/index' +import { CCard } from '@src/components/CCard' +import { CMyPage } from '@src/components/CMyPage' +import { CTitleBanner } from '@src/components/CTitleBanner' +import { CGridTableRec } from '@src/components/CGridTableRec' + +import { colTableProductInfos } from '@src/store/Modules/fieldsTable' +import MixinMetaTags from '@src/mixins/mixin-metatags' + +export default defineComponent({ + name: 'productInfosComplete', + components: { CImgText, CCard, CMyPage, CTitleBanner, CGridTableRec }, + setup() { + + const { setmeta } = MixinMetaTags() + + return { + colTableProductInfos, + setmeta, + } + } +}) diff --git a/src/rootgen/admin/productInfosComplete/productInfosComplete.vue b/src/rootgen/admin/productInfosComplete/productInfosComplete.vue new file mode 100755 index 00000000..38638495 --- /dev/null +++ b/src/rootgen/admin/productInfosComplete/productInfosComplete.vue @@ -0,0 +1,28 @@ + + + diff --git a/src/rootgen/admin/products/products.ts b/src/rootgen/admin/products/products.ts index cb4317e7..3c50430a 100755 --- a/src/rootgen/admin/products/products.ts +++ b/src/rootgen/admin/products/products.ts @@ -7,6 +7,7 @@ import { CTitleBanner } from '@src/components/CTitleBanner' import { CGridTableRec } from '@src/components/CGridTableRec' import { colTableProducts } from '@src/store/Modules/fieldsTable' +import { colTableProdShort } from '@src/store/Modules/fieldsTable' import MixinMetaTags from '@src/mixins/mixin-metatags' export default defineComponent({ @@ -17,7 +18,7 @@ export default defineComponent({ const { setmeta } = MixinMetaTags() return { - colTableProducts, + colTableProdShort, setmeta, } } diff --git a/src/rootgen/admin/products/products.vue b/src/rootgen/admin/products/products.vue index 90a9d5a2..04155b45 100755 --- a/src/rootgen/admin/products/products.vue +++ b/src/rootgen/admin/products/products.vue @@ -7,7 +7,7 @@ diff --git a/src/router/routesECommerce.ts b/src/router/routesECommerce.ts index 8f7f46b9..7f480507 100644 --- a/src/router/routesECommerce.ts +++ b/src/router/routesECommerce.ts @@ -101,10 +101,10 @@ function getRoutesEcomm(site: ISites) { { active: true, order: 30, - path: '/admin/ecommerce/gestoreordini', + path: '/admin/ecommerce/products', materialIcon: 'fas fa-lemon', - name: 'mypages.gestoreordini', - component: () => import('@src/views/admin/gestoreordini/gestoreordini.vue'), + name: 'mypages.listinoprodotti', + component: () => import('@src/rootgen/admin/products/products.vue'), inmenu: true, submenu: true, level_parent: 0, @@ -115,10 +115,10 @@ function getRoutesEcomm(site: ISites) { { active: true, order: 30, - path: '/admin/ecommerce/products', + path: '/admin/ecommerce/gestoreordini', materialIcon: 'fas fa-lemon', - name: 'mypages.listinoprodotti', - component: () => import('@src/rootgen/admin/products/products.vue'), + name: 'mypages.gestoreordini', + component: () => import('@src/views/admin/gestoreordini/gestoreordini.vue'), inmenu: true, submenu: true, level_parent: 0, diff --git a/src/store/Api/Instance.ts b/src/store/Api/Instance.ts index 0777328f..b4ffe829 100755 --- a/src/store/Api/Instance.ts +++ b/src/store/Api/Instance.ts @@ -112,7 +112,7 @@ function getIterableStream(stream: NodeJS.ReadableStream): AsyncIterable { } // Funzione helper per inviare la richiesta HTTP -async function Request(type, path, payload, responsedata = {}, options = {}) { +async function Request(type: string, path: string, payload: any, responsedata = {}, options: any = {}) { const userStore = useUserStore(); const globalStore = useGlobalStore(); const baseURL = globalStore.getServerHost(); diff --git a/src/store/Api/index.ts b/src/store/Api/index.ts index 47e9a5fb..ff35b7e1 100755 --- a/src/store/Api/index.ts +++ b/src/store/Api/index.ts @@ -122,7 +122,7 @@ export const Api = { } }, - async checkTokenScaduto(status, evitaloop, url, method, mydata, setAuthToken = false) { + async checkTokenScaduto(status: number, evitaloop: boolean, url: string, method: string, mydata: any, setAuthToken: boolean = false) { const userStore = useUserStore(); if (status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED) { @@ -167,7 +167,7 @@ export const Api = { }, // Base per la chiamata con gestione degli errori e retry - async SendReqBase(url, method, mydata, setAuthToken = false, evitaloop = false, myformdata, responsedata, options) { + async SendReqBase(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false, myformdata: any, responsedata: any, options: any) { const mydataout = { ...mydata, keyappid: import.meta.env.VITE_PAO_APP_ID, @@ -199,7 +199,7 @@ export const Api = { } // Verifica sul token (funzione custom) - const ret = await this.checkTokenScaduto(res.status, evitaloop, url, method, mydata, setAuthToken); + const ret: any = await this.checkTokenScaduto(res.status, evitaloop, url, method, mydata, setAuthToken); if (ret) return ret; if (tools.isDebug()) console.log(' ----> ', res); @@ -214,7 +214,7 @@ export const Api = { } }, 1000); - const ret = await this.checkTokenScaduto(error.status, evitaloop, url, method, mydataout, setAuthToken); + const ret: any = await this.checkTokenScaduto(error.status, evitaloop, url, method, mydataout, setAuthToken); if (ret) return ret; console.error('Errore nella richiesta:', error); @@ -255,7 +255,7 @@ export const Api = { }, // Funzione che gestisce la chiamata con retry - async SendReq(url, method, mydata, setAuthToken = false, evitaloop = false, retryCount = 1, retryDelay = 5000, myformdata = null, responsedata = null, options = null) { + async SendReq(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false, retryCount = 1, retryDelay = 5000, myformdata = null, responsedata = null, options = null) { try { return await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop, myformdata, responsedata, options); } catch (error) { diff --git a/src/store/Modules/costanti.ts b/src/store/Modules/costanti.ts index 128320ad..8c45ad75 100755 --- a/src/store/Modules/costanti.ts +++ b/src/store/Modules/costanti.ts @@ -463,9 +463,10 @@ export const costanti = { password: 512, listimages: 1024, exact: 2048, - image: 3000, + imagerec: 3000, pdf: 3050, image_and_filename: 3100, + imgfile_sfuso: 3150, imgcard: 3500, coordinates: 3800, select_by_server: 4000, diff --git a/src/store/Modules/fieldsTable.ts b/src/store/Modules/fieldsTable.ts index 6d7faf67..2c7bd4dc 100755 --- a/src/store/Modules/fieldsTable.ts +++ b/src/store/Modules/fieldsTable.ts @@ -130,7 +130,7 @@ export const colTableRaccoltaCataloghi = [ AddCol({ name: 'foto_raccolta', label_trans: 'racccat.foto_raccolta', - fieldtype: costanti.FieldType.image, + fieldtype: costanti.FieldType.imagerec, jointable: '', showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit, isadvanced_field: false, @@ -186,7 +186,7 @@ export const colTableCatalogList = [ AddCol({ name: 'foto_collana', label_trans: 'cataloglist.foto_collana', - fieldtype: costanti.FieldType.image, + fieldtype: costanti.FieldType.imagerec, jointable: '', showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit, isadvanced_field: false, @@ -254,7 +254,7 @@ export const colTableCatalogList = [ AddCol({ name: 'img_bordata', label_trans: 'cataloglist.img_bordata', - fieldtype: costanti.FieldType.image, + fieldtype: costanti.FieldType.imagerec, jointable: '', showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit, isadvanced_field: false, @@ -262,7 +262,7 @@ export const colTableCatalogList = [ AddCol({ name: 'img_intro', label_trans: 'cataloglist.img_intro', - fieldtype: costanti.FieldType.image, + fieldtype: costanti.FieldType.imagerec, jointable: '', showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit, isadvanced_field: false, @@ -282,7 +282,7 @@ export const colTableCatalogList = [ AddCol({ name: 'img_bordata_stampa', label_trans: 'cataloglist.img_bordata_stampa', - fieldtype: costanti.FieldType.image, + fieldtype: costanti.FieldType.imagerec, jointable: '', showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit, isadvanced_field: false, @@ -290,7 +290,7 @@ export const colTableCatalogList = [ AddCol({ name: 'img_intro_stampa', label_trans: 'cataloglist.img_intro_stampa', - fieldtype: costanti.FieldType.image, + fieldtype: costanti.FieldType.imagerec, jointable: '', showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit, isadvanced_field: false, @@ -371,7 +371,7 @@ export const colIText = [ AddCol({ name: 'line_height', label_trans: 'catalogo.line_height', fieldtype: costanti.FieldType.number }), ] export const colmyIImg = [ - AddCol({ name: 'imagefile', label_trans: 'iimg.imagefile', fieldtype: costanti.FieldType.image }), + AddCol({ name: 'imagefile', label_trans: 'iimg.imagefile', fieldtype: costanti.FieldType.imagerec }), AddCol({ name: 'fit', label_trans: 'iimg.fit', fieldtype: costanti.FieldType.string }), ] @@ -504,7 +504,7 @@ export const colmyelems = [ AddCol({ name: 'image', label_trans: 'myelems.image', - fieldtype: costanti.FieldType.image, + fieldtype: costanti.FieldType.imagerec, }), AddCol(DeleteRec), AddCol(DuplicateRec), @@ -1737,7 +1737,7 @@ export const colAttivita = [ AddCol({ name: 'logo', label_trans: 'attivita.logo', - fieldtype: costanti.FieldType.image, + fieldtype: costanti.FieldType.imagerec, jointable: '', showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit, isadvanced_field: false, @@ -2699,6 +2699,21 @@ export const colTableVariazioni = [ AddCol({ name: 'eta', label_trans: 'catalogo.eta', fieldtype: costanti.FieldType.string }), ] +export const colTableProductInfosShort = [ + AddCol({ name: 'code', label_trans: 'products.code', required: true }), + AddCol({ name: 'name', label_trans: 'products.name' }), + AddCol({ name: 'description', label_trans: 'products.description', fieldtype: costanti.FieldType.html }), + AddCol({ name: 'imagefile', label_trans: 'products.img', fieldtype: costanti.FieldType.imgfile_sfuso, path: 'products/' }), + AddCol({ + name: 'idCatProds', + label_trans: 'products.category', + fieldtype: costanti.FieldType.multiselect, + jointable: 'catprods', + }), + AddCol(DeleteRec), + AddCol(DuplicateRec), +] + export const colTableProductInfos = [ AddCol({ name: 'code', label_trans: 'products.code', required: true }), AddCol({ name: 'codice_EAN', label_trans: 'products.codice_EAN' }), @@ -2768,6 +2783,20 @@ export const colTableOrdersCart = [ AddCol({ name: 'status', label_trans: 'orderscart.status', fieldtype: costanti.FieldType.number }), ] +export const colTableProdShort = [ + AddCol({ name: 'active', label_trans: 'products.active', fieldtype: costanti.FieldType.boolean }), + AddCol({ name: 'name', label_trans: 'products.name' }), + AddCol({ name: 'price', label_trans: 'products.price', fieldtype: costanti.FieldType.number, required: true }), + AddCol({ name: 'price_acquistato', label_trans: 'products.price_acquistato', fieldtype: costanti.FieldType.number, required: true }), + AddCol({ + name: 'idProductInfo', + label_trans: 'products.productInfo', + fieldtype: costanti.FieldType.select, + jointable: 'productinfos', + }), + +] + export const colTableProducts = [ AddCol({ name: 'active', label_trans: 'products.active', fieldtype: costanti.FieldType.boolean }), AddCol({ name: 'isbn', label_trans: 'products.isbn' }), diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index a507663f..d862d2e6 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -8937,7 +8937,7 @@ export const tools = { } }, - getDirectoryGall(myrow: any, table: string, path: string) { + getDirectoryGall(myrow: any, table: string, path: string, fieldtype: number = 0) { const userStore = useUserStore(); // console.log('getDirectoryGall', myrow) @@ -10178,7 +10178,7 @@ export const tools = { let eseguito = false; // if (table === 'myelems') { - if (type === costanti.FieldType.image && newval.imagefile) { + if (type === costanti.FieldType.imagerec && newval.imagefile) { let myval = newval.imagefile; await setValDb( $q, diff --git a/src/views/user/editprofile/editprofile.vue b/src/views/user/editprofile/editprofile.vue index 7b1be41c..d04a1271 100755 --- a/src/views/user/editprofile/editprofile.vue +++ b/src/views/user/editprofile/editprofile.vue @@ -99,7 +99,7 @@ table="users" mykey="profile" mysubkey="img" - :type="costanti.FieldType.image" + :type="costanti.FieldType.imagerec" >
diff --git a/src/views/user/profile/profile.vue b/src/views/user/profile/profile.vue index aed5c358..f8dfd59b 100755 --- a/src/views/user/profile/profile.vue +++ b/src/views/user/profile/profile.vue @@ -26,7 +26,7 @@ table="users" mykey="profile" mysubkey="img" - :type="costanti.FieldType.image"> + :type="costanti.FieldType.imagerec">