diff --git a/src/components/NotificationRuleList.vue b/src/components/NotificationRuleList.vue index 6d9170b5..cd684866 100644 --- a/src/components/NotificationRuleList.vue +++ b/src/components/NotificationRuleList.vue @@ -355,7 +355,7 @@ add @@ -569,7 +569,7 @@ {{ $t('Cancel') }} @@ -736,7 +736,7 @@
@@ -989,7 +989,7 @@ export default { dialog: false, active_dialog: false, headers: [ - { text: i18n.t('Acitve'), value: 'active' }, + { text: i18n.t('Active'), value: 'active' }, { text: i18n.t('Reactivate'), value: 'reactivate' }, { text: i18n.t('Customer'), value: 'customer' }, { text: i18n.t('Delay'), value: 'delay' }, @@ -1263,9 +1263,21 @@ export default { this.getUsers() this.getGroups() this.getNotificaitonGroups() - this.editedItem = Object.assign({}, this.defaultItem) + this.editedItem = Object.assign({}, JSON.parse(JSON.stringify(this.defaultItem))) + this.editedItemStart = JSON.parse(JSON.stringify(this.defaultItem)) }, methods: { + compareDict(a, b) { + if (a === null) return true + for (const key in a) { + if (b[key] === undefined) return false + if (typeof a[key] === typeof({})) { + if (!this.compareDict(a[key], b[key])) return false + } + else if (a[key] !== b[key]) return false + } + return true + }, emptyArray(arr) { for (let t in arr) { return false @@ -1329,6 +1341,7 @@ export default { editItem(item) { this.editedId = item.id this.editedItem = Object.assign({}, item) + this.editedItemStart = JSON.parse(JSON.stringify(item)) this.dialog = true }, copyItem(item) { @@ -1344,17 +1357,22 @@ export default { ) }, close() { - this.dialog = false - setTimeout(() => { - this.$refs.form.resetValidation() - this.editedItem = Object.assign({}, this.defaultItem) - this.editedId = null - }, 300) + let change = !this.compareDict(this.editedItem, this.editedItemStart) + if (this.saved || !change || confirm('Are you sure you want to close the dialog?')) { + setTimeout(() => { + this.$refs.form.resetValidation() + this.editedItem = JSON.parse(JSON.stringify(this.defaultItem)) + this.editedItemStart = JSON.parse(JSON.stringify(this.defaultItem)) + this.editedId = null + this.saved = false + }, 300) + } + else setTimeout(() => this.dialog = true, 0.1) }, close_active() { this.active_dialog = false setTimeout(() => { - this.editedItem = Object.assign({}, this.defaultItem) + this.editedItem = Object.assign({}, JSON.parse(JSON.stringify(this.defaultItem))) this.editedId = null }, 300) }, @@ -1477,7 +1495,8 @@ export default { }) ) } - this.close() + this.saved = true + this.dialog = false } } }