Commit 267111d6 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Fix: Validation does not break RCV (coscine/issues#1129)

parent f683e6c0
......@@ -108,11 +108,36 @@ export default Vue.extend({
errorMessages: {} as any,
timeouts: {} as any,
timeoutInterval: 500,
validations: {} as any,
};
},
validations() : any {
const me = this;
if (!this.fixedValueMode) {
return {
formData: this.validations,
};
}
return {
formData: {},
};
},
beforeMount() {
i18n.locale = this.languageLocale;
this.handleApplicationProfiles();
},
watch: {
SHACLDefinition() {
this.handleApplicationProfiles();
},
formData() {
this.$v.$reset();
this.createValidations();
},
},
methods: {
createValidations() {
const me = this;
const validator = {} as any;
for (const nodename of Object.keys(this.formData)) {
validator[nodename] = {
......@@ -139,27 +164,8 @@ export default Vue.extend({
},
};
}
return {
formData: validator,
};
}
return {
formData: {},
};
},
beforeMount() {
i18n.locale = this.languageLocale;
this.handleApplicationProfiles();
},
watch: {
SHACLDefinition() {
this.handleApplicationProfiles();
},
formData() {
this.$v.$reset();
this.validations = validator;
},
},
methods: {
async validatorFunction() {
const shapes = await this.loadDataset(this.SHACLDefinition, this.mimeType, this.applicationProfileId);
// RDF/JSON => JSON-LD since the loadDataset function doesn't support RDF/JSON
......@@ -282,8 +288,15 @@ export default Vue.extend({
for (let i = 0; i < keys.length; i++) {
this.fixedValueIds.push(unmappedSubjects[keys[i]][0].subject.value);
this.sortedSHACLDefinition.push(unmappedSubjects[keys[i]]);
const nodeName = FieldReader.getNodeName(unmappedSubjects[keys[i]]);
// if formData is empty intialize it with an empty value
if (!FieldReader.isDataValueAssignedToKey(this.formData, nodeName, 'value')) {
this.$set(this.formData, nodeName, [{ value: '' }]);
}
}
this.createValidations();
await this.validatorFunction();
},
},
......
......@@ -239,10 +239,6 @@ export default Vue.extend({
]);
}
}
// if formdata is still empty intialize it with an empty value
if (!this.formDataExists()) {
this.$set(this.formData, this.nodeName, [{ value: '' }]);
}
this.valueRequired =
this.checkField(
......
......@@ -33,7 +33,8 @@ export default {
property === null ||
data[nodename] === undefined ||
data[nodename][0] === undefined ||
data[nodename][0][property] === undefined
data[nodename][0][property] === undefined ||
data[nodename][0][property] === ''
) {
return false;
}
......
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