Skip to content

Commit

Permalink
feat: add confirm for closing notification rule dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
sbgap committed Nov 11, 2024
1 parent 5216c35 commit a551bde
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions src/components/NotificationRuleList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
<v-btn
icon
@click="
editedItem.triggers.push({ from_severity: [], to_severity: [], status: [], text: null })
editedItem.triggers = [...editedItem.triggers, { from_severity: [], to_severity: [], status: [], text: null}]
"
>
add
Expand Down Expand Up @@ -569,7 +569,7 @@
<v-btn
color="blue darken-1"
flat
@click="close"
@click="dialog = false"
>
{{ $t('Cancel') }}
</v-btn>
Expand Down Expand Up @@ -736,7 +736,7 @@
<div style="margin: auto;">
<v-container
v-for="(trigger, index) in props.item.triggers"
:key="trigger"
:key="index"
grid-list-md
style="padding: 1px;"
>
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
},
Expand Down Expand Up @@ -1477,7 +1495,8 @@ export default {
})
)
}
this.close()
this.saved = true
this.dialog = false
}
}
}
Expand Down

0 comments on commit a551bde

Please sign in to comment.