mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Fix FileItem value 'current' prop
This commit is contained in:
parent
76c6a0eb70
commit
97bd1564c4
2 changed files with 6 additions and 12 deletions
|
@ -9,7 +9,7 @@
|
||||||
</b-button>
|
</b-button>
|
||||||
|
|
||||||
<b-form-file
|
<b-form-file
|
||||||
v-model="file"
|
:value="value.file"
|
||||||
ref="input-file"
|
ref="input-file"
|
||||||
:id="id"
|
:id="id"
|
||||||
:required="required"
|
:required="required"
|
||||||
|
@ -33,7 +33,7 @@ export default {
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
id: { type: String, default: null },
|
id: { type: String, default: null },
|
||||||
value: { type: Object, default: () => ({}) },
|
value: { type: Object, default: () => ({ file: null }) },
|
||||||
placeholder: { type: String, default: 'Choose a file or drop it here...' },
|
placeholder: { type: String, default: 'Choose a file or drop it here...' },
|
||||||
dropPlaceholder: { type: String, default: null },
|
dropPlaceholder: { type: String, default: null },
|
||||||
accept: { type: String, default: null },
|
accept: { type: String, default: null },
|
||||||
|
@ -42,12 +42,6 @@ export default {
|
||||||
name: { type: String, default: null }
|
name: { type: String, default: null }
|
||||||
},
|
},
|
||||||
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
file: this.value.file
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
_placeholder: function () {
|
_placeholder: function () {
|
||||||
return this.value.file === null ? this.placeholder : this.value.file.name
|
return this.value.file === null ? this.placeholder : this.value.file.name
|
||||||
|
@ -59,7 +53,7 @@ export default {
|
||||||
const value = {
|
const value = {
|
||||||
file,
|
file,
|
||||||
content: '',
|
content: '',
|
||||||
currentfile: false,
|
current: false,
|
||||||
removed: false
|
removed: false
|
||||||
}
|
}
|
||||||
// Update the value with the new File and an empty content for now
|
// Update the value with the new File and an empty content for now
|
||||||
|
@ -76,7 +70,7 @@ export default {
|
||||||
this.$emit('input', {
|
this.$emit('input', {
|
||||||
file: null,
|
file: null,
|
||||||
content: '',
|
content: '',
|
||||||
current_file: false,
|
current: false,
|
||||||
removed: true
|
removed: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ export function formatYunoHostArgument (arg) {
|
||||||
// in case of already defined file, we receive only the file path (not the actual file)
|
// in case of already defined file, we receive only the file path (not the actual file)
|
||||||
file: value ? new File([''], value) : null,
|
file: value ? new File([''], value) : null,
|
||||||
content: '',
|
content: '',
|
||||||
current_file: !!value,
|
current: !!value,
|
||||||
removed: false
|
removed: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,7 +399,7 @@ export function formatFormDataValue (value, key = null) {
|
||||||
// File has to be deleted
|
// File has to be deleted
|
||||||
if (value.removed) result = ''
|
if (value.removed) result = ''
|
||||||
// File has not changed (will not be sent)
|
// File has not changed (will not be sent)
|
||||||
else if (value.current_file || value.file === null) result = null
|
else if (value.current || value.file === null) result = null
|
||||||
else {
|
else {
|
||||||
return getFileContent(value.file, { base64: true }).then(content => {
|
return getFileContent(value.file, { base64: true }).then(content => {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Reference in a new issue