Properly navigate user after jt/wfjt deletion

This commit is contained in:
Michael Abashian
2017-01-28 12:05:15 -05:00
parent e5f7556fc2
commit aee30a7fc6

View File

@@ -113,10 +113,11 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest',
body: '<div class="Prompt-bodyQuery">Are you sure you want to delete the template below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(template.name) + '</div>', body: '<div class="Prompt-bodyQuery">Are you sure you want to delete the template below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(template.name) + '</div>',
action: function() { action: function() {
function handleSuccessfulDelete() { function handleSuccessfulDelete(isWorkflow) {
// TODO: look at this let stateParamId = isWorkflow ? $state.params.workflow_job_template_id : $state.params.job_template_id;
if (parseInt($state.params.id) === template.id) { if (parseInt(stateParamId) === template.id) {
$state.go("^", null, {reload: true}); // Move the user back to the templates list
$state.go("templates", null, {reload: true});
} else { } else {
$state.go(".", null, {reload: true}); $state.go(".", null, {reload: true});
} }
@@ -128,7 +129,7 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest',
if(template.type && (template.type === 'Workflow Job Template' || template.type === 'workflow_job_template')) { if(template.type && (template.type === 'Workflow Job Template' || template.type === 'workflow_job_template')) {
TemplatesService.deleteWorkflowJobTemplate(template.id) TemplatesService.deleteWorkflowJobTemplate(template.id)
.then(function () { .then(function () {
handleSuccessfulDelete(); handleSuccessfulDelete(true);
}, function (data) { }, function (data) {
Wait('stop'); Wait('stop');
ProcessErrors($scope, data, data.status, null, { hdr: 'Error!', ProcessErrors($scope, data, data.status, null, { hdr: 'Error!',