Skip to content

Commit

Permalink
Merge pull request #564 from open-sausages/pulls/1.0/select-them-all-…
Browse files Browse the repository at this point in the history
…again

Enhancement Switch CheckboxSetField to TreeMultiselectField for better UX
  • Loading branch information
Damian Mooyman committed Jul 28, 2017
2 parents 32e0be0 + 31e1fcb commit 9ba9ff0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
24 changes: 10 additions & 14 deletions code/Forms/AssetFormFactory.php
Expand Up @@ -4,12 +4,11 @@

use InvalidArgumentException;
use SilverStripe\Assets\File;
use SilverStripe\Control\RequestHandler;
use SilverStripe\Assets\Folder;
use SilverStripe\Control\RequestHandler;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Forms\CheckboxSetField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction;
Expand All @@ -23,8 +22,8 @@
use SilverStripe\Forms\Tab;
use SilverStripe\Forms\TabSet;
use SilverStripe\Forms\TextField;
use SilverStripe\Security\Group;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\Forms\TreeMultiselectField;

/**
* @skipUpgrade
Expand Down Expand Up @@ -335,13 +334,6 @@ protected function getPath($record, $context = [])
*/
protected function getFormFieldSecurityTab($record, $context = [])
{
// Get groups
$groupsMap = array();
foreach (Group::get() as $group) {
$groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
}
asort($groupsMap);

// Get permissions
$viewersOptionsField = [
'Inherit' => _t(__CLASS__.'.INHERIT', 'Inherit from parent folder'),
Expand All @@ -361,15 +353,19 @@ protected function getFormFieldSecurityTab($record, $context = [])
_t(__CLASS__.'.ACCESSHEADER', 'Who can view this file?')
)
->setSource($viewersOptionsField),
CheckboxSetField::create('ViewerGroups', _t(__CLASS__.'.VIEWERGROUPS', 'Viewer Groups'))
->setSource($groupsMap),
TreeMultiselectField::create(
'ViewerGroups',
_t(__CLASS__.'.VIEWERGROUPS', 'Viewer Groups')
),
OptionsetField::create(
"CanEditType",
_t(__CLASS__.'.EDITHEADER', 'Who can edit this file?')
)
->setSource($editorsOptionsField),
CheckboxSetField::create('EditorGroups', _t(__CLASS__.'.EDITORGROUPS', 'Editor Groups'))
->setSource($groupsMap)
TreeMultiselectField::create(
'EditorGroups',
_t(__CLASS__.'.EDITORGROUPS', 'Editor Groups')
)
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/behat/features/manage-file-permissions.feature
Expand Up @@ -22,7 +22,7 @@ Feature: Manage files
Then I should see the "Form_fileEditForm" form
When I click "Permissions" in the "#Editor .nav-tabs" element
And I select "Only these people (choose from list)" from "Who can edit this file?" input group
And I select "ADMIN group" from "Editor Groups" input group
And I select "ADMIN group" in the "#Form_fileEditForm_EditorGroups_Holder" tree dropdown
And I press the "Save" button
And I am not logged in
And I am logged in with "EDITOR" permissions
Expand All @@ -44,7 +44,7 @@ Feature: Manage files
Then I should see the "Form_fileEditForm" form
When I click "Permissions" in the "#Editor .nav-tabs" element
And I select "Only these people (choose from list)" from "Who can edit this file?" input group
And I select "EDITOR group" from "Editor Groups" input group
And I select "EDITOR group" in the "#Form_fileEditForm_EditorGroups_Holder" tree dropdown
And I press the "Save" button
And I am not logged in
And I am logged in with "EDITOR" permissions
Expand Down
6 changes: 2 additions & 4 deletions tests/behat/features/manage-files.feature
Expand Up @@ -121,15 +121,13 @@ Feature: Manage files
When I click on the file named "folder1" in the gallery
And I click on the file named "file1" in the gallery
Then I should see the "Form_fileEditForm" form
When I click "folder1" in the ".Select-value" element
And I click "(Top level)" in the ".treedropdownfield__menu" element
When I select "(Top level)" in the "#Form_fileEditForm_ParentID_Holder" tree dropdown
And I press the "Save" button
Then I should see the file named "file1" in the gallery
And I should see the file named "folder1" in the gallery
And I should not see "File cannot be found" in the "#Form_fileEditForm" element
# test moving again to see if Tuple has updated value
When I click "(Top level)" in the ".Select-value" element
And I click "folder2" in the ".treedropdownfield__menu" element
When I select "folder2" in the "#Form_fileEditForm_ParentID_Holder" tree dropdown
And I press the "Save" button
Then I should see the file named "file1" in the gallery
And I should not see the file named "folder2" in the gallery
Expand Down

0 comments on commit 9ba9ff0

Please sign in to comment.