diff options
author | Udo Walter | 2017-04-07 15:49:54 +0200 |
---|---|---|
committer | Udo Walter | 2017-04-07 15:49:54 +0200 |
commit | d033483d3ed9e05f1109a3713ec6a3df883a1dae (patch) | |
tree | 13df2276d6c137901d87ea5daf23464e5c7bb869 /modules-available/permissionmanager/templates/roleeditor.html | |
parent | [permission-manager] added possibility to select all permissions (diff) | |
download | slx-admin-d033483d3ed9e05f1109a3713ec6a3df883a1dae.tar.gz slx-admin-d033483d3ed9e05f1109a3713ec6a3df883a1dae.tar.xz slx-admin-d033483d3ed9e05f1109a3713ec6a3df883a1dae.zip |
[permission-manager] renamed some files, moved html generation to templates,
using bind variables in mysql code, changed order of modules in role editor
Diffstat (limited to 'modules-available/permissionmanager/templates/roleeditor.html')
-rw-r--r-- | modules-available/permissionmanager/templates/roleeditor.html | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/modules-available/permissionmanager/templates/roleeditor.html b/modules-available/permissionmanager/templates/roleeditor.html new file mode 100644 index 00000000..7de8eaf3 --- /dev/null +++ b/modules-available/permissionmanager/templates/roleeditor.html @@ -0,0 +1,147 @@ +<form method="post" action="?do=permissionmanager"> + <input type="hidden" name="action" value="saveRole"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="roleid" value="{{roleid}}"> + <div class="row"> + <div class="col-md-12"> + <b>{{lang_Name}}:</b> + <input name="roleName" value="{{roleName}}" type="text" id="roleName" class="form-control"> + <button type="button" id="cancelButton" class="btn btn-default pull-right"><span class="glyphicon glyphicon-remove"></span> {{lang_Cancel}}</button> + <button type="submit" id="saveButton" class="btn btn-primary pull-right"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_Save}}</button> + </div> + </div> + <div class="row"> + <div class="col-md-3"> + <b style="line-height: 34px">{{lang_Locations}}:</b> + <div class="pull-right"><input name="allLocations" {{allLocChecked}} type="checkbox" id="allLocations"></div> + </div> + <div id="selectize-container" class="col-md-9 text-left {{selectizeClass}}"> + <select multiple name="locations[]" id="select-location"> + <option value></option> + {{#locations}} + <option value="{{locid}}" {{selected}}>{{locName}}</option> + {{/locations}} + </select> + </div> + </div> + <div class="row"> + <div class="col-md-3"> + <b style="line-height: 34px">{{lang_Permissions}}:</b> + <div class="pull-right"><input name="allPermissions" {{allPermChecked}} type="checkbox" id="allPermissions"></div> + <div class="btn-group-vertical module-toggle-group permissions-container {{permissionsClass}}" role="group"> + {{#moduleNames}} + <button id="button-{{id}}" type="button" class="btn btn-default module-toggle" data-moduleid="{{id}}">{{name}}</button> + {{/moduleNames}} + </div> + </div> + <div class="col-md-9 module-container permissions-container {{permissionsClass}}"> + {{{permissionHTML}}} + </div> + </div> +</form> + +<script type="application/javascript"> + + selectedPermissions = "{{selectedPermissions}}"; + + document.addEventListener("DOMContentLoaded", function () { + $('#select-location').selectize({ + allowEmptyOption: false, + maxItems: null, + highlight: false, + hideSelected: true, + create: false, + plugins: [ "remove_button" ] + }); + + var allLocations = $("#allLocations"); + allLocations.bootstrapSwitch("size", "normal"); + allLocations.bootstrapSwitch("labelWidth", 1); + allLocations.bootstrapSwitch("onText", "{{lang_all}}"); + allLocations.bootstrapSwitch("offText", "{{lang_selected}}"); + + allLocations.on('switchChange.bootstrapSwitch', function(event, state) { + if (state) { + $("#selectize-container").addClass("disabled"); + } else { + $("#selectize-container").removeClass("disabled"); + } + }); + + var allPermissions = $("#allPermissions"); + allPermissions.bootstrapSwitch("size", "normal"); + allPermissions.bootstrapSwitch("labelWidth", 1); + allPermissions.bootstrapSwitch("onText", "{{lang_all}}"); + allPermissions.bootstrapSwitch("offText", "{{lang_selected}}"); + + + allPermissions.on('switchChange.bootstrapSwitch', function(event, state) { + if (state) { + $(".permissions-container").addClass("disabled"); + } else { + $(".permissions-container").removeClass("disabled"); + } + }); + + $("form input").keydown(function(e) { + if (e.keyCode === 13) e.preventDefault(); + }); + + $(".module-toggle").click(function () { + var button = $(this); + var moduleBox = $("#" + button.data("moduleid")); + if (button.hasClass("btn-default")) { + button.removeClass("btn-default"); + button.addClass("btn-primary"); + moduleBox.show(); + } else { + button.removeClass("btn-primary"); + button.addClass("btn-default"); + moduleBox.hide(); + } + }); + + $(".module-container input[type=checkbox]").change(function () { + var parent = $(this).parent().parent(); + if (parent.hasClass("panel-heading")) parent = parent.parent(); + parent = parent.find("ul:first"); + parent.find("ul").removeClass("disabled"); + var checkboxes = parent.find("input[type=checkbox]"); + if (parent.hasClass("disabled")) { + checkboxes.prop("disabled", false); + checkboxes.prop("checked", false); + parent.removeClass("disabled"); + } else { + checkboxes.prop("disabled", true); + checkboxes.prop("checked", true); + parent.addClass("disabled"); + } + }); + + $("#cancelButton").click(function () { + window.location.replace("?do=permissionmanager&show=roles"); + }); + + $('form').submit(function () { + var name = $.trim($('#roleName').val()); + if (name === '') { + alert('{{lang_emptyNameWarning}}'); + return false; + } + }); + + var permissions = selectedPermissions.split(" "); + var arrayLength = permissions.length; + for (var i = 0; i < arrayLength; i++) { + var checkbox = $("input[type=checkbox][value='"+permissions[i]+"']"); + checkbox.trigger('change').attr('checked', 'checked'); + var moduleBox = checkbox.closest(".module-box"); + moduleBox.show(); + var button = $("#button-"+moduleBox.attr('id')); + button.removeClass("btn-default"); + button.addClass("btn-primary"); + } + + }); + +</script>
\ No newline at end of file |