Skip to content

Commit

Permalink
Merge pull request #405 from bildvitta/feature/deleteRoute
Browse files Browse the repository at this point in the history
unsaved-changes for delete actions
  • Loading branch information
plowzzer authored Sep 22, 2021
2 parents 14219d9 + ffee02b commit 260e684
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added
- Mixin changes on `unsaved-changes` for not show the edit dialog when is a delete action

## 2.9.5 - 2021-09-21

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions ui/src/components/form-view/QasFormView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ export default {
},
methods: {
beforeRouteLeave (to, from, next) {
beforeRouteLeave (to, from, next, fromDelete) {
if (!this.showDialogOnUnsavedChanges) {
return null
}
if (isEqual(this.value, this.cachedResult)) {
if (fromDelete || isEqual(this.value, this.cachedResult)) {
return next()
}
this.handleDialog(next)
},
Expand Down
14 changes: 13 additions & 1 deletion ui/src/mixins/unsaved-changes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export default {
data () {
return {
$_fromDelete: false
}
},

beforeRouteLeave (to, from, next) {
if (!this.$refs.formView) {
throw new Error(
Expand All @@ -7,6 +13,12 @@ export default {
)
}

this.$refs.formView.beforeRouteLeave(to, from, next)
this.$refs.formView.beforeRouteLeave(to, from, next, this.$_fromDelete)
},

methods: {
$_deleteSuccess () {
this.$_fromDelete = true
}
}
}

0 comments on commit 260e684

Please sign in to comment.