Skip to content

Commit

Permalink
FIX Correct field name in execute action handler and update icons to …
Browse files Browse the repository at this point in the history
…use admin icons
  • Loading branch information
robbieaverill committed Jan 26, 2018
1 parent 3234740 commit 02b3218
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
1 change: 0 additions & 1 deletion composer.json
Expand Up @@ -26,7 +26,6 @@
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"expose": ["images"],
"branch-alias": {
"dev-master": "4.x-dev"
}
Expand Down
Binary file removed images/cog_go.png
Binary file not shown.
Binary file removed images/control_pause_blue.png
Binary file not shown.
Binary file removed images/control_play_blue.png
Binary file not shown.
6 changes: 3 additions & 3 deletions src/Controllers/QueuedJobsAdmin.php
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\DatetimeField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\GridField\GridField;
Expand Down Expand Up @@ -106,7 +107,6 @@ public function getEditForm($id = null, $fields = null)
}))
->removeComponentsByType(GridFieldAddNewButton::class);


// Set messages to HTML display format
$formatting = array(
'Messages' => function ($val, $obj) {
Expand All @@ -119,14 +119,14 @@ public function getEditForm($id = null, $fields = null)
// Replace gridfield
/** @skipUpgrade */
$grid = GridField::create(
QueuedJobDescriptor::class,
'QueuedJobDescriptor',
_t(__CLASS__ . '.JobsFieldTitle', 'Jobs'),
$list,
$gridFieldConfig
);
$grid->setForm($form);
/** @skipUpgrade */
$form->Fields()->replaceField('QueuedJobDescriptor', $grid);
$form->Fields()->replaceField($this->sanitiseClassName(QueuedJobDescriptor::class), $grid);

if (Permission::check('ADMIN')) {
$types = ClassInfo::subclassesFor(AbstractQueuedJob::class);
Expand Down
47 changes: 22 additions & 25 deletions src/Forms/GridFieldQueuedJobExecute.php
Expand Up @@ -6,41 +6,30 @@
use SilverStripe\Forms\GridField\GridField_ActionProvider;
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
use SilverStripe\Forms\GridField\GridField_FormAction;
use Symbiote\QueuedJobs\Services\QueuedJob;
use SilverStripe\ORM\DataObject;
use SilverStripe\View\Requirements;
use Symbiote\QueuedJobs\Services\QueuedJob;

/**
* This class is a {@link GridField} component that adds a delete action for objects.
*
* This component also supports unlinking a relation instead of deleting the object.
* Use the {@link $removeRelation} property set in the constructor.
*
* <code>
* $action = new GridFieldDeleteAction(); // delete objects permanently
* $action = new GridFieldDeleteAction(true); // removes the relation to object, instead of deleting
* </code>
*
* @package queuedjobs
* @subpackage forms
*/
class GridFieldQueuedJobExecute implements GridField_ColumnProvider, GridField_ActionProvider
{

protected $action = 'execute';

/**
* CSS icon class names for each action (see silverstripe-admin fonts)
*
* @var array
*/
protected $icons = array(
'execute' => 'navigation',
'pause' => 'minus-circle_disabled',
'resume' => 'arrow-circle-double',
);
protected $icons = [
'execute' => 'font-icon-block-media',
'pause' => 'font-icon-cancel-circled',
'resume' => 'font-icon-sync',
];

/**
* Call back to see if the record's action icon should be shown.
*
* @var closure
* @var callable
*/
protected $viewCheck;

Expand Down Expand Up @@ -83,7 +72,7 @@ public function augmentColumns($gridField, &$columns)
*/
public function getColumnAttributes($gridField, $record, $columnName)
{
return array('class' => 'col-buttons');
return array('class' => 'grid-field__col-compact');
}

/**
Expand Down Expand Up @@ -146,9 +135,17 @@ public function getColumnContent($gridField, $record, $columnName)
$this->action,
array('RecordID' => $record->ID)
);
$field->addExtraClass('gridfield-button-job' . $this->action)
->setAttribute('title', ucfirst($this->action))
->setAttribute('data-icon', $icon);

$humanTitle = ucfirst($this->action);
$title = _t(__CLASS__ . '.' . $humanTitle, $humanTitle);

$field
->addExtraClass('gridfield-button-job' . $this->action)
->addExtraClass($icon)
->addExtraClass('btn--icon-md btn--no-text grid-field__icon-action')
->setAttribute('title', $title)
->setDescription($title);

return $field->Field();
}

Expand Down

0 comments on commit 02b3218

Please sign in to comment.