mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Lint fixes and allow a few other components by default
This commit is contained in:
parent
4c3a068859
commit
3fc49dd4ce
@ -111,13 +111,16 @@ class GridField extends FormField
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $readonlyComponents = array(
|
protected $readonlyComponents = array(
|
||||||
|
GridField_ActionMenu::class,
|
||||||
|
GridState_Component::class,
|
||||||
|
GridFieldConfig_RecordViewer::class,
|
||||||
GridFieldDetailForm::class,
|
GridFieldDetailForm::class,
|
||||||
GridFieldDataColumns::class,
|
GridFieldDataColumns::class,
|
||||||
GridFieldConfig_RecordViewer::class,
|
|
||||||
GridFieldToolbarHeader::class,
|
|
||||||
GridFieldPageCount::class,
|
GridFieldPageCount::class,
|
||||||
GridFieldPaginator::class,
|
GridFieldPaginator::class,
|
||||||
GridState_Component::class
|
GridFieldSortableHeader::class,
|
||||||
|
GridFieldToolbarHeader::class,
|
||||||
|
GridFieldViewButton::class,
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,7 +244,6 @@ class GridField extends FormField
|
|||||||
// get the whitelist for allowable readonly components
|
// get the whitelist for allowable readonly components
|
||||||
$allowedComponents = $this->getReadonlyComponents();
|
$allowedComponents = $this->getReadonlyComponents();
|
||||||
foreach ($this->getConfig()->getComponents() as $component) {
|
foreach ($this->getConfig()->getComponents() as $component) {
|
||||||
|
|
||||||
// if a component doesn't exist, remove it from the readonly version.
|
// if a component doesn't exist, remove it from the readonly version.
|
||||||
if (!in_array(get_class($component), $allowedComponents)) {
|
if (!in_array(get_class($component), $allowedComponents)) {
|
||||||
$copy->getConfig()->removeComponent($component);
|
$copy->getConfig()->removeComponent($component);
|
||||||
@ -256,7 +258,8 @@ class GridField extends FormField
|
|||||||
*
|
*
|
||||||
* @return GridField
|
* @return GridField
|
||||||
*/
|
*/
|
||||||
public function performDisabledTransformation(){
|
public function performDisabledTransformation()
|
||||||
|
{
|
||||||
parent::performDisabledTransformation();
|
parent::performDisabledTransformation();
|
||||||
|
|
||||||
return $this->performReadonlyTransformation();
|
return $this->performReadonlyTransformation();
|
||||||
|
@ -14,6 +14,7 @@ class GridFieldConfig_RecordViewer extends GridFieldConfig_Base
|
|||||||
|
|
||||||
$this->addComponent(new GridFieldViewButton());
|
$this->addComponent(new GridFieldViewButton());
|
||||||
$this->addComponent(new GridFieldDetailForm());
|
$this->addComponent(new GridFieldDetailForm());
|
||||||
|
$this->removeComponentsByType(GridFieldFilterHeader::class);
|
||||||
|
|
||||||
$this->extend('updateConfig');
|
$this->extend('updateConfig');
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ class GridFieldReadonlyTest extends SapphireTest
|
|||||||
$readonlyComponents = $readonlyGridField->getReadonlyComponents();
|
$readonlyComponents = $readonlyGridField->getReadonlyComponents();
|
||||||
|
|
||||||
// assert that all the components in the readonly version are present in the whitelist.
|
// assert that all the components in the readonly version are present in the whitelist.
|
||||||
foreach($readonlyGridField->getConfig()->getComponents() as $component){
|
foreach ($readonlyGridField->getConfig()->getComponents() as $component) {
|
||||||
$this->assertTrue(in_array(get_class($component), $readonlyComponents));
|
$this->assertTrue(in_array(get_class($component), $readonlyComponents));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user