diff --git a/README.md b/README.md index f79e71eac..9499ec380 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# G3W-CLIENT v3.10.0 +# G3W-CLIENT v3.10.1-alpha.0 [![License](https://img.shields.io/badge/license-MPL%202-blue.svg?style=flat)](LICENSE) @@ -357,8 +357,8 @@ All notable changes to this project are documented in the [releases](https://git --- **Compatibile with:** -[![g3w-admin version](https://img.shields.io/badge/g3w--admin-3.7-1EB300.svg?style=flat)](https://github.com/g3w-suite/g3w-admin/tree/v.3.7.x) -[![g3w-suite-docker version](https://img.shields.io/badge/g3w--suite--docker-3.7-1EB300.svg?style=flat)](https://github.com/g3w-suite/g3w-suite-docker/tree/v3.7.x) +[![g3w-admin version](https://img.shields.io/badge/g3w--admin-3.8-1EB300.svg?style=flat)](https://github.com/g3w-suite/g3w-admin/tree/v.3.8.x) +[![g3w-suite-docker version](https://img.shields.io/badge/g3w--suite--docker-3.8-1EB300.svg?style=flat)](https://github.com/g3w-suite/g3w-suite-docker/tree/v3.8.x) --- diff --git a/package.json b/package.json index 86802c251..78ee00be1 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "g3w-client", - "version": "3.10.0", + "version": "3.10.1-alpha.0", "description": "Gis3W WebGIS Client", "main": "index.js", "scripts": { diff --git a/src/app/constant.js b/src/app/constant.js index cbb5735eb..c8a4042a0 100644 --- a/src/app/constant.js +++ b/src/app/constant.js @@ -60,7 +60,7 @@ export const DOWNLOAD_FORMATS = { }, download_pdf: { format: 'pdf', - url: 'pdf' + url: 'pdf' }, }; @@ -402,12 +402,8 @@ export const TOC_THEMES_INIT_STATUS = 'collapsed'; */ export const VIEWPORT = { resize: { - map: { - min: 200 - }, - content: { - min: 200 - } + map: { min: 200 }, + content: { min: 200 }, } }; diff --git a/src/app/core/layers/features/featuresstore.js b/src/app/core/layers/features/featuresstore.js index dab3cf0d9..88220df31 100644 --- a/src/app/core/layers/features/featuresstore.js +++ b/src/app/core/layers/features/featuresstore.js @@ -204,7 +204,7 @@ proto._updateFeature = function(feature) { }); }; -proto.setFeatures = function(features) { +proto.setFeatures = function(features = []) { this._features = features; }; diff --git a/src/app/core/layers/features/olfeaturesstore.js b/src/app/core/layers/features/olfeaturesstore.js index e0b983313..9977a6d52 100644 --- a/src/app/core/layers/features/olfeaturesstore.js +++ b/src/app/core/layers/features/olfeaturesstore.js @@ -16,8 +16,12 @@ proto.getLength = function() { }; //overwrite -proto.setFeatures = function(features=[]) { - features.forEach(feature => this._features.push(feature)); +proto.setFeatures = function(features = []) { + //remove features + this._features.clear(); + //add new features + this.addFeatures(features); + this._features.dispatchEvent('change'); }; // overwrite proto.readFeatures = function() { diff --git a/src/app/gui/fields/fields.js b/src/app/gui/fields/fields.js index 75033607a..ddf0a79d6 100644 --- a/src/app/gui/fields/fields.js +++ b/src/app/gui/fields/fields.js @@ -7,13 +7,13 @@ import VueField from 'components/FieldVue.vue'; const Fields = { simple_field: Text, - text_field: Text, - link_field: Link, - image_field: Image, - geo_field: Geo, - photo_field: Image, - media_field: Media, - vue_field: VueField + text_field: Text, + link_field: Link, + image_field: Image, + geo_field: Geo, + photo_field: Image, + media_field: Media, + vue_field: VueField }; module.exports = Fields; diff --git a/src/app/gui/fields/fieldsservice.js b/src/app/gui/fields/fieldsservice.js index 0194b75aa..658d61176 100644 --- a/src/app/gui/fields/fieldsservice.js +++ b/src/app/gui/fields/fieldsservice.js @@ -7,15 +7,15 @@ const URLPattern = /^(https?:\/\/[^\s]+)/g; const PhotoPattern = /[^\s]+.(png|jpg|jpeg|gif)$/g; const FieldType = { - SIMPLE:'simple', - GEO:'geo', - LINK:'link', - PHOTO: 'photo', - PHOTOLINK: "photolink", - IMAGE:'image', - POINTLINK:'pointlink', - ROUTE: 'route', - VUE: 'vue' + SIMPLE: 'simple', + GEO: 'geo', + LINK: 'link', + PHOTO: 'photo', + PHOTOLINK: 'photolink', + IMAGE: 'image', + POINTLINK: 'pointlink', + ROUTE: 'route', + VUE: 'vue' }; module.exports = { @@ -27,9 +27,9 @@ module.exports = { */ getType(field) { let type = field.type; - if (type !== 'vue'){ + if ('vue' !== type){ const fieldValue = field.value; - const value = fieldValue && toRawType(fieldValue) === 'Object' && !fieldValue.coordinates && !fieldValue.vue ? fieldValue.value : fieldValue; + const value = fieldValue && 'Object' === toRawType(fieldValue) && !fieldValue.coordinates && !fieldValue.vue ? fieldValue.value : fieldValue; if (!value) { type = FieldType.SIMPLE; } else if (value && typeof value == 'object') { diff --git a/src/app/gui/form/formservice.js b/src/app/gui/form/formservice.js index 0681d7e4b..ee668c44c 100644 --- a/src/app/gui/form/formservice.js +++ b/src/app/gui/form/formservice.js @@ -18,14 +18,14 @@ function FormService() { */ this.force = { update: false, - valid: false // NOT USED FOR THE MOMENT + valid: false // NOT USED FOR THE MOMENT }; this.layer; this.setters = { - setInitForm(options={}) { + setInitForm(options = {}) { this._setInitForm(options); }, @@ -33,7 +33,7 @@ function FormService() { this.state.formstructure = formStructure; }, - setFormFields(fields=[]) { + setFormFields(fields = []) { this.state.fields = fields; this.handleFieldsWithExpression(fields); }, @@ -56,14 +56,13 @@ function FormService() { postRender(element) { // hook for listener to chenge DOM - } }; base(this); - this.init = function(options={}) { + this.init = function(options = {}) { this._setInitForm(options); }; @@ -91,19 +90,19 @@ function FormService() { /** * Cloned feature */ - this.feature = feature.clone(); + this.feature = feature.clone(); - this.title = title; + this.title = title; - this.formId = formId; + this.formId = formId; - this.name = name; + this.name = name; - this.buttons = buttons; + this.buttons = buttons; - this.context_inputs = context_inputs; + this.context_inputs = context_inputs; - this.parentData = parentData; + this.parentData = parentData; this.headerComponent = headerComponent; @@ -112,25 +111,25 @@ function FormService() { * (eg. setted on a child to parent form service relation) */ this.state = { - layerid: layer.getId(), - loading:false, - components: [], - disabledcomponents: [], - component: null, - headers: [], - currentheaderid: null, - fields: null, - buttons: this.buttons, - disabled: false, + layerid: layer.getId(), + loading: false, + components: [], + disabledcomponents: [], + component: null, + headers: [], + currentheaderid: null, + fields: null, + buttons: this.buttons, + disabled: false, isnew, - valid: true, // global form validation state. True at beginning - update: feature.isNew(), // set update in case or not is a new feature + 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 - tovalidate: {}, + tovalidate: {}, feature, componentstovalidate: {}, footer, - ready: false + ready: false }; this.force.update = feature.isNew(); @@ -164,14 +163,14 @@ function FormService() { } }; - this.eventBus.$on('set-loading-form', (bool=false) => this.state.loading = bool); + this.eventBus.$on('set-loading-form', (bool = false) => this.state.loading = bool); } inherit(FormService, G3WObject); const proto = FormService.prototype; -proto.setReady = function(bool=false) { +proto.setReady = function(bool = false) { this.state.ready = bool; }; @@ -208,7 +207,7 @@ proto.isUpdated = function(input) { /** * */ -proto.setUpdate = function(bool=false, options={}) { +proto.setUpdate = function(bool = false, options = {}) { const { force = false } = options; this.force.update = force; this.state.update = this.force.update || bool; @@ -223,16 +222,16 @@ proto.setUpdate = function(bool=false, options={}) { * * @param input */ -proto.evaluateDefaultExpressionFields = function(input={}) { +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 =>{ + filter.forEach(dependency_field => { FormService._getDefaultExpression({ - parentData: this.parentData, + parentData: this.parentData, qgs_layer_id: this.layer.getId(), - field: this._getField(dependency_field), - feature: this.feature, + field: this._getField(dependency_field), + feature: this.feature, }) }) } @@ -243,21 +242,19 @@ proto.evaluateDefaultExpressionFields = function(input={}) { * * @param input */ -proto.evaluateFilterExpressionFields = function(input={}) { +proto.evaluateFilterExpressionFields = function(input = {}) { const filter = this.filter_expression_fields_dependencies[input.name]; 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); - } + if (fieldForm) { this.feature.set(fieldForm.name, fieldForm.value) } filter.forEach(dependency_field => { FormService._getFilterExpression({ - parentData: this.parentData, + parentData: this.parentData, qgs_layer_id: this.layer.getId(), - field: this._getField(dependency_field), - feature: this.feature, + field: this._getField(dependency_field), + feature: this.feature, }) }) } @@ -269,9 +266,7 @@ proto.evaluateFilterExpressionFields = function(input={}) { * @since 3.8.0 */ proto._handleFieldWithFilterExpression = function(field, filter_expression) { - if (!filter_expression) { - return; - } + if (!filter_expression) { return } const { referencing_fields = [], @@ -296,10 +291,10 @@ proto._handleFieldWithFilterExpression = function(field, filter_expression) { // Call input service if a field has a `filter_expression` every time we open a form FormService._getFilterExpression({ - parentData: this.parentData, + parentData: this.parentData, qgs_layer_id: this.layer.getId(), + feature: this.feature, field, - feature: this.feature }); }; @@ -313,13 +308,11 @@ proto._handleFieldWithDefaultExpression = function(field, default_expression) { const { referencing_fields = [], referenced_columns = [], - apply_on_update = false, + apply_on_update = false, } = default_expression; // Skip if not apply_on_update (listen dependencies change only for new Feature) - if (!apply_on_update && !this.state.isnew) { - return; - } + if (!apply_on_update && !this.state.isnew) { return } const dependency_fields = new Set(); @@ -349,9 +342,9 @@ proto._handleFieldWithDefaultExpression = function(field, default_expression) { if (this.state.isnew) { FormService._getDefaultExpression({ field, - feature: this.feature, + feature: this.feature, qgs_layer_id: this.layer.getId(), - parentData: this.parentData, + parentData: this.parentData, }); } } @@ -379,7 +372,7 @@ proto.setCurrentFormPercentage = function(perc) { this.layer.setFormPercentage(perc) }; -proto.setLoading = function(bool=false) { +proto.setLoading = function(bool = false) { this.state.loading = bool; }; @@ -412,14 +405,14 @@ proto.isValid = function(input) { let filled = []; for (let i = input.validate.mutually.length; i--;) { const input_name = input.validate.mutually[i]; - if (!this.state.tovalidate[input_name].validate.empty) { - filled.push(input_name) ; - } + + if (!this.state.tovalidate[input_name].validate.empty) { filled.push(input_name) } + } if (filled.length < 2) { filled.forEach((input_name) => { this.state.tovalidate[input_name].validate.mutually_valid = true; - this.state.tovalidate[input_name].validate.valid = true; + this.state.tovalidate[input_name].validate.valid = true; setTimeout(() => { this.state.tovalidate[input_name].validate.valid = this.state.tovalidate[input_name].validate._valid; this.state.valid = this.state.valid && this.state.tovalidate[input_name].validate.valid; @@ -435,14 +428,12 @@ proto.isValid = function(input) { ? this.state.tovalidate[input.validate.min_field].validate.empty || 1 * input.value > 1 * this.state.tovalidate[input.validate.min_field].value : this.state.tovalidate[input.validate.max_field].validate.empty || 1 * input.value < 1 * this.state.tovalidate[input.validate.max_field].value ); - if (input.validate.valid) { - this.state.tovalidate[input_name].validate.valid = true; - } + if (input.validate.valid) { this.state.tovalidate[input_name].validate.valid = true } } } this.state.valid = ( - Object.values(this.state.tovalidate).reduce((previous, input) => previous && input.validate.valid, true) && - Object.values(this.state.componentstovalidate).reduce((previous, valid) => previous && valid, true) + Object.values(this.state.tovalidate).reduce((previous, input) => previous && input.validate.valid, true) + && Object.values(this.state.componentstovalidate).reduce((previous, valid) => previous && valid, true) ); }; @@ -453,10 +444,8 @@ proto.addComponents = function(components = []) { }; proto.addComponent = function(component) { - if (!component) { - return; - } - const {id, title, name, icon, valid, headerComponent, header=true} = component; + if (!component) { return } + const { id, title, name, icon, valid, headerComponent, header = true } = component; if (undefined !== valid) { this.state.componentstovalidate[id] = valid; this.state.valid = this.state.valid && valid; @@ -474,23 +463,19 @@ proto.addComponent = function(component) { this.state.components.push(component); }; -proto.replaceComponent = function({id, component}={}) { - const index = this.state.components.findIndex(component => component.id === id); - this.state.components.splice(index, 1, component); +proto.replaceComponent = function({ id, component } = {}) { + this.state.components.splice(this.state.components.findIndex(c => id === c.id), 1, component); }; proto.disableComponent = function({id, disabled}) { - if (disabled) { - this.state.disabledcomponents.push(id); - } else { - this.state.disabledcomponents = this.state.disabledcomponents.filter(disableId => disabledId !== id); - } + if (disabled) { this.state.disabledcomponents.push(id) } + else { this.state.disabledcomponents = this.state.disabledcomponents.filter(disableId => id !== disabledId) } }; proto.setCurrentComponentById = function(id) { - if (this.state.disabledcomponents.indexOf(id) === -1) { + if (-1 === this.state.disabledcomponents.indexOf(id)) { this.setIdHeader(id); - this.state.component = this.state.components.find(component => component.id === id).component; + this.state.component = this.state.components.find(c => id === c.id).component; return this.state.component; } }; @@ -499,19 +484,19 @@ proto.setCurrentComponentById = function(id) { * setRootComponent (is form) */ proto.setRootComponent = function() { - this.state.component = this.state.components.find(component => component.root).component; + this.state.component = this.state.components.find(c => c.root).component; }; proto.getRootComponent = function() { - return this.state.components.find(component => component.root).component; + return this.state.components.find(c => c.root).component; }; proto.isRootComponent = function(component) { - return this.getRootComponent() == component; + return component == this.getRootComponent(); }; proto.getComponentById = function(id) { - return this.state.components.find(component => component.id === id); + return this.state.components.find(c => id === c.id); }; proto.setComponent = function(component) { @@ -525,9 +510,7 @@ proto.addedComponentTo = function(formcomponent = 'body') { proto.addToValidate = function(input) { this.state.tovalidate[input.name] = input; // check if is mounted on form gui otherwise leave form component to run is Valid when form is mounted on dom - if (this.state.ready) { - this.isValid(input); - } + if (this.state.ready) { this.isValid(input) } }; proto.removeToValidate = function(input) { @@ -548,7 +531,7 @@ proto.getFields = function() { }; proto._getField = function(fieldName) { - return this.state.fields.find(field => field.name === fieldName); + return this.state.fields.find(f => fieldName === f.name); }; proto.getEventBus = function() { @@ -596,17 +579,14 @@ proto.clearAll = function() { * @since 3.8.0 */ proto.saveDefaultExpressionFieldsNotDependencies = async function() { - if (0 === this.default_expression_fields_on_update.length) { - return; - } + if (0 === this.default_expression_fields_on_update.length) { return } // disable listen changeInput - this.listenChangeInput = false; - + this.listenChangeInput = false; // Array contains field name already resolved with server default_expression request const requested_expressions = []; // array of defaultExpressionPromises request - const pending_expressions = []; + const pending_expressions = []; // loop through default_expression_fields for (let i = 0; i < this.default_expression_fields_on_update.length; i++) { @@ -626,43 +606,43 @@ proto.saveDefaultExpressionFieldsNotDependencies = async function() { // need to evaluate its value and after evaluate field value expression for (let i = 0; i < dFs.length; i++) { // in case already done a default_expression request evaluation from server - if (undefined !== requested_expressions.find(name => name === dFs[i])) { + if (undefined !== requested_expressions.find(name => dFs[i] === name)) { continue; } // get value. Need to wait response try { const value = await FormService._getDefaultExpression({ - field: this._getField(dFs[i]), - feature: this.feature, + field: this._getField(dFs[i]), + feature: this.feature, qgs_layer_id: this.layer.getId(), - parentData: this.parentData + parentData: this.parentData }); // update field with evaluated value to feature this.feature.set(dFs[i], value); // add to array requested_expressions.push(dFs[i]); - } catch(err) { - console.warn(err); + } catch(e) { + console.warn(e); } } } this.default_expression_fields_on_update.forEach(field => { - if (undefined === requested_expressions.find(name => name === field.name)) { + if (undefined === requested_expressions.find(name => field.name === name)) { pending_expressions.push(FormService._getDefaultExpression({ field, - feature: this.feature, + feature: this.feature, qgs_layer_id: this.layer.getId(), - parentData: this.parentData + parentData: this.parentData })) } }); try { await Promise.allSettled(pending_expressions); - } catch(err) { - console.warn(err); + } catch(e) { + console.warn(e); } // enable listen changeInput @@ -699,9 +679,7 @@ FormService._getFilterExpression = async function({ /** * @FIXME should return Promise.reject('some error message') ? */ - if (!filter_expression) { - return; - } + if (!filter_expression) { return } loading.state = 'loading'; @@ -714,11 +692,11 @@ FormService._getFilterExpression = async function({ qgs_layer_id, form_data: convertFeatureToGEOJSON(feature), parent: parentData && ({ - form_data: convertFeatureToGEOJSON(parentData.feature), + form_data: convertFeatureToGEOJSON(parentData.feature), qgs_layer_id: parentData.qgs_layer_id, - formatter: 0, + formatter: 0, }), - formatter: 0, + formatter: 0, expression: filter_expression.expression, }, outputs: false, @@ -730,7 +708,7 @@ FormService._getFilterExpression = async function({ const values = []; for (let i = 0; i < features.length; i++) { values.push({ - key: features[i].properties[key], + key: features[i].properties[key], value: features[i].properties[value] }) } @@ -748,8 +726,9 @@ FormService._getFilterExpression = async function({ return features; - } catch(err) { - return Promise.reject(err); + } catch(e) { + console.warn(e); + return Promise.reject(e); } finally { loading.state = 'ready'; } @@ -785,9 +764,7 @@ FormService._getDefaultExpression = async function({ /** * @FIXME should return Promise.reject('some error message') ? */ - if (!default_expression) { - return; - } + if (!default_expression) { return } loading.state = 'loading'; @@ -799,13 +776,13 @@ FormService._getDefaultExpression = async function({ field_name: field.name, layer_id, // qgs_layer_id, //layer id owner of the data - form_data: convertFeatureToGEOJSON(feature), - formatter: 0, + form_data: convertFeatureToGEOJSON(feature), + formatter: 0, expression: default_expression.expression, parent: parentData && { - form_data: convertFeatureToGEOJSON(parentData.feature), + form_data: convertFeatureToGEOJSON(parentData.feature), qgs_layer_id: parentData.qgs_layer_id, - formatter: 0 + formatter: 0 } }, outputs: false @@ -815,11 +792,10 @@ FormService._getDefaultExpression = async function({ return value; - } catch(err) { - if (undefined !== default_value) { - field.value = default_value - } - return Promise.reject(err); + } catch(e) { + if (undefined !== default_value) { field.value = default_value } + console.warn(e); + return Promise.reject(e); } finally { loading.state = 'ready'; } diff --git a/src/app/gui/inputs/checkbox/service.js b/src/app/gui/inputs/checkbox/service.js index b6e694c13..aac4f761c 100644 --- a/src/app/gui/inputs/checkbox/service.js +++ b/src/app/gui/inputs/checkbox/service.js @@ -1,13 +1,12 @@ const { inherit, base } = require('utils'); -const Service = require('gui/inputs/service'); +const Service = require('gui/inputs/service'); -function CheckBoxService(options={}) { +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; + if (options.state.value === null && !options.state.forceNull) { options.state.value = value.value } base(this, options); } @@ -16,18 +15,19 @@ inherit(CheckBoxService, Service); const proto = CheckBoxService.prototype; proto.convertCheckedToValue = function(checked) { - checked = checked === null || checked === undefined ? false : checked; - const option = this.state.input.options.values.find(value => value.checked === 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; + return this.state.value; }; proto.convertValueToChecked = function() { const valueToCheck = this.state.value; - if (valueToCheck === null || valueToCheck === undefined) return false; - let option = this.state.input.options.values.find(value => value.value == valueToCheck); - if (option === undefined) { - option = this.state.input.options.values.find(value => value.checked === false); + if ([null, undefined].includes(valueToCheck)) { return false } + let option = this.state.input.options.values.find(value => valueToCheck == value.value); + if (undefined === option) { + option = this.state.input.options.values.find(value => false === value.checked); this.state.value = option.value; } return option.checked; diff --git a/src/app/gui/inputs/datetimepicker/service.js b/src/app/gui/inputs/datetimepicker/service.js index 512de20d1..11977728f 100644 --- a/src/app/gui/inputs/datetimepicker/service.js +++ b/src/app/gui/inputs/datetimepicker/service.js @@ -1,9 +1,12 @@ import ApplicationService from 'services/application'; -const { inherit, base, convertQGISDateTimeFormatToMoment } = require('utils'); -const Service = require('gui/inputs/service'); +const { + inherit, + base, + convertQGISDateTimeFormatToMoment } = require('utils'); +const Service = require('gui/inputs/service'); -function DateTimePickerService(options={}) { +function DateTimePickerService(options = {}) { this.validatorOptions = {}; base(this, options); } diff --git a/src/app/gui/inputs/float/service.js b/src/app/gui/inputs/float/service.js index 0feaa42ac..a9ac661af 100644 --- a/src/app/gui/inputs/float/service.js +++ b/src/app/gui/inputs/float/service.js @@ -1,7 +1,7 @@ const { base, inherit } = require('utils'); -const Service = require('gui/inputs/service'); +const Service = require('gui/inputs/service'); -function FloatService(options={}) { +function FloatService(options = {}) { base(this, options); } diff --git a/src/app/gui/inputs/input.js b/src/app/gui/inputs/input.js index bc36a7e61..d51d41cbd 100644 --- a/src/app/gui/inputs/input.js +++ b/src/app/gui/inputs/input.js @@ -5,16 +5,16 @@ import { baseInputMixin as BaseInputMixin } from 'mixins'; const InputServices = require('./services'); const Input = { - props: ['state'], - mixins: [BaseInputMixin], + props: ['state'], + mixins: [BaseInputMixin], components: { 'baseinput': BaseInputComponent }, watch: { 'notvalid'(notvalid) { - notvalid && this.service.setErrorMessage() + if (notvalid) { this.service.setErrorMessage() } }, - 'state.value'(){ + 'state.value'() { if (undefined !== this.state.input.options.default_expression) { // need to postpone state.value watch parent that use mixin setTimeout(() => this.change()); @@ -22,9 +22,7 @@ const Input = { } }, created() { - this.service = new InputServices[this.state.input.type]({ - state: this.state, - }); + this.service = new InputServices[this.state.input.type]({ state: this.state }); this.$watch( () => ApplicationState.language, @@ -63,9 +61,9 @@ const Input = { } in this case if we start a validation, it fail because default value is a string while input is interger */ - this.state.value_from_default_value && this.$emit('changeinput', this.state); + if (this.state.value_from_default_value) { this.$emit('changeinput', this.state) } }, - destroyed(){ + destroyed() { // emit remove input to form (in case for example tab visibility condition) this.$emit('removeinput', this.state); } diff --git a/src/app/gui/inputs/inputs.js b/src/app/gui/inputs/inputs.js index 7c9238d15..e025fb78e 100644 --- a/src/app/gui/inputs/inputs.js +++ b/src/app/gui/inputs/inputs.js @@ -1,22 +1,22 @@ const InputsComponents = { - 'text_input': require('./text/vue/text'), - 'texthtml_input': require('./texthtml/vue/texthtml'), - 'textarea_input': require('./textarea/vue/textarea'), - 'integer_input': require('./integer/vue/integer'), - 'string_input':require('./text/vue/text'), //temporary - 'float_input': require('./float/vue/float'), - 'radio_input': require('./radio/vue/radio'), - 'check_input': require('./checkbox/vue/checkbox'), - 'range_input': require('./range/vue/range'), - 'datetimepicker_input': require('./datetimepicker/vue/datetimepicker'), - 'unique_input': require('./unique/vue/unique'), - 'select_input': require('./select/vue/select'), - 'media_input': require('./media/vue/media'), + 'text_input': require('./text/vue/text'), + 'texthtml_input': require('./texthtml/vue/texthtml'), + 'textarea_input': require('./textarea/vue/textarea'), + 'integer_input': require('./integer/vue/integer'), + 'string_input': require('./text/vue/text'), //temporary + 'float_input': require('./float/vue/float'), + 'radio_input': require('./radio/vue/radio'), + 'check_input': require('./checkbox/vue/checkbox'), + 'range_input': require('./range/vue/range'), + 'datetimepicker_input': require('./datetimepicker/vue/datetimepicker'), + 'unique_input': require('./unique/vue/unique'), + 'select_input': require('./select/vue/select'), + 'media_input': require('./media/vue/media'), 'select_autocomplete_input': require('./select/vue/select'), - 'picklayer_input': require('./picklayer/vue/picklayer'), - 'color_input': require('./color/vue/color'), - 'slider_input': require('./sliderrange/vue/sliderrange'), - 'lonlat_input': require('./lonlat/vue/lonlat') + 'picklayer_input': require('./picklayer/vue/picklayer'), + 'color_input': require('./color/vue/color'), + 'slider_input': require('./sliderrange/vue/sliderrange'), + 'lonlat_input': require('./lonlat/vue/lonlat'), }; module.exports = InputsComponents; diff --git a/src/app/gui/inputs/integer/service.js b/src/app/gui/inputs/integer/service.js index 7b674b767..aaf9f283c 100644 --- a/src/app/gui/inputs/integer/service.js +++ b/src/app/gui/inputs/integer/service.js @@ -1,11 +1,10 @@ const { base, inherit } = require('utils'); -const Service = require('gui/inputs/service'); +const Service = require('gui/inputs/service'); -function IntegerService(options={}) { +function IntegerService(options = {}) { base(this, options); } inherit(IntegerService, Service); - module.exports = IntegerService; diff --git a/src/app/gui/inputs/lonlat/service.js b/src/app/gui/inputs/lonlat/service.js index e95b78802..18b020fba 100644 --- a/src/app/gui/inputs/lonlat/service.js +++ b/src/app/gui/inputs/lonlat/service.js @@ -1,20 +1,21 @@ import GUI from 'services/gui'; const { base, inherit } = require('utils'); -const Service = require('gui/inputs/service'); +const Service = require('gui/inputs/service'); -function LonLatService(options={}) { +function LonLatService(options = {}) { base(this, options); this.coordinatebutton; this.mapService = GUI.getComponent('map').getService(); - this.mapEpsg = this.mapService.getCrs(); + this.mapEpsg = this.mapService.getCrs(); this.mapControlToggleEventHandler = evt =>{ if (evt.target.isToggled() && evt.target.isClickMap()){ this.coordinatebutton.active && this.toggleGetCoordinate(); } }; - this.map = GUI.getComponent('map').getService().getMap(); + this.map = this.mapService.getMap(); this.outputEpsg = this.state.epsg || this.mapEpsg; + //Store event map key this.eventMapKey; } @@ -22,43 +23,44 @@ inherit(LonLatService, Service); const proto = LonLatService.prototype; -proto.setCoordinateButtonReactiveObject = function(coordinatebutton){ +proto.setCoordinateButtonReactiveObject = function(coordinatebutton) { this.coordinatebutton = coordinatebutton; }; -proto.validate = function(){ - if (this.state.values.lon < -180) this.state.values.lon = -180; - else if (this.state.values.lon > 180) this.state.values.lon = 180; - if (this.state.values.lat < -90) this.state.values.lon = -90; - else if (this.state.values.lat > 90) this.state.values.lon = 90; +proto.validate = function() { + if (this.state.values.lon < -180) { this.state.values.lon = -180} + else if (this.state.values.lon > 180) { this.state.values.lon = 180 } + if (this.state.values.lat < -90) { this.state.values.lon = -90 } + else if (this.state.values.lat > 90) { this.state.values.lon = 90 } + this.state.validate.valid = !Number.isNaN(1*this.state.values.lon); }; -proto.toggleGetCoordinate = function(){ +proto.toggleGetCoordinate = function() { this.coordinatebutton.active = !this.coordinatebutton.active; this.coordinatebutton.active ? this.startToGetCoordinates() : this.stopToGetCoordinates(); }; -proto.startToGetCoordinates = function(){ +proto.startToGetCoordinates = function() { this.mapService.deactiveMapControls(); this.mapService.on('mapcontrol:toggled', this.mapControlToggleEventHandler); this.eventMapKey = this.map.on('click', evt =>{ evt.originalEvent.stopPropagation(); evt.preventDefault(); const coordinate = this.mapEpsg !== this.outputEpsg ? ol.proj.transform(evt.coordinate, this.mapEpsg, this.outputEpsg) : evt.coordinate; - this.state.value = [coordinate]; - const [lon, lat] = coordinate; + this.state.value = [coordinate]; + const [lon, lat] = coordinate; this.state.values.lon = lon; this.state.values.lat = lat; }) }; -proto.stopToGetCoordinates = function(){ +proto.stopToGetCoordinates = function() { ol.Observable.unByKey(this.eventMapKey); this.mapService.off('mapcontrol:toggled', this.mapControlToggleEventHandler) }; -proto.clear = function(){ +proto.clear = function() { this.stopToGetCoordinates(); }; diff --git a/src/app/gui/inputs/media/service.js b/src/app/gui/inputs/media/service.js index b5a04e8eb..45b75f1c9 100644 --- a/src/app/gui/inputs/media/service.js +++ b/src/app/gui/inputs/media/service.js @@ -1,7 +1,7 @@ const { inherit, base } = require('utils'); -const Service = require('gui/inputs/service'); +const Service = require('gui/inputs/service'); -function MediaService(options={}) { +function MediaService(options = {}) { base(this, options); } diff --git a/src/app/gui/inputs/picklayer/service.js b/src/app/gui/inputs/picklayer/service.js index 9f0911454..eb18d061d 100644 --- a/src/app/gui/inputs/picklayer/service.js +++ b/src/app/gui/inputs/picklayer/service.js @@ -5,7 +5,7 @@ import { getQueryLayersPromisesByCoordinates } from 'utils/getQueryLayersPromise const PickFeatureInteraction = require('g3w-ol/interactions/pickfeatureinteraction'); const PickCoordinatesInteraction = require('g3w-ol/interactions/pickcoordinatesinteraction'); -function PickLayerService(options={}) { +function PickLayerService(options = {}) { this.pick_type = options.pick_type || 'wms'; this.ispicked = false; this.fields = options.fields || [options.value]; @@ -22,13 +22,13 @@ const proto = PickLayerService.prototype; * * @return {boolean|*} */ -proto.isPicked = function(){ +proto.isPicked = function() { return this.ispicked; }; //bind interrupt event proto.escKeyUpHandler = function({ keyCode, data : { owner } }) { - keyCode === 27 && owner.unpick(); + if (27 === keyCode) { owner.unpick() } }; /** @@ -68,7 +68,7 @@ proto.pick = function() { }; GUI.setModal(false); this.mapService.addInteraction(this.interaction); - this.interaction.once('picked', (e) => { + this.interaction.once('picked', e => { if ('map' === this.pick_type) { const feature = e.feature; afterPick(feature); @@ -78,11 +78,11 @@ proto.pick = function() { getQueryLayersPromisesByCoordinates( [layer], { - map: this.mapService.getMap(), + map: this.mapService.getMap(), feature_count: 1, - coordinates: e.coordinate - }).then((response) => { - const { data=[] } = response[0]; + coordinates: e.coordinate + }).then(response => { + const { data = [] } = response[0]; const feature = data.length && data[0].features[0] || null; afterPick(feature); }) @@ -106,9 +106,7 @@ proto.unpick = function() { * */ proto.clear = function() { - if (this.isPicked()) { - this.unpick(); - } + if (this.isPicked()) { this.unpick() } this.mapService = this.interaction = this.field = null; }; diff --git a/src/app/gui/inputs/radio/service.js b/src/app/gui/inputs/radio/service.js index bca3373db..8a6f31137 100644 --- a/src/app/gui/inputs/radio/service.js +++ b/src/app/gui/inputs/radio/service.js @@ -1,7 +1,7 @@ const { inherit, base } = require('utils'); -const Service = require('gui/inputs/service'); +const Service = require('gui/inputs/service'); -function RadioService(options={}) { +function RadioService(options = {}) { base(this, options); } diff --git a/src/app/gui/inputs/range/service.js b/src/app/gui/inputs/range/service.js index 566b279f4..cc660742d 100644 --- a/src/app/gui/inputs/range/service.js +++ b/src/app/gui/inputs/range/service.js @@ -1,9 +1,9 @@ const { inherit, base } = require('utils'); -const Service = require('gui/inputs/service'); -const Validators = require('utils/validators'); +const Service = require('gui/inputs/service'); +const Validators = require('utils/validators'); -function RangeService(options={}) { - const {min, max} = options.state.input.options.values[0]; +function RangeService(options = {}) { + const { min, max } = options.state.input.options.values[0]; options.state.info = `[MIN: ${min} - MAX: ${max}]`; base(this, options); const validator = Validators.get('range', { diff --git a/src/app/gui/inputs/select/service.js b/src/app/gui/inputs/select/service.js index 2e944f684..e65c73803 100644 --- a/src/app/gui/inputs/select/service.js +++ b/src/app/gui/inputs/select/service.js @@ -1,9 +1,9 @@ import CatalogLayersStoresRegistry from 'store/catalog-layers'; const { inherit, base } = require('utils'); -const Service = require('gui/inputs/service'); +const Service = require('gui/inputs/service'); -function SelectService(options={}) { +function SelectService(options = {}) { base(this, options); this.layer = null; } @@ -24,7 +24,7 @@ proto.getKeyByValue = function({ search }={}) { const { value, key } = this.state.input.options; return new Promise((resolve, reject) => { this.getData({ - key: value, + key: value, value: key, search }).then(arrayValues => { @@ -35,9 +35,9 @@ proto.getKeyByValue = function({ search }={}) { value }) resolve(this.state.input.options.values) - }).catch(err => { - console.warn(err); - reject(err); + }).catch(e => { + console.warn(e); + reject(e); }); }) }; @@ -51,26 +51,26 @@ proto.getKeyByValue = function({ search }={}) { * @return {Promise} */ proto.getData = function({ - layer_id= this.state.input.options.layer_id, - key=this.state.input.options.key, - value=this.state.input.options.value, search + layer_id = this.state.input.options.layer_id, + key = this.state.input.options.key, + value = this.state.input.options.value, + search, } = {}) { const search_value = `${key}|${search}`.trim(); return new Promise((resolve, reject) => { - if (!this._layer) { - this._layer = this._getLayerById(layer_id); - } + if (!this._layer) { this._layer = this._getLayerById(layer_id) } + this._layer.getDataTable({ - suggest: search_value, + suggest: search_value, ordering: key }).then(response => { const values = response.features.map(f =>({ - text:f.properties[key], - id: f.properties[value], + text: f.properties[key], + id: f.properties[value], $value: f.properties[value] })) resolve(values); - }).fail(err => reject(err)); + }).fail(e => { console.warn(e); reject(e) }); }); }; diff --git a/src/app/gui/inputs/service.js b/src/app/gui/inputs/service.js index 15cb203f2..9279ecd39 100644 --- a/src/app/gui/inputs/service.js +++ b/src/app/gui/inputs/service.js @@ -35,18 +35,15 @@ proto.getValue = function() { * @returns {void} */ proto.setValue = function(value) { - if (null !== value && undefined !== value) { - return; - } + if (![null, undefined].includes(value)) { return } const { options } = this.state.input; - let default_value = options.default; + let default_value = options.default; /** @TODO (maybe need to removed in v3.9.0) double check G3W-ADMIN server configuration. */ if (Array.isArray(options)) { - if (options[0].default) { - default_value = options[0].default; - } else if (Array.isArray(options.values) && options.values.length > 0) { + if (options[0].default) { default_value = options[0].default } + else if (Array.isArray(options.values) && options.values.length > 0) { default_value = options.values[0] && (options.values[0].value || options.values[0]); } } @@ -75,7 +72,7 @@ proto._getValidatorType = function() { return this.state.type; }; -proto.setState = function(state={}) { +proto.setState = function(state = {}) { this.state = _.isObject(state) ? state : {}; }; @@ -95,17 +92,17 @@ proto.setEmpty = function(){ // the general method to check the value of the state is valid or not proto.validate = function() { if (this.state.validate.empty) { - this.state.validate.empty = true; - this.state.value = null; + this.state.validate.empty = true; + this.state.value = null; this.state.validate.unique = true; // check if you require or check validation - this.state.validate.valid = this.state.validate.required ? false : this._validator.validate(this.state.value); + this.state.validate.valid = this.state.validate.required ? false : this._validator.validate(this.state.value); } else { - if (this.state.input.type === 'integer' || this.state.input.type === 'float') { + if (['integer', 'float'].includes(this.state.input.type)) { if (+this.state.value < 0) { - this.state.value = null; - this.state.validate.empty = true; - this.state.validate.valid = !this.state.validate.required; + this.state.value = null; + this.state.validate.empty = true; + this.state.validate.valid = !this.state.validate.required; } else this.state.validate.valid = this._validator.validate(this.state.value); } if (this.state.validate.exclude_values && this.state.validate.exclude_values.size) { @@ -151,9 +148,9 @@ proto.setErrorMessage = function() { */ proto.setUpdate = function(){ const {value, _value} = this.state; - if (this.state.input.type === 'media' && toRawType(value) !== 'Object' && toRawType(_value) !== 'Object') { + if ('media' === this.state.input.type && 'Object' !== toRawType(value) && 'Object' !== toRawType(_value)) { this.state.update = value.value != _value.value; - } else if (this.state.input.type === "datetimepicker") { + } else if ("datetimepicker" === this.state.input.type) { //check this.state.update = (null !== value ? value.toUpperCase(): value) != (_value ? _value.toUpperCase(): _value); } else { diff --git a/src/app/gui/inputs/services.js b/src/app/gui/inputs/services.js index 180550203..897e0a336 100644 --- a/src/app/gui/inputs/services.js +++ b/src/app/gui/inputs/services.js @@ -1,22 +1,22 @@ const InputsServices = { - 'text': require('./service'), - 'textarea': require('./service'), - 'texthtml': require('./service'), - 'integer': require('./integer/service'), - 'string':require('./service'), - 'float': require('./float/service'), - 'radio': require('./radio/service'), - 'check': require('./checkbox/service'), - 'range': require('./range/service'), - 'datetimepicker': require('./datetimepicker/service'), - 'unique': require('./unique/service'), - 'select': require('./select/service'), - 'media': require('./media/service'), + 'text': require('./service'), + 'textarea': require('./service'), + 'texthtml': require('./service'), + 'integer': require('./integer/service'), + 'string': require('./service'), + 'float': require('./float/service'), + 'radio': require('./radio/service'), + 'check': require('./checkbox/service'), + 'range': require('./range/service'), + 'datetimepicker': require('./datetimepicker/service'), + 'unique': require('./unique/service'), + 'select': require('./select/service'), + 'media': require('./media/service'), 'select_autocomplete': require('./select/service'), - 'picklayer': require('./service'), - 'color': require('./service'), - 'slider': require('./sliderrange/service'), - 'lonlat': require('./lonlat/service') + 'picklayer': require('./service'), + 'color': require('./service'), + 'slider': require('./sliderrange/service'), + 'lonlat': require('./lonlat/service'), }; module.exports = InputsServices; diff --git a/src/app/gui/inputs/sliderrange/service.js b/src/app/gui/inputs/sliderrange/service.js index dfbeb1ca6..848f50093 100644 --- a/src/app/gui/inputs/sliderrange/service.js +++ b/src/app/gui/inputs/sliderrange/service.js @@ -1,9 +1,9 @@ const { base, inherit } = require('utils'); -const Service = require('gui/inputs/service'); -const Validators = require('utils/validators'); +const Service = require('gui/inputs/service'); +const Validators = require('utils/validators'); -function SliderRangeService(options={}) { - const {state} = options; +function SliderRangeService(options = {}) { + const { state } = options; options.state.info = `[MIN: ${state.input.options.min} - MAX: ${state.input.options.max}]`; base(this, options); const validator = Validators.get('range', { @@ -11,8 +11,8 @@ function SliderRangeService(options={}) { max: 1*state.input.options.max }); this.setValidator(validator); - this.validate = function(){ - this.state.value = 1*this.state.value; + this.validate = function() { + this.state.value = 1*this.state.value; this.state.validate.valid = this.state.value >= this.state.input.options.min || this.state.value <= this.state.input.options.max; } } @@ -21,7 +21,7 @@ inherit(SliderRangeService, Service); const proto = SliderRangeService.prototype; -proto.changeInfoMessage = function(){ +proto.changeInfoMessage = function() { this.state.info = `[MIN: ${this.state.input.options.min} - MAX: ${this.state.input.options.max}]`; }; diff --git a/src/app/gui/inputs/unique/service.js b/src/app/gui/inputs/unique/service.js index f29cf34dc..579bea530 100644 --- a/src/app/gui/inputs/unique/service.js +++ b/src/app/gui/inputs/unique/service.js @@ -1,7 +1,7 @@ const { inherit, base } = require('utils'); -const Service = require('gui/inputs/service'); +const Service = require('gui/inputs/service'); -function UniqueService(options={}) { +function UniqueService(options = {}) { base(this, options); } diff --git a/src/app/gui/map/mapservice.js b/src/app/gui/map/mapservice.js index 8294c5899..8e907de99 100644 --- a/src/app/gui/map/mapservice.js +++ b/src/app/gui/map/mapservice.js @@ -7,7 +7,7 @@ import ControlsRegistry from 'store/map-controls'; import GUI from 'services/gui'; import MapControlZoomHistory from 'components/MapControlZoomHistory.vue'; import MapControlGeocoding from 'components/MapControlGeocoding.vue'; -import { createVectorLayerFromFile } from 'utils/createVectorLayerFromFile'; +import { createVectorLayerFromFile } from 'utils/createVectorLayerFromFile'; import { createWMSLayer } from 'utils/createWMSLayer'; import { createSelectedStyle } from 'utils/createSelectedStyle'; import { getMapLayersByFilter } from 'utils/getMapLayersByFilter'; @@ -1096,19 +1096,21 @@ proto._setupControls = function() { case 'mouseposition': if (!isMobile.any) { - const coordinateLabels = this.getProjection().getUnits() === 'm' ? ['X', 'Y'] : ['Lng', 'Lat']; + // @since 3.8. + const decimalNumber = 'degrees' === this.getProjection().getUnits() ? 4 : 2; + const coordinateLabels = 'degrees' === this.getProjection().getUnits() ? ['Lng', 'Lat'] : ['X', 'Y']; const crs = this.getCrs(); control = this.createMapControl(controlType, { add: false, options: { coordinateFormat(coordinate) { - return ol.coordinate.format(coordinate, `\u00A0${coordinateLabels[0]}: {x}, ${coordinateLabels[1]}: {y}\u00A0\u00A0 [${crs}]\u00A0`, 4); + return ol.coordinate.format(coordinate, `\u00A0${coordinateLabels[0]}: {x}, ${coordinateLabels[1]}: {y}\u00A0\u00A0 [${crs}]\u00A0`, decimalNumber); }, undefinedHTML: false, projection: this.getCrs() } }); - if (this.getEpsg() !== 'EPSG:4326') { + if ('EPSG:4326' !== this.getEpsg()) { const mapEspg = this.getEpsg(); const coordinateLabels = ['Lng', 'Lat']; const crs = this.getCrs(); @@ -1118,7 +1120,7 @@ proto._setupControls = function() { target: 'mouse-position-control-epsg-4326', coordinateFormat(coordinate) { coordinate = ol.proj.transform(coordinate, mapEspg, 'EPSG:4326'); - return ol.coordinate.format(coordinate, `\u00A0${coordinateLabels[0]}: {x}, ${coordinateLabels[1]}: {y}\u00A0\u00A0 [${crs}]\u00A0`, 4); + return ol.coordinate.format(coordinate, `\u00A0${coordinateLabels[0]}: {x}, ${coordinateLabels[1]}: {y}\u00A0\u00A0 [${crs}]\u00A0`, decimalNumber); }, undefinedHTML: false, projection: this.getCrs() diff --git a/src/assets/style/less/app.less b/src/assets/style/less/app.less index 47545ba52..8d109112e 100644 --- a/src/assets/style/less/app.less +++ b/src/assets/style/less/app.less @@ -392,8 +392,9 @@ header.main-header #main-navbar .navbar-right.app-navbar-nav { padding-right: :root { @media (max-width: 767px) { - a.sidebar-aside-toggle { display: none !important; } - .main-sidebar, .main-sidebar-mobile, .left-side { transform: translate(-100%, 0); width: 100%; } + a.sidebar-aside-toggle { display: none !important; } + .main-sidebar, .main-sidebar-mobile, .left-side { transform: translate(-100%, 0); width: 100%; } + .sidebar-open .main-sidebar, .sidebar-open .sidebar-aside-toggle { transform: translate(0, 0) } } } @@ -661,7 +662,7 @@ ul.g3w-tools .tool:hover { background-color: #374850; } .query_relation_field { display: inline-block; cursor: pointer; color: white; margin: 5px; width: 30px; height: 30px; text-align: center; border-radius: 3px; box-shadow: 0 3px 5px rgba(0,0,0,0.5); } .query_relation_field i { padding: 6px; } .query_relation_field_message { font-weight: bold; margin-left: 5px; } -.queryresults-wrapper { height: 100%; } +.queryresults-wrapper { height: 100%; caret-color: transparent;} .queryresults-wrapper .queryresults-text-html.text { white-space: break-spaces; } .queryresults-wrapper .queryresults-container { height: 100%; overflow-y: auto; position: relative; } .queryresults-wrapper .queryresults-container .query-results-not-found { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; background-color: #fff; border-radius: 3px; } @@ -681,7 +682,7 @@ ul.g3w-tools .tool:hover { background-color: #374850; } .queryresults-wrapper .queryresults-container ul { list-style-type: none; overflow: auto; padding: 0; } .queryresults-wrapper .queryresults-container ul > li .queryresults-multi { margin-top: 25px; } .queryresults-wrapper .queryresults-container ul > li span.key { font-weight: bold; font-size: 1.2em; margin-bottom: 10px; display: block; } -.queryresults-wrapper .queryresults-container ul > li .box-header { padding: 0; display: flex; flex-wrap: nowrap; align-items: baseline; font-weight: bold !important; font-size: 1.2em !important; justify-content: space-between; } +.queryresults-wrapper .queryresults-container ul > li .box-header { padding: 0; display: flex; flex-wrap: nowrap; align-items: center; font-weight: bold !important; font-size: 1.2em !important; justify-content: space-between; } .queryresults-wrapper .queryresults-container ul > li .box-header.mobile { padding: 5px; } .queryresults-wrapper .queryresults-container ul > li .box-header .box-title { margin: auto; margin-left: 0; font-weight: bold !important; font-size: 1.2em !important; } .queryresults-wrapper .queryresults-container ul > li .box-header .box-title.query-layer-title { padding: 5px; overflow: hidden; white-space: normal; text-overflow: ellipsis; } diff --git a/src/components/QueryResults.vue b/src/components/QueryResults.vue index f37016c77..d1cf63b3b 100644 --- a/src/components/QueryResults.vue +++ b/src/components/QueryResults.vue @@ -478,6 +478,7 @@ import HeaderFeatureBody from 'components/QueryResultsHeaderFeatureBody.vue'; import HeaderFeatureActionsBody from "components/QueryResultsHeaderFeatureActionsBody.vue"; import { toRawType, throttle } from 'utils'; + import GUI from 'services/gui'; const MAX_SUBSET_LENGTH = 3; const headerExpandActionCellWidth = 10; @@ -532,17 +533,20 @@ */ info() { if (this.state.query) { - const query = this.state.query; + const query = this.state.query; + //@since 3.8.1 coordinates show only four decimal numbers + //In case of map units degrees, show four decimal numbers otherwise, meter, show only two decimal numbers + const decimalNumber = 'degrees' === GUI.getService('map').getMapUnits() ? 4 : 2; switch (query.type) { case 'coordinates': return { - icon: 'marker', - message: ` ${query.coordinates[0]}, ${query.coordinates[1]}` + icon: 'marker', + message: ` ${query.coordinates[0].toFixed(decimalNumber)}, ${query.coordinates[1].toFixed(decimalNumber)}` }; case 'bbox': return { - icon: 'square', - message: ` [${query.bbox.join(' , ')}]` + icon: 'square', + message: ` [${query.bbox.map(c => c.toFixed(decimalNumber)).join(' , ')}]` }; case 'polygon': case 'drawpolygon': diff --git a/src/components/Relation.vue b/src/components/Relation.vue index 2a2ca5aea..6fbc40a66 100644 --- a/src/components/Relation.vue +++ b/src/components/Relation.vue @@ -128,11 +128,11 @@ > - - - + + - - @@ -198,359 +182,387 @@ \ No newline at end of file diff --git a/src/utils/getDataForSearchInput.js b/src/utils/getDataForSearchInput.js index 87f64e40f..036e0a896 100644 --- a/src/utils/getDataForSearchInput.js +++ b/src/utils/getDataForSearchInput.js @@ -1,5 +1,4 @@ import { SEARCH_ALLVALUE } from 'app/constant'; -import { createSingleFieldParameter } from 'utils/createSingleFieldParameter'; /** * @returns { Array } of unique values from field @@ -7,33 +6,22 @@ import { createSingleFieldParameter } from 'utils/createSingleFieldParameter'; export async function getDataForSearchInput({ state, field, suggest }) { try { - - // check if a field has a dependance - const parent = state.forminputs.find(d => d.attribute === field); - let dep = parent && parent.dependance; - const cached = dep && state.forminputs.some(d => dep === d.dependance && d.dvalues.length); - // get unique value from each layers - let response = ( + return ( await Promise.allSettled(state.search_layers.map(l => l.getFilterData({ - suggest, - fformatter: field, - ordering: field, - field: getDataForSearchInput.field({ - state, - field: dep, - fields: cached && ![SEARCH_ALLVALUE, undefined].includes(parent.value) - ? [createSingleFieldParameter({ field: dep, value: parent.value, operator: state.forminputs.find(d => d.attribute === dep).operator }) ] - : [], - }), - }))) + suggest, + fformatter: field, + ordering: field, + field: getDataForSearchInput.field({ + state, + field: (state.forminputs.find(i => i.attribute === field) || {}).dependance || field, + }), + }))) ) .filter(d => 'fulfilled' === d.status) .reduce((acc, d) => acc.concat(d.value.data || []), []) // uniques by fformatter .map(([value, key]) => ({ key, value })); - return response; - } catch(e) { console.warn(e); } return []; @@ -43,21 +31,19 @@ export async function getDataForSearchInput({ state, field, suggest }) { * Traverse field dependecies */ getDataForSearchInput.field = ({ state, field, fields = [] } = {}) => { - const parent = state.forminputs.find(d => d.attribute === field); - let dep = parent && parent.dependance; - const cached = dep && state.forminputs.some(d => dep === d.dependance && d.dvalues.length); + field = state.forminputs.find(i => i.attribute === field); // current input + const parent = state.forminputs.find(i => i.attribute === field.dependance); // current input dependance (parent field) - if (!cached || SEARCH_ALLVALUE === parent.value) { + // get all values (un-filtered) + if (!parent || SEARCH_ALLVALUE === parent.value) { return (fields || []).join() || undefined; } - // get current field dependance - // In case of some input dependency is not filled + // filter by parent field if (undefined !== parent.value) { - // need to set to lower a case for api purpose - const { op, logicop } = state.forminputs.find(f => f.attribute === dep).operator; - fields.unshift(`${dep}|${op.toLowerCase()}|${encodeURI(parent.value)}|` + (fields.length ? logicop.toLowerCase() : '')); + fields.unshift(`${parent.attribute}|${parent.operator.toLowerCase()}|${encodeURI(parent.value)}|` + (fields.length ? parent.logicop : '')); } - return getDataForSearchInput.field({ state, fields, field: dep }); + // recursion step + return getDataForSearchInput.field({ state, fields, field: parent.attribute }); } \ No newline at end of file diff --git a/src/utils/reverseGeometry.js b/src/utils/reverseGeometry.js index 0e4e7aca6..4763e4e5e 100644 --- a/src/utils/reverseGeometry.js +++ b/src/utils/reverseGeometry.js @@ -4,15 +4,15 @@ export function reverseGeometry(geometry) { geometry.setCoordinates(_reverseCoords(geometry.getCoordinates())); return geometry -}; +} -function _reverseCoords(c) { - c.find(c => { +function _reverseCoords(coords) { + coords.find(c => { if (!Array.isArray(c)) { - const [y, x] = c; c[0] = x; c[1] = y; + const [y, x] = coords; coords[0] = x; coords[1] = y; return true; } _reverseCoords(c); }); - return c; + return coords; } \ No newline at end of file diff --git a/src/version.js b/src/version.js index acd010cfd..bd505cc40 100644 --- a/src/version.js +++ b/src/version.js @@ -1,3 +1,3 @@ /* Generated by gulpfile.js, do not edit manually */ -export default '3.10.0'; \ No newline at end of file +export default '3.10.1-alpha.0'; \ No newline at end of file