Posted by
Leon Torres-2 on
URL: http://ofbiz.116.s1.nabble.com/Dev-configurable-custom-views-take-2-tp167983.html
After attempting to implement ViewPreferences, we found a few issues that
suggested overdesign. Upon reconsidering the model, we came up with a much
better one,
ViewPreference
- viewPreferenceId* (serial ID)
- userLoginId*
- viewPrefTypeId* (see ViewPrefType)
- fromDate
- thruDate
- viewPrefItemTypeId (Whether the value is Enum or a String)
- viewPrefEnumId (Stores Enum value)
- viewPrefValue (Stores String value)
ViewPrefType
- viewPrefTypeId*
- application (e.g., OFBIZ, CRMSFA, etc.)
- applicationSection (e.g., ORDERMGR)
- screenName
- formName
Essentially, the ViewPreference is key-value data tied to a specific
userLoginId. The key is simply the viewPrefTypeId, which contains
information about the "coordinates" of where in the applicatin the
preference applies. That way one can select all keys (preferences)
for a given form, screen, etc.
An example of usage: Suppose we want to let the user select from several
possible views of the order list in ordermgr,
* Sales Orders Only
* Purchase Orders Only
* All Orders
We define a ViewPrefType for this preference (global cooridnate for simplicity):
<ViewPrefType viewPrefTypeId="ORDER_LIST_PREF" application="OFBIZ" />
And the options are by enumeration,
<Enumeration enumId="ORDER_LIST_PREF_ALL" ... />
<Enumeration enumId="ORDER_LIST_PREF_SALES" ... />
<Enumeration enumId="ORDER_LIST_PREF_PURCH" ... />
Then the value is determined by a ViewPreference entry,
<ViewPreference viewPreferenceId="1000" userLoginId="admin"
viewPrefTypeId="ORDER_LIST_PREF" fromDate="..."
viewPrefItemTypeId="ENUMERATION" viewPrefEnumId="ORDER_LIST_PREF_ALL" />
So now the admin will see all orders. If the admin changes it to list
sales orders, the viewPrefEnumId is updated to "ORDER_LIST_PREF_SALES".
Next time the admin comes to the order list, he'll see sales orders.
Later on, if we want to group them, we can have ViewPrefGroup.
- Leon
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev