diff --git a/doc/01-installation.md b/doc/01-installation.md index 71ac013e..814412f1 100644 --- a/doc/01-installation.md +++ b/doc/01-installation.md @@ -29,8 +29,8 @@ return [ ```yaml # config/packages/_sylius.yaml imports: - ... - - { resource: "@BitBagSyliusWishlistPlugin/Resources/config/config.yml" } + ... + - { resource: "@BitBagSyliusWishlistPlugin/Resources/config/config.yml" } ``` 4. (optional) Import routing in your `config/routes.yaml` file: @@ -45,10 +45,10 @@ bitbag_sylius_wishlist_plugin: ```yaml sylius_order: - resources: - order_item: - classes: - controller: BitBag\SyliusWishlistPlugin\Controller\OrderItemController + resources: + order_item: + classes: + controller: BitBag\SyliusWishlistPlugin\Controller\OrderItemController ``` @@ -59,11 +59,6 @@ sylius_order: ```yaml sylius_ui: events: - sylius.shop.layout.header.grid: - blocks: - cart: - template: "@BitBagSyliusWishlistPlugin/_cart.html.twig" - priority: 10 sylius.shop.product.index.box: blocks: content: diff --git a/spec/Controller/Action/ListWishlistProductsActionSpec.php b/spec/Controller/Action/ListWishlistProductsActionSpec.php index 41713379..52d6b3ee 100644 --- a/spec/Controller/Action/ListWishlistProductsActionSpec.php +++ b/spec/Controller/Action/ListWishlistProductsActionSpec.php @@ -93,7 +93,7 @@ public function it_lists_wishlist_items( $form->createView()->willReturn($formView); $twigEnvironment ->render( - '@BitBagSyliusWishlistPlugin/WishlistDetails/index.html.twig', + '@BitBagSyliusWishlistPlugin/shop/wishlist/index.html.twig', [ 'wishlist' => $wishlist, 'form' => $formView, diff --git a/spec/Exporter/DomPdfWishlistExporterSpec.php b/spec/Exporter/DomPdfWishlistExporterSpec.php index 0ee40f99..f79fcbf3 100644 --- a/spec/Exporter/DomPdfWishlistExporterSpec.php +++ b/spec/Exporter/DomPdfWishlistExporterSpec.php @@ -52,7 +52,7 @@ public function it_returns_pdf_as_attachment( $html = ''; - $twigEnvironment->render('@BitBagSyliusWishlistPlugin/_wishlist_pdf.html.twig', [ + $twigEnvironment->render('@BitBagSyliusWishlistPlugin/shop/wishlist/wishlist_pdf.html.twig', [ 'title' => 'My wishlist products', 'date' => date('d.m.Y'), 'products' => $data, diff --git a/src/Controller/Action/ImportWishlistFromCsvAction.php b/src/Controller/Action/ImportWishlistFromCsvAction.php index 711b91c9..346eead7 100644 --- a/src/Controller/Action/ImportWishlistFromCsvAction.php +++ b/src/Controller/Action/ImportWishlistFromCsvAction.php @@ -60,7 +60,7 @@ public function __invoke(Request $request): Response } return new Response( - $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/importWishlist.html.twig', [ + $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/shop/wishlist/import_wishlist.html.twig', [ 'form' => $form->createView(), ]), ); diff --git a/src/Controller/Action/ListWishlistProductsAction.php b/src/Controller/Action/ListWishlistProductsAction.php index 63281665..9f122a7b 100644 --- a/src/Controller/Action/ListWishlistProductsAction.php +++ b/src/Controller/Action/ListWishlistProductsAction.php @@ -90,7 +90,7 @@ public function __invoke(Request $request): Response ]); return new Response( - $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/WishlistDetails/index.html.twig', [ + $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/shop/wishlist/index.html.twig', [ 'wishlist' => $wishlist, 'form' => $form->createView(), ]), diff --git a/src/Controller/Action/ShowChosenWishlistAction.php b/src/Controller/Action/ShowChosenWishlistAction.php index 3f9288f5..0f1cf925 100644 --- a/src/Controller/Action/ShowChosenWishlistAction.php +++ b/src/Controller/Action/ShowChosenWishlistAction.php @@ -70,7 +70,7 @@ public function __invoke(string $wishlistId, Request $request): Response $form = $this->createForm($wishlist); return new Response( - $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/WishlistDetails/index.html.twig', [ + $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/shop/wishlist/index.html.twig', [ 'wishlist' => $wishlist, 'form' => $form->createView(), ]), diff --git a/src/Exporter/DomPdfWishlistExporter.php b/src/Exporter/DomPdfWishlistExporter.php index f5099874..32b2c460 100644 --- a/src/Exporter/DomPdfWishlistExporter.php +++ b/src/Exporter/DomPdfWishlistExporter.php @@ -26,7 +26,7 @@ public function __construct( public function export(Collection $data): void { $dompdf = $this->domPdfFactory->createNewWithDefaultOptions(); - $html = $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/_wishlist_pdf.html.twig', [ + $html = $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/shop/wishlist/wishlist_pdf.html.twig', [ 'title' => 'My wishlist products', 'date' => date('d.m.Y'), 'products' => $data, diff --git a/src/Form/Type/AddProductsToCartType.php b/src/Form/Type/AddProductsToCartType.php index 6069add6..d5477a7b 100644 --- a/src/Form/Type/AddProductsToCartType.php +++ b/src/Form/Type/AddProductsToCartType.php @@ -54,6 +54,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add('selected', CheckboxType::class, [ 'required' => false, + 'label' => false, ]); }); } diff --git a/src/Resources/assets/shop/js/WishlistVariantPrice.js b/src/Resources/assets/shop/js/WishlistVariantPrice.js index 2d8aaa71..68cdcf86 100644 --- a/src/Resources/assets/shop/js/WishlistVariantPrice.js +++ b/src/Resources/assets/shop/js/WishlistVariantPrice.js @@ -1,3 +1,4 @@ +//TODO adjust this to work with the new wishlist view export class WishlistVariantPrice { constructor(node) { if (node === null || !node.nodeType) throw new Error("The first parameter must be a NodeElement"); diff --git a/src/Resources/assets/shop/js/wishlistMainCheckboxUpdater.js b/src/Resources/assets/shop/js/wishlistMainCheckboxUpdater.js index 0f1dc144..33020f0b 100644 --- a/src/Resources/assets/shop/js/wishlistMainCheckboxUpdater.js +++ b/src/Resources/assets/shop/js/wishlistMainCheckboxUpdater.js @@ -6,7 +6,7 @@ export class WishlistMainCheckboxUpdater { this.defaultConfig = { mainCheckboxId: '#toggle-checkboxes', checkboxesData: '[data-bb-checkboxes] input', - bulkActionsBtnClass: '.bb-colective-actions', + bulkActionsBtnClass: '.bb-collective-actions', }; this.finalConfig = {...this.defaultConfig, ...config}; this.mainCheckbox = document.querySelector(this.finalConfig.mainCheckboxId) diff --git a/src/Resources/assets/shop/scss/pages/wishlist-details/_actions.scss b/src/Resources/assets/shop/scss/pages/wishlist-details/_actions.scss index 94dc5d35..6907c863 100644 --- a/src/Resources/assets/shop/scss/pages/wishlist-details/_actions.scss +++ b/src/Resources/assets/shop/scss/pages/wishlist-details/_actions.scss @@ -3,15 +3,4 @@ align-items: center; justify-content: space-between; margin: $spacer * 1.5 0 $spacer * .75; - -} - -.bb-wishlist-actions-import-button { - background-color: #E0E1E2 !important; - color: rgba(0, 0, 0, 0.6) !important; -} - -.bb-wishlist-actions-import-button:hover { - background-color: #CACBCD !important; - color: rgba(0, 0, 0, 0.8) !important; } diff --git a/src/Resources/assets/shop/scss/pages/wishlist-details/_item.scss b/src/Resources/assets/shop/scss/pages/wishlist-details/_item.scss index f3efdca2..e02d0349 100644 --- a/src/Resources/assets/shop/scss/pages/wishlist-details/_item.scss +++ b/src/Resources/assets/shop/scss/pages/wishlist-details/_item.scss @@ -38,12 +38,6 @@ &-image { grid-area: image; - width: 75%; - height: 75%; - - img { - margin-bottom: 24px; - } } &-name { @@ -76,11 +70,5 @@ align-items: center; justify-content: center; } - - > * { - span { - color: $lightgray; - } - } } } diff --git a/src/Resources/assets/shop/scss/pages/wishlist-details/bulkActions.scss b/src/Resources/assets/shop/scss/pages/wishlist-details/bulkActions.scss index 115ad6e8..ad8c62bd 100644 --- a/src/Resources/assets/shop/scss/pages/wishlist-details/bulkActions.scss +++ b/src/Resources/assets/shop/scss/pages/wishlist-details/bulkActions.scss @@ -1,28 +1,9 @@ -.bb-colective-actions { - &.disabled { - opacity: .45; - pointer-events: none; - } - - &.enabled { - } - - .wishlist-dropdown-menu { - &__item { - .wishlist-item--button { - text-align: left; - background: #ffffff !important; - color: rgba(0, 0, 0, 0.95) !important; - width: 100%; - } - - .wishlist-item--button:hover { - background: #E0E1E2 !important; - } - } - - &__item:hover { - background: #ffffff !important; +.bb-dropdown { + .dropdown-item { + &:hover, + &:focus, + &:active{ + background-color: transparent; } } } diff --git a/src/Resources/config/config.yml b/src/Resources/config/config.yml index 53ed0724..6b5ad204 100644 --- a/src/Resources/config/config.yml +++ b/src/Resources/config/config.yml @@ -1,2 +1,3 @@ imports: - { resource: "@BitBagSyliusWishlistPlugin/Resources/config/services.xml" } + - { resource: "@BitBagSyliusWishlistPlugin/Resources/config/twig_hooks/**/*.yaml" } diff --git a/src/Resources/config/twig_hooks/shop/wishlist/index.yaml b/src/Resources/config/twig_hooks/shop/wishlist/index.yaml new file mode 100644 index 00000000..7e5c6631 --- /dev/null +++ b/src/Resources/config/twig_hooks/shop/wishlist/index.yaml @@ -0,0 +1,124 @@ +sylius_twig_hooks: + hooks: + 'bitbag_sylius_wishlist_plugin.wishlist.index': + content: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content': + header: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/header.html.twig" + priority: 100 + form: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.header': + title: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/header/title.html.twig" + priority: 100 + actions: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/header/actions.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.header.actions': + clear: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/header/actions/clear.html.twig" + priority: 100 + new: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/header/actions/new.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.form': + form: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.form.sections': + items: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items.html.twig" + priority: 100 + actions: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.form.sections.actions': + bulk: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions/bulk.html.twig" + priority: 100 + global: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions/global.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.form.sections.actions.global': + import: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions/global/import.html.twig" + priority: 100 + add_to_cart: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions/global/add_to_cart.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.form.sections.actions.bulk': + add_to_cart: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions/bulk/add_to_cart.html.twig" + priority: 400 + remove: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions/bulk/remove.html.twig" + priority: 300 + copy: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions/bulk/copy.html.twig" + priority: 200 + download_csv: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions/bulk/download_csv.html.twig" + priority: 100 + download_pdf: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/actions/bulk/download_pdf.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.form.sections.items': + head: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/head.html.twig" + priority: 100 + body: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/body.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.form.sections.items.head': + select_all: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/head/select_all.html.twig" + priority: 400 + image: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/head/image.html.twig" + priority: 300 + price: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/head/price.html.twig" + priority: 200 + quantity: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/head/quantity.html.twig" + priority: 100 + actions: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/head/actions.html.twig" + priority: 0 + + 'bitbag_sylius_wishlist_plugin.wishlist.index.content.form.sections.items.body': + checkbox: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/body/checkbox.html.twig" + priority: 600 + image: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/body/image.html.twig" + priority: 500 + name: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/body/name.html.twig" + priority: 400 + variant: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/body/variant.html.twig" + priority: 300 + price: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/body/price.html.twig" + priority: 200 + quantity: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/body/quantity.html.twig" + priority: 100 + remove: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist/index/content/form/sections/items/body/remove.html.twig" + priority: 0 diff --git a/src/Resources/config/twig_hooks/shop/wishlist/layout.yaml b/src/Resources/config/twig_hooks/shop/wishlist/layout.yaml new file mode 100644 index 00000000..fdf526f7 --- /dev/null +++ b/src/Resources/config/twig_hooks/shop/wishlist/layout.yaml @@ -0,0 +1,13 @@ +sylius_twig_hooks: + hooks: + 'sylius_shop.base.header.content': + wishlist_header: + template: "@BitBagSyliusWishlistPlugin/shop/wishlist_header.html.twig" + priority: 150 + +# TODO find the right way to extend product box's content +#sylius.shop.product.index.box: +# blocks: +# content: +# template: "@BitBagSyliusWishlistPlugin/Product/Box/_content.html.twig" +# priority: 10 diff --git a/src/Resources/views/Common/_removeFromWishlist.html.twig b/src/Resources/views/Common/_removeFromWishlist.html.twig deleted file mode 100644 index 45067ac9..00000000 --- a/src/Resources/views/Common/_removeFromWishlist.html.twig +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/src/Resources/views/Product/Box/_content.html.twig b/src/Resources/views/Product/Box/_content.html.twig index 04f4b3a2..a5508884 100644 --- a/src/Resources/views/Product/Box/_content.html.twig +++ b/src/Resources/views/Product/Box/_content.html.twig @@ -1,4 +1,4 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} +{% import "@SyliusShop/shared/macro/money.html.twig" as money %}
- - {{ 'sylius.ui.bulk_actions'|trans }} - -
diff --git a/src/Resources/views/WishlistDetails/_globalActions.html.twig b/src/Resources/views/WishlistDetails/_globalActions.html.twig deleted file mode 100644 index d3b696f9..00000000 --- a/src/Resources/views/WishlistDetails/_globalActions.html.twig +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - diff --git a/src/Resources/views/WishlistDetails/_item.html.twig b/src/Resources/views/WishlistDetails/_item.html.twig deleted file mode 100644 index 48ecb5c7..00000000 --- a/src/Resources/views/WishlistDetails/_item.html.twig +++ /dev/null @@ -1,59 +0,0 @@ -{% import "@SyliusCore/Common/Macro/money.html.twig" as money %} - -{% set variant = itemForm.vars.value.wishlistProduct.variant %} -{% set product = variant.product %} -{% set productUrl = path('sylius_shop_product_show', { slug: product.slug, _locale: product.translation.locale }) %} -{% set itemId = "wishlist_item_#{ variant.id }_#{ product.id }" %} - -
- -
- {{ form_widget(itemForm.selected, { id: product.name }) }} -
- -
- {% include '@SyliusShop/Product/_mainImage.html.twig' %} -
- -
- - {{ product.name }} - -
- -
- {% if itemForm.cartItem.cartItem.variant is defined %} -
- {% for child in itemForm.cartItem.cartItem.variant.children %} -
- {{ form_label(child, null, { label_attr: { class: 'bb-wishlist-variant-label'} } ) }} - {{ form_widget(child, { attr: { class: 'bb-wishlist-variant-select', 'data-name': child.vars.name } } ) }} -
- {% endfor %} -
- {% endif %} -
- -
- {% if not product.variants.empty() %} - {% include '@BitBagSyliusWishlistPlugin/WishlistDetails/_variantPrice.html.twig' %} - {% endif %} -
- -
- {{ form_widget(itemForm.cartItem.cartItem.quantity, { - 'attr': { - 'min': 0, - 'data-product-name': product.name, - 'value': itemForm.cartItem.cartItem.quantity.vars.value is same as("0") ? 1 : itemForm.cartItem.cartItem.quantity.vars.value - } - }) }} -
- -
- {% include '@BitBagSyliusWishlistPlugin/Common/_removeFromWishlist.html.twig' %} -
- - {{ sonata_block_render_event('sylius.shop.product.index.after_box', {'product': product}) }} - -
diff --git a/src/Resources/views/WishlistDetails/_variantPrice.html.twig b/src/Resources/views/WishlistDetails/_variantPrice.html.twig deleted file mode 100644 index 6a487e37..00000000 --- a/src/Resources/views/WishlistDetails/_variantPrice.html.twig +++ /dev/null @@ -1,28 +0,0 @@ -{% import "@SyliusCore/Common/Macro/money.html.twig" as money %} - -{% set pricing = sylius_product_variant_prices(product, sylius.channel) %} - -{% set prices %} - [ - {%- for price in pricing -%} - { - {%- for option, value in price -%} - "{{- option -}}": - {%- if option == 'value' or option == 'original-price' -%} - "{{ money.convertAndFormat(value) -}}" - {%- elseif not value is iterable -%} - "{{ value|replace({'\"': '\''}) -}}" - {%- else -%} - "" - {%- endif -%} - {{- not loop.last ? ', '-}} - {%- endfor -%} - } - {{- not loop.last ? ', '-}} - {%- endfor -%} - ] -{% endset %} - - - {{ money.calculatePrice(variant) }} - diff --git a/src/Resources/views/WishlistDetails/index.html.twig b/src/Resources/views/WishlistDetails/index.html.twig deleted file mode 100644 index 80ee0700..00000000 --- a/src/Resources/views/WishlistDetails/index.html.twig +++ /dev/null @@ -1,96 +0,0 @@ -{% extends '@SyliusShop/shared/layout/base.html.twig' %} - -{% import '@SyliusShop/shared/messages.html.twig' as messages %} - -{% block title %}{{ 'bitbag_sylius_wishlist_plugin.ui.your_wishlist'|trans }} | {{ parent() }}{% endblock %} - -{% block content %} -

- -
- {{ wishlist.name }} -
-

- {% if sylius.channel is not null %} - {% set wishlists = findAllByAnonymousAndChannel(sylius.channel) %} - {% else %} - {% set wishlists = findAllByAnonymous() %} - {% endif %} - {% if wishlists|length > 1 %} - {% else %} -
- - -
- {% endif %} - - - {% if wishlist.wishlistProducts.count > 0 %} -
- - {{ 'bitbag_sylius_wishlist_plugin.ui.clear_wishlist'|trans }} - -
- - - - {{ form_start(form, { attr: { class: 'bb-wishlist ui form', id: "wishlist_form" } }) }} - -
- -
-
- -
-
- {{ 'sylius.ui.item'|trans }} -
-
- {{ 'sylius.ui.unit_price'|trans }} -
-
- {{ 'sylius.ui.qty'|trans }} -
-
- {{ 'sylius.ui.actions'|trans }} -
-
- - {% for itemForm in form.items %} - {% include "@BitBagSyliusWishlistPlugin/WishlistDetails/_item.html.twig" %} - - {% endfor %} - -
- {% include "@BitBagSyliusWishlistPlugin/WishlistDetails/_collectiveActions.html.twig" %} - {% include "@BitBagSyliusWishlistPlugin/WishlistDetails/_globalActions.html.twig" %} -
- -
- - {{ form_row(form._token) }} - {{ form_end(form, {'render_rest': false} ) }} - {% else %} -
-
- {{ messages.info('bitbag_sylius_wishlist_plugin.ui.your_wishlist_is_empty'|trans) }} -
- - - -
- {% endif %} - -{% endblock %} diff --git a/src/Resources/views/_cart.html.twig b/src/Resources/views/_cart.html.twig deleted file mode 100644 index 0ce557b2..00000000 --- a/src/Resources/views/_cart.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -
- {% include '@BitBagSyliusWishlistPlugin/_wishlist_header.html.twig' %} - {{ render(url('sylius_shop_partial_cart_summary', {'template': '@SyliusShop/Cart/_widget.html.twig'})) }} -
diff --git a/src/Resources/views/importWishlist.html.twig b/src/Resources/views/shop/wishlist/import_wishlist.html.twig similarity index 100% rename from src/Resources/views/importWishlist.html.twig rename to src/Resources/views/shop/wishlist/import_wishlist.html.twig diff --git a/src/Resources/views/shop/wishlist/index.html.twig b/src/Resources/views/shop/wishlist/index.html.twig new file mode 100644 index 00000000..9ff041c2 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index.html.twig @@ -0,0 +1,9 @@ +{% extends '@SyliusShop/shared/layout/base.html.twig' %} + +{% set prefixes = ['bitbag_sylius_wishlist_plugin.wishlist'] %} + +{% block title %}{{ 'bitbag_sylius_wishlist_plugin.ui.your_wishlist'|trans }} | {{ parent() }}{% endblock %} + +{% block content %} + {% hook 'index' with { _prefixes: prefixes, wishlist, form } %} +{% endblock %} diff --git a/src/Resources/views/shop/wishlist/index/content.html.twig b/src/Resources/views/shop/wishlist/index/content.html.twig new file mode 100644 index 00000000..9203aaff --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content.html.twig @@ -0,0 +1,6 @@ +{% set wishlist = hookable_metadata.context.wishlist %} +{% set form = hookable_metadata.context.form %} + +
+ {% hook 'content' with { wishlist, form } %} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form.html.twig b/src/Resources/views/shop/wishlist/index/content/form.html.twig new file mode 100644 index 00000000..71df562e --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form.html.twig @@ -0,0 +1,20 @@ +{% import '@SyliusShop/shared/messages.html.twig' as messages %} + +{% set wishlist = hookable_metadata.context.wishlist %} +{% set form = hookable_metadata.context.form %} + +{% if wishlist.wishlistProducts.count > 0 %} + + + {% hook 'form' with { wishlist, form } %} +{% else %} +
+ {{ messages.info('bitbag_sylius_wishlist_plugin.ui.your_wishlist_is_empty'|trans) }} +
+ + + +{% endif %} diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections.html.twig new file mode 100644 index 00000000..fdccdb3c --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections.html.twig @@ -0,0 +1,15 @@ +{% set wishlist = hookable_metadata.context.wishlist %} +{% set form = hookable_metadata.context.form %} + +{% form_theme form '@SyliusShop/form/theme.html.twig' %} + +{{ form_start(form, { attr: { class: 'bb-wishlist ui form', id: "wishlist_form" } }) }} + +
+ {% hook 'sections' with { form, wishlist } %} + + +
+ +{{ form_row(form._token) }} +{{ form_end(form, {'render_rest': false} ) }} diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions.html.twig new file mode 100644 index 00000000..b753d8db --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions.html.twig @@ -0,0 +1,6 @@ +{% set wishlist = hookable_metadata.context.wishlist %} +{% set form = hookable_metadata.context.form %} + +
+ {% hook 'actions' with { form, wishlist } %} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk.html.twig new file mode 100644 index 00000000..5345028a --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk.html.twig @@ -0,0 +1,11 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + + diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/add_to_cart.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/add_to_cart.html.twig new file mode 100644 index 00000000..20c9dcf8 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/add_to_cart.html.twig @@ -0,0 +1,8 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + + diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/copy.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/copy.html.twig new file mode 100644 index 00000000..6f129c20 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/copy.html.twig @@ -0,0 +1,28 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + +{% if app.user %} + {% set wishlists = findAllByShopUserAndToken(app.user) %} +{% else %} + {% set wishlists = findAllByAnonymous() %} +{% endif %} + +{% if wishlists|length > 1 %} + +{% endif %} + +{% for wishlistTarget in wishlists %} + {% if wishlist.id != wishlistTarget.id %} + + {% endif %} +{% endfor %} diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/download_csv.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/download_csv.html.twig new file mode 100644 index 00000000..4a119067 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/download_csv.html.twig @@ -0,0 +1,8 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + + diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/download_pdf.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/download_pdf.html.twig new file mode 100644 index 00000000..ab914b76 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/download_pdf.html.twig @@ -0,0 +1,8 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + + diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/remove.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/remove.html.twig new file mode 100644 index 00000000..14083f9a --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/bulk/remove.html.twig @@ -0,0 +1,8 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + + diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions/global.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/global.html.twig new file mode 100644 index 00000000..1155395d --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/global.html.twig @@ -0,0 +1,4 @@ +{% set form = hookable_metadata.context.form %} +{% set wishlist = hookable_metadata.context.wishlist %} + +{% hook 'global' with { form, wishlist } %} diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions/global/add_to_cart.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/global/add_to_cart.html.twig new file mode 100644 index 00000000..3ad278da --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/global/add_to_cart.html.twig @@ -0,0 +1,14 @@ +{% set form = hookable_metadata.context.form %} +{% set wishlist = hookable_metadata.context.wishlist %} + + diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/actions/global/import.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/global/import.html.twig new file mode 100644 index 00000000..26611bcf --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/actions/global/import.html.twig @@ -0,0 +1,6 @@ + + + diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items.html.twig new file mode 100644 index 00000000..36b6c8a9 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items.html.twig @@ -0,0 +1,4 @@ +{% set wishlist = hookable_metadata.context.wishlist %} +{% set form = hookable_metadata.context.form %} + +{% hook 'items' with { wishlist, form } %} diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/body.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body.html.twig new file mode 100644 index 00000000..77e0363b --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body.html.twig @@ -0,0 +1,13 @@ +{% set wishlist = hookable_metadata.context.wishlist %} +{% set form = hookable_metadata.context.form %} + +{% for item in form.items %} + {% set variant = item.vars.value.wishlistProduct.variant %} + {% set product = variant.product %} + {% set itemId = "wishlist_item_#{ variant.id }_#{ product.id }" %} + +
+ {% hook 'body' with { item, product, variant } %} +
+ +{% endfor %} diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/checkbox.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/checkbox.html.twig new file mode 100644 index 00000000..ce4dc5ab --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/checkbox.html.twig @@ -0,0 +1,6 @@ +{% set item = hookable_metadata.context.item %} +{% set product = hookable_metadata.context.product %} + +
+ {{ form_widget(item.selected, { id: product.name }) }} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/image.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/image.html.twig new file mode 100644 index 00000000..c949e321 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/image.html.twig @@ -0,0 +1,10 @@ +{% set product = hookable_metadata.context.product %} +{% set variant = hookable_metadata.context.variant %} + +
+ {{ component('sylius_shop:main_image', { + product: variant.hasImages ? variant : product, + class: "w-100 h-100 object-fit-cover", + filter: 'sylius_shop_product_small_thumbnail' + }) }} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/name.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/name.html.twig new file mode 100644 index 00000000..5746aec8 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/name.html.twig @@ -0,0 +1,8 @@ +{% set product = hookable_metadata.context.product %} +{% set product_url = path('sylius_shop_product_show', { slug: product.slug, _locale: product.translation.locale }) %} + +
+ + {{ product.name }} + +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/price.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/price.html.twig new file mode 100644 index 00000000..7d81ac4f --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/price.html.twig @@ -0,0 +1,12 @@ +{% import "@SyliusShop/shared/macro/money.html.twig" as money %} + +{% set product = hookable_metadata.context.product %} +{% set variant = hookable_metadata.context.variant %} + +
+ {% if not product.variants.empty() %} + + {{ money.calculatePrice(variant) }} + + {% endif %} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/quantity.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/quantity.html.twig new file mode 100644 index 00000000..6d16e51e --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/quantity.html.twig @@ -0,0 +1,12 @@ +{% set item = hookable_metadata.context.item %} +{% set product = hookable_metadata.context.product %} + +
+ {{ form_widget(item.cartItem.cartItem.quantity, { + 'attr': { + 'min': 0, + 'data-product-name': product.name, + 'value': item.cartItem.cartItem.quantity.vars.value is same as("0") ? 1 : item.cartItem.cartItem.quantity.vars.value + } + }) }} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/remove.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/remove.html.twig new file mode 100644 index 00000000..871c0468 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/remove.html.twig @@ -0,0 +1,15 @@ +{% set wishlist = hookable_metadata.context.wishlist %} +{% set product = hookable_metadata.context.product %} +{% set variant = hookable_metadata.context.variant %} + +
+ + {{ ux_icon('mdi:remove') }} + +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/variant.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/variant.html.twig new file mode 100644 index 00000000..662dac38 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/body/variant.html.twig @@ -0,0 +1,14 @@ +{% set item = hookable_metadata.context.item %} + +
+ {% if item.cartItem.cartItem.variant is defined %} +
+ {% for child in item.cartItem.cartItem.variant.children %} +
+ {{ form_label(child, null, { label_attr: { class: 'bb-wishlist-variant-label'} } ) }} + {{ form_widget(child, { attr: { class: 'bb-wishlist-variant-select', 'data-name': child.vars.name } } ) }} +
+ {% endfor %} +
+ {% endif %} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/head.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head.html.twig new file mode 100644 index 00000000..c0e7818f --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head.html.twig @@ -0,0 +1,3 @@ +
+ {% hook 'head' %} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/actions.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/actions.html.twig new file mode 100644 index 00000000..375193c9 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/actions.html.twig @@ -0,0 +1,3 @@ +
+ {{ 'sylius.ui.actions'|trans }} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/image.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/image.html.twig new file mode 100644 index 00000000..94acaf42 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/image.html.twig @@ -0,0 +1,3 @@ +
+ {{ 'sylius.ui.item'|trans }} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/price.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/price.html.twig new file mode 100644 index 00000000..e04afc55 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/price.html.twig @@ -0,0 +1,3 @@ +
+ {{ 'sylius.ui.unit_price'|trans }} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/quantity.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/quantity.html.twig new file mode 100644 index 00000000..6e67dbbf --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/quantity.html.twig @@ -0,0 +1,3 @@ +
+ {{ 'sylius.ui.qty'|trans }} +
diff --git a/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/select_all.html.twig b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/select_all.html.twig new file mode 100644 index 00000000..872efbb5 --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/form/sections/items/head/select_all.html.twig @@ -0,0 +1,5 @@ +
+
+ +
+
diff --git a/src/Resources/views/shop/wishlist/index/content/header.html.twig b/src/Resources/views/shop/wishlist/index/content/header.html.twig new file mode 100644 index 00000000..2234d3eb --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/header.html.twig @@ -0,0 +1,3 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + +{% hook 'header' with { wishlist } %} diff --git a/src/Resources/views/shop/wishlist/index/content/header/actions.html.twig b/src/Resources/views/shop/wishlist/index/content/header/actions.html.twig new file mode 100644 index 00000000..65462aac --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/header/actions.html.twig @@ -0,0 +1,5 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + +
+ {% hook 'actions' with { wishlist } %} +
diff --git a/src/Resources/views/shop/wishlist/index/content/header/actions/clear.html.twig b/src/Resources/views/shop/wishlist/index/content/header/actions/clear.html.twig new file mode 100644 index 00000000..64b6afaf --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/header/actions/clear.html.twig @@ -0,0 +1,12 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + +{% if wishlist.wishlistProducts.count > 0 %} +
+ + {{ ux_icon('mdi:remove') }} + + {{ 'bitbag_sylius_wishlist_plugin.ui.clear_wishlist'|trans }} + + +
+{% endif %} diff --git a/src/Resources/views/shop/wishlist/index/content/header/actions/new.html.twig b/src/Resources/views/shop/wishlist/index/content/header/actions/new.html.twig new file mode 100644 index 00000000..8874b75b --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/header/actions/new.html.twig @@ -0,0 +1,19 @@ +{% if sylius.channel is not null %} + {% set wishlists = findAllByAnonymousAndChannel(sylius.channel) %} +{% else %} + {% set wishlists = findAllByAnonymous() %} +{% endif %} + +{% if wishlists|length <= 1 %} + + +{% endif %} diff --git a/src/Resources/views/shop/wishlist/index/content/header/title.html.twig b/src/Resources/views/shop/wishlist/index/content/header/title.html.twig new file mode 100644 index 00000000..1ac0172e --- /dev/null +++ b/src/Resources/views/shop/wishlist/index/content/header/title.html.twig @@ -0,0 +1,7 @@ +{% set wishlist = hookable_metadata.context.wishlist %} + +

+
+ {{ wishlist.name }} +
+

diff --git a/src/Resources/views/_wishlist_pdf.html.twig b/src/Resources/views/shop/wishlist/wishlist_pdf.html.twig similarity index 95% rename from src/Resources/views/_wishlist_pdf.html.twig rename to src/Resources/views/shop/wishlist/wishlist_pdf.html.twig index 48586e2c..80c257a1 100644 --- a/src/Resources/views/_wishlist_pdf.html.twig +++ b/src/Resources/views/shop/wishlist/wishlist_pdf.html.twig @@ -1,4 +1,4 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} +{% import "@SyliusShop/shared/macro/money.html.twig" as money %} @@ -41,4 +41,4 @@ - \ No newline at end of file + diff --git a/src/Resources/views/_wishlist_header.html.twig b/src/Resources/views/shop/wishlist_header.html.twig similarity index 100% rename from src/Resources/views/_wishlist_header.html.twig rename to src/Resources/views/shop/wishlist_header.html.twig diff --git a/tests/Application/config/packages/twig_hooks.yaml b/tests/Application/config/packages/twig_hooks.yaml index 5e6dd99c..7659946e 100644 --- a/tests/Application/config/packages/twig_hooks.yaml +++ b/tests/Application/config/packages/twig_hooks.yaml @@ -15,15 +15,3 @@ sylius_twig_hooks: 'sylius_shop.base#javascripts': app_javascripts: template: "shop/javascripts.html.twig" - - 'sylius_shop.base.header.content': - wishlist_header: - template: "@BitBagSyliusWishlistPlugin/_wishlist_header.html.twig" - priority: 150 - -# TODO find the right way to extend product box's content -#sylius.shop.product.index.box: -# blocks: -# content: -# template: "@BitBagSyliusWishlistPlugin/Product/Box/_content.html.twig" -# priority: 10