Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Fix: Field Image (#2535)
Browse files Browse the repository at this point in the history
* Fix: Field Image

* Minimal changes
  • Loading branch information
elsiosanchez authored Jul 30, 2024
1 parent 33acc27 commit f04d66d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
9 changes: 4 additions & 5 deletions src/components/ADempiere/FieldDefinition/FieldImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
:resource-name="displayedValue"
:file="fileResource"
:file-name="displayedValue"
:file-url="infoImage.name"
class="popover-info"
/>

Expand Down Expand Up @@ -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)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export default defineComponent({
fileName: {
type: String,
default: undefined
},
fileUrl: {
type: String,
default: undefined
}
},

Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
:resource-name="file.file_name"
:file="file"
:file-name="file.name"
:file-url="file.fullName"
class="class-group-botton-option"
/>
<el-button
Expand Down

0 comments on commit f04d66d

Please sign in to comment.