2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00

Add directory option to File control

This commit is contained in:
Faris Ansari 2018-07-14 17:09:42 +05:30
parent 46e3fa9193
commit c8fb834e51
3 changed files with 22 additions and 9 deletions

View File

@ -57,6 +57,7 @@ export default {
},
filter() {
// return a function that filters list suggestions based on input
return Awesomplete.FILTER_CONTAINS
}
}
};

View File

@ -8,7 +8,7 @@ export default {
},
props: {
docfield: Object,
value: [String, Number, Array],
value: [String, Number, Array, FileList],
onlyInput: {
type: Boolean,
default: false
@ -93,6 +93,9 @@ export default {
const isValid = await this.validate(value);
this.$refs.input.setCustomValidity(isValid === false ? 'error' : '');
this.$emit('change', value);
},
getValueFromInput(e) {
},
validate() {
return true;

View File

@ -10,7 +10,7 @@ export default {
},
methods: {
getWrapperElement(h) {
let fileName = 'Choose a file..';
let fileName = this._('Choose a file..');
if (this.$refs.input && this.$refs.input.files.length) {
fileName = this.$refs.input.files[0].name;
@ -27,11 +27,11 @@ export default {
});
return h('div', {
class: ['form-group', ...this.wrapperClass],
attrs: {
class: ['form-group', ...this.wrapperClass],
attrs: {
'data-fieldname': this.docfield.fieldname
}
}, [this.getLabelElement(h), this.getInputElement(h), fileButton]);
}
}, [this.getLabelElement(h), this.getInputElement(h), fileButton]);
},
getInputAttrs() {
return {
@ -39,9 +39,18 @@ export default {
type: 'file',
value: this.value,
required: this.docfield.required,
disabled: this.disabled
}
disabled: this.disabled,
webkitdirectory: this.docfield.directory,
directory: this.docfield.directory
};
},
getInputListeners() {
return {
change: e => {
this.handleChange(e.target.files);
}
};
}
}
}
};
</script>