ENH Allow GridField readonly components to be globally modified.

This commit is contained in:
Guy Sartorelli 2021-06-29 11:21:41 +12:00
parent 82e0d8f24b
commit 009a32fbec

View File

@ -52,6 +52,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.
*
@ -113,21 +135,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
@ -144,6 +152,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) {