Mercurial > gemma
changeset 3692:3138836bf840
import_soundingresults: bottlenecks grouped by countrycode
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 18 Jun 2019 17:44:28 +0200 |
parents | afc8ac7001ee |
children | 10cbf467fd63 |
files | client/src/components/importconfiguration/types/Soundingresults.vue client/src/store/bottlenecks.js |
diffstat | 2 files changed, 44 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importconfiguration/types/Soundingresults.vue Tue Jun 18 17:04:45 2019 +0200 +++ b/client/src/components/importconfiguration/types/Soundingresults.vue Tue Jun 18 17:44:28 2019 +0200 @@ -13,14 +13,21 @@ <small class="text-muted"> <translate>Bottleneck</translate> </small> - <select v-model="bottleneck" class="custom-select custom-select-sm"> - <option - v-for="bottleneck in availableBottlenecks" - :value="bottleneck" - :key="bottleneck.properties.objnam" + <select class="form-control font-weight-bold" v-model="bottleneck"> + <option :value="null">{{ placeholder }}</option> + <optgroup + v-for="(bottlenecksForCountry, cc) in orderedBottlenecks" + :key="cc" + :label="cc" > - {{ bottleneck.properties.objnam }} - </option> + <option + v-for="bn in bottlenecksForCountry" + :key="bn.properties.objnam" + :value="bn" + > + {{ bn.properties.objnam }} + </option> + </optgroup> </select> <span class="text-danger"> <small v-if="!bottleneck"> @@ -356,6 +363,30 @@ availableBottlenecks() { return this.bottlenecks; }, + placeholder() { + return this.$gettext("Select bottleneck"); + }, + orderedBottlenecks() { + let groupedBottlenecks = {}, + orderedGroups = {}; + + // group bottlenecks by cc + this.availableBottlenecks.forEach(bn => { + let cc = bn.properties.responsible_country; + if (groupedBottlenecks.hasOwnProperty(cc)) { + groupedBottlenecks[cc].push(bn); + } else { + groupedBottlenecks[cc] = [bn]; + } + }); + + // order groups by cc + Object.keys(groupedBottlenecks) + .sort() + .forEach(cc => (orderedGroups[cc] = groupedBottlenecks[cc])); + + return orderedGroups; + }, editState() { return this.importState === IMPORTSTATE.EDIT; },
--- a/client/src/store/bottlenecks.js Tue Jun 18 17:04:45 2019 +0200 +++ b/client/src/store/bottlenecks.js Tue Jun 18 17:44:28 2019 +0200 @@ -175,7 +175,12 @@ featurePrefix: "gemma", featureTypes: ["bottlenecks_geoserver"], outputFormat: "application/json", - propertyNames: ["objnam", "limiting", "reference_water_levels"] + propertyNames: [ + "objnam", + "responsible_country", + "limiting", + "reference_water_levels" + ] }); HTTP.post( "/internal/wfs",