Commits (3)
{
"name": "@coscine/form-generator",
"version": "1.9.1",
"version": "1.9.2",
"main": "./dist/index.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
......
......@@ -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,
......