From e69e65c1e3d20dd7e5bbb38ebbcdde39cfb70495 Mon Sep 17 00:00:00 2001 From: madmatt Date: Wed, 15 Jan 2014 15:51:35 +1300 Subject: [PATCH 1/2] BUGFIX: Fix JS for PermissionCheckboxsetField in SecurityAdmin --- admin/javascript/SecurityAdmin.js | 12 ++++++------ javascript/PermissionCheckboxSetField.js | 25 +++++++++++------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/admin/javascript/SecurityAdmin.js b/admin/javascript/SecurityAdmin.js index 90c494715..7b1f901e3 100644 --- a/admin/javascript/SecurityAdmin.js +++ b/admin/javascript/SecurityAdmin.js @@ -60,15 +60,15 @@ if(this.is(':checked')) { checkboxes.each(function() { - $(this).data('SecurityAdmin.oldChecked', $(this).attr('checked')); - $(this).data('SecurityAdmin.oldDisabled', $(this).attr('disabled')); - $(this).attr('disabled', 'disabled'); - $(this).attr('checked', 'checked'); + $(this).data('SecurityAdmin.oldChecked', $(this).is(':checked')); + $(this).data('SecurityAdmin.oldDisabled', $(this).is(':disabled')); + $(this).prop('disabled', true); + $(this).prop('checked', true); }); } else { checkboxes.each(function() { - $(this).attr('checked', $(this).data('SecurityAdmin.oldChecked')); - $(this).attr('disabled', $(this).data('SecurityAdmin.oldDisabled')); + $(this).prop('checked', $(this).data('SecurityAdmin.oldChecked')); + $(this).prop('disabled', $(this).data('SecurityAdmin.oldDisabled')); }); } } diff --git a/javascript/PermissionCheckboxSetField.js b/javascript/PermissionCheckboxSetField.js index 5e234befe..04205e95e 100644 --- a/javascript/PermissionCheckboxSetField.js +++ b/javascript/PermissionCheckboxSetField.js @@ -10,8 +10,6 @@ $('.permissioncheckboxset .valADMIN input').entwine({ onmatch: function() { this._super(); - - this.toggleCheckboxes(); }, onunmatch: function() { this._super(); @@ -55,30 +53,29 @@ }).find('.checkbox').not(this); }, onmatch: function() { - var checkboxes = this.getCheckboxesExceptThisOne(); - if($(this).is(':checked')) { - checkboxes.each(function() { - $(this).attr('disabled', 'disabled'); - $(this).attr('checked', 'checked'); - }); - } - + this.toggleCheckboxes(); + this._super(); }, onunmatch: function() { this._super(); }, onclick: function(e) { + this.toggleCheckboxes(); + }, + toggleCheckboxes: function() { var checkboxes = this.getCheckboxesExceptThisOne(); if($(this).is(':checked')) { checkboxes.each(function() { - $(this).attr('disabled', 'disabled'); - $(this).attr('checked', 'checked'); + $(this).data('PermissionCheckboxSetField.oldChecked', $(this).is(':checked')); + $(this).data('PermissionCheckboxSetField.oldDisabled', $(this).is(':disabled')); + $(this).prop('disabled', 'disabled'); + $(this).prop('checked', 'checked'); }); } else { checkboxes.each(function() { - $(this).prop('checked', false); - $(this).prop('disabled', false); + $(this).prop('checked', $(this).data('PermissionCheckboxSetField.oldChecked')); + $(this).prop('disabled', $(this).data('PermissionCheckboxSetField.oldDisabled')); }); } } From e0b4e6125c509aad3428c4e5eebbd8ad6b83d019 Mon Sep 17 00:00:00 2001 From: madmatt Date: Wed, 15 Jan 2014 16:20:19 +1300 Subject: [PATCH 2/2] MINOR: Added behat test to cover changes made in e69e65c. --- .../features/security-permissions.feature | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/behat/features/security-permissions.feature diff --git a/tests/behat/features/security-permissions.feature b/tests/behat/features/security-permissions.feature new file mode 100644 index 000000000..dd0fa4013 --- /dev/null +++ b/tests/behat/features/security-permissions.feature @@ -0,0 +1,36 @@ +@javascript +Feature: Manage Security Permissions for Groups + As a site administrator + I want to control my user's security permissions in an intuitive way + So that I can easily control access to the CMS + + Background: + Given a "member" "ADMIN" belonging to "ADMIN Group" with "Email"="admin@test.com" + And the "group" "ADMIN group" has permissions "Full administrative rights" + And I am logged in with "ADMIN" permissions + And I go to "/admin/security" + + Scenario: I can change permissions easily + When I click the "Groups" CMS tab + And I press the "Add Group" button + And I click the "Permissions" CMS tab + And I check "Access to 'Pages' section" + And I check "Access to all CMS sections" + Then the "Access to 'Reports' section" checkbox should be checked + And I uncheck "Access to all CMS sections" + Then the "Access to 'Reports' section" checkbox should not be checked + And the "Access to 'Pages' section" checkbox should be checked + And I uncheck "Access to 'Pages' section" + And I check "Full administrative rights" + Then the "Access to 'Reports' section" checkbox should be checked + And I press the "Create" button + And I click the "Permissions" CMS tab + Then the "Full administrative rights" checkbox should be checked + And the "Access to 'Pages' section" checkbox should be checked + And I uncheck "Full administrative rights" + Then the "Access to 'Pages' section" checkbox should not be checked + And I check "Access to all CMS sections" + And I press the "Save" button + Then the "Access to 'Pages' section" checkbox should be checked + And I uncheck "Access to all CMS sections" + Then the "Access to 'Pages' section" checkbox should not be checked