Skip to content

Conversation

@Cholin2000
Copy link
Contributor

No description provided.

@Cholin2000 Cholin2000 marked this pull request as ready for review September 19, 2025 07:45
@Cholin2000 Cholin2000 requested a review from a team as a code owner September 19, 2025 07:45
<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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

<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]'))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

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]'))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just extract all of them


$selectionJson = (string) $request->request->get('selection', '[]');
$indices = $this->decodeSelection($selectionJson);
$wishlistName = trim((string) $request->request->get('wishlistName', 'wishlist'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, is this really needed for exporting?

use Symfony\UX\LiveComponent\DefaultActionTrait;

#[AsLiveComponent]
final class AddAllToCartComponent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this either select/deselect all? ATM, it seems to flip the current selection

}

try {
$this->messageBus->dispatch(new UpdateWishlistName($newName, $wishlist));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the action of changing a name really need a separate command?

Comment on lines +1 to +3
<?php

declare(strict_types=1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing license, in a lot of other classes as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants