Warn when navigating away from page if there are edits
This commit is contained in:
parent
80cdff7024
commit
e08b2cec5a
|
@ -598,6 +598,11 @@ var osmOrangeMarker = ExtraMarkers.icon({
|
||||||
prefix: "fa",
|
prefix: "fa",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function beforeUnloadListener(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
return event.returnValue = "";
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
startLat: Number,
|
startLat: Number,
|
||||||
|
@ -745,6 +750,9 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
edits(edit_list) {
|
||||||
|
this.update_unload_warning(edit_list);
|
||||||
|
},
|
||||||
selected_items(new_items, old_items) {
|
selected_items(new_items, old_items) {
|
||||||
for (const qid of Object.keys(new_items)) {
|
for (const qid of Object.keys(new_items)) {
|
||||||
if (!old_items[qid])
|
if (!old_items[qid])
|
||||||
|
@ -807,6 +815,13 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
update_unload_warning(edit_list) {
|
||||||
|
if (edit_list.length) {
|
||||||
|
addEventListener("beforeunload", beforeUnloadListener, {capture: true});
|
||||||
|
} else {
|
||||||
|
removeEventListener("beforeunload", beforeUnloadListener, {capture: true});
|
||||||
|
}
|
||||||
|
},
|
||||||
format_area(area) {
|
format_area(area) {
|
||||||
var value, unit, dp;
|
var value, unit, dp;
|
||||||
if(area > 1000 * 1000) {
|
if(area > 1000 * 1000) {
|
||||||
|
@ -898,6 +913,7 @@ export default {
|
||||||
break;
|
break;
|
||||||
case "done":
|
case "done":
|
||||||
app.upload_state = "done";
|
app.upload_state = "done";
|
||||||
|
removeEventListener("beforeunload", beforeUnloadListener, {capture: true});
|
||||||
es.close();
|
es.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -936,6 +952,8 @@ export default {
|
||||||
this.edits.splice(index, 1);
|
this.edits.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.update_unload_warning(this.edits);
|
||||||
|
|
||||||
var marker = this.getMarker(item);
|
var marker = this.getMarker(item);
|
||||||
|
|
||||||
item.wikidata.markers.forEach((marker_data) => {
|
item.wikidata.markers.forEach((marker_data) => {
|
||||||
|
|
Loading…
Reference in a new issue