Mercurial > gemma
annotate client/src/components/sections/Sections.vue @ 3678:8f58851927c0
client: make layer factory only return new layer config for individual maps
instead of each time it is invoked. The purpose of the factory was to support multiple maps with individual layers.
But returning a new config each time it is invoked leads to bugs that rely on the layer's state. Now this factory
reuses the same objects it created before, per map.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Mon, 17 Jun 2019 17:31:35 +0200 |
parents | 3ada3d0347bd |
children | dc435fbb2d7a |
rev | line source |
---|---|
3290
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 <template> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
2 <div class="d-flex flex-column"> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
3 <UIBoxHeader icon="road" :title="title" :closeCallback="$parent.close" /> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
4 <div class="position-relative"> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
5 <UISpinnerOverlay v-if="loading" /> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
6 <SectionForm v-if="showForm" :editSection="editSection" /> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
7 <div v-else> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
8 <UITableHeader |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
9 :columns="[ |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
10 { id: 'properties.name', title: `${nameLabel}`, class: 'col-4' }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
11 { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
12 id: 'properties.date_info', |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
13 title: `${dateLabel}`, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
14 class: 'col-2' |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
15 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
16 { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
17 id: 'properties.source_organization', |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
18 title: `${sourceorganizationLabel}`, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
19 class: 'col-3' |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
20 } |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
21 ]" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
22 /> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
23 <UITableBody |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
24 :data="filteredSections() | sortTable(sortColumn, sortDirection)" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
25 > |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
26 <template v-slot:row="{ item: section }"> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
27 <div class="py-1 px-2 col-4"> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
28 <a @click="moveMapToSection(section)" href="#"> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
29 {{ section.properties.name }} |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
30 </a> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
31 </div> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
32 <div class="py-1 px-2 col-2"> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
33 {{ section.properties.date_info | surveyDate }} |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
34 </div> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
35 <div class="py-1 px-2 col-3"> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
36 {{ section.properties.source_organization }} |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
37 </div> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
38 <div class="py-1 px-2 col text-right"> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
39 <button |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
40 v-if="isInStaging(section.properties.name)" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
41 @click="gotoStaging(section.properties.name)" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
42 class="btn btn-xs btn-danger mr-1" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
43 > |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
44 <font-awesome-icon |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
45 icon="exclamation-triangle" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
46 fixed-width |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
47 v-tooltip="reviewTooltip" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
48 /> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
49 </button> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
50 <button |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
51 class="btn btn-xs btn-dark mr-1" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
52 @click=" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
53 showForm = true; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
54 editSection = section; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
55 " |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
56 > |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
57 <font-awesome-icon icon="pencil-alt" fixed-width /> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
58 </button> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
59 <button |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
60 class="btn btn-xs btn-dark" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
61 @click="deleteSection(section)" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
62 > |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
63 <font-awesome-icon icon="trash" fixed-width /> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
64 </button> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
65 </div> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
66 </template> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
67 </UITableBody> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
68 <div class="text-right p-2 border-top"> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
69 <button |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
70 @click=" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
71 showForm = true; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
72 editSection = null; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
73 " |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
74 class="btn btn-sm btn-info" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
75 > |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
76 <translate>New section</translate> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
77 </button> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
78 </div> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
79 </div> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
80 </div> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
81 </div> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
82 </template> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
83 |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
84 <style lang="sass" scoped> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
85 .input-button |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
86 border-top-left-radius: 0 |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
87 border-bottom-left-radius: 0 |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
88 right: 0 |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
89 height: 31px |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
90 </style> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
91 |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
92 <script> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
93 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
94 * without warranty, see README.md and license for details. |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
95 * |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
96 * SPDX-License-Identifier: AGPL-3.0-or-later |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
97 * License-Filename: LICENSES/AGPL-3.0.txt |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
98 * |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
99 * Copyright (C) 2018, 2019 by via donau |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
100 * – Österreichische Wasserstraßen-Gesellschaft mbH |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
101 * Software engineering by Intevation GmbH |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
102 * |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
103 * Author(s): |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
104 * Thomas Junk <thomas.junk@intevation.de> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
105 * Tom Gottfried <tom.gottfried@intevation.de> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
106 */ |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
107 import { mapState, mapGetters } from "vuex"; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
108 import { displayError, displayInfo } from "@/lib/errors"; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
109 import { HTTP } from "@/lib/http"; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
110 import { sortTable } from "@/lib/mixins"; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
111 |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
112 export default { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
113 mixins: [sortTable], |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
114 components: { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
115 SectionForm: () => import("./SectionForm") |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
116 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
117 data() { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
118 return { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
119 staging: [], |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
120 loading: false, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
121 showForm: false, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
122 editSection: null |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
123 }; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
124 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
125 computed: { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
126 ...mapState("application", ["searchQuery"]), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
127 ...mapGetters("map", ["openLayersMap"]), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
128 ...mapState("imports", ["sections"]), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
129 title() { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
130 return this.$gettext("Define Sections"); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
131 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
132 nameLabel() { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
133 return this.$gettext("Name"); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
134 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
135 dateLabel() { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
136 return this.$gettext("Date"); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
137 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
138 sourceorganizationLabel() { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
139 return this.$gettext("Source organization"); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
140 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
141 reviewTooltip() { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
142 return this.$gettext("Review pending import"); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
143 } |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
144 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
145 methods: { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
146 filteredSections() { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
147 return this.sections.filter(s => { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
148 return (s.properties.name + s.properties.source_organization) |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
149 .toLowerCase() |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
150 .includes(this.searchQuery.toLowerCase()); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
151 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
152 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
153 gotoStaging(sectionName) { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
154 let pendingImport = this.staging.find(s => s.name === sectionName); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
155 if (pendingImport) |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
156 this.$router.push("/imports/overview/" + pendingImport.id); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
157 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
158 isInStaging(sectionName) { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
159 return !!this.staging.find(s => s.name === sectionName); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
160 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
161 loadStagingData() { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
162 HTTP.get("/imports?states=pending&kinds=sec", { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
163 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
164 }) |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
165 .then(response => { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
166 response.data.imports.forEach(i => { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
167 HTTP.get("/imports/" + i.id, { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
168 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
169 }) |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
170 .then(response => { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
171 this.staging.push({ |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
172 id: i.id, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
173 name: response.data.summary.section |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
174 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
175 }) |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
176 .catch(error => { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
177 const { status, data } = error.response; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
178 displayError({ |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
179 title: this.$gettext("Backend Error"), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
180 message: `${status}: ${data.message || data}` |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
181 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
182 }) |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
183 .finally(() => (this.loading = false)); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
184 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
185 }) |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
186 .catch(error => { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
187 const { status, data } = error.response; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
188 displayError({ |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
189 title: this.$gettext("Backend Error"), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
190 message: `${status}: ${data.message || data}` |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
191 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
192 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
193 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
194 deleteSection(section) { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
195 this.$store.commit("application/popup", { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
196 icon: "trash", |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
197 title: this.$gettext("Delete Section"), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
198 content: |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
199 this.$gettext("Do you really want to delete this section:") + |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
200 `<br> |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
201 <b>${section.properties.name}, ${ |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
202 section.properties.source_organization |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
203 } (${section.properties.countries})</b>`, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
204 confirm: { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
205 label: this.$gettext("Delete"), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
206 icon: "trash", |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
207 callback: () => { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
208 displayInfo({ |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
209 title: this.$gettext("Not implemented"), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
210 message: this.$gettext("Deleting ") + section.id |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
211 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
212 } |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
213 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
214 cancel: { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
215 label: this.$gettext("Cancel"), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
216 icon: "times" |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
217 } |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
218 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
219 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
220 moveMapToSection(section) { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
221 this.$store.commit("imports/selectedSectionId", section.id); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
222 this.$store.commit("fairwayavailability/type", "sections"); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
223 this.$store.commit("application/showFairwayDepth", true); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
224 this.openLayersMap() |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
225 .getLayer("SECTIONS") |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
226 .setVisible(true); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
227 this.$store.dispatch("map/moveToFeauture", { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
228 feature: section, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
229 zoom: 17, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
230 preventZoomOut: true |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
231 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
232 } |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
233 }, |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
234 mounted() { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
235 this.loading = true; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
236 this.$store |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
237 .dispatch("imports/loadSections") |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
238 .catch(error => { |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
239 const { status, data } = error.response; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
240 displayError({ |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
241 title: this.$gettext("Backend Error"), |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
242 message: `${status}: ${data.message || data}` |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
243 }); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
244 }) |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
245 .finally(() => (this.loading = false)); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
246 this.loadStagingData(); |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
247 } |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
248 }; |
3ada3d0347bd
client: define sections: duplicated and adjusted code from stretches
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
249 </script> |