diff --git a/src/app/gui/form/formservice.js b/src/app/gui/form/formservice.js index ee668c44c..94163e775 100644 --- a/src/app/gui/form/formservice.js +++ b/src/app/gui/form/formservice.js @@ -108,7 +108,7 @@ function FormService() { /** * Force update state of the service - * (eg. setted on a child to parent form service relation) + * (e.g., setted on a child to parent form service relation) */ this.state = { layerid: layer.getId(), @@ -124,9 +124,9 @@ function FormService() { isnew, valid: true, // global form validation state. True at beginning update: feature.isNew(), // set update in case or not is a new feature - // when input change will be update + // when input change will be updated tovalidate: {}, - feature, + feature: this.feature, //need to get feature cloned, componentstovalidate: {}, footer, ready: false @@ -180,6 +180,7 @@ proto.setReady = function(bool = false) { * @param input */ proto.changeInput = function(input) { + this.feature.set(input.name, input.value); if (true === this.listenChangeInput) { this.evaluateFilterExpressionFields(input); this.evaluateDefaultExpressionFields(input); @@ -225,7 +226,6 @@ proto.setUpdate = function(bool = false, options = {}) { proto.evaluateDefaultExpressionFields = function(input = {}) { const filter = this.default_expression_fields_dependencies[input.name]; if (filter) { - this.feature.set(input.name, input.value); filter.forEach(dependency_field => { FormService._getDefaultExpression({ parentData: this.parentData, @@ -247,8 +247,6 @@ proto.evaluateFilterExpressionFields = function(input = {}) { if (filter) { // on form service inititalization `filter_expression` option has // `referencing_fields` or `referenced_columns` from another layer - const fieldForm = this._getField(input.name); - if (fieldForm) { this.feature.set(fieldForm.name, fieldForm.value) } filter.forEach(dependency_field => { FormService._getFilterExpression({ parentData: this.parentData, diff --git a/src/app/gui/inputs/checkbox/service.js b/src/app/gui/inputs/checkbox/service.js index aac4f761c..ff2fef187 100644 --- a/src/app/gui/inputs/checkbox/service.js +++ b/src/app/gui/inputs/checkbox/service.js @@ -2,11 +2,9 @@ const { inherit, base } = require('utils'); const Service = require('gui/inputs/service'); function CheckBoxService(options = {}) { - const value = options.state.input.options.values.find(value => value.checked === false); options.validatorOptions = { values: options.state.input.options.values.map(value => value) }; - if (options.state.value === null && !options.state.forceNull) { options.state.value = value.value } base(this, options); } @@ -16,22 +14,20 @@ const proto = CheckBoxService.prototype; proto.convertCheckedToValue = function(checked) { checked = [null, undefined].includes(checked) ? false : checked; - const option = this.state.input.options.values.find(value => checked === value.checked); - this.state.value = option.value; - + this.state.value = [true, false].includes(this.state.value) //check if is a boolean value + ? (this.state.input.options.values.find(v => checked === v.checked) || {}).value //get boolean value + : `${(this.state.input.options.values.find(v => checked === v.checked) || {}).value}`; // Need to convert it to string because server return always string value return this.state.value; }; proto.convertValueToChecked = function() { - const valueToCheck = this.state.value; - if ([null, undefined].includes(valueToCheck)) { return false } - let option = this.state.input.options.values.find(value => valueToCheck == value.value); + if ([null, undefined].includes(this.state.value)) { return false } + let option = this.state.input.options.values.find(v => this.state.value == v.value); if (undefined === option) { - option = this.state.input.options.values.find(value => false === value.checked); + option = this.state.input.options.values.find(v => false === v.checked); this.state.value = option.value; } return option.checked; }; - module.exports = CheckBoxService; diff --git a/src/components/GlobalTabs.vue b/src/components/GlobalTabs.vue index 0a96c2ebf..e5121e598 100644 --- a/src/components/GlobalTabs.vue +++ b/src/components/GlobalTabs.vue @@ -212,8 +212,7 @@ const field = this.fields.find(f => c === f.name); this.unwatch.push( this.$watch(() => field.value, - async (v) => { - this.feature.set(field.name, v); + async () => { await this.setVisibility(tab); }) ) diff --git a/src/components/InputCheckbox.vue b/src/components/InputCheckbox.vue index ba388cd4b..aaada0010 100644 --- a/src/components/InputCheckbox.vue +++ b/src/components/InputCheckbox.vue @@ -36,7 +36,7 @@ export default { return { value: null, label: null, - id: getUniqueDomId() // new id + id: getUniqueDomId() // new id } }, methods: { @@ -58,9 +58,8 @@ export default { } }, mounted() { - if (this.state.forceNull) { - this.setLabel(); - } + //Need to set label and value + this.stateValueChanged(); } }; \ No newline at end of file