diff --git a/config/grids.yaml b/config/grids.yaml index e1956741..3fc6e873 100644 --- a/config/grids.yaml +++ b/config/grids.yaml @@ -1,5 +1,6 @@ sylius_grid: grids: + # Grid of commands (that will be scheduled) synolia_admin_commands: driver: options: @@ -58,11 +59,22 @@ sylius_grid: main: create: type: create + history: + type: link + label: synolia.menu.admin.main.configuration.scheduler_command_history + options: + class: 'btn-ghost-azure' + icon: 'tabler:clock' + link: + route: 'synolia_admin_scheduled_command_index' + parameters: {} item: execute: - type: schedule_command_execute_immediate + type: link label: synolia.ui.scheduled_command.execute_immediate options: + icon: 'tabler:refresh' + class: 'btn-primary' link: route: execute_immediate_schedule parameters: @@ -74,6 +86,7 @@ sylius_grid: bulk: delete: type: delete + # Grid of scheduled commands (historical) synolia_admin_scheduled_commands: driver: options: @@ -90,12 +103,13 @@ sylius_grid: options: template: '@SynoliaSyliusSchedulerCommandPlugin/Grid/Column/scheduled_command_state.html.twig' executedAt: - type: scheduled_command_executed_at + type: twig sortable: createdAt label: synolia.ui.scheduled_command.last_execution options: - date_format: !php/const \IntlDateFormatter::SHORT - time_format: !php/const \IntlDateFormatter::SHORT + template: '@SyliusAdmin/shared/grid/field/date.html.twig' + vars: + th_class: 'w-1 text-center' commandExecutionTime: type: scheduled_command_execution_time label: synolia.ui.scheduled_command.command_execution_time @@ -129,6 +143,15 @@ sylius_grid: create: type: create label: synolia.ui.launch_a_command + list: + type: link + label: synolia.menu.admin.main.configuration.scheduler_command + options: + class: 'btn-ghost-azure' + icon: 'tabler:list' + link: + route: 'synolia_admin_command_index' + parameters: {} item: delete: type: delete @@ -137,5 +160,4 @@ sylius_grid: type: delete templates: action: - schedule_command_execute_immediate: "@SynoliaSyliusSchedulerCommandPlugin/Grid/Action/execute_immediate.html.twig" link: "@SynoliaSyliusSchedulerCommandPlugin/Grid/Action/link.html.twig" diff --git a/src/Grid/FieldType/DatetimeFieldType.php b/src/Grid/FieldType/DatetimeFieldType.php deleted file mode 100644 index 933291c7..00000000 --- a/src/Grid/FieldType/DatetimeFieldType.php +++ /dev/null @@ -1,57 +0,0 @@ - 'scheduled_command_executed_at'])] -final readonly class DatetimeFieldType implements FieldTypeInterface -{ - public function __construct( - #[Autowire('@sylius.grid.data_extractor.property_access')] - private DataExtractorInterface $dataExtractor, - private LocaleContextInterface $localeContext, - ) { - } - - /** - * @inheritDoc - */ - public function render(Field $field, $data, array $options): string - { - $value = $this->dataExtractor->get($field, $data); - if (!$value instanceof \DateTimeInterface) { - return ''; - } - - /** @var \IntlDateFormatter|null $fmt */ - $fmt = \datefmt_create($this->localeContext->getLocaleCode(), $options['date_format'], $options['time_format']); - - if (!$fmt instanceof \IntlDateFormatter) { - return ''; - } - - /** @phpstan-ignore-next-line */ - return $fmt->format($value) ?: ''; - } - - public function configureOptions(OptionsResolver $resolver): void - { - $resolver->setDefaults([ - 'format' => 'Y-m-d H:i:s', - 'date_format' => \IntlDateFormatter::SHORT, - 'time_format' => \IntlDateFormatter::SHORT, - ]); - $resolver->setAllowedTypes('format', 'string'); - $resolver->setAllowedTypes('date_format', 'integer'); - $resolver->setAllowedTypes('time_format', 'integer'); - } -} diff --git a/src/Listener/Grid/GoToCommandsButtonGridListener.php b/src/Listener/Grid/GoToCommandsButtonGridListener.php deleted file mode 100644 index 2e975dc9..00000000 --- a/src/Listener/Grid/GoToCommandsButtonGridListener.php +++ /dev/null @@ -1,42 +0,0 @@ -getGrid(); - - if (!$grid->hasActionGroup('main')) { - $grid->addActionGroup(ActionGroup::named('main')); - } - - $actionGroup = $grid->getActionGroup('main'); - - if ($actionGroup->hasAction('go_to_commands')) { - return; - } - - $action = Action::fromNameAndType('go_to_commands', 'link'); - $action->setLabel('synolia.menu.admin.main.configuration.scheduler_command'); - $action->setOptions([ - 'class' => 'btn-ghost-azure', - 'icon' => 'tabler:list', - 'link' => [ - 'route' => 'synolia_admin_command_index', - 'parameters' => [], - ], - ]); - - $actionGroup->addAction($action); - } -} diff --git a/src/Listener/Grid/GoToHistoryButtonGridListener.php b/src/Listener/Grid/GoToHistoryButtonGridListener.php deleted file mode 100644 index 6773d854..00000000 --- a/src/Listener/Grid/GoToHistoryButtonGridListener.php +++ /dev/null @@ -1,42 +0,0 @@ -getGrid(); - - if (!$grid->hasActionGroup('main')) { - $grid->addActionGroup(ActionGroup::named('main')); - } - - $actionGroup = $grid->getActionGroup('main'); - - if ($actionGroup->hasAction('go_to_history')) { - return; - } - - $action = Action::fromNameAndType('go_to_history', 'link'); - $action->setLabel('synolia.menu.admin.main.configuration.scheduler_command_history'); - $action->setOptions([ - 'class' => 'btn-ghost-azure', - 'icon' => 'tabler:clock', - 'link' => [ - 'route' => 'synolia_admin_scheduled_command_index', - 'parameters' => [], - ], - ]); - - $actionGroup->addAction($action); - } -} diff --git a/templates/Controller/show.html.twig b/templates/Controller/show.html.twig index 878580f3..130b83eb 100644 --- a/templates/Controller/show.html.twig +++ b/templates/Controller/show.html.twig @@ -10,7 +10,7 @@ -
+    
         
     
diff --git a/templates/Grid/Action/execute_immediate.html.twig b/templates/Grid/Action/execute_immediate.html.twig deleted file mode 100644 index a6fe32e0..00000000 --- a/templates/Grid/Action/execute_immediate.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -{% import '@SyliusAdmin/shared/helper/button.html.twig' as buttons %} - -{% set path = options.link.url|default(path(options.link.route, options.link.parameters)) %} - -{{ buttons.default({url: path, text: action.label|trans, icon: 'tabler:refresh', class: 'btn-primary'}) }}