Skip to content

Commit

Permalink
Merge ed5a534 into e165645
Browse files Browse the repository at this point in the history
  • Loading branch information
davisvagris committed Aug 14, 2019
2 parents e165645 + ed5a534 commit a4c425b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
33 changes: 33 additions & 0 deletions src/Admin/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class Grid
*/
protected $rowUrlCallback;

/**
* @var bool
*/
protected $hasToolbox = true;

/**
* @param Model $model
* @param Closure $layout
Expand Down Expand Up @@ -147,6 +152,34 @@ public function addTool(RenderableInterface $tool, string $side = null)
$this->tools[] = [$tool, $side ?: self::FOOTER_SIDE_SECONDARY];
}

/**
* @return \Arbory\Base\Admin\Grid
*/
public function showToolbox(): self
{
$this->hasToolbox = true;

return $this;
}

/**
* @return \Arbory\Base\Admin\Grid
*/
public function hideToolbox(): self
{
$this->hasToolbox = false;

return $this;
}

/**
* @return bool
*/
public function isToolboxEnable(): bool
{
return $this->hasToolbox;
}

/**
* @return array
*/
Expand Down
4 changes: 3 additions & 1 deletion src/Admin/Grid/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ protected function getTableColumns()
return $this->getColumnHeader($column);
});

$tableColumns->push(Html::th(Html::span(' ')));
if ($this->grid->isToolboxEnable()) {
$tableColumns->push(Html::th(Html::span(' ')));
}

return $tableColumns;
}
Expand Down
16 changes: 9 additions & 7 deletions src/Admin/Grid/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ public function render()
{
$cells = $this->getCells();

$cells->push(
Html::td(
Toolbox::create(
$this->grid->getModule()->url('dialog', ['dialog' => 'toolbox', 'id' => $this->model->getKey()])
)->render()
)->addClass('only-icon toolbox-cell')
);
if ($this->grid->isToolboxEnable()) {
$cells->push(
Html::td(
Toolbox::create(
$this->grid->getModule()->url('dialog', ['dialog' => 'toolbox', 'id' => $this->model->getKey()])
)->render()
)->addClass('only-icon toolbox-cell')
);
}

return Html::tr($cells->toArray())
->addAttributes([
Expand Down

0 comments on commit a4c425b

Please sign in to comment.