Skip to content

Commit

Permalink
Add tree titleBlock_text, titleBlock_options and titleBlock_onHover c…
Browse files Browse the repository at this point in the history
…onfig params
  • Loading branch information
ereminmdev committed Jun 10, 2021
1 parent 46696c7 commit 5ba1711
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ public static function crudConfig()
'titleBlock' => function (self $model, DefaultController $controller, Crud $crud) {
return Html::encode($model->title);
},
'titleBlock_text' => function (self $model, DefaultController $controller, Crud $crud) {
return Html::encode($model->name);
},
'titleBlock_options' => function (self $model, DefaultController $controller, Crud $crud) {
return ['class' => 'red'];
},
'titleBlock_onHover' => function (self $model, DefaultController $controller, Crud $crud) {
return Html::encode($model->statusText);
},
'rightBlock' => function (self $model, DefaultController $controller, Crud $crud) {
return $model->status;
},
Expand Down
7 changes: 4 additions & 3 deletions components/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -1232,13 +1232,14 @@ public function getTreeActions($model, $controller)
public function getTreeTitleBlock($model, $controller)
{
$block = $this->getConfig('tree.titleBlock', function ($model, $controller, $crud) {
$text = $this->getConfig('tree.titleBlockText', $model->title);
$text = $this->getConfig('tree.titleBlock_text', $model->title);
$options = $this->getConfig('tree.titleBlock_options', []);

$hover = $this->getConfig('tree.titleBlockOnHover', '');
$hover = $this->getConfig('tree.titleBlock_onHover', '');
$hover = $hover instanceof Closure ? call_user_func_array($hover, [$model, $controller, $this]) : $hover;
$hover = !empty($hover) ? '<span class="tree-item--on-hover"> &nbsp; &nbsp; &nbsp; ' . $hover . '</span>' : '';

return Html::a($text, $controller->urlCreate(['update', 'id' => $model->id])) . $hover;
return Html::a($text, $controller->urlCreate(['update', 'id' => $model->id]), $options) . $hover;
});
return $block instanceof Closure ? call_user_func_array($block, [$model, $controller, $this]) : $block;
}
Expand Down

0 comments on commit 5ba1711

Please sign in to comment.