From 98a0792a8226d98828ea1a5f25a4f6e561040524 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 16 Jul 2021 11:59:07 +0200 Subject: [PATCH] Update map after closing save panel --- frontend/App.vue | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/frontend/App.vue b/frontend/App.vue index d0394f9..fd153fc 100644 --- a/frontend/App.vue +++ b/frontend/App.vue @@ -847,11 +847,39 @@ export default { }, close_edit_list() { this.view_edits = false; - if (this.upload_state == 'done') { - this.edits = []; - this.upload_progress = 0; - this.upload_state = undefined; - } + if (this.upload_state != 'done') return; + + this.edits.forEach(edit => { + var item = edit.item; + var identifier = edit.osm.identifier; + edit.outline.removeFrom(this.map); + if (edit.osm.selected) { + if (item.osm) { + if (item.osm[identifier]) return; + } else { + item.osm = {}; + } + + var keys = ['identifier', 'id', 'type', 'geojson', 'centroid', 'name']; + var osm = Object.fromEntries(keys.map(key => [key, edit.osm[key]])); + osm['wikidata'] = item.qid; + item.osm[identifier] = osm; + this.add_osm_to_map(item, osm); + } + }); + + var updated_items = new Set(this.edits.map(edit => edit.item)); + this.edits = []; + this.upload_progress = 0; + this.upload_state = undefined; + + updated_items.forEach(item => { + var marker = this.getMarker(item); + + item.wikidata.markers.forEach((marker_data) => { + marker_data.marker.setIcon(marker); + }); + }); }, upload() { console.log('upload triggered');