-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFR] Delete view: back to previous state, not edit or list view #538
Merged
jpetitcolas
merged 3 commits into
marmelab:master
from
vasiakorobkin:delete_back_to_prev
Jul 24, 2015
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,9 @@ | |
define(function () { | ||
'use strict'; | ||
|
||
var DeleteController = function ($scope, $state, WriteQueries, notification, params, view, entry) { | ||
var DeleteController = function ($scope, $window, WriteQueries, notification, params, view, entry) { | ||
this.$scope = $scope; | ||
this.$state = $state; | ||
this.$window = $window; | ||
this.WriteQueries = WriteQueries; | ||
this.entityLabel = params.entity; | ||
this.entityId = params.id; | ||
|
@@ -22,14 +22,11 @@ define(function () { | |
|
||
DeleteController.prototype.deleteOne = function () { | ||
var notification = this.notification, | ||
$state = this.$state, entityName = this.entity.name(); | ||
entityName = this.entity.name(), | ||
$window = this.$window; | ||
|
||
this.WriteQueries.deleteOne(this.view, this.entityId).then(function () { | ||
|
||
$state.go($state.get('list'), angular.extend({ | ||
entity: entityName, | ||
id: this.entityId | ||
}, $state.params)); | ||
this.back(); | ||
notification.log('Element successfully deleted.', { addnCls: 'humane-flatty-success' }); | ||
}.bind(this), function (response) { | ||
// @TODO: share this method when splitting controllers | ||
|
@@ -43,23 +40,17 @@ define(function () { | |
}; | ||
|
||
DeleteController.prototype.back = function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not implement the "back" logic in this method instead? |
||
var $state = this.$state; | ||
|
||
$state.go($state.get('edit'), angular.extend({ | ||
entity: this.entity.name(), | ||
id: this.entityId | ||
}, $state.params)); | ||
this.$window.history.back(); | ||
}; | ||
|
||
DeleteController.prototype.destroy = function () { | ||
this.$scope = undefined; | ||
this.WriteQueries = undefined; | ||
this.$state = undefined; | ||
this.view = undefined; | ||
this.entity = undefined; | ||
}; | ||
|
||
DeleteController.$inject = ['$scope', '$state', 'WriteQueries', 'notification', 'params', 'view', 'entry']; | ||
DeleteController.$inject = ['$scope', '$window', 'WriteQueries', 'notification', 'params', 'view', 'entry']; | ||
|
||
return DeleteController; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks to me like this causes a regression: if you click "delete" while on the
showView
page, the new code sends you "back" to that page which 404's.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahgittin this is taken care of in #642. Could you test it and report your findings in the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahgittin: incoming #642 indeed fixes this issue. If you are on the show view and click delete, the controller is going to check if the previous page is related to the deleted entity. If so, it redirects you to the list view. Otherwise, to the previous page.