Mercurial > gemma
changeset 3236:5914d615f703
available_fairway_depth: use the store luke
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 10 May 2019 11:33:46 +0200 |
parents | 0c5a28ffe9ee |
children | 86e108358216 |
files | client/src/components/fairway/AvailableFairwayDepthDialogue.vue client/src/components/fairway/Profiles.vue client/src/store/bottlenecks.js |
diffstat | 3 files changed, 49 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Fri May 10 10:49:37 2019 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Fri May 10 11:33:46 2019 +0200 @@ -33,6 +33,30 @@ </div> <div class="d-flex flex-column"> <select + :key="1" + v-if="type === $options.BOTTLENECKS" + @change="entrySelected" + class="form-control form-control-sm font-weight-bold" + v-model="selectedEntry" + > + <option :value="null">{{ empty }}</option> + <optgroup + v-for="(bottlenecksForCountry, cc) in orderedBottlenecks" + :key="cc" + :label="cc" + > + <option + v-for="bn in bottlenecksForCountry" + :key="bn.properties.name" + :value="bn" + > + {{ bn.properties.name }} + </option> + </optgroup> + </select> + <select + :key="2" + v-else @change="entrySelected" class="form-control form-control-sm font-weight-bold" v-model="selectedEntry" @@ -223,6 +247,7 @@ ...mapState("imports", ["stretches"]), ...mapState("bottlenecks", ["bottlenecksList", "selectedBottleneck"]), ...mapGetters("map", ["openLayersMap"]), + ...mapGetters("bottlenecks", ["orderedBottlenecks"]), isComplete() { return ( this.from == null ||
--- a/client/src/components/fairway/Profiles.vue Fri May 10 10:49:37 2019 +0200 +++ b/client/src/components/fairway/Profiles.vue Fri May 10 11:33:46 2019 +0200 @@ -313,27 +313,7 @@ "currentProfile" ]), ...mapGetters("map", ["openLayersMap"]), - orderedBottlenecks() { - let groupedBottlenecks = {}, - orderedGroups = {}; - - // group bottlenecks by cc - this.bottlenecksList.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; - }, + ...mapGetters("bottlenecks", ["orderedBottlenecks"]), profilesLable() { return this.$gettext("Bottleneck"); },
--- a/client/src/store/bottlenecks.js Fri May 10 10:49:37 2019 +0200 +++ b/client/src/store/bottlenecks.js Fri May 10 11:33:46 2019 +0200 @@ -32,6 +32,29 @@ init, namespaced: true, state: init(), + getters: { + orderedBottlenecks: state => { + let groupedBottlenecks = {}, + orderedGroups = {}; + + // group bottlenecks by cc + state.bottlenecksList.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; + } + }, mutations: { setBottlenecks: (state, bottlenecks) => { state.bottlenecks = bottlenecks;