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

Commit

Permalink
Bugfix/fix field image delete (#2534)
Browse files Browse the repository at this point in the history
* Error in Deleting the Field Image

* Minimal changes

* minimal changes
  • Loading branch information
elsiosanchez authored Jul 30, 2024
1 parent 255d6b1 commit 33acc27
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 56 deletions.
52 changes: 31 additions & 21 deletions src/components/ADempiere/FieldDefinition/FieldImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<file-info
:image-id="value"
:resource-name="displayedValue"
:info-image="infoImage"
class="popover-info"
/>

Expand All @@ -92,7 +93,7 @@
icon="el-icon-delete"
class="button-manage-file"
plain
:disabled="isDisabled"
:disabled="isEmptyValue(infoImage)"
@click="handleRemove()"
/>

Expand Down Expand Up @@ -124,7 +125,7 @@
<el-button
class="button-manage-file-svg"
plain
:disabled="!isDownload"
:disabled="isEmptyValue(infoImage)"
@click="handleDownload()"
>
<svg-icon
Expand Down Expand Up @@ -186,6 +187,7 @@ import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
import { getToken } from '@/utils/auth'
import { pathImageWindows } from '@/utils/ADempiere/resource'
import { showMessage } from '@/utils/ADempiere/notification'
import { refreshRecord } from '@/utils/ADempiere/dictionary/window'

export default {
name: 'FieldImage',
Expand Down Expand Up @@ -303,6 +305,7 @@ export default {
},

mounted() {
this.getListResources()
this.valideImage()
},
updated() {
Expand Down Expand Up @@ -433,6 +436,7 @@ export default {
method: 'PUT',
body: file
}).then(() => {
this.getListResources()
setTimeout(() => {
this.imageSourceSmall = this.pathImage
this.valideImage(file)
Expand All @@ -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
},

Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@

<el-descriptions v-else class="margin-top" :column="1" border>
<el-descriptions-item :label="$t('component.attachment.fileName')">
{{ resourceReference.name }}
{{ infoImage.name }}
</el-descriptions-item>
<el-descriptions-item :label="$t('component.attachment.fileSize')">
{{ formatFileSize(resourceReference.file_size) }}
{{ formatFileSize(infoImage.size) }}
</el-descriptions-item>
<el-descriptions-item :label="$t('component.attachment.fileFormat')">
{{ resourceReference.content_type }}
{{ infoImage.content_type }}
</el-descriptions-item>

<el-descriptions-item :label="$t('component.attachment.description')">
<!-- <el-descriptions-item :label="$t('component.attachment.description')">
{{ resourceReference.description }}
</el-descriptions-item>
<el-descriptions-item :label="$t('component.attachment.message')">
</el-descriptions-item> -->
<!-- <el-descriptions-item :label="$t('component.attachment.message')">
{{ resourceReference.text_message }}
</el-descriptions-item>
</el-descriptions-item> -->
</el-descriptions>

<el-button
Expand Down Expand Up @@ -102,6 +102,10 @@ export default defineComponent({
isEditDescription: {
type: Boolean,
default: false
},
infoImage: {
type: Object,
default: undefined
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,11 @@
{{ file.name }}
</el-descriptions-item>
<el-descriptions-item :label="$t('component.attachment.fileSize')">
{{ formatFileSize(file.file_size) }}
{{ formatFileSize(file.size) }}
</el-descriptions-item>
<el-descriptions-item :label="$t('component.attachment.fileFormat')">
{{ file.content_type }}
</el-descriptions-item>
<el-descriptions-item :label="$t('component.attachment.description')">
{{ file.description }}
</el-descriptions-item>
<el-descriptions-item :label="$t('component.attachment.message')">
{{ file.text_message }}
</el-descriptions-item>
</el-descriptions>
<el-button
slot="reference"
Expand Down
11 changes: 8 additions & 3 deletions src/components/ADempiere/TabManager/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ export default defineComponent({
return store.getters.getShowLogs
})

const clientUuid = computed(() => {
const { client } = store.getters['user/getRole']
return client.uuid
})

const isShowedTabs = computed(() => {
const storedWindow = store.getters.getStoredWindow(props.parentUuid)
return storedWindow.isShowedTabsParent
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -929,6 +933,7 @@ export default defineComponent({
tableHeaders,
recordsList,
drawer,
clientUuid,
currentRecordLogs,
openPanelInfo,
showChatAvailable,
Expand Down

0 comments on commit 33acc27

Please sign in to comment.