diff --git a/app/AccountancyModule/Components/Cashbook/InvertChitDialog.php b/app/AccountancyModule/Components/Cashbook/InvertChitDialog.php index acf58c5ea..fdff6dd55 100644 --- a/app/AccountancyModule/Components/Cashbook/InvertChitDialog.php +++ b/app/AccountancyModule/Components/Cashbook/InvertChitDialog.php @@ -4,7 +4,7 @@ namespace App\AccountancyModule\Components\Cashbook; -use App\AccountancyModule\Components\BaseControl; +use App\AccountancyModule\Components\Dialog; use App\Forms\BaseForm; use Model\Cashbook\Cashbook\CashbookId; use Model\Cashbook\Cashbook\CashbookType; @@ -29,7 +29,7 @@ use function in_array; use function sprintf; -class InvertChitDialog extends BaseControl +class InvertChitDialog extends Dialog { /** * (string because persistent parameters aren't auto-casted) @@ -46,14 +46,9 @@ public function __construct(private CashbookId $cashbookId, private CommandBus $ { } - public function handleOpen(int $chitId): void + public function handleOpen(int|null $chitId = null): void { $this->chitId = $chitId; - $this->redrawControl(); - } - - public function render(): void - { if ($this->chitId !== null && ! $this->isChitValid()) { throw new BadRequestException( sprintf('Chit %d doesn\'t exist or can\'t be inverted', $this->chitId), @@ -61,15 +56,16 @@ public function render(): void ); } - $template = $this->template; + $this->show(); + } - $template->setParameters([ + public function beforeRender(): void + { + $this->template->setFile(__DIR__ . '/templates/InvertChitDialog.latte'); + $this->template->setParameters([ 'renderModal' => $this->chitId !== null, 'noCashbooks' => ! $this->isChitValid() || count($this->getCashbooks()) === 0, ]); - - $template->setFile(__DIR__ . '/templates/InvertChitDialog.latte'); - $template->render(); } /** @return CashbookType[] */ @@ -177,6 +173,6 @@ private function getChit(): Chit|null private function close(): void { $this->chitId = null; - $this->redrawControl(); + $this->hide(); } } diff --git a/app/AccountancyModule/Components/Cashbook/templates/InvertChitDialog.latte b/app/AccountancyModule/Components/Cashbook/templates/InvertChitDialog.latte index 31810f7f9..e8a80a1e5 100644 --- a/app/AccountancyModule/Components/Cashbook/templates/InvertChitDialog.latte +++ b/app/AccountancyModule/Components/Cashbook/templates/InvertChitDialog.latte @@ -1,23 +1,23 @@ - +{layout $layout} + +{define control $input, $extraClasses} + +{/define} + +{define errors $input} +
{$error}
+{/define} + +{block dialog-title}Vytvořit protidoklad{/block} + +{block dialog-body} + {if $noCashbooks} + Nemáte žádné pokladní knihy, ve kterých můžete vytvořit protidoklad. + {else} +

+ Vyberte pokladní knihu, ve které má být protidoklad vytvořen: +

+ {control form} + {/if} + +{/block} \ No newline at end of file