Improved direct group assignment for agents.

This commit is contained in:
Martin Edenhofer 2017-09-11 04:19:16 +02:00
parent 003d60d6b1
commit 714cede3e2
4 changed files with 41 additions and 52 deletions

View file

@ -67,9 +67,14 @@ class App.UiElement.user_permission
item = $( App.view('generic/user_permission')(
attribute: attribute
roles: roles
groups: groups
params: params
rolesSelected: rolesSelected
) )
item.find('.js-groups').html(App.view('generic/user_permission_group')(
attribute: attribute
groups: groups
params: params
groupsSelected: groupsSelected
hideGroups: hideGroups
groupAccesses: App.Group.accesses()
@ -101,7 +106,11 @@ class App.UiElement.user_permission
# if role with groups plugin is deselected, hide group selection
if !checked
if rolesWithGroupPlugin[role_id] is 'group'
show = false
for role_id, group of rolesWithGroupPlugin
if item.find("[name=role_ids][value=#{role_id}]").prop('checked')
show = true
if !show
item.find('.js-groupList').addClass('hidden')
# select groups if only one is available

View file

@ -40,6 +40,5 @@ class App.Group extends App.Model
read: 'Read'
create: 'Create'
change: 'Change'
delete: 'Delete'
overview: 'Overview'
full: 'Full'

View file

@ -1,18 +1,4 @@
<div class="checkbox <%= @attribute.class %> checkbox">
<% showGroups = false %>
<% for role in @roles: %>
<% if role.permissions: %>
<% for permission in role.permissions: %>
<% if _.contains(permission.preferences.plugin, 'groups'): %>
<% if showGroups is true: %>
<% showGroups = false %>
<% break %>
<% end %>
<% showGroups = true %>
<% end %>
<% end %>
<% end %>
<% end %>
<% for role in @roles: %>
<label class="inline-label checkbox-replacement">
<input type="checkbox" value="<%= role.id %>" name="role_ids" <% if @rolesSelected[role.id]: %>checked<% end %>/>
@ -20,40 +6,6 @@
<%- @Icon('checkbox-checked', 'icon-checked') %>
<span class="label-text"><%- @T(role.displayName()) %> <% if role.note: %>- <span class="help-text"><%- @T(role.note) %></span><% end %></span>
</label>
<% if role.permissions: %>
<% for permission in role.permissions: %>
<% if showGroups is true && _.contains(permission.preferences.plugin, 'groups'): %>
<div style="padding-left: 18px; padding-top: 10px;" class="js-groupList <% if @hideGroups: %>js-groupListHide hidden<% end %>">
<table class="settings-list">
<thead>
<th><%- @T('Group') %>
<% for key, text of @groupAccesses: %>
<th><%- @T(text) %>
<% end %>
<tbody>
<% for group in @groups: %>
<% permissions = [] %>
<% if @params.group_ids && @params.group_ids[group.id]: %>
<% permissions = @params.group_ids[group.id] %>
<% end %>
<tr>
<td>
<%= group.displayName() %>
<% for key, text of @groupAccesses: %>
<td>
<label class="inline-label checkbox-replacement">
<input class="js-groupListItem" type="checkbox" value="<%= key %>" name="group_ids::<%= group.id %>" <% if _.contains(permissions, key): %>checked<% end %>/>
<%- @Icon('checkbox', 'icon-unchecked') %>
<%- @Icon('checkbox-checked', 'icon-checked') %>
</label>
<% end %>
</tr>
<% end %>
</table>
</div>
<% break %>
<% end %>
<% end %>
<% end %>
<% end %>
<div class="js-groups"></div>
</div>

View file

@ -0,0 +1,29 @@
<div style="padding-left: 18px; padding-top: 10px; width: 95%;" class="js-groupList <% if @hideGroups: %>js-groupListHide hidden<% end %>">
<hr>
<table class="settings-list" style="width: 100%;">
<thead>
<th><%- @T('Group') %>
<% for key, text of @groupAccesses: %>
<th><%- @T(text) %>
<% end %>
<tbody>
<% for group in @groups: %>
<% permissions = [] %>
<% if @params.group_ids && @params.group_ids[group.id]: %>
<% permissions = @params.group_ids[group.id] %>
<% end %>
<tr>
<td>
<%= group.displayName() %>
<% for key, text of @groupAccesses: %>
<td>
<label class="inline-label checkbox-replacement">
<input class="js-groupListItem" type="checkbox" value="<%= key %>" name="group_ids::<%= group.id %>" <% if _.contains(permissions, key): %>checked<% end %>/>
<%- @Icon('checkbox', 'icon-unchecked') %>
<%- @Icon('checkbox-checked', 'icon-checked') %>
</label>
<% end %>
</tr>
<% end %>
</table>
</div>