diff options
author | Christian Hofmaier | 2017-04-07 16:00:50 +0200 |
---|---|---|
committer | Christian Hofmaier | 2017-04-07 16:00:50 +0200 |
commit | 094fbb64a8a373a723d5497746616a080d981e7c (patch) | |
tree | 30dcd1afb6e3f2a1e8ee6762760753923386db04 /modules-available/permissionmanager/templates/userstable.html | |
parent | [permission-manager] renamed some files, moved html generation to templates, (diff) | |
download | slx-admin-094fbb64a8a373a723d5497746616a080d981e7c.tar.gz slx-admin-094fbb64a8a373a723d5497746616a080d981e7c.tar.xz slx-admin-094fbb64a8a373a723d5497746616a080d981e7c.zip |
[permission-manager] filter for roles in user and location table, changed structure of role-spans in both tables
Diffstat (limited to 'modules-available/permissionmanager/templates/userstable.html')
-rw-r--r-- | modules-available/permissionmanager/templates/userstable.html | 119 |
1 files changed, 88 insertions, 31 deletions
diff --git a/modules-available/permissionmanager/templates/userstable.html b/modules-available/permissionmanager/templates/userstable.html index 3db1ebdb..e15228d5 100644 --- a/modules-available/permissionmanager/templates/userstable.html +++ b/modules-available/permissionmanager/templates/userstable.html @@ -1,27 +1,40 @@ -<form method="post" action="?do=permissionmanager"> +<form method="post" action="?do=permissionmanager&show=users"> <input type="hidden" name="token" value="{{token}}"> - <button class="btn btn-success" type="button" data-toggle="modal" data-target="#addRoleToUserModal"><span class="glyphicon glyphicon-share-alt"></span> {{lang_addRole}}</button> - <button class="btn btn-danger" type="button" data-toggle="modal" data-target="#removeRoleFromUserModal"><span class="glyphicon glyphicon-trash"></span> {{lang_removeRole}}</button> + + <div class="row"> + <div class="col-md-4"> + <button class="btn btn-success" type="button" data-toggle="modal" data-target="#addRoleToUserModal"><span class="glyphicon glyphicon-share-alt"></span> {{lang_addRole}}</button> + <button class="btn btn-danger" type="button" data-toggle="modal" data-target="#removeRoleFromUserModal"><span class="glyphicon glyphicon-trash"></span> {{lang_removeRole}}</button> + </div> + <div class="col-md-4 text-left"> + <select multiple name="roles[]" id="select-role"> + <option value></option> + {{#roles}} + <option value="{{roleId}}">{{roleName}}</option> + {{/roles}} + </select> + </div> + </div> <div class="row"> <div class="col-md-12"> <table id="usersTable" class="table table-condensed table-hover"> <thead> - <tr> - <th data-sort="string">{{lang_Users}}</th> - <th>{{lang_Roles}}</th> - <th data-sort="int" data-sort-default="desc">{{lang_Selected}}</th> - </tr> + <tr> + <th data-sort="string">{{lang_Users}}</th> + <th>{{lang_Roles}}</th> + <th data-sort="int" data-sort-default="desc">{{lang_Selected}}</th> + </tr> </thead> <tbody> {{#user}} - <tr> - <td>{{name}}</td> + <tr data-selectizeCount='0'> + <td>{{username}}</td> <td> - {{#role}} - <span class="label label-default customSpanMargin">{{.}}</span> - {{/role}} + {{#roles}} + <span class="label label-default customSpanMargin roleId-{{roleId}}">{{roleName}}</span> + {{/roles}} </td> <td data-sort-value="0"> <div class="checkbox"> @@ -49,25 +62,25 @@ <div class="col-md-12 scrollingTable"> <table id="addRoleToUserTable" class="table table-condensed table-hover"> <thead> - <tr> - <th data-sort="string">{{lang_Roles}}</th> - <th data-sort="int" data-sort-default="desc">{{lang_Selected}}</th> - </tr> + <tr> + <th data-sort="string">{{lang_Roles}}</th> + <th data-sort="int" data-sort-default="desc">{{lang_Selected}}</th> + </tr> </thead> - <tbody> - {{#roles}} - <tr> - <td>{{roleName}}</td> - <td data-sort-value="0"> - <div class="checkbox"> - <input id="add{{roleId}}" type="checkbox" name="roles[]" value='{{roleId}}'> - <label for="add{{roleId}}"></label> - </div> - </td> - </tr> - {{/roles}} - </tbody> + <tbody> + {{#roles}} + <tr> + <td>{{roleName}}</td> + <td data-sort-value="0"> + <div class="checkbox"> + <input id="add{{roleId}}" type="checkbox" name="roles[]" value='{{roleId}}'> + <label for="add{{roleId}}"></label> + </div> + </td> + </tr> + {{/roles}} + </tbody> </table> </div> </div> @@ -138,6 +151,51 @@ }); + var selectize = $('#select-role').selectize({ + allowEmptyOption: false, + maxItems: null, + highlight: false, + hideSelected: true, + create: false, + placeholder: "{{lang_selectizePlaceholder}}", + plugins: [ "remove_button" ] + })[0].selectize; + + // If Site gets refreshed, all data-selectizeCounts will be reset to 0, so delete the filters from the selectize + selectize.clear(); + + selectize.on('item_add', function(value, $item) { + // When first item gets added the filter isn't empty anymore, so hide all rows + if (selectize.items.length === 1) { + $('#locationsTable').find('tr').hide(); + } + // Find all rows which shall be shown and increase their counter by 1 + $(".roleId-"+value).closest("tr").each(function() { + $(this).data("selectizeCount", $(this).data("selectizeCount") + 1); + $(this).show(); + }); + }); + + selectize.on('item_remove', function(value, $item) { + // When no items in the filter, show all rows again + if (selectize.items.length === 0) { + $('#locationsTable').find('tr').show(); + } else { + // Find all rows which have the delete role, decrease their counter by 1 + $(".roleId-"+value).closest("tr").each(function() { + $(this).data("selectizeCount", $(this).data("selectizeCount") - 1); + // If counter is 0, hide the row (no filter given to show the row anymore) + if ($(this).data("selectizeCount") === 0) { + $(this).closest("tr").hide(); + } + }); + } + }); + + $("form input").keydown(function(e) { + if (e.keyCode === 13) e.preventDefault(); + }); + }); @@ -156,5 +214,4 @@ .prop("checked", "") .end(); } - </script>
\ No newline at end of file |