Skip to content

Commit 18f3f19

Browse files
committed
Close editor pannel wen empty #505 and emove ExternalVueAppEvent
1 parent afbbda4 commit 18f3f19

File tree

5 files changed

+65
-59
lines changed

5 files changed

+65
-59
lines changed

web/src/ExternalVueAppEvent.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

web/src/pages/map/editor-menu.vue

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,17 @@
1111
<script lang="ts">
1212
import Vue from 'vue'
1313
14-
import ExternalVueAppEvent from '../../ExternalVueAppEvent'
15-
1614
export default Vue.extend({
17-
data(): {
18-
object_count: number
19-
} {
20-
return {
21-
object_count: 0,
22-
}
23-
},
24-
25-
mounted() {
26-
ExternalVueAppEvent.$on('editor-count', this.count)
15+
props: {
16+
object_count: {
17+
type: Number,
18+
default: null,
19+
},
2720
},
2821
2922
methods: {
30-
count(n: number): void {
31-
this.object_count = n
32-
},
33-
3423
save(): void {
35-
ExternalVueAppEvent.$emit('editor-save')
24+
this.$emit('editor-save')
3625
},
3726
},
3827
})

web/src/pages/map/editor.vue

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
<template>
22
<div id="editor" :data-user="!!user">
3-
<div v-if="!user">
3+
<div v-if="status == 'error'">{{ error }}</div>
4+
<div v-else-if="!user">
45
<p>
56
<translate>You must be logged in to use the tag editor</translate>
67
</p>
7-
<a href="../login"><translate>Login</translate></a>
8+
<p>
9+
<a href="../login"><translate>Login</translate></a>
10+
</p>
11+
<input
12+
type="button"
13+
class="btn btn-secondary"
14+
:value="$t('Cancel')"
15+
@click="cancel"
16+
/>
817
</div>
9-
<div v-if="status == 'error'">{{ error }}</div>
10-
<div v-if="status == 'loading'">
18+
<div v-else-if="status == 'loading'">
1119
<center>
1220
<img src="~../../../static/images/throbbler.gif" alt="downloading" />
1321
</center>
1422
</div>
15-
<div v-if="status == 'editor'">
23+
<div v-else-if="status == 'editor'">
1624
<h1><translate>Tags Editor</translate></h1>
1725
<form id="editor_form">
1826
<div
@@ -59,7 +67,7 @@
5967
type="button"
6068
class="btn btn-secondary"
6169
:value="$t('Cancel')"
62-
@click="cancel()"
70+
@click="cancel"
6371
/>
6472
<input
6573
type="button"
@@ -71,10 +79,10 @@
7179
</form>
7280
</div>
7381

74-
<div v-if="status == 'saving'">
82+
<div v-else-if="status == 'saving'">
7583
<editor-modal
7684
:edition_stack="edition_stack"
77-
@cancel="status = null"
85+
@cancel="cancel"
7886
@saved="saved"
7987
/>
8088
</div>
@@ -86,7 +94,6 @@ import Vue, { PropType } from 'vue'
8694
8795
import EditorModal from './editor-modal.vue'
8896
import EditorTag from './editor-tag.vue'
89-
import ExternalVueAppEvent from '../../ExternalVueAppEvent'
9097
import { Elem } from '../../types'
9198
9299
type FixTagAction = 'add' | 'mod' | 'del'
@@ -101,14 +108,14 @@ export default Vue.extend({
101108
type: String as PropType<string | undefined>,
102109
default: undefined,
103110
},
104-
issue: {
105-
type: Array as PropType<string[]>,
106-
default: undefined,
107-
},
108111
main_website: {
109112
type: String,
110113
required: true,
111114
},
115+
edition_stack: {
116+
type: Array as PropType<string[]>,
117+
required: true,
118+
},
112119
},
113120
114121
data(): {
@@ -117,7 +124,6 @@ export default Vue.extend({
117124
elems: { [type_id: string]: Elem }
118125
elems_action: { [type_id: string]: FixTagAction }
119126
elems_deleted: { [type_id: string]: string }
120-
edition_stack: string[]
121127
elems_base: { [type_id: string]: Elem }
122128
elems_action_base: { [type_id: string]: { [key: string]: FixTagAction } }
123129
} {
@@ -127,28 +133,23 @@ export default Vue.extend({
127133
elems: {},
128134
elems_action: {},
129135
elems_deleted: {},
130-
edition_stack: [],
131136
elems_base: {},
132137
elems_action_base: {},
133138
}
134139
},
135140
136141
watch: {
137-
issue(): void {
138-
if (this.issue) {
139-
this.load(this.issue[0], this.issue[1])
140-
}
141-
},
142-
143142
elems: {
144143
deep: true,
145144
handler(): void {
146145
this.set_action()
147146
},
148147
},
149148
150-
edition_stack(): void {
151-
ExternalVueAppEvent.$emit('editor-count', this.edition_stack.length)
149+
status(): void {
150+
if (!this.status) {
151+
this.$emit('cancel')
152+
}
152153
},
153154
154155
status(): void {
@@ -166,17 +167,11 @@ export default Vue.extend({
166167
window.removeEventListener('beforeunload', this.beforeunload)
167168
},
168169
169-
mounted(): void {
170-
ExternalVueAppEvent.$on('editor-save', () => {
170+
methods: {
171+
save() {
171172
this.status = 'saving'
172-
})
173-
174-
if (this.issue) {
175-
this.load(this.issue[0], this.issue[1])
176-
}
177-
},
173+
},
178174
179-
methods: {
180175
load(uuid: string, fix): void {
181176
this.status = 'loading'
182177
@@ -205,6 +200,7 @@ export default Vue.extend({
205200
},
206201
207202
validate(uuid: string): void {
203+
const elems = []
208204
Object.entries(JSON.parse(JSON.stringify(this.elems))).forEach(
209205
([type_id, elem]: [string, Elem]) => {
210206
const changed = elem.tags.some(
@@ -217,10 +213,11 @@ export default Vue.extend({
217213
.filter((tag) => tag.key != '' && tag.value != '')
218214
.map((tag) => [tag.key, tag.value])
219215
)
220-
this.edition_stack.push(elem)
216+
elems.push(elem)
221217
}
222218
}
223219
)
220+
this.$emit('edition', [...this.edition_stack, ...elems])
224221
225222
fetch(API_URL + `/api/0.3/issue/${uuid}/done`).then(() => {
226223
this.$emit('issue-done')
@@ -348,7 +345,7 @@ export default Vue.extend({
348345
},
349346
350347
saved(): void {
351-
this.edition_stack = []
348+
this.$emit('edition', [])
352349
this.status = null
353350
},
354351
},

web/src/pages/map/index.vue

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
:user="user"
1212
:user_error_count="user_error_count"
1313
:timestamp="timestamp"
14+
:object_count="editionStack.length"
15+
@editor-save="
16+
$refs.editor.show()
17+
$nextTick(() => {
18+
$refs.editorEditor.save()
19+
})
20+
"
1421
/>
1522
<div class="map-container">
1623
<side-pannel
@@ -70,10 +77,16 @@
7077
class="side-pannel"
7178
>
7279
<editor
80+
ref="editorEditor"
7381
:main_website="main_website"
7482
:user="user"
75-
:issue="editor"
76-
@issue-done="$refs.popup.corrected()"
83+
:edition_stack="editionStack"
84+
@edition="editionStack = $event"
85+
@issue-done="
86+
$refs.popup.corrected()
87+
$refs.editor.hide()
88+
"
89+
@cancel="$refs.editor.hide()"
7790
/>
7891
</side-pannel>
7992
</div>
@@ -89,9 +102,10 @@
89102
@q="$refs.osmObject.select($event)"
90103
@remove-marker="$refs.markerLayer.remove($event)"
91104
@fix-edit="
92-
$refs.doc.hide()
93105
$refs.editor.show()
94-
editor = [$event.uuid, $event.fix]
106+
$nextTick(() => {
107+
$refs.editorEditor.load($event.uuid, $event.fix)
108+
})
95109
"
96110
@show-doc="showDoc"
97111
@load-doc="loadDoc"
@@ -142,6 +156,7 @@ export default VueParent.extend({
142156
mapState: MapState
143157
editor: string[]
144158
doc: string[]
159+
editionStack: string[]
145160
} {
146161
return {
147162
error: undefined,
@@ -176,6 +191,7 @@ export default VueParent.extend({
176191
},
177192
editor: null,
178193
doc: null,
194+
editionStack: [],
179195
}
180196
},
181197

web/src/pages/map/top.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@
188188
<translate>Login</translate>
189189
</a>
190190
</li>
191-
<editor-menu />
191+
<editor-menu
192+
:object_count="object_count"
193+
@editor-save="$emit('editor-save')"
194+
/>
192195
</ul>
193196
</div>
194197
</template>
@@ -237,6 +240,10 @@ export default Vue.extend({
237240
type: String as PropType<string | undefined>,
238241
default: undefined,
239242
},
243+
object_count: {
244+
type: Number,
245+
default: null,
246+
},
240247
},
241248
242249
data(): {

0 commit comments

Comments
 (0)