+5
Requested

Products: inherit Control instead of UserControls

Nik De Clercq 6 years ago in Products updated by anonymous 3 years ago 0

For a customer, Delaware consulting was requested to create a fields panel that would show some fields, but would hide other fields (If you want I can provide the reason why).
To do that, I hoped to extend the FieldsPanel with a property "HiddenFields". I created a class CustomFieldsPanel and overwrote OnInit to change the property CategoriesGenerator of the panel's FieldGridView. To make the HiddenFields property configurable via xml, I also overwrote the Read method.
Unfortuneatly, all PIMS panels inherit UserControl. Making it impossible for me to inherit FieldsPanel (or any other panel).
I still needed the HiddenFields property on the panel, so I opened up DotPeek and started copying all code from the FieldsPanel in to my own CustomFieldsPanel class.
Although this works perfectly, as a partner developer, I wasted a lot of time copy pasting from DotPeek. Obfuscating the code of your dll also doesn't help. Not only that, but if at some point you find a bug in the FieldPanel or add some feature or ... I have to go back to DotPeek and search for whatever code you added or removed an copy the behavior back into my code.
To make matters worse, the FieldsPanel uses the internal class BinderControlHelper. So I ended up copying that class as well.

Another example of overriding a panel is the ProductClassificationsPanel. All I wanted to do was not show the "Manage classifications..." button. But ended up copying a class of 300+ lines of code. Copying other panels was also considered, but we didn't do it because of the copy/paste risk. Instead we created simpler controls using and overriding Adam.Web controls.

I had the same problem when creating a custom ViewControl. Since I started creating the custom ViewControl in PIMS 3.x and had to upgrade to Products 4, I had to write the class twice because the styling and the HTML of a ViewControl was completly changed.

To finish here's my feature request. I would like to see all PIMS panels inherit Control instead of UserControl. In addition to that, I would also like you to do the same for ViewControl (inheriting from Control instead of UserControl).
That way partners can override existing panels and add small features. This would lower the cost of custom code, making ADAM customers very happy.

UX meta-data configurability fields

I would like to ask not to focus on working around my extension to the FieldsPanel. That's why, next to the example of the FieldsPanel and the ProductClassificationsPanel, I will give you a third example of why your panel controls should inherit Control instead of UserControl.

We would like to extend the LinkedItemsPanel. We would like to change the search expression that is used for searching linked products. A static search expression in xml isn't sufficient. We want the user to only link products that are in the same catalog. So we want a search expression like this: FieldName("DLW_EntityCode")="Models" AND Classification.AncestorOrSelf.Id = ?. Where ? is the id of the category of the product that is edited. Of course, we could create a panel for each catalog and set a template on each catalog. But if you have 50+ catalogs, you need 50+ panel settings and 50+ templates. I think you will agree that this is not maintainable.

So please don't focus on my examples. Try to realize that whatever great solution you think of to fix these specific problems, there will always be another problem that just doesn't fit your solution. That's why I'm suggesting making panels and ViewControls overridable instead of asking a specific solution for a specific problem we have.

Thanks ADAM Software, and more specifically the Products team, for taking this feature request into consideration. With Products 4.1 you have clearly changed some of the panels. It has already had its value. We are already overriding the LinkedImagesPanel for a customer of ours. In the past we would have tried to convince the customer to live with the shortcomings. Now we can say: yes we can.

Thanks. I'm looking forward to 4.2 where you will undoubtedly will have moved even more panels and view controls.