diff --git a/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js b/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js index a42b9acb1d..e42d67659d 100644 --- a/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js +++ b/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js @@ -6,11 +6,11 @@ export default ['$scope', '$rootScope', '$location', '$log', '$stateParams', 'Rest', 'Alert', 'Prompt', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', - 'GetBasePath', 'JobTemplateForm', 'InitiatePlaybookRun', 'Wait', + 'GetBasePath', 'JobTemplateForm', 'InitiatePlaybookRun', 'Wait', 'TemplateCopyService', '$compile', '$state', 'OrgJobTemplateList', 'OrgJobTemplateDataset', 'QuerySet', function($scope, $rootScope, $location, $log, $stateParams, Rest, Alert, Prompt, ReturnToCaller, ClearScope, ProcessErrors, - GetBasePath, JobTemplateForm, InitiatePlaybookRun, Wait, + GetBasePath, JobTemplateForm, InitiatePlaybookRun, Wait, TemplateCopyService, $compile, $state, OrgJobTemplateList, Dataset, qs) { var list = OrgJobTemplateList, @@ -71,12 +71,8 @@ export default ['$scope', '$rootScope', '$location', '$log', }); } - $scope.addJobTemplate = function() { - $state.go('jobTemplates.add'); - }; - $scope.editJobTemplate = function(id) { - $state.go('jobTemplates.edit', { id: id }); + $state.go('templates.editJobTemplate', { job_template_id: id }); }; $scope.submitJob = function(id) { @@ -87,8 +83,23 @@ export default ['$scope', '$rootScope', '$location', '$log', $state.go('jobTemplateSchedules', { id: id }); }; - $scope.formCancel = function() { - $state.go('organizations'); + $scope.copyTemplate = function(id) { + Wait('start'); + TemplateCopyService.get(id) + .success(function(res){ + TemplateCopyService.set(res) + .success(function(res){ + Wait('stop'); + if(res.type && res.type === 'job_template') { + $state.go('templates.editJobTemplate', {job_template_id: res.id}, {reload: true}); + } + }); + }) + .error(function(res, status){ + ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', + msg: 'Call failed. Return status: '+ status}); + }); + }; } diff --git a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js index 517e37c8c0..33f4bf7226 100644 --- a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js +++ b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js @@ -295,13 +295,24 @@ export default [{ delete list.actions; // @issue Why is the delete action unavailable in this view? delete list.fieldActions.delete; - list.emptyListText = "This list is populated by job templates added from the Job Templates section"; + delete list.fields.type; + list.listTitle = N_('Job Templates'); + list.emptyListText = "This list is populated by job templates added from the Job Templates section"; list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12"; list.iterator = 'job_template'; list.name = 'job_templates'; list.basePath = "job_templates"; - list.fields.type.ngBind = "job_template.type_label"; list.fields.smart_status.ngInclude = "'/static/partials/organizations-job-template-smart-status.html'"; + list.fields.name.ngHref = '#/templates/job_template/{{job_template.id}}'; + list.fieldActions.submit.ngClick = 'submitJob(job_template.id)'; + list.fieldActions.submit.ngShow = 'job_template.summary_fields.user_capabilities.start'; + list.fieldActions.schedule.ngClick = 'scheduleJob(job_template.id)'; + list.fieldActions.copy.ngClick = 'copyTemplate(job_template.id)'; + list.fieldActions.copy.ngShow = 'job_template.summary_fields.user_capabilities.copy'; + list.fieldActions.edit.ngClick = "editJobTemplate(job_template.id)"; + list.fieldActions.edit.ngShow = 'job_template.summary_fields.user_capabilities.edit'; + list.fieldActions.view.ngClick = "editJobTemplate(job_template.id)"; + list.fieldActions.view.ngShow = '!job_template.summary_fields.user_capabilities.edit'; return list; }], OrgJobTemplateDataset: ['OrgJobTemplateList', 'QuerySet', '$stateParams', 'GetBasePath',