Open
Conversation
mpysiak
reviewed
Sep 19, 2025
| <button type="button" | ||
| class="{{ btn_class }}" | ||
| {{ sylius_test_html_attribute('wishlist-add-selected-to-cart') }} | ||
| onmousedown="(function(btn){try{var root=btn.closest('[data-controller]'); var elSel=document.getElementById('wishlist_selected_indices'); var json = (elSel && elSel.value) ? elSel.value : '[]'; btn.setAttribute('data-live-param-selection-value', json); if(root){ var el=root.querySelector('#bulk_selection_holder'); if(el){ el.value=json; el.dispatchEvent(new Event('input',{bubbles:true})); el.dispatchEvent(new Event('change',{bubbles:true})); } }}catch(e){console.error(e);}})(this)" |
Contributor
There was a problem hiding this comment.
This should be extracted to a js file, same case below
| > | ||
| class="{{ btn_class }}" | ||
| {{ sylius_test_html_attribute('wishlist-copy-to-wishlist') }} | ||
| onclick="(function(btn){try{var json=(document.getElementById('wishlist_selected_indices')||{value:'[]'}).value; var indices=[]; try{indices=JSON.parse(json)||[];}catch(_){} var ids=[]; indices.forEach(function(idx){ var hid=document.querySelector('input[name=\'wishlist_collection[items]['+idx+'][variant]\']'); if(hid){ ids.push(parseInt(hid.value)); } }); btn.setAttribute('data-live-param-selection-value', JSON.stringify(ids)); var root=btn.closest('[data-controller]'); if(root){ var el=root.querySelector('#copy_preselected_holder'); if(el){ el.value=JSON.stringify(ids); el.dispatchEvent(new Event('input',{bubbles:true})); el.dispatchEvent(new Event('change',{bubbles:true})); } }}catch(e){console.error(e);}})(this)" |
| <button type="button" | ||
| class="{{ btn_class }}" {{ sylius_test_html_attribute('wishlist-export-to-pdf-from-wishlist') }} | ||
| formaction="{{ path('sylius_wishlist_plugin_shop_locale_wishlist_export_to_pdf', { wishlistId: wishlist.id }) }}"> | ||
| onmousedown="(function(root){try{var json=(document.getElementById('wishlist_selected_indices')||{value:'[]'}).value; var el=root.querySelector('#export_pdf_selection_holder'); el.value=json; el.dispatchEvent(new Event('input',{bubbles:true})); el.dispatchEvent(new Event('change',{bubbles:true}));}catch(e){console.error(e);}})(this.closest('[data-controller]'))" |
| type="button" | ||
| data-bb-toggle="wishlist-save" | ||
| {{ sylius_test_html_attribute('wishlist-save-changes') }} | ||
| onclick="(function(root){try{var inputs=document.querySelectorAll('input[name^=\'wishlist_collection[items]\'][name$=\'[cartItem][cartItem][quantity]\']');var map={};inputs.forEach(function(inp){var m=inp.name.match(/items\]\[(\d+)\]/); if(m){map[m[1]]=parseInt(inp.value||'0')||0;}}); var holder=root.querySelector('#quantities_holder'); if(holder){ holder.value=JSON.stringify(map); holder.dispatchEvent(new Event('input',{bubbles:true})); }}catch(e){console.error(e);}})(this.closest('[data-controller]'))" |
Contributor
There was a problem hiding this comment.
Just extract all of them
|
|
||
| $selectionJson = (string) $request->request->get('selection', '[]'); | ||
| $indices = $this->decodeSelection($selectionJson); | ||
| $wishlistName = trim((string) $request->request->get('wishlistName', 'wishlist')); |
Contributor
There was a problem hiding this comment.
Is the wishlist name not included in the wishlist itself? Why is the value taken from the request?
Comment on lines
+147
to
+167
| private function buildSelectedWishlistItems(Collection $wishlistProducts, array $indices): ArrayCollection | ||
| { | ||
| $cart = $this->cartContext->getCart(); | ||
| $collection = new ArrayCollection(); | ||
| foreach ($indices as $index) { | ||
| $wp = $wishlistProducts->get((int) $index); | ||
| if (null === $wp) { | ||
| continue; | ||
| } | ||
| $wi = new WishlistItem(); | ||
| $wi->setWishlistProduct($wp); | ||
| /** @var OrderItemInterface $cartItem */ | ||
| $cartItem = $this->cartItemFactory->createForProduct($wp->getProduct()); | ||
| $cartItem->setVariant($wp->getVariant()); | ||
| $this->orderItemQuantityModifier->modify($cartItem, $wp->getQuantity()); | ||
| $wi->setCartItem($this->addToCartCommandFactory->createWithCartAndCartItem($cart, $cartItem)); | ||
| $collection->add($wi); | ||
| } | ||
|
|
||
| return $collection; | ||
| } |
Contributor
There was a problem hiding this comment.
Again, is this really needed for exporting?
| use Symfony\UX\LiveComponent\DefaultActionTrait; | ||
|
|
||
| #[AsLiveComponent] | ||
| final class AddAllToCartComponent |
Contributor
There was a problem hiding this comment.
Suggested change
| final class AddAllToCartComponent | |
| final class AddWishlistToCartComponent |
or
Suggested change
| final class AddAllToCartComponent | |
| final class AddWishlistedProductsToCartComponent |
?
Comment on lines
+66
to
+73
| public function toggleAll(): void | ||
| { | ||
| $all = []; | ||
| for ($i = 0; $i < $this->itemsCount; ++$i) { | ||
| $all[$i] = !($this->selection[$i] ?? false); | ||
| } | ||
| $this->selection = $all; | ||
| } |
Contributor
There was a problem hiding this comment.
Shouldn't this either select/deselect all? ATM, it seems to flip the current selection
| } | ||
|
|
||
| try { | ||
| $this->messageBus->dispatch(new UpdateWishlistName($newName, $wishlist)); |
Contributor
There was a problem hiding this comment.
Does the action of changing a name really need a separate command?
Comment on lines
+1
to
+3
| <?php | ||
|
|
||
| declare(strict_types=1); |
Contributor
There was a problem hiding this comment.
Missing license, in a lot of other classes as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.