mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #9996 from signify-nz/enh/gridfield-readonly-transformation
ENH Provide ways to modify read-only gridfields globally.
This commit is contained in:
commit
ba80f4baa9
@ -53,6 +53,28 @@ class GridField extends FormField
|
||||
'gridFieldAlterAction',
|
||||
];
|
||||
|
||||
/**
|
||||
* Default globally configured readonly components.
|
||||
*
|
||||
* @see $readonlyComponents
|
||||
* @var array
|
||||
*/
|
||||
private static $default_readonly_components = [
|
||||
GridField_ActionMenu::class,
|
||||
GridFieldConfig_RecordViewer::class,
|
||||
GridFieldButtonRow::class,
|
||||
GridFieldDataColumns::class,
|
||||
GridFieldDetailForm::class,
|
||||
GridFieldLazyLoader::class,
|
||||
GridFieldPageCount::class,
|
||||
GridFieldPaginator::class,
|
||||
GridFieldFilterHeader::class,
|
||||
GridFieldSortableHeader::class,
|
||||
GridFieldToolbarHeader::class,
|
||||
GridFieldViewButton::class,
|
||||
GridState_Component::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Data source.
|
||||
*
|
||||
@ -114,21 +136,7 @@ class GridField extends FormField
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $readonlyComponents = [
|
||||
GridField_ActionMenu::class,
|
||||
GridFieldConfig_RecordViewer::class,
|
||||
GridFieldButtonRow::class,
|
||||
GridFieldDataColumns::class,
|
||||
GridFieldDetailForm::class,
|
||||
GridFieldLazyLoader::class,
|
||||
GridFieldPageCount::class,
|
||||
GridFieldPaginator::class,
|
||||
GridFieldFilterHeader::class,
|
||||
GridFieldSortableHeader::class,
|
||||
GridFieldToolbarHeader::class,
|
||||
GridFieldViewButton::class,
|
||||
GridState_Component::class,
|
||||
];
|
||||
protected $readonlyComponents = [];
|
||||
|
||||
/**
|
||||
* Pattern used for looking up
|
||||
@ -145,6 +153,9 @@ class GridField extends FormField
|
||||
{
|
||||
parent::__construct($name, $title, null);
|
||||
|
||||
// Set readonly components for this gridfield.
|
||||
$this->setReadonlyComponents($this->config()->get('default_readonly_components'));
|
||||
|
||||
$this->name = $name;
|
||||
|
||||
if ($dataList) {
|
||||
@ -262,6 +273,8 @@ class GridField extends FormField
|
||||
$copyConfig->addComponent(GridFieldViewButton::create());
|
||||
}
|
||||
|
||||
$copy->extend('afterPerformReadonlyTransformation', $this);
|
||||
|
||||
return $copy;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user