diff --git a/awx/ui/client/src/credential-types/list/list.controller.js b/awx/ui/client/src/credential-types/list/list.controller.js
index 54ff04c397..912a8b01a9 100644
--- a/awx/ui/client/src/credential-types/list/list.controller.js
+++ b/awx/ui/client/src/credential-types/list/list.controller.js
@@ -61,10 +61,18 @@ export default ['$rootScope', '$scope', 'Wait', 'CredentialTypesList',
Rest.setUrl(url);
Rest.destroy()
.success(function() {
+
+ let reloadListStateParams = null;
+
+ if($scope.credential_types.length === 1 && $state.params.credential_type_search && !_.isEmpty($state.params.credential_type_search.page) && $state.params.credential_type_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.credential_type_search.page = (parseInt(reloadListStateParams.credential_type_search.page)-1).toString();
+ }
+
if (parseInt($state.params.credential_type_id) === id) {
- $state.go('^', null, { reload: true });
+ $state.go('^', reloadListStateParams, { reload: true });
} else {
- $state.go('.', null, { reload: true });
+ $state.go('.', reloadListStateParams, { reload: true });
}
})
.error(function(data, status) {
diff --git a/awx/ui/client/src/credentials/list/credentials-list.controller.js b/awx/ui/client/src/credentials/list/credentials-list.controller.js
index 968b7def7c..1fa0c3a352 100644
--- a/awx/ui/client/src/credentials/list/credentials-list.controller.js
+++ b/awx/ui/client/src/credentials/list/credentials-list.controller.js
@@ -74,10 +74,18 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt',
Rest.setUrl(url);
Rest.destroy()
.success(function() {
+
+ let reloadListStateParams = null;
+
+ if($scope.credentials.length === 1 && $state.params.credential_search && !_.isEmpty($state.params.credential_search.page) && $state.params.credential_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.credential_search.page = (parseInt(reloadListStateParams.credential_search.page)-1).toString();
+ }
+
if (parseInt($state.params.credential_id) === id) {
- $state.go("^", null, { reload: true });
+ $state.go("^", reloadListStateParams, { reload: true });
} else {
- $state.go('.', null, {reload: true});
+ $state.go('.', reloadListStateParams, {reload: true});
}
Wait('stop');
})
diff --git a/awx/ui/client/src/inventories-hosts/hosts/list/host-list.controller.js b/awx/ui/client/src/inventories-hosts/hosts/list/host-list.controller.js
index 3853d80462..52a565b40c 100644
--- a/awx/ui/client/src/inventories-hosts/hosts/list/host-list.controller.js
+++ b/awx/ui/client/src/inventories-hosts/hosts/list/host-list.controller.js
@@ -68,31 +68,6 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath,
$scope.goToInsights = function(id){
$state.go('hosts.edit.insights', {host_id:id});
};
- $scope.deleteHost = function(id, name){
- var body = '
Are you sure you want to permanently delete the host below from the inventory?
' + $filter('sanitize')(name) + '
';
- var action = function(){
- delete $rootScope.promptActionBtnClass;
- Wait('start');
- HostsService.delete(id).then(() => {
- $('#prompt-modal').modal('hide');
- if (parseInt($state.params.host_id) === id) {
- $state.go("hosts", null, {reload: true});
- } else {
- $state.go($state.current.name, null, {reload: true});
- }
- Wait('stop');
- });
- };
- // Prompt depends on having $rootScope.promptActionBtnClass available...
- Prompt({
- hdr: 'Delete Host',
- body: body,
- action: action,
- actionText: 'DELETE',
- });
- $rootScope.promptActionBtnClass = 'Modal-errorButton';
- };
-
$scope.toggleHost = function(event, host) {
try {
$(event.target).tooltip('hide');
diff --git a/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups.controller.js b/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups.controller.js
index bd32646dcc..f2fe567cd3 100644
--- a/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups.controller.js
+++ b/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups.controller.js
@@ -70,7 +70,15 @@
$('#host-disassociate-modal').off('hidden.bs.modal').on('hidden.bs.modal', function () {
$('#host-disassociate-modal').off('hidden.bs.modal');
- $state.go('.', null, {reload: true});
+
+ let reloadListStateParams = null;
+
+ if($scope.groups.length === 1 && $state.params.group_search && !_.isEmpty($state.params.group_search.page) && $state.params.group_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.group_search.page = (parseInt(reloadListStateParams.group_search.page)-1).toString();
+ }
+
+ $state.go('.', reloadListStateParams, {reload: true});
});
GroupsService.disassociateHost(host.id, $scope.disassociateGroup.id).then(() => {
diff --git a/awx/ui/client/src/inventories-hosts/inventories/list/inventory-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/list/inventory-list.controller.js
index 0af4c78392..c74b819df5 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/list/inventory-list.controller.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/list/inventory-list.controller.js
@@ -86,12 +86,7 @@ function InventoriesList($scope,
Rest.setUrl(url);
Rest.destroy()
.success(function () {
- if (parseInt($state.params.inventory_id) === id) {
- $state.go("^", null, {reload: true});
- } else {
- $state.go('.', null, {reload: true});
- Wait('stop');
- }
+ Wait('stop');
})
.error(function (data, status) {
ProcessErrors( $scope, data, status, null, { hdr: 'Error!',
@@ -114,6 +109,20 @@ function InventoriesList($scope,
if (data.status === 'pending_deletion') {
inventory.pending_deletion = true;
}
+ if (data.status === 'deleted') {
+ let reloadListStateParams = null;
+
+ if($scope.inventories.length === 1 && $state.params.inventory_search && !_.isEmpty($state.params.inventory_search.page) && $state.params.inventory_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.inventory_search.page = (parseInt(reloadListStateParams.inventory_search.page)-1).toString();
+ }
+
+ if (parseInt($state.params.inventory_id) === data.inventory_id) {
+ $state.go("^", reloadListStateParams, {reload: true});
+ } else {
+ $state.go('.', reloadListStateParams, {reload: true});
+ }
+ }
});
}
diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/list/groups-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/list/groups-list.controller.js
index fdcb27b9ba..78a0969009 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/list/groups-list.controller.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/list/groups-list.controller.js
@@ -100,14 +100,21 @@
$state.go('.', null, {reload: true});
});
+ let reloadListStateParams = null;
+
+ if($scope.groups.length === 1 && $state.params.group_search && !_.isEmpty($state.params.group_search.page) && $state.params.group_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.group_search.page = (parseInt(reloadListStateParams.group_search.page)-1).toString();
+ }
+
switch($scope.deleteOption){
case 'promote':
GroupsService.promote($scope.toDelete.id, $stateParams.inventory_id)
.then(() => {
if (parseInt($state.params.group_id) === $scope.toDelete.id) {
- $state.go("^", null, {reload: true});
+ $state.go("^", reloadListStateParams, {reload: true});
} else {
- $state.go($state.current, null, {reload: true});
+ $state.go($state.current, reloadListStateParams, {reload: true});
}
$('#group-delete-modal').modal('hide');
$('body').removeClass('modal-open');
@@ -117,9 +124,9 @@
default:
GroupsService.delete($scope.toDelete.id).then(() => {
if (parseInt($state.params.group_id) === $scope.toDelete.id) {
- $state.go("^", null, {reload: true});
+ $state.go("^", reloadListStateParams, {reload: true});
} else {
- $state.go($state.current, null, {reload: true});
+ $state.go($state.current, reloadListStateParams, {reload: true});
}
$('#group-delete-modal').modal('hide');
$('body').removeClass('modal-open');
diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-list.controller.js
index 77db55e705..d5e5c39ffb 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-list.controller.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-list.controller.js
@@ -87,8 +87,16 @@
$('#group-disassociate-modal').off('hidden.bs.modal').on('hidden.bs.modal', function () {
// Remove the event handler so that we don't end up with multiple bindings
$('#group-disassociate-modal').off('hidden.bs.modal');
+
+ let reloadListStateParams = null;
+
+ if($scope.nested_groups.length === 1 && $state.params.nested_group_search && !_.isEmpty($state.params.nested_group_search.page) && $state.params.nested_group_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.nested_group_search.page = (parseInt(reloadListStateParams.nested_group_search.page)-1).toString();
+ }
+
// Reload the inventory manage page and show that the group has been removed
- $state.go('.', null, {reload: true});
+ $state.go('.', reloadListStateParams, {reload: true});
});
let closeModal = function(){
diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js
index 42ba8bfbbe..54d090a181 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js
@@ -100,8 +100,16 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePat
$('#host-disassociate-modal').off('hidden.bs.modal').on('hidden.bs.modal', function () {
// Remove the event handler so that we don't end up with multiple bindings
$('#host-disassociate-modal').off('hidden.bs.modal');
+
+ let reloadListStateParams = null;
+
+ if($scope.nested_hosts.length === 1 && $state.params.nested_host_search && !_.isEmpty($state.params.nested_host_search.page) && $state.params.nested_host_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.nested_host_search.page = (parseInt(reloadListStateParams.nested_host_search.page)-1).toString();
+ }
+
// Reload the inventory manage page and show that the group has been removed
- $state.go('.', null, {reload: true});
+ $state.go('.', reloadListStateParams, {reload: true});
});
let closeModal = function(){
diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js
index 140a83e9dd..0f95cbd452 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js
@@ -96,10 +96,18 @@ export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath',
Wait('start');
HostsService.delete(id).then(() => {
$('#prompt-modal').modal('hide');
+
+ let reloadListStateParams = null;
+
+ if($scope.hosts.length === 1 && $state.params.host_search && !_.isEmpty($state.params.host_search.page) && $state.params.host_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.host_search.page = (parseInt(reloadListStateParams.host_search.page)-1).toString();
+ }
+
if (parseInt($state.params.host_id) === id) {
- $state.go("hosts", null, {reload: true});
+ $state.go('^', reloadListStateParams, {reload: true});
} else {
- $state.go($state.current.name, null, {reload: true});
+ $state.go('.', reloadListStateParams, {reload: true});
}
Wait('stop');
});
diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups-list.controller.js
index 34440156e1..288d86da2c 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups-list.controller.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups-list.controller.js
@@ -83,8 +83,16 @@
$('#group-disassociate-modal').off('hidden.bs.modal').on('hidden.bs.modal', function () {
// Remove the event handler so that we don't end up with multiple bindings
$('#group-disassociate-modal').off('hidden.bs.modal');
+
+ let reloadListStateParams = null;
+
+ if($scope.nested_groups.length === 1 && $state.params.nested_group_search && !_.isEmpty($state.params.nested_group_search.page) && $state.params.nested_group_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.nested_group_search.page = (parseInt(reloadListStateParams.nested_group_search.page)-1).toString();
+ }
+
// Reload the inventory manage page and show that the group has been removed
- $state.go('.', null, {reload: true});
+ $state.go('.', reloadListStateParams, {reload: true});
});
let closeModal = function(){
diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js
index 363d9d315f..981d002753 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js
@@ -123,10 +123,16 @@
Wait('start');
SourcesService.delete(inventory_source.id).then(() => {
$('#prompt-modal').modal('hide');
+ let reloadListStateParams = null;
+
+ if($scope.inventory_sources.length === 1 && $state.params.inventory_source_search && !_.isEmpty($state.params.inventory_source_search.page) && $state.params.inventory_source_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.inventory_source_search.page = (parseInt(reloadListStateParams.inventory_source_search.page)-1).toString();
+ }
if (parseInt($state.params.inventory_source_id) === inventory_source.id) {
- $state.go("inventories.edit.inventory_sources", {inventory_id: $scope.inventory_id}, {reload: true});
+ $state.go('^', reloadListStateParams, {reload: true});
} else {
- $state.go($state.current.name, null, {reload: true});
+ $state.go('.', reloadListStateParams, {reload: true});
}
Wait('stop');
});
diff --git a/awx/ui/client/src/inventory-scripts/list/list.controller.js b/awx/ui/client/src/inventory-scripts/list/list.controller.js
index 4aba6d6efb..cd28c440d4 100644
--- a/awx/ui/client/src/inventory-scripts/list/list.controller.js
+++ b/awx/ui/client/src/inventory-scripts/list/list.controller.js
@@ -51,10 +51,18 @@ export default ['$rootScope', '$scope', 'Wait', 'InventoryScriptsList',
Rest.setUrl(url);
Rest.destroy()
.success(function() {
+
+ let reloadListStateParams = null;
+
+ if($scope.inventory_scripts.length === 1 && $state.params.inventory_script_search && !_.isEmpty($state.params.inventory_script_search.page) && $state.params.inventory_script_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.inventory_script_search.page = (parseInt(reloadListStateParams.inventory_script_search.page)-1).toString();
+ }
+
if (parseInt($state.params.inventory_script_id) === id) {
- $state.go('^', null, { reload: true });
+ $state.go('^', reloadListStateParams, { reload: true });
} else {
- $state.go('.', null, { reload: true });
+ $state.go('.', reloadListStateParams, { reload: true });
}
})
.error(function(data, status) {
diff --git a/awx/ui/client/src/jobs/factories/delete-job.factory.js b/awx/ui/client/src/jobs/factories/delete-job.factory.js
index 05f29d0131..0bc75eb2e8 100644
--- a/awx/ui/client/src/jobs/factories/delete-job.factory.js
+++ b/awx/ui/client/src/jobs/factories/delete-job.factory.js
@@ -70,7 +70,14 @@ export default
scope.$emit(callback, action_label);
}
else {
- $state.reload();
+ let reloadListStateParams = null;
+
+ if(scope.jobs.length === 1 && $state.params.job_search && !_.isEmpty($state.params.job_search.page) && $state.params.job_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.job_search.page = (parseInt(reloadListStateParams.job_search.page)-1).toString();
+ }
+
+ $state.go('.', reloadListStateParams, {reload: true});
Wait('stop');
}
})
diff --git a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js
index 6d08e74b55..ba11f5cd9d 100644
--- a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js
+++ b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js
@@ -165,10 +165,18 @@
Rest.setUrl(url);
Rest.destroy()
.success(function() {
+
+ let reloadListStateParams = null;
+
+ if($scope.notification_templates.length === 1 && $state.params.notification_template_search && !_.isEmpty($state.params.notification_template_search.page) && $state.params.notification_template_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.notification_template_search.page = (parseInt(reloadListStateParams.notification_template_search.page)-1).toString();
+ }
+
if (parseInt($state.params.notification_template_id) === id) {
- $state.go("^", null, { reload: true });
+ $state.go("^", reloadListStateParams, { reload: true });
} else {
- $state.go('.', null, {reload: true});
+ $state.go('.', reloadListStateParams, {reload: true});
}
Wait('stop');
})
diff --git a/awx/ui/client/src/organizations/list/organizations-list.controller.js b/awx/ui/client/src/organizations/list/organizations-list.controller.js
index bf9640db26..6c259e1eef 100644
--- a/awx/ui/client/src/organizations/list/organizations-list.controller.js
+++ b/awx/ui/client/src/organizations/list/organizations-list.controller.js
@@ -145,10 +145,18 @@ export default ['$stateParams', '$scope', '$rootScope',
Rest.destroy()
.success(function() {
Wait('stop');
+
+ let reloadListStateParams = null;
+
+ if($scope.organizations.length === 1 && $state.params.organization_search && !_.isEmpty($state.params.organization_search.page) && $state.params.organization_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.organization_search.page = (parseInt(reloadListStateParams.organization_search.page)-1).toString();
+ }
+
if (isDeletedOrganizationBeingEdited(id, parseInt($stateParams.organization_id)) === true) {
- $state.go('^', null, { reload: true });
+ $state.go('^', reloadListStateParams, { reload: true });
} else {
- $state.reload('organizations');
+ $state.go('.', reloadListStateParams, { reload: true });
}
})
.error(function(data, status) {
diff --git a/awx/ui/client/src/projects/list/projects-list.controller.js b/awx/ui/client/src/projects/list/projects-list.controller.js
index e70c12f44d..5c98a1112a 100644
--- a/awx/ui/client/src/projects/list/projects-list.controller.js
+++ b/awx/ui/client/src/projects/list/projects-list.controller.js
@@ -179,10 +179,18 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
Rest.setUrl(url);
Rest.destroy()
.success(function() {
+
+ let reloadListStateParams = null;
+
+ if($scope.projects.length === 1 && $state.params.project_search && !_.isEmpty($state.params.project_search.page) && $state.params.project_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.project_search.page = (parseInt(reloadListStateParams.project_search.page)-1).toString();
+ }
+
if (parseInt($state.params.project_id) === id) {
- $state.go("^", null, { reload: true });
+ $state.go("^", reloadListStateParams, { reload: true });
} else {
- $state.go('.', null, {reload: true});
+ $state.go('.', reloadListStateParams, {reload: true});
}
})
.error(function (data, status) {
diff --git a/awx/ui/client/src/scheduler/factories/delete-schedule.factory.js b/awx/ui/client/src/scheduler/factories/delete-schedule.factory.js
index 7c75882966..45b8eca7bb 100644
--- a/awx/ui/client/src/scheduler/factories/delete-schedule.factory.js
+++ b/awx/ui/client/src/scheduler/factories/delete-schedule.factory.js
@@ -25,11 +25,19 @@ export default
.success(function () {
$('#prompt-modal').modal('hide');
scope.$emit(callback, id);
- if (new RegExp('/' + id + '$').test($location.$$url)) {
- $location.url($location.url().replace(/[/][0-9]+$/, "")); // go to list view
+
+ let reloadListStateParams = null;
+
+ if(scope.schedules.length === 1 && $state.params.schedule_search && !_.isEmpty($state.params.schedule_search.page) && $state.params.schedule_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.schedule_search.page = (parseInt(reloadListStateParams.schedule_search.page)-1).toString();
+ }
+
+ if (parseInt($state.params.schedule_id) === id) {
+ $state.go('^', reloadListStateParams, {reload: true});
}
else{
- $state.go('.', null, {reload: true});
+ $state.go('.', reloadListStateParams, {reload: true});
}
})
.error(function (data, status) {
diff --git a/awx/ui/client/src/teams/list/teams-list.controller.js b/awx/ui/client/src/teams/list/teams-list.controller.js
index ffea0daea6..80ed78c241 100644
--- a/awx/ui/client/src/teams/list/teams-list.controller.js
+++ b/awx/ui/client/src/teams/list/teams-list.controller.js
@@ -51,10 +51,18 @@ export default ['$scope', 'Rest', 'TeamList', 'Prompt',
.success(function() {
Wait('stop');
$('#prompt-modal').modal('hide');
+
+ let reloadListStateParams = null;
+
+ if($scope.teams.length === 1 && $state.params.team_search && !_.isEmpty($state.params.team_search.page) && $state.params.team_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.team_search.page = (parseInt(reloadListStateParams.team_search.page)-1).toString();
+ }
+
if (parseInt($state.params.team_id) === id) {
- $state.go('^', null, { reload: true });
+ $state.go('^', reloadListStateParams, { reload: true });
} else {
- $state.go('.', null, { reload: true });
+ $state.go('.', reloadListStateParams, { reload: true });
}
})
.error(function(data, status) {
diff --git a/awx/ui/client/src/templates/list/templates-list.controller.js b/awx/ui/client/src/templates/list/templates-list.controller.js
index b43e3f0232..664c94f70c 100644
--- a/awx/ui/client/src/templates/list/templates-list.controller.js
+++ b/awx/ui/client/src/templates/list/templates-list.controller.js
@@ -105,11 +105,19 @@ export default ['$scope', '$rootScope',
function handleSuccessfulDelete(isWorkflow) {
let stateParamId = isWorkflow ? $state.params.workflow_job_template_id : $state.params.job_template_id;
+
+ let reloadListStateParams = null;
+
+ if($scope.templates.length === 1 && $state.params.template_search && !_.isEmpty($state.params.template_search.page) && $state.params.template_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.template_search.page = (parseInt(reloadListStateParams.template_search.page)-1).toString();
+ }
+
if (parseInt(stateParamId) === template.id) {
// Move the user back to the templates list
- $state.go("templates", null, {reload: true});
+ $state.go("templates", reloadListStateParams, {reload: true});
} else {
- $state.go(".", null, {reload: true});
+ $state.go(".", reloadListStateParams, {reload: true});
}
Wait('stop');
}
diff --git a/awx/ui/client/src/users/list/users-list.controller.js b/awx/ui/client/src/users/list/users-list.controller.js
index 60a41def0a..d3dd6a7df8 100644
--- a/awx/ui/client/src/users/list/users-list.controller.js
+++ b/awx/ui/client/src/users/list/users-list.controller.js
@@ -63,6 +63,14 @@ export default ['$scope', '$rootScope', 'Rest', 'UserList', 'Prompt',
Rest.setUrl(url);
Rest.destroy()
.success(function() {
+
+ let reloadListStateParams = null;
+
+ if($scope.users.length === 1 && $state.params.user_search && !_.isEmpty($state.params.user_search.page) && $state.params.user_search.page !== '1') {
+ reloadListStateParams = _.cloneDeep($state.params);
+ reloadListStateParams.user_search.page = (parseInt(reloadListStateParams.user_search.page)-1).toString();
+ }
+
if (parseInt($state.params.user_id) === id) {
$state.go('^', null, { reload: true });
} else {