update data on change

This commit is contained in:
Klemek
2023-08-29 16:44:23 +02:00
parent 186a7efeaf
commit 5e81b9520e
+9 -10
View File
@@ -82,22 +82,13 @@ let app = {
}, },
deleteRow(i) { deleteRow(i) {
this.available.pop(i); this.available.pop(i);
this.updateData(); this.reset();
}, },
addRow() { addRow() {
if (this.newRow[0] && this.newRow[1]) { if (this.newRow[0] && this.newRow[1]) {
this.available.push(utils.cloneObject(this.newRow)); this.available.push(utils.cloneObject(this.newRow));
this.newRow = ["", ""]; this.newRow = ["", ""];
} }
this.updateData();
},
updateData() {
const data = utils.serialize(this.available);
const url = new URL(window.location);
if (url.searchParams.get("d") !== data) {
url.searchParams.set("d", data);
window.history.pushState({}, "", url);
}
this.reset(); this.reset();
}, },
reset() { reset() {
@@ -128,6 +119,14 @@ let app = {
this.reset(); this.reset();
} }
}, },
updated() {
const data = utils.serialize(this.available);
const url = new URL(window.location);
if (url.searchParams.get("d") !== data) {
url.searchParams.set("d", data);
window.history.pushState({}, "", url);
}
},
mounted: function () { mounted: function () {
setTimeout(this.showApp); setTimeout(this.showApp);
}, },