Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Extend new AbstractGridFieldComponent class #458

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require": {
"php": "^7.4 || ^8.0",
"silverstripe/cms": "^4",
"silverstripe/framework": "^4.10",
"silverstripe/framework": "^4.11",
"silverstripe/admin": "^1",
"silverstripe/versioned": "^1",
"symfony/yaml": "^3 || ^4"
Expand Down
10 changes: 5 additions & 5 deletions src/Admin/AdvancedWorkflowAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public function getEditForm($id = null, $fields = null)
}

// Pending/Submitted items GridField Config
$config = new GridFieldConfig_Base();
$config->addComponent(new GridFieldEditButton());
$config->addComponent(new GridFieldDetailForm());
$config = GridFieldConfig_Base::create();
$config->addComponent(GridFieldEditButton::create());
$config->addComponent(GridFieldDetailForm::create());
$config->getComponentByType(GridFieldPaginator::class)->setItemsPerPage(5);
$columns = $config->getComponentByType(GridFieldDataColumns::class);
$columns->setFieldFormatting($this->setFieldFormatting($config));
Expand Down Expand Up @@ -173,7 +173,7 @@ public function getEditForm($id = null, $fields = null)

$formFieldBottom->setForm($form);
$formFieldBottom->getConfig()->removeComponentsByType(GridFieldEditButton::class);
$formFieldBottom->getConfig()->addComponent(new GridFieldWorkflowRestrictedEditButton());
$formFieldBottom->getConfig()->addComponent(GridFieldWorkflowRestrictedEditButton::create());
$form->Fields()->insertBefore($definitionGridFieldName, $formFieldBottom);
}

Expand All @@ -189,7 +189,7 @@ public function getEditForm($id = null, $fields = null)

$grid->getConfig()->getComponentByType(GridFieldDetailForm::class)
->setItemRequestClass(WorkflowDefinitionItemRequestClass::class);
$grid->getConfig()->addComponent(new GridFieldExportAction());
$grid->getConfig()->addComponent(GridFieldExportAction::create());
$grid->getConfig()->removeComponentsByType(GridFieldExportButton::class);
$grid->getConfig()->removeComponentsByType(GridFieldImportButton::class);
}
Expand Down
16 changes: 8 additions & 8 deletions src/DataObjects/WorkflowDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,31 +342,31 @@ public function getCMSFields()
'WorkflowStatus' => ['Active', 'Paused']
]);

$active = new GridField(
$active = GridField::create(
'Active',
_t('WorkflowDefinition.WORKFLOWACTIVEIINSTANCES', 'Active Workflow Instances'),
$active,
new GridFieldConfig_RecordEditor()
GridFieldConfig_RecordEditor::create()
);

$active->getConfig()->removeComponentsByType(GridFieldAddNewButton::class);
$active->getConfig()->removeComponentsByType(GridFieldDeleteAction::class);

if (!Permission::check('REASSIGN_ACTIVE_WORKFLOWS')) {
$active->getConfig()->removeComponentsByType(GridFieldEditButton::class);
$active->getConfig()->addComponent(new GridFieldViewButton());
$active->getConfig()->addComponent(new GridFieldDetailForm());
$active->getConfig()->addComponent(GridFieldViewButton::create());
$active->getConfig()->addComponent(GridFieldDetailForm::create());
}

$completed = $this->Instances()->filter([
'WorkflowStatus' => ['Complete', 'Cancelled']
]);

$config = new GridFieldConfig_Base();
$config->addComponent(new GridFieldEditButton());
$config->addComponent(new GridFieldDetailForm());
$config = GridFieldConfig_Base::create();
$config->addComponent(GridFieldEditButton::create());
$config->addComponent(GridFieldDetailForm::create());

$completed = new GridField(
$completed = GridField::create(
'Completed',
_t('WorkflowDefinition.WORKFLOWCOMPLETEDIINSTANCES', 'Completed Workflow Instances'),
$completed,
Expand Down
2 changes: 1 addition & 1 deletion src/DataObjects/WorkflowInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function getCMSFields()
'WorkflowID' => $this->ID
));

$grid = new GridField(
$grid = GridField::create(
'Actions',
_t('WorkflowInstance.ActionLogTitle', 'Log'),
$items
Expand Down
8 changes: 4 additions & 4 deletions src/Extensions/WorkflowApplicable.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ public function updateFields(FieldList $fields)
}

if ($this->owner->ID) {
$config = new GridFieldConfig_Base();
$config->addComponent(new GridFieldEditButton());
$config->addComponent(new GridFieldDetailForm());
$config = GridFieldConfig_Base::create();
$config->addComponent(GridFieldEditButton::create());
$config->addComponent(GridFieldDetailForm::create());

$insts = $this->owner->WorkflowInstances();
$log = new GridField(
$log = GridField::create(
'WorkflowLog',
_t('WorkflowApplicable.WORKFLOWLOG', 'Workflow Log'),
$insts,
Expand Down
5 changes: 4 additions & 1 deletion src/Forms/gridfield/GridFieldExportAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use SilverStripe\Control\Controller;
use SilverStripe\Control\Director;
use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\GridField\AbstractGridFieldComponent;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridField_ActionProvider;
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
Expand All @@ -22,7 +23,9 @@
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*/
class GridFieldExportAction implements GridField_ColumnProvider, GridField_ActionProvider
class GridFieldExportAction extends AbstractGridFieldComponent implements
GridField_ColumnProvider,
GridField_ActionProvider
{
/**
* Add a column 'Delete'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Symbiote\AdvancedWorkflow\Forms\GridField;

use SilverStripe\Control\Controller;
use SilverStripe\Forms\GridField\AbstractGridFieldComponent;
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
use SilverStripe\Forms\GridField\GridFieldEditButton;
use SilverStripe\Security\Permission;
Expand All @@ -14,7 +15,7 @@
*
* @package advancedworkflow
*/
class GridFieldWorkflowRestrictedEditButton implements GridField_ColumnProvider
class GridFieldWorkflowRestrictedEditButton extends AbstractGridFieldComponent implements GridField_ColumnProvider
{
/**
* Add a column
Expand Down