From 86345760ea3e18f035e428289afe3c9d3041e4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20L=C3=B8vgaard?= Date: Fri, 3 Jan 2025 08:43:20 +0100 Subject: [PATCH] Create very simple grid for catalog promotion updates --- .../SetonoSyliusCatalogPromotionExtension.php | 44 +++++++++++++++++++ src/Resources/config/routes/admin.yaml | 12 +++++ src/Resources/translations/messages.en.yaml | 27 +++++++----- .../field/catalog_promotion_list.html.twig | 6 +++ 4 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 src/Resources/views/Admin/grid/field/catalog_promotion_list.html.twig diff --git a/src/DependencyInjection/SetonoSyliusCatalogPromotionExtension.php b/src/DependencyInjection/SetonoSyliusCatalogPromotionExtension.php index 016e2db..02d533a 100644 --- a/src/DependencyInjection/SetonoSyliusCatalogPromotionExtension.php +++ b/src/DependencyInjection/SetonoSyliusCatalogPromotionExtension.php @@ -49,6 +49,50 @@ public function prepend(ContainerBuilder $container): void $container->prependExtensionConfig('sylius_grid', [ 'grids' => [ + 'setono_sylius_catalog_promotion_admin_catalog_promotion_update' => [ + 'driver' => [ + 'name' => 'doctrine/orm', + 'options' => [ + 'class' => '%setono_sylius_catalog_promotion.model.catalog_promotion_update.class%', + ], + ], + 'sorting' => [ + 'createdAt' => 'desc', + ], + 'limits' => [100, 200, 500], + 'fields' => [ + 'state' => [ + 'type' => 'string', + 'label' => 'sylius.ui.state', + 'sortable' => null, + ], + 'catalogPromotions' => [ + 'type' => 'twig', + 'label' => 'setono_sylius_catalog_promotion.ui.catalog_promotions', + 'options' => [ + 'template' => '@SetonoSyliusCatalogPromotionPlugin/Admin/grid/field/catalog_promotion_list.html.twig', + ], + ], + 'createdAt' => [ + 'type' => 'datetime', + 'label' => 'sylius.ui.created_at', + 'sortable' => null, + ], + 'updatedAt' => [ + 'type' => 'datetime', + 'label' => 'setono_sylius_catalog_promotion.ui.updated_at', + 'sortable' => null, + ], + ], +// todo add show action +// 'actions' => [ +// 'item' => [ +// 'show' => [ +// 'type' => 'show', +// ], +// ], +// ], + ], 'setono_sylius_catalog_promotion_admin_promotion' => [ 'driver' => [ 'name' => 'doctrine/orm', diff --git a/src/Resources/config/routes/admin.yaml b/src/Resources/config/routes/admin.yaml index b8837ff..8534018 100644 --- a/src/Resources/config/routes/admin.yaml +++ b/src/Resources/config/routes/admin.yaml @@ -1,3 +1,15 @@ +setono_sylius_catalog_promotion_admin_catalog_promotion_update: + resource: | + alias: setono_sylius_catalog_promotion.catalog_promotion_update + section: admin + templates: '@SyliusAdmin\\Crud' + grid: setono_sylius_catalog_promotion_admin_catalog_promotion_update + permission: true + vars: + index: + icon: in cart + type: sylius.resource + setono_sylius_catalog_promotion_admin_promotion: resource: | alias: setono_sylius_catalog_promotion.promotion diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 0a7ff56..1b15302 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -1,16 +1,4 @@ setono_sylius_catalog_promotion: - ui: - edit_promotion: Edit catalog promotion - manage_promotions: Manage catalog promotions - new_promotion: Create new catalog promotion - promotion: Catalog promotion - promotions: Catalog promotions - rules_explanation: If you don't add any rules, the promotion will be applied to all products - menu: - admin: - main: - marketing: - promotions: Catalog promotions form: promotion: add_rule: Add rule @@ -40,3 +28,18 @@ setono_sylius_catalog_promotion: taxons: Taxons taxonomy: Taxonomy type: Type + menu: + admin: + main: + marketing: + promotions: Catalog promotions + ui: + catalog_promotions: Catalog promotions + edit_promotion: Edit catalog promotion + manage_promotions: Manage catalog promotions + new_promotion: Create new catalog promotion + promotion: Catalog promotion + promotions: Catalog promotions + rules_explanation: If you don't add any rules, the promotion will be applied to all products + updated_at: Updated at + catalog_promotion_updates: Catalog promotion updates diff --git a/src/Resources/views/Admin/grid/field/catalog_promotion_list.html.twig b/src/Resources/views/Admin/grid/field/catalog_promotion_list.html.twig new file mode 100644 index 0000000..718136b --- /dev/null +++ b/src/Resources/views/Admin/grid/field/catalog_promotion_list.html.twig @@ -0,0 +1,6 @@ +{# @var data string[] #} +