annotate client/src/components/Bottlenecks.vue @ 2880:c40540889b53

client: code cleanup, slight style improvements
author Markus Kottlaender <markus@intevation.de>
date Mon, 01 Apr 2019 17:37:22 +0200
parents b9a6abef9f1c
children 399b03e59411
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1 <template>
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
2 <div>
2387
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2154
diff changeset
3 <UIBoxHeader
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2154
diff changeset
4 icon="ship"
2760
c6fba10926cc client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2739
diff changeset
5 :title="bottlenecksLabel"
2387
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2154
diff changeset
6 :closeCallback="$parent.close"
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2154
diff changeset
7 />
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
8 <UITableHeader
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
9 :columns="[
2874
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
10 { id: 'properties.name', title: `${nameLabel}`, width: '230px' },
2871
2cdf43c84a8c client: aligned width of searchbar and content box
Markus Kottlaender <markus@intevation.de>
parents: 2779
diff changeset
11 {
2cdf43c84a8c client: aligned width of searchbar and content box
Markus Kottlaender <markus@intevation.de>
parents: 2779
diff changeset
12 id: 'properties.responsible_country',
2cdf43c84a8c client: aligned width of searchbar and content box
Markus Kottlaender <markus@intevation.de>
parents: 2779
diff changeset
13 title: `${countryLabel}`,
2874
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
14 width: '100px'
2871
2cdf43c84a8c client: aligned width of searchbar and content box
Markus Kottlaender <markus@intevation.de>
parents: 2779
diff changeset
15 },
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
16 {
2738
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
17 id: 'properties.current',
2779
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
18 title: `${latestmeasurementLabel}`,
2871
2cdf43c84a8c client: aligned width of searchbar and content box
Markus Kottlaender <markus@intevation.de>
parents: 2779
diff changeset
19 width: '150px'
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
20 },
2871
2cdf43c84a8c client: aligned width of searchbar and content box
Markus Kottlaender <markus@intevation.de>
parents: 2779
diff changeset
21 { id: 'properties.from', title: `${chainageLabel}`, width: '150px' }
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
22 ]"
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
23 />
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
24 <UITableBody
2738
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
25 :data="filteredBottlenecks() | sortTable(sortColumn, sortDirection)"
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
26 :maxHeight="(showSplitscreen ? 18 : 35) + 'rem'"
2880
c40540889b53 client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents: 2874
diff changeset
27 :isActive="item => item === this.openBottleneck"
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
28 >
2874
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
29 <template v-slot:row="{ item: bottleneck }">
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
30 <div class="table-cell truncate text-left" style="width: 230px">
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
31 <a href="#" @click="selectBottleneck(bottleneck)">{{
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
32 bottleneck.properties.name
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
33 }}</a>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
34 </div>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
35 <div class="table-cell text-center" style="width: 100px">
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
36 {{ bottleneck.properties.responsible_country }}
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
37 </div>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
38 <div class="table-cell" style="width: 150px">
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
39 {{ bottleneck.properties.current | surveyDate }}
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
40 </div>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
41 <div class="table-cell" style="width: 150px">
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
42 {{
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
43 displayCurrentChainage(
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
44 bottleneck.properties.from,
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
45 bottleneck.properties.to
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
46 )
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
47 }}
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
48 </div>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
49 <div class="table-cell center" style="width: 30px">
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
50 <a
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
51 class="text-info"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
52 @click="loadSurveys(bottleneck)"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
53 v-if="bottleneck.properties.current"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
54 >
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
55 <font-awesome-icon
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
56 class="pointer"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
57 icon="spinner"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
58 fixed-width
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
59 spin
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
60 v-if="loading === bottleneck"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
61 ></font-awesome-icon>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
62 <font-awesome-icon
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
63 class="pointer"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
64 icon="angle-down"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
65 fixed-width
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
66 v-if="loading !== bottleneck && openBottleneck !== bottleneck"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
67 ></font-awesome-icon>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
68 <font-awesome-icon
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
69 class="pointer"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
70 icon="angle-up"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
71 fixed-width
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
72 v-if="loading !== bottleneck && openBottleneck === bottleneck"
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
73 ></font-awesome-icon>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
74 </a>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
75 </div>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
76 </template>
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
77 <template v-slot:expand="{ item: bottleneck }">
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
78 <a
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
79 href="#"
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
80 class="d-inline-block px-3 py-2"
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
81 v-for="(survey, index) in openBottleneckSurveys"
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
82 :key="index"
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
83 @click="selectSurvey(survey, bottleneck)"
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
84 >
2541
468c8dc796cf client: convert lib helper functions to Vue filters
Markus Kottlaender <markus@intevation.de>
parents: 2462
diff changeset
85 {{ survey.date_info | surveyDate }}
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
86 </a>
2874
b9a6abef9f1c client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents: 2871
diff changeset
87 </template>
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
88 </UITableBody>
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
89 </div>
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
90 </template>
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
91
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
92 <script>
1362
ca33ad696594 remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
93 /* This is Free Software under GNU Affero General Public License v >= 3.0
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
94 * without warranty, see README.md and license for details.
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
95 *
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
96 * SPDX-License-Identifier: AGPL-3.0-or-later
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
97 * License-Filename: LICENSES/AGPL-3.0.txt
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
98 *
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
99 * Copyright (C) 2018 by via donau
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
100 * – Österreichische Wasserstraßen-Gesellschaft mbH
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
101 * Software engineering by Intevation GmbH
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
102 *
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
103 * Author(s):
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
104 * Markus Kottländer <markus.kottlaender@intevation.de>
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
105 */
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
106 import { mapState } from "vuex";
1613
f2d24dceecc7 refac: cleanup import paths
Thomas Junk <thomas.junk@intevation.de>
parents: 1560
diff changeset
107 import { HTTP } from "@/lib/http";
2738
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
108 import { displayError } from "@/lib/errors";
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
109 import { sortTable } from "@/lib/mixins";
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
110
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
111 export default {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
112 name: "bottlenecks",
2738
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
113 mixins: [sortTable],
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
114 data() {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
115 return {
2738
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
116 sortColumn: "properties.name",
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
117 openBottleneck: null,
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
118 openBottleneckSurveys: null,
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
119 loading: null
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
120 };
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
121 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
122 computed: {
1403
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
123 ...mapState("application", [
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
124 "searchQuery",
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
125 "showSearchbarLastState",
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
126 "showSplitscreen"
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
127 ]),
2436
64ff5984351e client: renamed store property
Markus Kottlaender <markus@intevation.de>
parents: 2435
diff changeset
128 ...mapState("bottlenecks", ["bottlenecksList"]),
2760
c6fba10926cc client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2739
diff changeset
129 bottlenecksLabel() {
c6fba10926cc client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2739
diff changeset
130 return this.$gettext("Bottlenecks");
c6fba10926cc client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2739
diff changeset
131 },
2871
2cdf43c84a8c client: aligned width of searchbar and content box
Markus Kottlaender <markus@intevation.de>
parents: 2779
diff changeset
132 countryLabel() {
2cdf43c84a8c client: aligned width of searchbar and content box
Markus Kottlaender <markus@intevation.de>
parents: 2779
diff changeset
133 return this.$gettext("Country");
2cdf43c84a8c client: aligned width of searchbar and content box
Markus Kottlaender <markus@intevation.de>
parents: 2779
diff changeset
134 },
2779
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
135 nameLabel() {
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
136 return this.$gettext("Name");
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
137 },
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
138 latestmeasurementLabel() {
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
139 return this.$gettext("Latest Measurement");
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
140 },
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
141 chainageLabel() {
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
142 return this.$gettext("Chainage");
21eb85cdfe45 Client: improve a set of strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2760
diff changeset
143 },
1299
2738a6ae9ad8 fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents: 1282
diff changeset
144 sortIcon() {
2738a6ae9ad8 fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents: 1282
diff changeset
145 return this.sortDirection === "ASC"
2738a6ae9ad8 fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents: 1282
diff changeset
146 ? "sort-amount-down"
2738a6ae9ad8 fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents: 1282
diff changeset
147 : "sort-amount-up";
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
148 }
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
149 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
150 methods: {
2738
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
151 filteredBottlenecks() {
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
152 return this.bottlenecksList.filter(bn => {
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
153 return bn.properties.name
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
154 .toLowerCase()
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
155 .includes(this.searchQuery.toLowerCase());
add2d47c2567 client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents: 2541
diff changeset
156 });
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
157 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
158 selectSurvey(survey, bottleneck) {
1516
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
159 this.$store
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
160 .dispatch(
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
161 "bottlenecks/setSelectedBottleneck",
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
162 bottleneck.properties.name
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
163 )
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
164 .then(() => {
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
165 this.$store.commit("bottlenecks/selectedSurvey", survey);
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
166 })
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
167 .then(() => {
2136
3138d60dd1a6 moveToExtent substitutes moveMap where easy doable
Thomas Junk <thomas.junk@intevation.de>
parents: 1613
diff changeset
168 this.$store.commit("map/moveToExtent", {
3138d60dd1a6 moveToExtent substitutes moveMap where easy doable
Thomas Junk <thomas.junk@intevation.de>
parents: 1613
diff changeset
169 feature: bottleneck,
1516
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
170 zoom: 17,
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
171 preventZoomOut: true
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
172 });
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
173 });
1417
bd9253eec499 select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1415
diff changeset
174 },
bd9253eec499 select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1415
diff changeset
175 selectBottleneck(bottleneck) {
1516
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
176 this.$store
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
177 .dispatch(
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
178 "bottlenecks/setSelectedBottleneck",
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
179 bottleneck.properties.name
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
180 )
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
181 .then(() => {
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
182 this.$store.commit("bottlenecks/setFirstSurveySelected");
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
183 })
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
184 .then(() => {
2136
3138d60dd1a6 moveToExtent substitutes moveMap where easy doable
Thomas Junk <thomas.junk@intevation.de>
parents: 1613
diff changeset
185 this.$store.commit("map/moveToExtent", {
3138d60dd1a6 moveToExtent substitutes moveMap where easy doable
Thomas Junk <thomas.junk@intevation.de>
parents: 1613
diff changeset
186 feature: bottleneck,
1516
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
187 zoom: 17,
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
188 preventZoomOut: true
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
189 });
6b3756676bbe refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents: 1512
diff changeset
190 });
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
191 },
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
192 loadSurveys(bottleneck) {
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
193 if (bottleneck === this.openBottleneck) {
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
194 this.openBottleneck = null;
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
195 this.openBottleneckSurveys = null;
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
196 } else {
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
197 this.loading = bottleneck;
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
198
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
199 HTTP.get("/surveys/" + bottleneck.properties.name, {
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
200 headers: {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
201 "X-Gemma-Auth": localStorage.getItem("token"),
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
202 "Content-type": "text/xml; charset=UTF-8"
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
203 }
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
204 })
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
205 .then(response => {
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
206 this.openBottleneckSurveys = response.data.surveys.sort((a, b) => {
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
207 return a.date_info < b.date_info ? 1 : -1;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
208 });
2462
9ae2a2f758bb client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents: 2436
diff changeset
209 this.openBottleneck = bottleneck;
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
210 })
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
211 .catch(error => {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
212 const { status, data } = error.response;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
213 displayError({
1460
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1449
diff changeset
214 title: this.$gettext("Backend Error"),
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
215 message: `${status}: ${data.message || data}`
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
216 });
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
217 })
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
218 .finally(() => (this.loading = null));
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
219 }
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
220 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
221 displayCurrentChainage(from, to) {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
222 return from / 10 + " - " + to / 10;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
223 }
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
224 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
225 mounted() {
2435
3679d604645e client: renamed store action
Markus Kottlaender <markus@intevation.de>
parents: 2387
diff changeset
226 this.$store.dispatch("bottlenecks/loadBottlenecksList");
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
227 }
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
228 };
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
229 </script>