Commit 2ca68a83 authored by BojanSovticEngIT's avatar BojanSovticEngIT
Browse files

Bugfix KNOWAGE-6958

parent c6f74a0b
...@@ -44,5 +44,5 @@ export interface iMetadata { ...@@ -44,5 +44,5 @@ export interface iMetadata {
generalMetadata: { name: string, value: string }[], generalMetadata: { name: string, value: string }[],
shortText: { id: number, name: string, value: string }[], shortText: { id: number, name: string, value: string }[],
longText: { id: number, name: string, value: string }[], longText: { id: number, name: string, value: string }[],
file: { id: number, name: string, value: string }[] file: { id: number, name: string, value: string, fileToSave?: { file: {}, fileName: string } }[],
} }
\ No newline at end of file
...@@ -812,10 +812,10 @@ export default defineComponent({ ...@@ -812,10 +812,10 @@ export default defineComponent({
async onMetadataSave(metadata: any) { async onMetadataSave(metadata: any) {
this.loading = true this.loading = true
const jsonMeta = [] as any[] const jsonMeta = [] as any[]
const properties = ['shortText', 'longText'] const properties = ['shortText', 'longText', 'file']
properties.forEach((property: string) => properties.forEach((property: string) =>
metadata[property].forEach((el: any) => { metadata[property].forEach((el: any) => {
if (el.value) { if (el.value || (property === 'file' && el.fileToSave)) {
jsonMeta.push(el) jsonMeta.push(el)
} }
}) })
......
...@@ -153,6 +153,7 @@ export default defineComponent({ ...@@ -153,6 +153,7 @@ export default defineComponent({
title: this.$t('common.uploadFile'), title: this.$t('common.uploadFile'),
msg: this.$t('common.uploadFileSuccess') msg: this.$t('common.uploadFileSuccess')
}) })
this.updateMetadataFile(meta.id, this.uploadedFiles[meta.id].name)
}) })
.catch((error: any) => .catch((error: any) =>
this.$store.commit('setError', { this.$store.commit('setError', {
...@@ -163,10 +164,17 @@ export default defineComponent({ ...@@ -163,10 +164,17 @@ export default defineComponent({
this.loading = false this.loading = false
} }
}, },
updateMetadataFile(fileId: number, fileName: string) {
if (!this.metadata) return
const index = this.metadata?.file.findIndex((tempFile: any) => tempFile.id === fileId)
if (index !== -1) this.metadata.file[index].fileToSave = { file: {}, fileName: fileName }
},
cleanFile(meta: any) { cleanFile(meta: any) {
const temp = this.$refs[meta.id] as any const temp = this.$refs[meta.id] as any
if (temp) { if (temp && this.metadata) {
temp.resetInput() temp.resetInput()
const index = this.metadata.file.findIndex((tempFile: any) => tempFile.id === meta.id)
if (index !== -1) delete this.metadata.file[index].fileToSave
} }
}, },
closeDialog() { closeDialog() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment