filter-menu needs additional param 'model-name' (or context)
Reported by Tim Griffin | March 16th, 2011 @ 01:32 AM | in Hobo 1.3 (Rails 3)
The implementation of <filter-menu> in Hobo 1.3pre30
currently allows its options to be specified in the locale file as
follows:
en: tags: filter_menu: state: no_filter: All options: - [ "Draft", "draft" ] - [ "Submitted", "submitted" ] - [ "In Review", "in_review" ] - [ "Accepted", "accepted" ] - [ "Rejected", "rejected" ] - [ "Withdrawn", "withdrawn" ] - [ "Archived", "archived" ]
But as soon as another model exists that uses the param-name
'state', we're unable to specify its options because the
<filter-menu> tag is hard-coded to pick up its keys
as:
<% opt = t("tags.filter_menu.#{param_name}.options", :default=>'')
This would be more useful if it instead used the model level of
definition:
<% opt = t("#{model_name}.filter_menu.#{param_name}.options", :default=>'')
so that filter-menu options in the locale file can be associated with their respective models:
instruments: filter_menu: status: no_filter: All options: - [ "Unregistered", "unregistered" ] - [ "Registered", "registered" ] packages: filter_menu: state: no_filter: All options: - [ "Draft", "draft" ] - [ "Submitted", "submitted" ] - [ "In Review", "in_review" ] - [ "Accepted", "accepted" ] - [ "Rejected", "rejected" ] - [ "Withdrawn", "withdrawn" ] - [ "Archived", "archived" ]
Perhaps there is some more magical way of referencing or inferring the model from the context in which the filter-menu is called; regardless, it needs to be more flexible between models.
Tim
Comments and changes to this ticket
-
Domizio Demichelis March 27th, 2011 @ 09:54 PM
- State changed from new to open
- Milestone set to Hobo 1.3 (Rails 3)
- Assigned user set to Domizio Demichelis
- Milestone order changed from 197961 to 0
Done, but with no magic: you have to pass a model name to the tag, then you can use it under the activerecord.attributes. namespace. The old behaviour is preserved as a fallback so it will not break legacy apps, and it will be simpler when you don't need to have different options for different models.
-
Domizio Demichelis March 27th, 2011 @ 09:55 PM
- State changed from open to resolved
(from [a1aae8f931cec3c18cbdb3fb7cbb31906e64836d]) i18n filter-menu improvement: the options can be set also on a per-model basis [#931 state:resolved] https://github.com/tablatom/hobo/commit/a1aae8f931cec3c18cbdb3fb7cb...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
People watching this ticket
Referenced by
- 931 filter-menu needs additional param 'model-name' (or context) (from [a1aae8f931cec3c18cbdb3fb7cbb31906e64836d]) i18n fi...