From 667dfaa0d6376bd50c3ee7eca87c4c4d50b0e79e Mon Sep 17 00:00:00 2001 From: Yannick Schaus Date: Thu, 14 Jan 2021 14:04:51 +0100 Subject: [PATCH] Don't update the model until save Fixes #671. Fixes #681. Signed-off-by: Yannick Schaus --- .../web/src/components/model/item-details.vue | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/model/item-details.vue b/bundles/org.openhab.ui/web/src/components/model/item-details.vue index 6b76abfb5c..bb4145c7ca 100644 --- a/bundles/org.openhab.ui/web/src/components/model/item-details.vue +++ b/bundles/org.openhab.ui/web/src/components/model/item-details.vue @@ -9,10 +9,10 @@
- +
- +
@@ -21,7 +21,7 @@ Cancel - Edit + Edit Remove @@ -41,7 +41,8 @@ export default { return { editMode: false, createMode: false, - forceSemantics: false + forceSemantics: false, + editedItem: {} } }, mounted () { @@ -61,14 +62,14 @@ export default { }, save () { this.editMode = false - this.$oh.api.put('/rest/items/' + this.model.item.name, this.model.item).then((data) => { + this.$oh.api.put('/rest/items/' + this.editedItem.name, this.editedItem).then((data) => { this.$f7.toast.create({ text: 'Item updated', destroyOnClose: true, closeTimeout: 2000 }).open() }) - this.$emit('item-updated', this.model.item) + this.$emit('item-updated', this.editedItem) }, create () { this.editMode = false @@ -126,12 +127,17 @@ export default { }).open() }) }, + edit () { + this.editMode = true + this.$set(this, 'editedItem', Object.assign({}, this.model.item)) + }, cancel () { if (this.createMode) { this.$emit('cancel-create') } this.createMode = false this.editMode = false + this.$set(this, 'editedItem', {}) } }, watch: {