Plan UI: confirm on unsaved changes (#12797)

This commit is contained in:
Michael Geers 2024-03-09 18:38:43 +01:00 • committed by GitHub
parent b88c310142
commit 82aa5d9598
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View file

@ -224,12 +224,22 @@ export default {
this.modal = Modal.getOrCreateInstance(this.$refs.modal);
this.$refs.modal.addEventListener("show.bs.modal", this.modalVisible);
this.$refs.modal.addEventListener("hidden.bs.modal", this.modalInvisible);
this.$refs.modal.addEventListener("hide.bs.modal", this.checkUnsavedOnClose);
},
unmounted() {
this.$refs.modal?.removeEventListener("show.bs.modal", this.modalVisible);
this.$refs.modal?.removeEventListener("hidden.bs.modal", this.modalInvisible);
this.$refs.modal?.removeEventListener("hide.bs.modal", this.checkUnsavedOnClose);
},
methods: {
checkUnsavedOnClose: function () {
const $applyButton = this.$refs.modal.querySelector("[data-testid=plan-apply]");
if ($applyButton) {
if (confirm(this.$t("main.chargingPlan.unsavedChanges"))) {
$applyButton.click();
}
}
},
modalVisible: function () {
this.isModalVisible = true;
},

View file

@ -208,6 +208,7 @@ time = "Zeit"
title = "Plan"
titleMinSoc = "Min. Ladung"
titleTargetCharge = "Abfahrt"
unsavedChanges = "Ungespeicherte Änderungen vorhanden. Jetzt anwenden?"
update = "Anwenden"
[main.energyflow]

View file

@ -205,6 +205,7 @@ time = "Time"
title = "Plan"
titleMinSoc = "Min charge"
titleTargetCharge = "Departure"
unsavedChanges = "There are unsaved changes. Apply now?"
update = "Apply"
[main.energyflow]