Skip to content

Commit

Permalink
#443 fixed missing validation on server file field creation
Browse files Browse the repository at this point in the history
  • Loading branch information
bugy committed May 23, 2021
1 parent 31f5eec commit 80c55bc
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions web-src/src/common/components/server_file_field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export default {
M.Modal.init(this.$refs.modal, {onCloseEnd: this.dialogClosed});
this.isMounted = true;
this.validate(this.value)
},
beforeDestroy: function () {
Expand All @@ -104,21 +106,9 @@ export default {
methods: {
selectFile(path) {
this.error = this.getValidationError(path);
var inputField = this.$refs.inputField;
if (!isNull(inputField)) {
// setCustomValidity doesn't work since input is readonly
if (this.error) {
addClass(inputField, 'invalid');
} else {
removeClass(inputField, 'invalid');
}
}
this.closeDialog();
this.$emit('error', this.error);
this.validate(path)
if (!arraysEqual(this.value, path)) {
this.$emit('input', path);
Expand Down Expand Up @@ -154,6 +144,22 @@ export default {
this.$refs.fileDialog.setChosenFile(this.value);
this.dialogOpened = true;
this.$refs.fileDialog.focus();
},
validate(path) {
this.error = this.getValidationError(path);
const inputField = this.$refs.inputField;
if (!isNull(inputField)) {
// setCustomValidity doesn't work since input is readonly
if (this.error) {
addClass(inputField, 'invalid');
} else {
removeClass(inputField, 'invalid');
}
}
this.$emit('error', this.error);
}
}
}
Expand Down

0 comments on commit 80c55bc

Please sign in to comment.