Hi Hryhorii,
thanks for your suggestion. I tried to use it, but, however stucks as at the beginning. Layout is one thing – data delivered to the layout the other. I think, my problem is a data problem … ?!
To find a solution for a real case, let us work with the following
(see screeshot-links on snaggy below):
# Starting point in MyCustomShoppingListBundle:
Product-entity has a custom property, for example ‘COLOR’, which may be equal ‘yellow’ or ‘blue’.
A shopping list can contain only yellow products, or blue ones.
So, everytime a guest-user adds a product to shopping list, my script is checking the product color first, and creates a new shopping list automatically, if there does not yet exist a shopping list with the given color.
That means, multiple shopping lists are allowed for a guest user. The maximum of shipping lists is identical to the number of colors allowed – in our example 2.
# Real situation:
A guest user has created 2 shoppinglists (No 52 [yellow products], and No 54 [blue products]), current one is No 52.
Shopping list widget shows 2 shopping lists 52, 54.
Shopping list buttons in the product grid have actions add/remove to/from 52/54.
# The goal is:
1. to modify a product’s shopping-list button as follows:
a. The product is of yellow color, and not in one of the 2 shopping lists contained
> Button actions
Now: – ‘Add to 52’
– ‘Add to 54’
To: – ‘Add to 52’ – 54-action must be removed, as a yellow product can be added to 52 only!
b. The product is of yellow color, and has been added to 52 shopping list earlier
> Button actions
Now: – ‘Remove from 52’
– ‘Add to 54’
To: – ‘Remove from 52’ – 54-action must be removed, as a yellow product can be added to 52 only!
c. The product is of blue color, and has been added to 54 shopping list earlier
> Button actions
Now: – ‘Add to 52’
– ‘Add to 54’
To: – ‘Add to 52’ – 54-action must be removed, as a yellow product can be added to 52 only!
2. to show the correct (colored) ‘IS-IN-SHOPPINGLIST’ div-container in the product tile of a grid.
Now: – div-container is green, and shown for current shopping list 52, only
To: – div-container should be shown,
not only for current shopping list (52 – yellow div-container),
but also, if the product is in the other shopping list (54 – blue div-container)
Both goals are depending how the data flows into the layout.
An additional problem for me is, that the shopping list buttons are rendered once again after page has been loaded, or after add-to-shopping-cart event.
I think this is done by
OroShoppingListBundle/Resources/public/js/app/views/product-add-to-shopping-list-view.js
However, if I delete all the code from product-add-to-shopping-list-view.js using an empty
define(function(require) { ‘use strict’; return; }) function loading page-loading and rerendering still works fine.
That means at least rerendering after page loading is driven by another script then the mentioned one.
(I am still very weak in Javascript OO.)
# Lst not least the ‘NOW’-screenshots:
https://snag.gy/LAfSPy.jpg
https://snag.gy/BlRW5H.jpg
https://snag.gy/J54RGV.jpg
Hope, this not too much .. (is always boring).
Would be very happy for any help!
Kind regards to the Ukraine from Germany
Frank