mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
rough pass on rbac-selected-list directive
This commit is contained in:
parent
c753328a0b
commit
1090d74ea0
@ -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);
|
@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
];
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
<div class="Form-tab"
|
||||
ng-click="selectTab('job_templates')"
|
||||
ng-class="{'is-selected': tab.job_templates }">
|
||||
Templates
|
||||
Job Templates
|
||||
</div>
|
||||
<div class="Form-tab"
|
||||
ng-click="selectTab('workflow_templates')"
|
||||
@ -95,10 +95,16 @@
|
||||
</div>
|
||||
<div class="Form-tabHolder">
|
||||
<div class="Form-tab"
|
||||
ng-click="selectTab('templates')"
|
||||
ng-class="{'is-selected': tab.templates }"
|
||||
ng-show="showSection2Tab('templates')">
|
||||
Templates
|
||||
ng-click="selectTab('job_templates')"
|
||||
ng-class="{'is-selected': tab.job_templates }"
|
||||
ng-show="showSection2Tab('job_templates')">
|
||||
Job Templates
|
||||
</div>
|
||||
<div class="Form-tab"
|
||||
ng-click="selectTab('workflow_templates')"
|
||||
ng-class="{'is-selected': tab.workflow_templates }"
|
||||
ng-show="showSection2Tab('workflow_templates')">
|
||||
Workflow Templates
|
||||
</div>
|
||||
<div class="Form-tab"
|
||||
ng-click="selectTab('projects')"
|
||||
@ -134,30 +140,19 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form name="multiselectRoles" novalidate>
|
||||
<!-- type of selected resources -->
|
||||
<div ng-repeat="(type, list) in selected">
|
||||
<!-- controllerAs: 'rbac' -->
|
||||
<div class="AddPermissions-roleRow"
|
||||
ng-repeat="resource in list"
|
||||
ng-show="tab[type]">
|
||||
<div class="AddPermissions-roleName">
|
||||
<span class="AddPermissions-roleNameVal">
|
||||
{{ resource.name }}
|
||||
</span>
|
||||
<span class="AddPermissions-roleType">
|
||||
{{ resource.type }}
|
||||
</span>
|
||||
</div>
|
||||
<rbac-multiselect-role class="AddPermissions-roleSelect" roles="resource.summary_fields.object_roles" model="resource.roles">
|
||||
</rbac-multiselect-role>
|
||||
<button class="AddPermissions-roleRemove"
|
||||
ng-click="removeSelection(resource, type)">
|
||||
<i class="fa fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- role drop-down -->
|
||||
|
||||
<!-- lists of selected resources -->
|
||||
<!-- (type, collection) => ('resource', {id: {}, ... }) -->
|
||||
<div ng-repeat="(type, collection) in selected">
|
||||
<rbac-selected-list
|
||||
resource-type="type"
|
||||
collection="collection"
|
||||
selected="selected">
|
||||
</rbac-selected-list>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- end section 2 -->
|
||||
</div>
|
||||
|
@ -443,12 +443,14 @@ export default ['$location', '$compile', '$rootScope', 'Attr', 'Icon',
|
||||
html += "</div>\n";
|
||||
}
|
||||
|
||||
html += `<paginate
|
||||
if (options.paginate === undefined || options.paginate === true) {
|
||||
html += `<paginate
|
||||
base-path="${list.basePath || list.name}"
|
||||
collection="${list.name}"
|
||||
dataset="${list.iterator}_dataset"
|
||||
iterator="${list.iterator}">
|
||||
</paginate></div>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user