Sort options in form fields by their visible description (also if localized)
---------------------------------------------------------------------------- Key: OFBIZ-2507 URL: https://issues.apache.org/jira/browse/OFBIZ-2507 Project: OFBiz Issue Type: Improvement Components: framework Affects Versions: SVN trunk Reporter: Karim Rahimpur Fix For: SVN trunk Currently, when options are shown in drop-down fields we can use entity-order-by to sort the options by e.g. description. *But the order in which options appear is only valid for non-localized descriptions.* If we have localized descriptions we want to make sure that these also appear in order, otherwise we make it difficult for the user to find the desired option especially in drop-down fields with many options. Btw i consider this _major_ because for users who do not use the default language: - the presentation is non-standard and a usability obstacle - it's simply a real pain to look for an option in 'strangely-ordered' drop-downs *Proposed Solution* My proposal is to have a default ordering based on the description value of the _OptionValue_ key-description-pairs in ModelFormField.java. The advantage of doing this is that you get what you'd normally expect, by default, in any drop-down field without even having to tell the system to order by description. An implementation should of course respect _entity-order-by_ if present. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
[ https://issues.apache.org/jira/browse/OFBIZ-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Karim Rahimpur updated OFBIZ-2507: ---------------------------------- Attachment: ModelFormField.java.patch This patch adapts ModelFormField.java implementing the proposed solution: - order options by the description that the user will see, if: 1. no specific field(s) is to be used for sorting (<entity-order-by field-name="..."/>) 2. the description field should be used to order by (<entity-order-by field-name="description"/>) This takes care of the problem and also, no changes to existing forms are needed with this approach (as there are drop-down fields that indicate the description field with entity-order-by). > Sort options in form fields by their visible description (also if localized) > ---------------------------------------------------------------------------- > > Key: OFBIZ-2507 > URL: https://issues.apache.org/jira/browse/OFBIZ-2507 > Project: OFBiz > Issue Type: Improvement > Components: framework > Affects Versions: SVN trunk > Reporter: Karim Rahimpur > Fix For: SVN trunk > > Attachments: ModelFormField.java.patch > > > Currently, when options are shown in drop-down fields we can use entity-order-by to sort the options by e.g. description. > *But the order in which options appear is only valid for non-localized descriptions.* > If we have localized descriptions we want to make sure that these also appear in order, otherwise we make it difficult for the user to find the desired option especially in drop-down fields with many options. > Btw i consider this _major_ because for users who do not use the default language: > - the presentation is non-standard and a usability obstacle > - it's simply a real pain to look for an option in 'strangely-ordered' drop-downs > *Proposed Solution* > My proposal is to have a default ordering based on the description value of the _OptionValue_ key-description-pairs in ModelFormField.java. > The advantage of doing this is that you get what you'd normally expect, by default, in any drop-down field without even having to tell the system to order by description. An implementation should of course respect _entity-order-by_ if present. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712066#action_12712066 ] Scott Gray commented on OFBIZ-2507: ----------------------------------- Hi Karim description is nothing more than an entity field name and the results would already have been sorted by that during the query if specified so there is no need to include it in your if condition. You should simply only sort if the entity-order-by attribute is false. Also you can use Collections.sort(optionValues, new Comparator() ... instead of putting everything into an array, sorting and pulling them back out again. Regards Scott > Sort options in form fields by their visible description (also if localized) > ---------------------------------------------------------------------------- > > Key: OFBIZ-2507 > URL: https://issues.apache.org/jira/browse/OFBIZ-2507 > Project: OFBiz > Issue Type: Improvement > Components: framework > Affects Versions: SVN trunk > Reporter: Karim Rahimpur > Fix For: SVN trunk > > Attachments: ModelFormField.java.patch > > > Currently, when options are shown in drop-down fields we can use entity-order-by to sort the options by e.g. description. > *But the order in which options appear is only valid for non-localized descriptions.* > If we have localized descriptions we want to make sure that these also appear in order, otherwise we make it difficult for the user to find the desired option especially in drop-down fields with many options. > Btw i consider this _major_ because for users who do not use the default language: > - the presentation is non-standard and a usability obstacle > - it's simply a real pain to look for an option in 'strangely-ordered' drop-downs > *Proposed Solution* > My proposal is to have a default ordering based on the description value of the _OptionValue_ key-description-pairs in ModelFormField.java. > The advantage of doing this is that you get what you'd normally expect, by default, in any drop-down field without even having to tell the system to order by description. An implementation should of course respect _entity-order-by_ if present. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712077#action_12712077 ] Karim Rahimpur commented on OFBIZ-2507: --------------------------------------- Hi Scott, Thanks for your comments, let me explain: - The reason for explicitly checking the description field and not only testing if the entity-order-by attribute is empty is that other fields than 'description' can be used to order the options (there really are, see e.g. InvoiceForms.xml the NewPurchaseInvoice form to name one of many cases) and we don't want to interfere with that. Now if we only check for entity-order-by being empty, we'll end up with what we had before: when entity-order-by is used to order by description, we won't get our correctly ordered localized list of options. So in order to also order by localized description we have to check if the entity-order-by field is 'description'. For storing the ordered list you could also use Collections.sort(...) directly if you prefer, although there would at least be no 'speed gain' as the ops are equivalent. Regards, Karim > Sort options in form fields by their visible description (also if localized) > ---------------------------------------------------------------------------- > > Key: OFBIZ-2507 > URL: https://issues.apache.org/jira/browse/OFBIZ-2507 > Project: OFBiz > Issue Type: Improvement > Components: framework > Affects Versions: SVN trunk > Reporter: Karim Rahimpur > Fix For: SVN trunk > > Attachments: ModelFormField.java.patch > > > Currently, when options are shown in drop-down fields we can use entity-order-by to sort the options by e.g. description. > *But the order in which options appear is only valid for non-localized descriptions.* > If we have localized descriptions we want to make sure that these also appear in order, otherwise we make it difficult for the user to find the desired option especially in drop-down fields with many options. > Btw i consider this _major_ because for users who do not use the default language: > - the presentation is non-standard and a usability obstacle > - it's simply a real pain to look for an option in 'strangely-ordered' drop-downs > *Proposed Solution* > My proposal is to have a default ordering based on the description value of the _OptionValue_ key-description-pairs in ModelFormField.java. > The advantage of doing this is that you get what you'd normally expect, by default, in any drop-down field without even having to tell the system to order by description. An implementation should of course respect _entity-order-by_ if present. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712090#action_12712090 ] Scott Gray commented on OFBIZ-2507: ----------------------------------- I see what you are trying to do but at the end of the day description is still just an entity field to sort by, a field called "name" could be localized and your code wouldn't handle that situation, you are also enforcing the additional work of sorting when localization may not have taken place (although I guess it would be pretty quick considering the list would already be in the correct order). That said, while I don't think it is an ideal solution I do think it is acceptable. In an ideal world the GenericDelegator would be aware of the locale and also know that an order by field was localized and handle the localized sorting internally before we even see the list. Collections.sort(...) should be quicker because currently you are creating an array, iterating, sorting, clearing the list and iterating again whereas it could just be a sort only. But anyway cleaner code was the main reason for suggesting the change. > Sort options in form fields by their visible description (also if localized) > ---------------------------------------------------------------------------- > > Key: OFBIZ-2507 > URL: https://issues.apache.org/jira/browse/OFBIZ-2507 > Project: OFBiz > Issue Type: Improvement > Components: framework > Affects Versions: SVN trunk > Reporter: Karim Rahimpur > Fix For: SVN trunk > > Attachments: ModelFormField.java.patch > > > Currently, when options are shown in drop-down fields we can use entity-order-by to sort the options by e.g. description. > *But the order in which options appear is only valid for non-localized descriptions.* > If we have localized descriptions we want to make sure that these also appear in order, otherwise we make it difficult for the user to find the desired option especially in drop-down fields with many options. > Btw i consider this _major_ because for users who do not use the default language: > - the presentation is non-standard and a usability obstacle > - it's simply a real pain to look for an option in 'strangely-ordered' drop-downs > *Proposed Solution* > My proposal is to have a default ordering based on the description value of the _OptionValue_ key-description-pairs in ModelFormField.java. > The advantage of doing this is that you get what you'd normally expect, by default, in any drop-down field without even having to tell the system to order by description. An implementation should of course respect _entity-order-by_ if present. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712101#action_12712101 ] Karim Rahimpur commented on OFBIZ-2507: --------------------------------------- bq. a field called "name" could be localized and your code wouldn't handle that situation Yes that is true but my intent is to handle descriptions _now_ because it's really an issue, the typical client's comment is 'why isn't the list in order? It's so hard to find the right option, ...' bq. In an ideal world the GenericDelegator would be aware of the locale and also know that an order by field was localized and handle the localized sorting internally before we even see the list. That could be a good approach ... bq. But anyway cleaner code was the main reason for suggesting the change. I now :) but as I was looking at the Collection.sort(...) code I just had to mention it ... > Sort options in form fields by their visible description (also if localized) > ---------------------------------------------------------------------------- > > Key: OFBIZ-2507 > URL: https://issues.apache.org/jira/browse/OFBIZ-2507 > Project: OFBiz > Issue Type: Improvement > Components: framework > Affects Versions: SVN trunk > Reporter: Karim Rahimpur > Fix For: SVN trunk > > Attachments: ModelFormField.java.patch > > > Currently, when options are shown in drop-down fields we can use entity-order-by to sort the options by e.g. description. > *But the order in which options appear is only valid for non-localized descriptions.* > If we have localized descriptions we want to make sure that these also appear in order, otherwise we make it difficult for the user to find the desired option especially in drop-down fields with many options. > Btw i consider this _major_ because for users who do not use the default language: > - the presentation is non-standard and a usability obstacle > - it's simply a real pain to look for an option in 'strangely-ordered' drop-downs > *Proposed Solution* > My proposal is to have a default ordering based on the description value of the _OptionValue_ key-description-pairs in ModelFormField.java. > The advantage of doing this is that you get what you'd normally expect, by default, in any drop-down field without even having to tell the system to order by description. An implementation should of course respect _entity-order-by_ if present. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712266#action_12712266 ] Karim Rahimpur commented on OFBIZ-2507: --------------------------------------- Oops ... of course I wanted to say 'I know ...' Btw on second thought about the GenericDelegator being aware of the locale, this class is about data but localizing data is about presentation so it's not where one should be aiming at to 'automate' localization. So taking that into account, I say the ModelFormField which is about presentation is the right place to automate localization in this case as proposed. Regards, Karim > Sort options in form fields by their visible description (also if localized) > ---------------------------------------------------------------------------- > > Key: OFBIZ-2507 > URL: https://issues.apache.org/jira/browse/OFBIZ-2507 > Project: OFBiz > Issue Type: Improvement > Components: framework > Affects Versions: SVN trunk > Reporter: Karim Rahimpur > Fix For: SVN trunk > > Attachments: ModelFormField.java.patch > > > Currently, when options are shown in drop-down fields we can use entity-order-by to sort the options by e.g. description. > *But the order in which options appear is only valid for non-localized descriptions.* > If we have localized descriptions we want to make sure that these also appear in order, otherwise we make it difficult for the user to find the desired option especially in drop-down fields with many options. > Btw i consider this _major_ because for users who do not use the default language: > - the presentation is non-standard and a usability obstacle > - it's simply a real pain to look for an option in 'strangely-ordered' drop-downs > *Proposed Solution* > My proposal is to have a default ordering based on the description value of the _OptionValue_ key-description-pairs in ModelFormField.java. > The advantage of doing this is that you get what you'd normally expect, by default, in any drop-down field without even having to tell the system to order by description. An implementation should of course respect _entity-order-by_ if present. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
Free forum by Nabble | Edit this page |