1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Navigate to list view if you delete an object you are editing

This patch covers all the cases I could find of places where you could
delete items that you are currently editing. When this happens, we
should now exit the edit mode and return to the list view for whatever
we were viewing.

 Related to #1742
This commit is contained in:
Akita Noek 2016-06-07 10:49:34 -04:00
parent 0067e7006f
commit f24818148c
9 changed files with 33 additions and 6 deletions

View File

@ -103,6 +103,9 @@ export function CredentialsList($scope, $rootScope, $location, $log,
Rest.destroy() Rest.destroy()
.success(function () { .success(function () {
$scope.search(list.iterator); $scope.search(list.iterator);
if (new RegExp('/' + id + '$').test($location.$$url)) {
$state.transitionTo($state.current.name.replace(/[.][a-zA-Z]+$/, "")); /* go to the list view */
}
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', ProcessErrors($scope, data, status, null, { hdr: 'Error!',

View File

@ -247,6 +247,9 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $stateParams,
Rest.destroy() Rest.destroy()
.success(function () { .success(function () {
$scope.search(list.iterator); $scope.search(list.iterator);
if (new RegExp('/' + id + '$').test($location.$$url)) {
$state.transitionTo($state.current.name.replace(/[.][a-zA-Z]+$/, "")); /* go to the list view */
}
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', ProcessErrors($scope, data, status, null, { hdr: 'Error!',

View File

@ -98,6 +98,9 @@ export function TeamsList($scope, $rootScope, $location, $log, $stateParams,
Wait('stop'); Wait('stop');
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
$scope.search(list.iterator); $scope.search(list.iterator);
if (new RegExp('/' + id + '$').test($location.$$url)) {
$state.transitionTo($state.current.name.replace(/[.][a-zA-Z]+$/, "")); /* go to the list view */
}
}) })
.error(function (data, status) { .error(function (data, status) {
Wait('stop'); Wait('stop');

View File

@ -112,6 +112,9 @@ export function UsersList($scope, $rootScope, $location, $log, $stateParams,
Rest.destroy() Rest.destroy()
.success(function () { .success(function () {
$scope.search(list.iterator); $scope.search(list.iterator);
if (new RegExp('/' + id + '$').test($location.$$url)) {
$state.transitionTo($state.current.name.replace(/[.][a-zA-Z]+$/, "")); /* go to the list view */
}
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', ProcessErrors($scope, data, status, null, { hdr: 'Error!',

View File

@ -429,8 +429,8 @@ export default
* }) * })
* *
*/ */
.factory('DeleteSchedule', ['GetBasePath','Rest', 'Wait', 'ProcessErrors', 'Prompt', 'Find', .factory('DeleteSchedule', ['GetBasePath','Rest', 'Wait', 'ProcessErrors', 'Prompt', 'Find', '$location', '$state',
function(GetBasePath, Rest, Wait, ProcessErrors, Prompt, Find) { function(GetBasePath, Rest, Wait, ProcessErrors, Prompt, Find, $location, $state) {
return function(params) { return function(params) {
var scope = params.scope, var scope = params.scope,
@ -456,6 +456,9 @@ export default
.success(function () { .success(function () {
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
scope.$emit(callback, id); scope.$emit(callback, id);
if (new RegExp('/' + id + '$').test($location.$$url)) {
$location.url($location.url().replace(/[/][0-9]+$/, "")) // go to list view
}
}) })
.error(function (data, status) { .error(function (data, status) {
try { try {

View File

@ -323,6 +323,9 @@ function InventoriesList($scope, $rootScope, $location, $log,
Rest.destroy() Rest.destroy()
.success(function () { .success(function () {
$scope.search(list.iterator); $scope.search(list.iterator);
if (new RegExp('/' + id + '$').test($location.$$url)) {
$state.transitionTo($state.current.name.replace(/[.][a-zA-Z]+$/, "")); /* go to the list view */
}
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors( $scope, data, status, null, { hdr: 'Error!', ProcessErrors( $scope, data, status, null, { hdr: 'Error!',

View File

@ -7,11 +7,11 @@
export default export default
[ '$rootScope','Wait', 'generateList', 'inventoryScriptsListObject', [ '$rootScope','Wait', 'generateList', 'inventoryScriptsListObject',
'GetBasePath' , 'SearchInit' , 'PaginateInit', 'GetBasePath' , 'SearchInit' , 'PaginateInit',
'Rest' , 'ProcessErrors', 'Prompt', '$state', 'Rest' , 'ProcessErrors', 'Prompt', '$state', '$location',
function( function(
$rootScope,Wait, GenerateList, inventoryScriptsListObject, $rootScope,Wait, GenerateList, inventoryScriptsListObject,
GetBasePath, SearchInit, PaginateInit, GetBasePath, SearchInit, PaginateInit,
Rest, ProcessErrors, Prompt, $state Rest, ProcessErrors, Prompt, $state, $location
) { ) {
var scope = $rootScope.$new(), var scope = $rootScope.$new(),
defaultUrl = GetBasePath('inventory_scripts'), defaultUrl = GetBasePath('inventory_scripts'),
@ -59,6 +59,9 @@ export default
Rest.destroy() Rest.destroy()
.success(function () { .success(function () {
scope.search(list.iterator); scope.search(list.iterator);
if (new RegExp('/' + id + '$').test($location.$$url)) {
$state.transitionTo($state.current.name.replace(/[.][a-zA-Z]+$/, "")); /* go to the list view */
}
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',

View File

@ -78,6 +78,9 @@ export default
Rest.destroy() Rest.destroy()
.success(function () { .success(function () {
$scope.search(list.iterator); $scope.search(list.iterator);
if (new RegExp('/' + id + '$').test($location.$$url)) {
$state.transitionTo($state.current.name.replace(/[.][a-zA-Z]+$/, "")); /* go to the list view */
}
}) })
.error(function (data) { .error(function (data) {
Wait('stop'); Wait('stop');

View File

@ -8,12 +8,12 @@ export default
[ '$rootScope','Wait', 'generateList', 'NotificationTemplatesList', [ '$rootScope','Wait', 'generateList', 'NotificationTemplatesList',
'GetBasePath' , 'SearchInit' , 'PaginateInit', 'Rest' , 'GetBasePath' , 'SearchInit' , 'PaginateInit', 'Rest' ,
'ProcessErrors', 'Prompt', '$state', 'GetChoices', 'Empty', 'Find', 'ProcessErrors', 'Prompt', '$state', 'GetChoices', 'Empty', 'Find',
'ngToast', '$compile', '$filter', 'ngToast', '$compile', '$filter', '$location',
function( function(
$rootScope,Wait, GenerateList, NotificationTemplatesList, $rootScope,Wait, GenerateList, NotificationTemplatesList,
GetBasePath, SearchInit, PaginateInit, Rest, GetBasePath, SearchInit, PaginateInit, Rest,
ProcessErrors, Prompt, $state, GetChoices, Empty, Find, ngToast, ProcessErrors, Prompt, $state, GetChoices, Empty, Find, ngToast,
$compile, $filter) { $compile, $filter, $location) {
var scope = $rootScope.$new(), var scope = $rootScope.$new(),
defaultUrl = GetBasePath('notification_templates'), defaultUrl = GetBasePath('notification_templates'),
list = NotificationTemplatesList, list = NotificationTemplatesList,
@ -183,6 +183,9 @@ export default
Rest.destroy() Rest.destroy()
.success(function () { .success(function () {
scope.search(list.iterator); scope.search(list.iterator);
if (new RegExp('/' + id + '$').test($location.$$url)) {
$state.transitionTo($state.current.name.replace(/[.][a-zA-Z]+$/, "")); /* go to the list view */
}
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',