Page 1 of 1

Multiselect for crossreferenced entity or other in Admin

Posted: Sat Jun 21, 2014 2:26 pm
by retaildev
Hi All,

I have been a bit on customizing broadleaf admin. And in that process have noticed that in community admin there is no example or implementation for multiselect through checkboxes. All i see there is radio boxes.
I have a situation where one entity is related directly to another as many to many relation and i just want to show the 5 master values of this referenced entity out here and admin can do multi select.

Example:
Single created Offer can be off either of these types (general, extreme, oneoff etc). These types are managed as an different entity.
I would like to have a UI where while creating offer i can list all the types as checkboxes and user can select multiple types per offer.

Kindly help on how can i achieve this using the general broadleaf framework. I am on BLC 3.0 but i have checked the current demo site as well..

Regards
Dev

Re: Multiselect for crossreferenced entity or other in Admin

Posted: Sat Jun 21, 2014 8:27 pm
by RapidTransit
Depending on what you are doing

1) Are you working with your own controller Implementation, you can override from here, and note that overriding modifyEntityForm does not work on all actions
2) Using an existing controller (Not Overridden) then you can use a custom handler override AbstractFormBuilderExtensionHandler

From there you can manipulate an EntityForm

But why go through the trouble, Just use @AdminPresentationCollection it's not check boxes but it will save you headaches

Re: Multiselect for crossreferenced entity or other in Admin

Posted: Sun Jun 22, 2014 11:48 am
by retaildev
Hi,

Thanks for response. As you mentioned @AdminPresentationCollection , this brings out one thing.
I am trying to develop certain features in broadleaf.
Here i noticed one thing. Apart from the parent(cieling entity) grid on main page of admin other referenced entity grids doesn't have individual items as clickable.
Taking example of category and product. If i go to category in admin section than i move to marketing and there i add product in cross sale for this category. Now this creates a entry in bl_product_cross_sale. lets say this table have some other fields like these cross sell product viewed or sold and need to make a entry there. Now i want to view the details in this table. So there is no way to have the items in referenced grid as clickable or lookup

Thanks
Dev

Re: Multiselect for crossreferenced entity or other in Admin

Posted: Mon Jun 23, 2014 11:57 am
by phillipuniverse
You mentioned the join entities (blc_product_cross_sale) having additional properties that should be managed within the relationship. We actually manage this with an @AdminPresentationAdornedTargetCollection. The idea with this annotation is that you would like to relate 2 entities together (like Product and Category) but also want to manage fields on the join table in-between them.

This is what the list of cross sale products looks like on CategoryImpl:

Code: Select all

@OneToMany(mappedBy "category"targetEntity CrossSaleProductImpl.class, cascade = {CascadeType.ALL})
@
Cascade(value={org.hibernate.annotations.CascadeType.ALLorg.hibernate.annotations.CascadeType.DELETE_ORPHAN})
@
Cache(usage CacheConcurrencyStrategy.READ_WRITEregion="blCategories")
@
OrderBy(value="sequence")
@
AdminPresentationAdornedTargetCollection(friendlyName "crossSaleProductsTitle"order 2000,
        
tab Presentation.Tab.Name.MarketingtabOrder Presentation.Tab.Order.Marketing,
        
targetObjectProperty "relatedSaleProduct",
        
sortProperty "sequence",
        
maintainedAdornedTargetFields = { "promotionMessage" },
        
gridVisibleFields = { "defaultSku.name""promotionMessage" })
@
ClonePolicyAdornedTargetCollection
protected List<RelatedProductcrossSaleProducts = new ArrayList<RelatedProduct>();
 


And if you look at the CrossSaleProductImpl entity:

Code: Select all

@Column(name "CROSS_SALE_PRODUCT_ID")
protected 
Long id;

@
Column(name "PROMOTION_MESSAGE")
@
AdminPresentation(friendlyName "CrossSaleProductImpl_Cross_Sale_Promotion_Message"largeEntry=true)
protected 
String promotionMessage;

@
Column(name "SEQUENCE"precision 10scale 6)
@
AdminPresentation(visibility VisibilityEnum.HIDDEN_ALL)
protected 
BigDecimal sequence;

@
ManyToOne(targetEntity ProductImpl.class)
@
JoinColumn(name "PRODUCT_ID")
@
Index(name="CROSSSALE_INDEX"columnNames={"PRODUCT_ID"})
protected 
Product product;

@
ManyToOne(targetEntity CategoryImpl.class)
@
JoinColumn(name "CATEGORY_ID")
@
Index(name="CROSSSALE_CATEGORY_INDEX"columnNames={"CATEGORY_ID"})
protected 
Category category;

@
ManyToOne(targetEntity ProductImpl.class, optional=false)
@
JoinColumn(name "RELATED_SALE_PRODUCT_ID"referencedColumnName "PRODUCT_ID")
@
Index(name="CROSSSALE_RELATED_INDEX"columnNames={"RELATED_SALE_PRODUCT_ID"})
protected 
Product relatedSaleProduct = new ProductImpl();
 


The 'real' relationship is between the 'relatedSaleProduct' and a category. In the @AdminPresentationAdornedTargetCollection there is also a 'maintainedAdornedTargetFields = { "promotionMessage" }' which means that the UI will allow you to manage that field on the relationship.

The UI looks like when you add a cross sale product you first select a Product (step 1 of 2): http://cl.ly/image/1L221R1D2x0N and then you fill in the promotion message (which is a property on that join entity): http://cl.ly/image/3I0i013r1G3k.

You are right, we do not have the specific UI portion for multi-select but I think that the requirement is still met through our list grid UIs. Feel free to open a feature request describing this at https://github.com/BroadleafCommerce/Br ... rce/issues.

Re: Multiselect for crossreferenced entity or other in Admin

Posted: Mon Jun 23, 2014 2:31 pm
by retaildev
Hi Phillip,

Thanks for an elaborate exploitation of this functionality. But my sorry, that i wasn't able to correctly explain what i was meaning from my use case.

This is the thing which is already there and the adorned fields comes up when you are adding a product to cross-sale list and for later viewing it is there in the list.

Now, here is my extension, i want to have some more analytic around this by adding fields like views, checkout, redeemed, bought, new revenue etc, could be around 15 columns(this is needed to understand the effectiveness of cross-sale strategy). Now i cannot(15 being a big number) or doesn't want to display them in the grid. Also, these fields are not populated/managed by the admin as they are populated during the operation on the website. So adorned field doesn't work.

Now i would like to have a link on the primary field(name) which opens the popup/modal-window, where i can see all the details of fields of this join-in table(blc-product-cross-sale). This happens after the product has been added or already exists in the grid list.

This is a bit deviation from the generic approach in which the links or lookup links appear only on the grid which list the ceiling entity for that admin section. Building a another section for such an join-in entity will be a cumbersome job for the admin.

Kindly suggest for to achieve this. Also, let me know if there is any clarification to be sought.

Thanks
Dev

Re: Multiselect for crossreferenced entity or other in Admin

Posted: Mon Jun 30, 2014 1:49 pm
by retaildev
Hi,

Any suggestion on how to achieve this...

Thanks
Dev