Skip to content

Commit

Permalink
Add actionshould respect enabled/disabled switch (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkSide666 authored Jan 28, 2020
1 parent 678a301 commit d7a6446
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/CRUD.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,18 @@ public function setModel(\atk4\data\Model $m, $fields = null): \atk4\data\Model

if ($this->menu) {
foreach ($this->_getModelActions(Generic::NO_RECORDS) as $k => $action) {
$action->ui['executor'] = $this->initActionExecutor($action);
$this->menuItems[$k]['item'] = $this->menu->addItem([$action->getDescription(), 'icon' => 'plus']);
$this->menuItems[$k]['action'] = $action;
if ($action->enabled) {
$action->ui['executor'] = $this->initActionExecutor($action);
$this->menuItems[$k]['item'] = $this->menu->addItem([$action->getDescription(), 'icon' => 'plus']);
$this->menuItems[$k]['action'] = $action;
}
}
$this->setItemsAction();

// if no menuItems at all, then remove menu element
if (!$this->menuItems) {
$this->menu->destroy();
}
}

return $this->model;
Expand Down

0 comments on commit d7a6446

Please sign in to comment.