From 54e1d63bb2240cf0ce872b9cae91d74b5f63988c Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 21 Nov 2016 14:23:32 -0500 Subject: [PATCH] Job Template/Workflow Job Template related tabs work. Implemented WFJT notifications and permissions. --- awx/ui/client/src/forms/JobTemplates.js | 6 ++++- awx/ui/client/src/forms/Workflows.js | 5 +++- .../shared/toggle-notification.factory.js | 2 +- awx/ui/client/src/shared/form-generator.js | 25 +++++++++++-------- .../job-template-edit.controller.js | 3 +-- .../render/multiple-choice.directive.js | 2 +- .../render/survey-question.directive.js | 2 +- .../edit-workflow/workflow-edit.controller.js | 21 ++++++++++++++-- 8 files changed, 47 insertions(+), 19 deletions(-) diff --git a/awx/ui/client/src/forms/JobTemplates.js b/awx/ui/client/src/forms/JobTemplates.js index 6d91ef31d7..11a16701da 100644 --- a/awx/ui/client/src/forms/JobTemplates.js +++ b/awx/ui/client/src/forms/JobTemplates.js @@ -28,6 +28,7 @@ export default activeEditState: 'templates.editJobTemplate', // (optional) array of supporting templates to ng-include inside generated html include: ['/static/partials/survey-maker-modal.html'], + detailsClick: "$state.go('templates.editJobTemplate')", fields: { name: { @@ -420,6 +421,7 @@ export default iterator: 'permission', index: false, open: false, + ngClick: "$state.go('templates.editJobTemplate.permissions')", actions: { add: { ngClick: "$state.go('.add')", @@ -482,11 +484,13 @@ export default for (itm in JobTemplateFormObject.related) { if (JobTemplateFormObject.related[itm].include === "NotificationsList") { - JobTemplateFormObject.related[itm] = NotificationsList; + JobTemplateFormObject.related[itm] = _.clone(NotificationsList); + JobTemplateFormObject.related[itm].ngClick = "$state.go('templates.editJobTemplate.notifications')"; JobTemplateFormObject.related[itm].generateList = true; // tell form generator to call list generator and inject a list } if (JobTemplateFormObject.related[itm].include === "CompletedJobsList") { JobTemplateFormObject.related[itm] = CompletedJobsList; + JobTemplateFormObject.related[itm].ngClick = "$state.go('templates.editJobTemplate.completed_jobs')"; JobTemplateFormObject.related[itm].generateList = true; } } diff --git a/awx/ui/client/src/forms/Workflows.js b/awx/ui/client/src/forms/Workflows.js index b40839bea3..293536aadb 100644 --- a/awx/ui/client/src/forms/Workflows.js +++ b/awx/ui/client/src/forms/Workflows.js @@ -25,6 +25,7 @@ export default stateTree: 'templates', activeEditState: 'templates.editWorkflowJobTemplate', tabs: true, + detailsClick: "$state.go('templates.editWorkflowJobTemplate')", fields: { name: { @@ -114,6 +115,7 @@ export default iterator: 'permission', index: false, open: false, + ngClick: "$state.go('templates.editWorkflowJobTemplate.permissions')", actions: { add: { ngClick: "$state.go('.add')", @@ -198,7 +200,8 @@ export default for (itm in WorkflowFormObject.related) { if (WorkflowFormObject.related[itm].include === "NotificationsList") { - WorkflowFormObject.related[itm] = NotificationsList; + WorkflowFormObject.related[itm] = _.clone(NotificationsList); + WorkflowFormObject.related[itm].ngClick = "$state.go('templates.editWorkflowJobTemplate.notifications')"; WorkflowFormObject.related[itm].generateList = true; // tell form generator to call list generator and inject a list } } diff --git a/awx/ui/client/src/notifications/shared/toggle-notification.factory.js b/awx/ui/client/src/notifications/shared/toggle-notification.factory.js index b5f1fea99a..2389a6bce2 100644 --- a/awx/ui/client/src/notifications/shared/toggle-notification.factory.js +++ b/awx/ui/client/src/notifications/shared/toggle-notification.factory.js @@ -22,7 +22,7 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', notifier_id = params.notifier.id, callback = params.callback, column = params.column, // notification_template_success/notification_template__error - url = params.url + "/"+ column + '/'; + url = params.url + "/" + column + '/'; if(!notifier[column]){ params = { diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 77bf4616d1..b7f82f9fab 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -1149,7 +1149,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += ""; if(this.mode === "edit"){ - html += `
` + + html += `
` + `${details}
`; for (itm in this.form.related) { collection = this.form.related[itm]; html += `
`; } @@ -1648,7 +1648,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat } else if (!field.subForm && currentSubForm !== undefined) { currentSubForm = undefined; - html += '
'; + html += ' '; } html += this.buildField(fld, field, options, this.form); @@ -1773,12 +1773,17 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat } } + + if(!_.isEmpty(this.form.related) && this.mode === "edit"){ + html += ``; + } + if (this.form.include){ _.forEach(this.form.include, (template) =>{ html += `
`; }); } - // console.log(html) + // console.log(html); return this.wrapPanel(html, options.noPanel); }, diff --git a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js index 0ce5645a3d..8bfa760941 100644 --- a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js +++ b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js @@ -166,8 +166,7 @@ export default } ToggleNotification({ scope: $scope, - url: defaultUrl, - id: id, + url: defaultUrl + id, notifier: notifier, column: column, callback: 'NotificationRefresh' diff --git a/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js b/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js index 556d78ad9a..1be5229456 100644 --- a/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js +++ b/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js @@ -38,7 +38,7 @@ export default isDisabled: '=ngDisabled', preview: '=' }, - templateUrl: templateUrl('job-templates/survey-maker/render/multiple-choice'), + templateUrl: templateUrl('templates/survey-maker/render/multiple-choice'), link: _.partial(link, $timeout, CreateSelect2) }; return directive; diff --git a/awx/ui/client/src/templates/survey-maker/render/survey-question.directive.js b/awx/ui/client/src/templates/survey-maker/render/survey-question.directive.js index 843d0b08f2..ed613e745b 100644 --- a/awx/ui/client/src/templates/survey-maker/render/survey-question.directive.js +++ b/awx/ui/client/src/templates/survey-maker/render/survey-question.directive.js @@ -119,7 +119,7 @@ export default isDisabled: '@ngDisabled', preview: '=' }, - templateUrl: templateUrl('job-templates/survey-maker/render/survey-question'), + templateUrl: templateUrl('templates/survey-maker/render/survey-question'), link: _.partial(link, $sce, $filter, Empty) }; diff --git a/awx/ui/client/src/templates/workflows/edit-workflow/workflow-edit.controller.js b/awx/ui/client/src/templates/workflows/edit-workflow/workflow-edit.controller.js index b719614929..4a9504ad51 100644 --- a/awx/ui/client/src/templates/workflows/edit-workflow/workflow-edit.controller.js +++ b/awx/ui/client/src/templates/workflows/edit-workflow/workflow-edit.controller.js @@ -8,12 +8,12 @@ [ '$scope', '$stateParams', 'WorkflowForm', 'GenerateForm', 'Alert', 'ProcessErrors', 'ClearScope', 'GetBasePath', '$q', 'ParseTypeChange', 'Wait', 'Empty', 'ToJSON', 'initSurvey', '$state', 'CreateSelect2', 'ParseVariableString', - 'TemplatesService', 'OrganizationList', 'Rest', 'WorkflowService', + 'TemplatesService', 'OrganizationList', 'Rest', 'WorkflowService', 'ToggleNotification', function( $scope, $stateParams, WorkflowForm, GenerateForm, Alert, ProcessErrors, ClearScope, GetBasePath, $q, ParseTypeChange, Wait, Empty, ToJSON, SurveyControllerInit, $state, CreateSelect2, ParseVariableString, - TemplatesService, OrganizationList, Rest, WorkflowService + TemplatesService, OrganizationList, Rest, WorkflowService, ToggleNotification ) { ClearScope(); @@ -616,6 +616,23 @@ $state.transitionTo('templates'); }; + $scope.toggleNotification = function(event, notifier_id, column) { + var notifier = this.notification; + try { + $(event.target).tooltip('hide'); + } + catch(e) { + // ignore + } + ToggleNotification({ + scope: $scope, + url: GetBasePath('workflow_job_templates') + id, + notifier: notifier, + column: column, + callback: 'NotificationRefresh' + }); + }; + init(); } ];