Skip to content

Commit

Permalink
move dialog setter in GroupActionCollection class
Browse files Browse the repository at this point in the history
  • Loading branch information
nidjo17 committed Jan 27, 2023
1 parent 8c7d326 commit 1a2fa59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
10 changes: 0 additions & 10 deletions src/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -2857,16 +2857,6 @@ public function setCustomPaginatorTemplate(string $templateFile): void
}


public function setGroupActionsConfirmDialog(string $confirmDialog): void
{
$this->groupActionsConfirmDialog = $confirmDialog;
}

public function getGroupActionsConfirmDialog(): ?string
{
return $this->groupActionsConfirmDialog;
}

protected function createSorting(array $sort, ?callable $sortCallback = null): Sorting
{
foreach ($sort as $key => $order) {
Expand Down
13 changes: 10 additions & 3 deletions src/GroupAction/GroupActionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class GroupActionCollection
/** @var array<GroupAction> */
protected array $groupActions = [];

protected ?string $groupActionsConfirmDialog = null;


public function __construct(protected DataGrid $datagrid)
{
}
Expand Down Expand Up @@ -137,9 +140,8 @@ public function addToFormContainer(Container $container): void
strtolower($this->datagrid->getFullName()) . 'group_action_submit'
);

$confirmationDialog = $this->datagrid->getGroupActionsConfirmDialog();
if ($confirmationDialog !== null && $confirmationDialog !== '') {
$submit->setHtmlAttribute('data-' . Action::$dataConfirmAttributeName, $confirmationDialog);
if ($this->groupActionsConfirmDialog !== null) {
$submit->setHtmlAttribute('data-' . Action::$dataConfirmAttributeName, $this->groupActionsConfirmDialog);
$submit->setHtmlAttribute('data-group-action', 'true');
}
} else {
Expand Down Expand Up @@ -265,6 +267,11 @@ public function getGroupAction(string $title): GroupAction
throw new DataGridGroupActionException(sprintf('Group action %s does not exist.', $title));
}

public function setGroupActionsConfirmDialog(string $confirmDialog): void
{
$this->groupActionsConfirmDialog = $confirmDialog;
}

private function getFormSubmitter(NetteForm $form): ?SubmitButton
{
$container = $form['group_action'];
Expand Down

0 comments on commit 1a2fa59

Please sign in to comment.