From f04d66d713b9491bff380022c8471dc2f097f15a Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:23:17 -0400 Subject: [PATCH] Fix: Field Image (#2535) * Fix: Field Image * Minimal changes --- .../ADempiere/FieldDefinition/FieldImage.vue | 9 ++-- .../Component/AttachmentManager/FileShare.vue | 6 ++- .../Component/AttachmentManager/attachment.js | 48 +++++++++---------- .../AttachmentManager/modeDesktop.vue | 1 + 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/components/ADempiere/FieldDefinition/FieldImage.vue b/src/components/ADempiere/FieldDefinition/FieldImage.vue index 2ff60ef5a9..661c0d3661 100644 --- a/src/components/ADempiere/FieldDefinition/FieldImage.vue +++ b/src/components/ADempiere/FieldDefinition/FieldImage.vue @@ -75,6 +75,7 @@ :resource-name="displayedValue" :file="fileResource" :file-name="displayedValue" + :file-url="infoImage.name" class="popover-info" /> @@ -530,13 +531,11 @@ export default { tableName: table_name }) .then(response => { - let resource let image = '' - const resources = this.sortResource(response.resources) + const resources = response.resources.find(resource => resource.name.includes(this.columnNameImage)) if (!this.isEmptyValue(resources)) { - resource = resources[resources.length - 1] - image = resource.name - this.infoImage = resource + image = resources.name + this.infoImage = resources } resolve(image) }) diff --git a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/FileShare.vue b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/FileShare.vue index d69a108e5d..a98211ba77 100644 --- a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/FileShare.vue +++ b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/FileShare.vue @@ -128,6 +128,10 @@ export default defineComponent({ fileName: { type: String, default: undefined + }, + fileUrl: { + type: String, + default: undefined } }, @@ -137,7 +141,7 @@ export default defineComponent({ const isShowed = ref(false) const validTime = ref(3600) function loadData() { - linkShare.value = config.adempiere.resource.url + props.file.fullName + linkShare.value = config.adempiere.resource.url + props.fileUrl } function copyValue() { diff --git a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/attachment.js b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/attachment.js index 54f5d8e7ad..bc2e4cbf8e 100644 --- a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/attachment.js +++ b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/attachment.js @@ -28,8 +28,7 @@ import { } from '@/api/ADempiere/user-interface/component/resource' import { requestDeleteResourceReference, - requestDeleteResources, - requestShareResources + requestDeleteResources } from '@/api/ADempiere/file-management/resource-reference.ts' // Components and Mixins @@ -208,17 +207,16 @@ export default defineComponent({ * @param {Boolean} isDownload */ const handleDownload = async(file, isDownload = true) => { + const imageURL = config.adempiere.resource.url + file.fullName if (!isEmptyValue(file.content_type) && file.content_type.includes('image')) { - const link = document.createElement('a') - link.target = '_blank' - link.href = urlDownload({ fileName: file.name }) - link.download = this.displayedValue - link.style.display = 'none' - link.click() + const linkImage = document.createElement('a') + linkImage.href = config.adempiere.resource.url + file.fullName + linkImage.download = `${file.fullName}` + linkImage.target = '_blank' + linkImage.click() return } const link = document.createElement('a') - const imageURL = config.adempiere.resource.url + file.fullName link.href = imageURL link.download = file.fullName link.click() @@ -230,22 +228,22 @@ export default defineComponent({ return } - function urlDownload({ - fileName - }) { - return new Promise((resolve, reject) => { - requestShareResources({ - fileName, - seconds: 3600 - }) - .then(response => { - resolve(response) - }) - .catch(() => { - reject('') - }) - }) - } + // function urlDownload({ + // fileName + // }) { + // return new Promise((resolve, reject) => { + // requestShareResources({ + // fileName, + // seconds: 3600 + // }) + // .then(response => { + // resolve(response) + // }) + // .catch(() => { + // reject('') + // }) + // }) + // } /** * Get Surce File diff --git a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/modeDesktop.vue b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/modeDesktop.vue index 06c44e504b..7eb1e74a63 100644 --- a/src/components/ADempiere/PanelInfo/Component/AttachmentManager/modeDesktop.vue +++ b/src/components/ADempiere/PanelInfo/Component/AttachmentManager/modeDesktop.vue @@ -180,6 +180,7 @@ :resource-name="file.file_name" :file="file" :file-name="file.name" + :file-url="file.fullName" class="class-group-botton-option" />