Improved direct group assignment for agents.
This commit is contained in:
parent
003d60d6b1
commit
714cede3e2
4 changed files with 41 additions and 52 deletions
|
@ -67,9 +67,14 @@ class App.UiElement.user_permission
|
||||||
item = $( App.view('generic/user_permission')(
|
item = $( App.view('generic/user_permission')(
|
||||||
attribute: attribute
|
attribute: attribute
|
||||||
roles: roles
|
roles: roles
|
||||||
groups: groups
|
|
||||||
params: params
|
params: params
|
||||||
rolesSelected: rolesSelected
|
rolesSelected: rolesSelected
|
||||||
|
) )
|
||||||
|
|
||||||
|
item.find('.js-groups').html(App.view('generic/user_permission_group')(
|
||||||
|
attribute: attribute
|
||||||
|
groups: groups
|
||||||
|
params: params
|
||||||
groupsSelected: groupsSelected
|
groupsSelected: groupsSelected
|
||||||
hideGroups: hideGroups
|
hideGroups: hideGroups
|
||||||
groupAccesses: App.Group.accesses()
|
groupAccesses: App.Group.accesses()
|
||||||
|
@ -101,7 +106,11 @@ class App.UiElement.user_permission
|
||||||
|
|
||||||
# if role with groups plugin is deselected, hide group selection
|
# if role with groups plugin is deselected, hide group selection
|
||||||
if !checked
|
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')
|
item.find('.js-groupList').addClass('hidden')
|
||||||
|
|
||||||
# select groups if only one is available
|
# select groups if only one is available
|
||||||
|
|
|
@ -40,6 +40,5 @@ class App.Group extends App.Model
|
||||||
read: 'Read'
|
read: 'Read'
|
||||||
create: 'Create'
|
create: 'Create'
|
||||||
change: 'Change'
|
change: 'Change'
|
||||||
delete: 'Delete'
|
|
||||||
overview: 'Overview'
|
overview: 'Overview'
|
||||||
full: 'Full'
|
full: 'Full'
|
||||||
|
|
|
@ -1,18 +1,4 @@
|
||||||
<div class="checkbox <%= @attribute.class %> checkbox">
|
<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: %>
|
<% for role in @roles: %>
|
||||||
<label class="inline-label checkbox-replacement">
|
<label class="inline-label checkbox-replacement">
|
||||||
<input type="checkbox" value="<%= role.id %>" name="role_ids" <% if @rolesSelected[role.id]: %>checked<% end %>/>
|
<input type="checkbox" value="<%= role.id %>" name="role_ids" <% if @rolesSelected[role.id]: %>checked<% end %>/>
|
||||||
|
@ -20,40 +6,6 @@
|
||||||
<%- @Icon('checkbox-checked', 'icon-checked') %>
|
<%- @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>
|
<span class="label-text"><%- @T(role.displayName()) %> <% if role.note: %>- <span class="help-text"><%- @T(role.note) %></span><% end %></span>
|
||||||
</label>
|
</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 %>
|
<% end %>
|
||||||
|
<div class="js-groups"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -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>
|
Loading…
Reference in a new issue