diff options
author | Udo Walter | 2017-03-31 15:42:27 +0200 |
---|---|---|
committer | Udo Walter | 2017-03-31 15:42:27 +0200 |
commit | 41e0fe6356ece2f7c7a58eba7a87111919f826c8 (patch) | |
tree | 7d1212fceb8653c92da55b07022bce67da676fec /modules-available | |
parent | [permission-manager] fixed hardcoded strings (diff) | |
download | slx-admin-41e0fe6356ece2f7c7a58eba7a87111919f826c8.tar.gz slx-admin-41e0fe6356ece2f7c7a58eba7a87111919f826c8.tar.xz slx-admin-41e0fe6356ece2f7c7a58eba7a87111919f826c8.zip |
[permission-manager] added possibility to select all permissions
Diffstat (limited to 'modules-available')
5 files changed, 33 insertions, 14 deletions
diff --git a/modules-available/permissionmanager/lang/de/template-tags.json b/modules-available/permissionmanager/lang/de/template-tags.json index 9e7f79c1..d67bde65 100644 --- a/modules-available/permissionmanager/lang/de/template-tags.json +++ b/modules-available/permissionmanager/lang/de/template-tags.json @@ -16,5 +16,6 @@ "lang_Cancel": "Abbrechen", "lang_Save": "Speichern", "lang_all": "alle", - "lang_selected": "ausgewählte" + "lang_selected": "ausgewählte", + "lang_Permissions": "Rechte" }
\ No newline at end of file diff --git a/modules-available/permissionmanager/lang/en/template-tags.json b/modules-available/permissionmanager/lang/en/template-tags.json index 314824d4..e6227b90 100644 --- a/modules-available/permissionmanager/lang/en/template-tags.json +++ b/modules-available/permissionmanager/lang/en/template-tags.json @@ -16,5 +16,6 @@ "lang_Cancel": "Cancel", "lang_Save": "Save", "lang_all": "all", - "lang_selected": "selected" + "lang_selected": "selected", + "lang_Permissions": "Permissions" }
\ No newline at end of file diff --git a/modules-available/permissionmanager/page.inc.php b/modules-available/permissionmanager/page.inc.php index 700ed96a..15d2fb73 100644 --- a/modules-available/permissionmanager/page.inc.php +++ b/modules-available/permissionmanager/page.inc.php @@ -31,7 +31,7 @@ class Page_PermissionManager extends Page $roleID = Request::post("roleid", false); $roleName = Request::post("roleName"); $locations = Request::post("allLocations", "off") == "on" ? array(0) : Request::post("locations"); - $permissions = Request::post("permissions"); + $permissions = Request::post("allPermissions", "off") == "on" ? array("*") : Request::post("permissions");; DbUpdate::saveRole($roleName, $locations, $permissions, $roleID); } } @@ -81,10 +81,14 @@ class Page_PermissionManager extends Page $data["selectizeClass"] = ""; $selectedLocations = $roleData["locations"]; } - $data["selectedPermissions"] = implode(" ", $roleData["permissions"]); - } else { - $data["allLocChecked"] = "checked"; - $data["selectizeClass"] = "disabled"; + if (count($roleData["permissions"]) == 1 && $roleData["permissions"][0] == "*") { + $data["allPermChecked"] = "checked"; + $data["permissionsClass"] = "disabled"; + } else { + $data["allPermChecked"] = ""; + $data["permissionsClass"] = ""; + $data["selectedPermissions"] = implode(" ", $roleData["permissions"]); + } } $permissions = PermissionUtil::getPermissions(); @@ -111,7 +115,6 @@ class Page_PermissionManager extends Page $data["moduleNames"][] = array("id" => $moduleid, "name" => Dictionary::translateFileModule($moduleid, "module", "module_name")); } - $data["permissionHTML"] = $permissionHTML; Render::addTemplate('roleEditor', $data); } diff --git a/modules-available/permissionmanager/style.css b/modules-available/permissionmanager/style.css index fc7ad6e7..f1f8e250 100644 --- a/modules-available/permissionmanager/style.css +++ b/modules-available/permissionmanager/style.css @@ -53,6 +53,7 @@ .module-toggle-group { width: 100%; + margin-top: 20px; } .module-container { diff --git a/modules-available/permissionmanager/templates/roleEditor.html b/modules-available/permissionmanager/templates/roleEditor.html index 7f54a813..ee717fe6 100644 --- a/modules-available/permissionmanager/templates/roleEditor.html +++ b/modules-available/permissionmanager/templates/roleEditor.html @@ -27,16 +27,16 @@ {{abc}} <div class="row"> <div class="col-md-3"> - <div class="btn-group-vertical module-toggle-group" role="group"> + <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"> - + <div class="col-md-9 module-container permissions-container {{permissionsClass}}"> {{{permissionHTML}}} - </div> </div> </form> @@ -60,8 +60,6 @@ allLocations.bootstrapSwitch("labelWidth", 1); allLocations.bootstrapSwitch("onText", "{{lang_all}}"); allLocations.bootstrapSwitch("offText", "{{lang_selected}}"); - allLocations.bootstrapSwitch("onColor", "default"); - allLocations.bootstrapSwitch("offColor", "primary"); allLocations.on('switchChange.bootstrapSwitch', function(event, state) { if (state) { @@ -71,6 +69,21 @@ } }); + 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(); }); |