From 33acc27a9ee4d7581cd31d2f032c3021cfd0ddcc Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:33:56 -0400 Subject: [PATCH] Bugfix/fix field image delete (#2534) * Error in Deleting the Field Image * Minimal changes * minimal changes --- .../ADempiere/FieldDefinition/FieldImage.vue | 52 +++++++++++-------- .../Component/AttachmentManager/FileShare.vue | 18 +------ .../Component/AttachmentManager/attachment.js | 9 +++- .../Component/AttachmentManager/fileInfo.vue | 18 ++++--- .../AttachmentManager/modeDesktop.vue | 8 +-- src/components/ADempiere/TabManager/index.vue | 11 ++-- 6 files changed, 60 insertions(+), 56 deletions(-) diff --git a/src/components/ADempiere/FieldDefinition/FieldImage.vue b/src/components/ADempiere/FieldDefinition/FieldImage.vue index 6f8ff33873..2ff60ef5a9 100644 --- a/src/components/ADempiere/FieldDefinition/FieldImage.vue +++ b/src/components/ADempiere/FieldDefinition/FieldImage.vue @@ -66,6 +66,7 @@ @@ -92,7 +93,7 @@ icon="el-icon-delete" class="button-manage-file" plain - :disabled="isDisabled" + :disabled="isEmptyValue(infoImage)" @click="handleRemove()" /> @@ -124,7 +125,7 @@ { + this.getListResources() setTimeout(() => { this.imageSourceSmall = this.pathImage this.valideImage(file) @@ -457,14 +461,14 @@ export default { * Handle Download image */ async handleDownload() { - const link = document.createElement('a') - link.target = '_blank' - link.href = this.imageSourceSmall + '?f=' + Date.now() - link.download = this.displayedValue - link.style.display = 'none' - link.click() - document.body.appendChild(link) - document.body.removeChild(link) + const { + name + } = this.infoImage + const file = document.createElement('a') + file.href = `${config.adempiere.resource.url}${name}` + file.download = `${name}` + file.target = '_blank' + file.click() return }, @@ -489,27 +493,33 @@ export default { * Handle Removeya esta actualizado solop */ handleRemove() { - // if (this.isDisabled) { - // return - // } - const resourceName = this.nameImage - const { table_name } = this.currentTab - const pathImage = `${this.clientUuid}/client/attachment/${table_name}/${this.recordId}/${this.metadata.columnName}/${resourceName}` - if (isEmptyValue(pathImage)) { + const { name } = this.infoImage + if (isEmptyValue(name)) { + this.getListResources() return } + + const { + id, + parentUuid, + containerUuid + } = this.currentTab + requestDeleteResources({ - fileName: pathImage + fileName: name }) .then(() => { - this.clearValues() + refreshRecord.refreshRecord({ + parentUuid, + containerUuid, + tabId: id, + recordId: this.recordId + }) }) }, getListResources() { return new Promise((resolve, reject) => { - // const clientId = this.$store.getters.getSessionContextClientId - // const { action_id } = this.$route.meta const { table_name } = this.currentTab requestListResources({ clientId: this.clientUuid, diff --git a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/FileShare.vue b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/FileShare.vue index c60d4d6d15..d69a108e5d 100644 --- a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/FileShare.vue +++ b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/FileShare.vue @@ -77,17 +77,13 @@ import { ref } from '@vue/composition-api' -// API Request Methods -import { - requestShareResources -} from '@/api/ADempiere/file-management/resource-reference.ts' - // Utils and Helper Methods import { isEmptyValue } from '@/utils/ADempiere/valueUtils' import { copyToClipboard } from '@/utils/ADempiere/coreUtils.js' // import { formatFileSize } from '@/utils/ADempiere/resource.js' +import { config } from '@/utils/ADempiere/config' export default defineComponent({ name: 'FileShare', @@ -141,17 +137,7 @@ export default defineComponent({ const isShowed = ref(false) const validTime = ref(3600) function loadData() { - isLoading.value = true - requestShareResources({ - fileName: props.resourceName, - seconds: validTime.value - }) - .then(response => { - linkShare.value = response - }) - .finally(() => { - isLoading.value = false - }) + linkShare.value = config.adempiere.resource.url + props.file.fullName } function copyValue() { diff --git a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/attachment.js b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/attachment.js index 05c15f70da..54f5d8e7ad 100644 --- a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/attachment.js +++ b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/attachment.js @@ -218,10 +218,15 @@ export default defineComponent({ return } const link = document.createElement('a') - const imageURL = config.adempiere.resource.url + file.file_name + const imageURL = config.adempiere.resource.url + file.fullName link.href = imageURL - link.download = file.name + link.download = file.fullName link.click() + // const file = document.createElement('a') + // file.href = `${config.adempiere.resource.url}${file.fullName}` + // file.download = `${file.name}` + // file.target = '_blank' + // file.click() return } diff --git a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/fileInfo.vue b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/fileInfo.vue index ba52e51646..797defa871 100644 --- a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/fileInfo.vue +++ b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/fileInfo.vue @@ -26,21 +26,21 @@ - {{ resourceReference.name }} + {{ infoImage.name }} - {{ formatFileSize(resourceReference.file_size) }} + {{ formatFileSize(infoImage.size) }} - {{ resourceReference.content_type }} + {{ infoImage.content_type }} - + + - {{ formatFileSize(file.file_size) }} + {{ formatFileSize(file.size) }} {{ file.content_type }} - - {{ file.description }} - - - {{ file.text_message }} - { + const { client } = store.getters['user/getRole'] + return client.uuid + }) + const isShowedTabs = computed(() => { const storedWindow = store.getters.getStoredWindow(props.parentUuid) return storedWindow.isShowedTabsParent @@ -815,9 +820,8 @@ export default defineComponent({ requestListResources({ recordId: currentRecordId.value, tableName: currentTabTableName.value, - containerId: router.app._route.meta.action_id, - clientId: store.getters.getSessionContextClientId, - containerType: 'window' + clientId: clientUuid.value, + containerType: 'attachment' }) .then(response => { countAttachment.value = response.resources.length @@ -929,6 +933,7 @@ export default defineComponent({ tableHeaders, recordsList, drawer, + clientUuid, currentRecordLogs, openPanelInfo, showChatAvailable,