diff --git a/awx/ui/client/src/access/add-rbac-user-team/main.js b/awx/ui/client/src/access/add-rbac-user-team/main.js index 547815a1d7..94a1fa7c60 100644 --- a/awx/ui/client/src/access/add-rbac-user-team/main.js +++ b/awx/ui/client/src/access/add-rbac-user-team/main.js @@ -5,8 +5,9 @@ *************************************************/ import addRbacUserTeamDirective from './rbac-user-team.directive'; -import rbacMultiselect from '../rbac-multiselect/main'; +import rbacSelectedList from './rbac-selected-list.directive'; export default - angular.module('AddRbacUserTeamModule', [rbacMultiselect.name]) - .directive('addRbacUserTeam', addRbacUserTeamDirective); + angular.module('AddRbacUserTeamModule', []) + .directive('addRbacUserTeam', addRbacUserTeamDirective) + .directive('rbacSelectedList', rbacSelectedList); \ No newline at end of file diff --git a/awx/ui/client/src/access/add-rbac-user-team/rbac-selected-list.directive.js b/awx/ui/client/src/access/add-rbac-user-team/rbac-selected-list.directive.js new file mode 100644 index 0000000000..131a060523 --- /dev/null +++ b/awx/ui/client/src/access/add-rbac-user-team/rbac-selected-list.directive.js @@ -0,0 +1,108 @@ +/************************************************* + * Copyright (c) 2016 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +/* jshint unused: vars */ +export default ['$compile','templateUrl', 'i18n', 'generateList', + 'ProjectList', 'TemplateList', 'InventoryList', 'CredentialList', + function($compile, templateUrl, i18n, generateList, + ProjectList, TemplateList, InventoryList, CredentialList) { + return { + restrict: 'E', + scope: { + resourceType: "=", + collection: "=", + selected: "=" + }, + link: function(scope, element, attrs) { + console.log(scope.resourceType) + let listMap, list, list_html; + + listMap = { + projects: ProjectList, + job_templates: TemplateList, + workflow_templates: TemplateList, + inventories: InventoryList, + credentials: CredentialList + }; + + list = _.cloneDeep(listMap[scope.resourceType]) + + list.fieldActions = { + remove: { + ngClick: `removeSelection(${list.iterator}, resourceType)`, + icon: 'fa-remove', + awToolTip: i18n._(`Remove ${list.iterator}`), + label: i18n._('Remove'), + class: 'btn-sm' + } + }; + delete list.actions; + + list.listTitleBadge = false; + + switch(scope.resourceType){ + + case 'projects': + list.fields = { + name: list.fields.name, + scm_type: list.fields.scm_type + }; + break; + + case 'inventories': + list.fields = { + name: list.fields.name, + organization: list.fields.organization + }; + break; + + case 'job_templates': + list.name = 'job_templates'; + list.iterator = 'job_template'; + list.fields = { + name: list.fields.name, + description: list.fields.description + }; + break; + + case 'workflow_templates': + list.name = 'workflow_templates'; + list.iterator = 'workflow_template', + list.basePath = 'workflow_job_templates'; + list.fields = { + name: list.fields.name, + description: list.fields.description + }; + break; + + default: + list.fields = { + name: list.fields.name, + description: list.fields.description + }; + } + + list.fields = _.each(list.fields, (field) => field.nosort = true); + + list_html = generateList.build({ + mode: 'edit', + list: list, + related: false, + title: false, + showSearch: false, + paginate: false + }); + + scope.list = list; + scope[`${list.iterator}_dataset`] = scope.collection; + scope[list.name] = scope.collection; + + element.append(list_html); + $compile(element.contents())(scope); + } + }; + } +]; diff --git a/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.controller.js b/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.controller.js index 9888370e54..3e41460487 100644 --- a/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.controller.js +++ b/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.controller.js @@ -18,7 +18,7 @@ function(rootScope, scope, $state, GetBasePath, Rest, $q, Wait, ProcessErrors) { function init(){ - let resources = ['templates', 'projects', 'inventories', 'credentials']; + let resources = ['job_templates', 'workflow_templates', 'projects', 'inventories', 'credentials']; // data model: // selected - keyed by type of resource diff --git a/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.directive.js b/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.directive.js index 8790410ee3..ced1ceb744 100644 --- a/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.directive.js +++ b/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.directive.js @@ -16,6 +16,7 @@ export default ['templateUrl', controller: controller, templateUrl: templateUrl('access/add-rbac-user-team/rbac-user-team'), link: function(scope, element, attrs) { + scope.selectTab('job_templates'); $('#add-permissions-modal').modal('show'); window.scrollTo(0, 0); } diff --git a/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.partial.html b/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.partial.html index f148a25d70..dc330bc035 100644 --- a/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.partial.html +++ b/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.partial.html @@ -35,7 +35,7 @@