Commit 796f73f3 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Fix: Set fixed values correctly (coscine/issues#1146)

parent 4adfc766
......@@ -299,6 +299,9 @@ export default Vue.extend({
checkDataField(data: any, nodename: string, property: string = 'value') {
return FieldReader.isDataValueAssignedToKey(data, nodename, property);
},
checkFixedField(data: any, nodename: string, property: string = 'value') {
return FieldReader.isFixedValueAssignedToKey(data, nodename, property);
},
checkField(data: any, nodename: string, property: string = 'value') {
return FieldReader.isValueAssignedToKey(data, nodename, property);
},
......@@ -321,8 +324,8 @@ export default Vue.extend({
return this.checkDataField(this.formData, this.nodeName);
},
removeEmptyEntry(){
if ((this.checkDataField(this.fixedValues[this.idForFixedValues],'https://purl.org/coscine/fixedValue') && this.fixedValues[this.idForFixedValues]['https://purl.org/coscine/fixedValue'][0]['value'] === '') ||
this.checkDataField(this.fixedValues[this.idForFixedValues],'https://purl.org/coscine/defaultValue') && this.fixedValues[this.idForFixedValues]['https://purl.org/coscine/defaultValue'][0]['value'] === '') {
if ((this.checkFixedField(this.fixedValues[this.idForFixedValues],'https://purl.org/coscine/fixedValue') && this.fixedValues[this.idForFixedValues]['https://purl.org/coscine/fixedValue'][0]['value'] === '') ||
this.checkFixedField(this.fixedValues[this.idForFixedValues],'https://purl.org/coscine/defaultValue') && this.fixedValues[this.idForFixedValues]['https://purl.org/coscine/defaultValue'][0]['value'] === '') {
this.$delete(this.fixedValues[this.idForFixedValues],'https://purl.org/coscine/defaultValue');
this.$delete(this.fixedValues[this.idForFixedValues],'https://purl.org/coscine/fixedValue');
this.locked = false;
......
......@@ -40,6 +40,25 @@ export default {
}
return true;
},
isFixedValueAssignedToKey(
data: any,
nodename: string | null | undefined,
property: string | null = 'value'
) {
if (
data === null ||
data === undefined ||
nodename === null ||
nodename === undefined ||
property === null ||
data[nodename] === undefined ||
data[nodename][0] === undefined ||
data[nodename][0][property] === undefined
) {
return false;
}
return true;
},
isValueAssignedToKey(
data: any,
nodename: string | null | undefined,
......
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