diff --git a/src/Form/Extension/ProductTypeExtension.php b/src/Form/Extension/ProductTypeExtension.php
index 4e1122ba..86bf3bfb 100644
--- a/src/Form/Extension/ProductTypeExtension.php
+++ b/src/Form/Extension/ProductTypeExtension.php
@@ -12,7 +12,7 @@
namespace BitBag\SyliusProductBundlePlugin\Form\Extension;
use BitBag\SyliusProductBundlePlugin\Form\Type\ProductBundleType;
-use Sylius\Bundle\ProductBundle\Form\Type\ProductType;
+use Sylius\Bundle\AdminBundle\Form\Type\ProductType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Valid;
diff --git a/src/Form/Type/ProductBundleItemType.php b/src/Form/Type/ProductBundleItemType.php
index c40d928a..e66bac06 100644
--- a/src/Form/Type/ProductBundleItemType.php
+++ b/src/Form/Type/ProductBundleItemType.php
@@ -15,7 +15,13 @@
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField;
+use Symfony\UX\Autocomplete\Form\BaseEntityAutocompleteType;
+#[AsEntityAutocompleteField(
+ alias: 'sylius_admin_product_bundle_item',
+ route: 'sylius_admin_entity_autocomplete',
+)]
final class ProductBundleItemType extends AbstractResourceType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
@@ -38,4 +44,9 @@ public function getBlockPrefix(): string
{
return 'bitbag_sylius_product_bundle_plugin_product_bundle_item';
}
+
+ public function getParent(): string
+ {
+ return BaseEntityAutocompleteType::class;
+ }
}
diff --git a/src/Form/Type/ProductBundleType.php b/src/Form/Type/ProductBundleType.php
index d1cdd7ab..a703774b 100644
--- a/src/Form/Type/ProductBundleType.php
+++ b/src/Form/Type/ProductBundleType.php
@@ -11,10 +11,12 @@
namespace BitBag\SyliusProductBundlePlugin\Form\Type;
+use Sylius\Bundle\AdminBundle\Form\Type\AddButtonType;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType;
final class ProductBundleType extends AbstractResourceType
{
@@ -24,13 +26,32 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('isPackedProduct', CheckboxType::class, [
'label' => 'bitbag_sylius_product_bundle.ui.is_packed_product',
])
- ->add('productBundleItems', CollectionType::class, [
+// ->add('rules', LiveCollectionType::class, [
+// 'entry_type' => AutomaticBlacklistingRuleType::class,
+// 'allow_add' => true,
+// 'allow_delete' => true,
+// 'by_reference' => false,
+// 'button_add_type' => AddButtonType::class,
+// 'button_add_options' => [
+// 'label' => 'sylius.ui.add_rule',
+// 'types' => $this->rules,
+// ],
+// 'button_delete_options' => [
+// 'label' => false,
+// ],
+// ])
+ ->add('productBundleItems', LiveCollectionType::class, [
'entry_type' => ProductBundleItemType::class,
- 'entry_options' => ['label' => false],
+// 'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'label' => false,
+ 'button_add_type' => AddButtonType::class,
+// 'button_add_options' => [
+// 'label' => 'sylius.ui.add_rule',
+//// 'types' => $this->rules,
+// ],
])
;
}
diff --git a/src/Menu/AdminProductFormMenuListener.php b/src/Menu/AdminProductFormMenuListener.php
index f461e37d..f6bc4e46 100644
--- a/src/Menu/AdminProductFormMenuListener.php
+++ b/src/Menu/AdminProductFormMenuListener.php
@@ -21,7 +21,7 @@ public function addItems(ProductMenuBuilderEvent $event): void
$menu
->addChild('bundle')
- ->setAttribute('template', '@BitBagSyliusProductBundlePlugin/Admin/Product/Tab/_bundle.html.twig')
+ ->setAttribute('template', '@BitBagSyliusProductBundlePlugin/Admin/product/form/side_navigation/bundle.html.twig')
->setLabel('bitbag_sylius_product_bundle.ui.bundle')
;
}
diff --git a/src/Resources/config/config.yml b/src/Resources/config/config.yml
index a8236304..10cf4e9f 100644
--- a/src/Resources/config/config.yml
+++ b/src/Resources/config/config.yml
@@ -1,6 +1,7 @@
imports:
- { resource: resources.yml }
- { resource: services.xml }
+ - {resource: "@BitBagSyliusProductBundlePlugin/Resources/config/twig_hooks/twig_hooks.yaml"}
framework:
messenger:
diff --git a/src/Resources/config/routing/admin.yml b/src/Resources/config/routing/admin.yml
index 3cfad445..814fe3f1 100644
--- a/src/Resources/config/routing/admin.yml
+++ b/src/Resources/config/routing/admin.yml
@@ -11,6 +11,7 @@ bitbag_product_bundle_admin_product_create_bundle:
template: "@SyliusAdmin/shared/crud/create.html.twig"
redirect: sylius_admin_product_update
form:
+ type: Sylius\Bundle\AdminBundle\Form\Type\ProductType
options:
validation_groups:
- sylius
@@ -18,7 +19,7 @@ bitbag_product_bundle_admin_product_create_bundle:
vars:
subheader: sylius.ui.manage_your_product_catalog
templates:
- form: "@SyliusAdmin/Product/form.html.twig"
+ form: "@SyliusAdmin/product/form.html.twig"
route:
name: bitbag_product_bundle_admin_product_create_bundle
diff --git a/src/Resources/config/services/form.xml b/src/Resources/config/services/form.xml
index b64a68d5..79d3db6f 100644
--- a/src/Resources/config/services/form.xml
+++ b/src/Resources/config/services/form.xml
@@ -22,10 +22,11 @@
%bitbag_sylius_product_bundle.model.product_bundle_item.class%
%bitbag_sylius_product_bundle.form.type.product_bundle_item.validation_groups%
+
-
+
diff --git a/src/Resources/config/twig_hooks/product/create.yaml b/src/Resources/config/twig_hooks/product/create.yaml
new file mode 100644
index 00000000..a61adb7e
--- /dev/null
+++ b/src/Resources/config/twig_hooks/product/create.yaml
@@ -0,0 +1,57 @@
+twig_hooks:
+ hooks:
+ 'sylius_admin.product.create.content.form.side_navigation':
+ general:
+ template: '@SyliusAdmin/product/form/side_navigation/general.html.twig'
+ configuration:
+ active: true
+ channel_pricing:
+ template: '@SyliusAdmin/product/form/side_navigation/channel_pricing.html.twig'
+ taxes:
+ template: '@SyliusAdmin/product/form/side_navigation/taxes.html.twig'
+ shipping:
+ template: '@SyliusAdmin/product/form/side_navigation/shipping.html.twig'
+ inventory:
+ template: '@SyliusAdmin/product/form/side_navigation/inventory.html.twig'
+ translations:
+ template: '@SyliusAdmin/product/form/side_navigation/translations.html.twig'
+ taxonomy:
+ template: '@SyliusAdmin/product/form/side_navigation/taxonomy.html.twig'
+ attributes:
+ template: '@SyliusAdmin/product/form/side_navigation/attributes.html.twig'
+ associations:
+ template: '@SyliusAdmin/product/form/side_navigation/associations.html.twig'
+ media:
+ template: '@SyliusAdmin/product/form/side_navigation/media.html.twig'
+ bundle:
+ template: '@BitBagSyliusProductBundlePlugin/Admin/product/form/side_navigation/bundle.html.twig'
+
+ 'sylius_admin.product.create.content.form.sections':
+ general:
+ template: '@SyliusAdmin/product/form/sections/general.html.twig'
+ configuration:
+ active: true
+ channel_pricing:
+ template: '@SyliusAdmin/product/form/sections/channel_pricing.html.twig'
+ taxes:
+ template: '@SyliusAdmin/product/form/sections/taxes.html.twig'
+ shipping:
+ template: '@SyliusAdmin/product/form/sections/shipping.html.twig'
+ inventory:
+ template: '@SyliusAdmin/product/form/sections/inventory.html.twig'
+ translations:
+ template: '@SyliusAdmin/product/form/sections/translations.html.twig'
+ taxonomy:
+ template: '@SyliusAdmin/product/form/sections/taxonomy.html.twig'
+ attributes:
+ template: '@SyliusAdmin/product/form/sections/attributes.html.twig'
+ associations:
+ template: '@SyliusAdmin/product/form/sections/associations.html.twig'
+ media:
+ template: '@SyliusAdmin/product/form/sections/media.html.twig'
+ bundle:
+ template: '@BitBagSyliusProductBundlePlugin/Admin/product/form/sections/bundle.html.twig'
+
+ 'sylius_admin.product.create.content.form.sections.bundle':
+ item:
+ template: '@BitBagSyliusProductBundlePlugin/Admin/Form/productBundleItem.html.twig'
diff --git a/src/Resources/config/twig_hooks/twig_hooks.yaml b/src/Resources/config/twig_hooks/twig_hooks.yaml
new file mode 100644
index 00000000..9ac41c4b
--- /dev/null
+++ b/src/Resources/config/twig_hooks/twig_hooks.yaml
@@ -0,0 +1,2 @@
+imports:
+ - { resource: "@BitBagSyliusProductBundlePlugin/Resources/config/twig_hooks/product/create.yaml" }
diff --git a/src/Resources/views/Admin/Form/productBundleItem.html.twig b/src/Resources/views/Admin/Form/productBundleItem.html.twig
index 60d9deb8..8ae2fff2 100644
--- a/src/Resources/views/Admin/Form/productBundleItem.html.twig
+++ b/src/Resources/views/Admin/Form/productBundleItem.html.twig
@@ -1,68 +1,68 @@
-{% extends '@SyliusUi/Form/theme.html.twig' %}
+{#{% extends '@SyliusUi/Form/theme.html.twig' %}#}
-{% block collection_widget -%}
- {% from '@SyliusResource/Macros/notification.html.twig' import error %}
- {% import _self as self %}
- {% set attr = attr|merge({'class': attr.class|default ~ ' controls collection-widget'}) %}
+{#{% block collection_widget -%}#}
+{# {% from '@SyliusResource/Macros/notification.html.twig' import error %}#}
+{# {% import _self as self %}#}
+{# {% set attr = attr|merge({'class': attr.class|default ~ ' controls collection-widget'}) %}#}
- {% apply spaceless %}
-
- {{ error(form.vars.errors) }}
+{# {% apply spaceless %}#}
+{#
#}
+{# {{ error(form.vars.errors) }}#}
- {% if prototypes|default is iterable %}
- {% for key, subPrototype in prototypes %}
-
- {% endfor %}
- {% endif %}
+{# {% if prototypes|default is iterable %}#}
+{# {% for key, subPrototype in prototypes %}#}
+{#
#}
+{# {% endfor %}#}
+{# {% endif %}#}
-
-
-
- {{ 'bitbag_sylius_product_bundle.ui.product_variant'|trans }} |
- {{ 'bitbag_sylius_product_bundle.ui.quantity'|trans }} |
- {{ 'bitbag_sylius_product_bundle.ui.delete'|trans }} |
-
-
-
- {% for child in form %}
- {{ self.collection_item(child, allow_delete, button_delete_label, loop.index0) }}
- {% endfor %}
-
-
+{#
#}
+{# #}
+{# #}
+{# {{ 'bitbag_sylius_product_bundle.ui.product_variant'|trans }} | #}
+{# {{ 'bitbag_sylius_product_bundle.ui.quantity'|trans }} | #}
+{# {{ 'bitbag_sylius_product_bundle.ui.delete'|trans }} | #}
+{#
#}
+{# #}
+{# #}
+{# {% for child in form %}#}
+{# {{ self.collection_item(child, allow_delete, button_delete_label, loop.index0) }}#}
+{# {% endfor %}#}
+{# #}
+{#
#}
- {% if prototype is defined and allow_add %}
-
-
- {{ button_add_label|trans }}
-
- {% endif %}
-
- {% endapply %}
-{%- endblock collection_widget %}
+{# {% if prototype is defined and allow_add %}#}
+{#
#}
+{# #}
+{# {{ button_add_label|trans }}#}
+{# #}
+{# {% endif %}#}
+{#
#}
+{# {% endapply %}#}
+{#{%- endblock collection_widget %}#}
-{% macro collection_item(form, allow_delete, button_delete_label, index) %}
- {% apply spaceless %}
-
-
- {{ form_row(form.productVariant, {'remote_url': path('bitbag_product_bundle_admin_ajax_product_variants_by_phrase'), 'remote_criteria_type': 'contains', 'remote_criteria_name': 'phrase', 'load_edit_url': path('bitbag_product_bundle_admin_ajax_product_variants_by_codes')}) }}
- |
-
- {{ form_row(form.quantity) }}
- |
+{#{% macro collection_item(form, allow_delete, button_delete_label, index) %}#}
+{# {% apply spaceless %}#}
+{#
#}
+{# #}
+{# {{ form_row(form.productVariant, {'remote_url': path('bitbag_product_bundle_admin_ajax_product_variants_by_phrase'), 'remote_criteria_type': 'contains', 'remote_criteria_name': 'phrase', 'load_edit_url': path('bitbag_product_bundle_admin_ajax_product_variants_by_codes')}) }} #}
+{# | #}
+{# #}
+{# {{ form_row(form.quantity) }}#}
+{# | #}
- {% if allow_delete %}
-
-
-
- {{ button_delete_label|trans }}
-
- |
- {% endif %}
-
- {% endapply %}
-{% endmacro %}
+{# {% if allow_delete %}#}
+{# #}
+{# #}
+{# #}
+{# {{ button_delete_label|trans }}#}
+{# #}
+{# | #}
+{# {% endif %}#}
+{# #}
+{# {% endapply %}#}
+{#{% endmacro %}#}
diff --git a/src/Resources/views/Admin/Product/Tab/_bundle.html.twig b/src/Resources/views/Admin/Product/Tab/_bundle.html.twig
deleted file mode 100644
index 586e8568..00000000
--- a/src/Resources/views/Admin/Product/Tab/_bundle.html.twig
+++ /dev/null
@@ -1,9 +0,0 @@
-{% form_theme form '@BitBagSyliusProductBundlePlugin/Admin/Form/productBundleItem.html.twig' %}
-
-
-
- {{ form_row(form.productBundle.isPackedProduct) }}
- {{ form_row(form.productBundle.productBundleItems) }}
-
- {{ sonata_block_render_event('sylius.admin.product.' ~ action ~ '.tab_bundle', {'form': form }) }}
-
diff --git a/src/Resources/views/Admin/product/form/sections/bundle.html.twig b/src/Resources/views/Admin/product/form/sections/bundle.html.twig
new file mode 100644
index 00000000..a488704d
--- /dev/null
+++ b/src/Resources/views/Admin/product/form/sections/bundle.html.twig
@@ -0,0 +1,21 @@
+{#{% form_theme form '@BitBagSyliusProductBundlePlugin/Admin/Form/productBundleItem.html.twig' %}#}
+{% set form = hookable_metadata.context.form %}
+{% set product = hookable_metadata.context.resource %}
+
+
+
+
+
+ {{ dump(form) }}
+ {{ form_row(form.productBundle.isPackedProduct) }}
+ {{ form_row(form.productBundle.productBundleItems) }}
+{# {{ sonata_block_render_event('sylius.admin.product.' ~ action ~ '.tab_bundle', {'form': form }) }}#}
+ {% hook 'bundle' with { product } %}
+
+
+
+
diff --git a/src/Resources/views/Admin/product/form/side_navigation/bundle.html.twig b/src/Resources/views/Admin/product/form/side_navigation/bundle.html.twig
new file mode 100644
index 00000000..65795eb9
--- /dev/null
+++ b/src/Resources/views/Admin/product/form/side_navigation/bundle.html.twig
@@ -0,0 +1,10 @@
+
diff --git a/tests/Application/config/routes/sylius_admin.yaml b/tests/Application/config/routes/sylius_admin.yaml
index 1ba48d6c..c76c4334 100644
--- a/tests/Application/config/routes/sylius_admin.yaml
+++ b/tests/Application/config/routes/sylius_admin.yaml
@@ -1,3 +1,7 @@
sylius_admin:
resource: "@SyliusAdminBundle/Resources/config/routing.yml"
prefix: /admin
+
+live_component:
+ resource: "@LiveComponentBundle/config/routes.php"
+ prefix: /_components
diff --git a/tests/Application/config/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml
index fae46cbf..45ffc62f 100644
--- a/tests/Application/config/routes/sylius_shop.yaml
+++ b/tests/Application/config/routes/sylius_shop.yaml
@@ -12,3 +12,7 @@ sylius_shop_default_locale:
methods: [GET]
defaults:
_controller: sylius.controller.shop.locale_switch::switchAction
+
+live_component:
+ resource: "@LiveComponentBundle/config/routes.php"
+ prefix: /_components