Skip to content

Commit

Permalink
Merge pull request #1399 from heyday/2
Browse files Browse the repository at this point in the history
fix: expose ShowInSearch field in access UI
  • Loading branch information
GuySartorelli authored Nov 19, 2023
2 parents 85dbbe3 + fd811f9 commit fdeacbe
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions code/Forms/AssetFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldGroup;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
Expand Down Expand Up @@ -152,13 +153,13 @@ protected function getSaveAction($record)
{
if ($record && $record->isInDB() && $record->canEdit()) {
/** @var FormAction $action */
$action = FormAction::create('save', _t(__CLASS__.'.SAVE', 'Save'))
$action = FormAction::create('save', _t(__CLASS__ . '.SAVE', 'Save'))
->setIcon('save')
->setSchemaState([
'data' => [
'pristineTitle' => _t(__CLASS__.'.SAVED', 'Saved'),
'pristineTitle' => _t(__CLASS__ . '.SAVED', 'Saved'),
'pristineIcon' => 'tick',
'dirtyTitle' => _t(__CLASS__.'.SAVE', 'Save'),
'dirtyTitle' => _t(__CLASS__ . '.SAVE', 'Save'),
'dirtyIcon' => 'save',
'pristineClass' => 'btn-outline-primary',
'dirtyClass' => '',
Expand Down Expand Up @@ -303,17 +304,28 @@ protected function getFormFieldDetailsTab($record, $context = [])
/** @var Tab $tab */
$tab = Tab::create(
'Details',
TextField::create('Name', _t(__CLASS__.'.FILENAME', 'Filename')),
TextField::create('Name', _t(__CLASS__ . '.FILENAME', 'Filename')),
$location = TreeDropdownField::create(
'ParentID',
_t(__CLASS__.'.FOLDERLOCATION', 'Location'),
_t(__CLASS__ . '.FOLDERLOCATION', 'Location'),
Folder::class
)
->setShowSelectedPath(true)
);


if (!$record instanceof Folder) {
$tab->push(
CheckboxField::create(
'ShowInSearch',
_t(__CLASS__ . '.SHOWINSEARRCH', 'Show in search?')
)
);
}


$location
->setEmptyString(_t(__CLASS__.'.ROOTNAME', '(Top level)'))
->setEmptyString(_t(__CLASS__ . '.ROOTNAME', '(Top level)'))
->setShowSearch(true);
return $tab;
}
Expand Down Expand Up @@ -358,11 +370,11 @@ protected function getFormFieldSecurityTab($record, $context = [])
{
// Get permissions
$viewersOptionsField = [
InheritedPermissions::INHERIT => _t(__CLASS__.'.INHERIT', 'Inherit from parent folder'),
InheritedPermissions::ANYONE => _t(__CLASS__.'.ANYONE', 'Anyone'),
InheritedPermissions::LOGGED_IN_USERS => _t(__CLASS__.'.LOGGED_IN', 'Logged-in users'),
InheritedPermissions::ONLY_THESE_USERS => _t(__CLASS__.'.ONLY_GROUPS', 'Only these groups (choose from list)'),
InheritedPermissions::ONLY_THESE_MEMBERS => _t(__CLASS__.'.ONLY_MEMBERS', 'Only these users (choose from list)'),
InheritedPermissions::INHERIT => _t(__CLASS__ . '.INHERIT', 'Inherit from parent folder'),
InheritedPermissions::ANYONE => _t(__CLASS__ . '.ANYONE', 'Anyone'),
InheritedPermissions::LOGGED_IN_USERS => _t(__CLASS__ . '.LOGGED_IN', 'Logged-in users'),
InheritedPermissions::ONLY_THESE_USERS => _t(__CLASS__ . '.ONLY_GROUPS', 'Only these groups (choose from list)'),
InheritedPermissions::ONLY_THESE_MEMBERS => _t(__CLASS__ . '.ONLY_MEMBERS', 'Only these users (choose from list)'),
];

// No "Anyone" editors option
Expand All @@ -379,37 +391,39 @@ protected function getFormFieldSecurityTab($record, $context = [])
->limit(100)
->map('ID', 'Name');

return Tab::create(
$tab = Tab::create(
'Permissions',
OptionsetField::create(
'CanViewType',
_t(__CLASS__.'.ACCESSHEADER', 'Who can view this file?')
_t(__CLASS__ . '.ACCESSHEADER', 'Who can view this file?')
)
->setSource($viewersOptionsField),
TreeMultiselectField::create(
'ViewerGroups',
_t(__CLASS__.'.VIEWERGROUPS', 'Viewer Groups')
_t(__CLASS__ . '.VIEWERGROUPS', 'Viewer Groups')
),
ListboxField::create(
'ViewerMembers',
_t(__CLASS__.'.VIEWERMEMBERS', 'Viewer Users'),
_t(__CLASS__ . '.VIEWERMEMBERS', 'Viewer Users'),
$membersMap
),
OptionsetField::create(
"CanEditType",
_t(__CLASS__.'.EDITHEADER', 'Who can edit this file?')
_t(__CLASS__ . '.EDITHEADER', 'Who can edit this file?')
)
->setSource($editorsOptionsField),
TreeMultiselectField::create(
'EditorGroups',
_t(__CLASS__.'.EDITORGROUPS', 'Editor Groups')
_t(__CLASS__ . '.EDITORGROUPS', 'Editor Groups')
),
ListboxField::create(
'EditorMembers',
_t(__CLASS__.'.EDITORMEMBERS', 'Editor Users'),
_t(__CLASS__ . '.EDITORMEMBERS', 'Editor Users'),
$membersMap
)
);

return $tab;
}

public function getRequiredContext()
Expand Down

0 comments on commit fdeacbe

Please sign in to comment.