-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTMLs for range filters don't conform to the HTML standards #325
Comments
I am open for the change to accept attributes values as I imagine the first step in supporting Besides that, I designed range filter attribute value as an array of two elements because Ruby didn't support infinite ranges ( Let me know what you think or let me digest my own thoughts for a few days and get back. |
Thank you very much for taking this up! Conceptually, I agree with you that a range filter should ideally return a Range, regardless of how it is actually dealt with in HTML forms and Rails built-in processing. Ruby 3 supports both I understand such changes in Range filters are more or less backward-incompatible. A major-version upgrade in versioning may be necessary? Personally, I would accept and welcome the breaking changes with this matter. A way to mitigate to minimise the disruption I can think of is this. This is not perfect, but I guess it should accommodate most use-cases. I suppose two primary, potentially breaking changes for users are the The parameter given to the block is more tricky. However, I guess most users access the given object (currently a 2-element Array) through methods of Obviously, users may have other use-cases. In particular, their controller tests of Grid, where parameters are directly passed to GET, will fail. But a bright side is all W3C-validation tests (in Controller and System tests) that currently fail with Datagrid with Range filters will pass at last. The above is just an idea of hopefully reducing (or minimising) the potential pain of Datagrid users associated with the breaking change. Please feel free to take it or leave it! |
Phase 1 - minor version release: Here is how it is usually done: we introduce a new configuration parameter Additional optional convenience would be to the ability to override a global configuraiton on per filter basis with the same parameter name. It would help larger projects with gradual migration. Phase 2 - major version release: We make the parameter default to Phase 3 - minor version release: We remove the parameter, saying instead that it is deprecated and new behaviour is enforced.
Good point. I believe we should maintain the ability to assign a range attribute as a 2 elements array. I don't see any problems with that. The other problem I see is serialization: in current version if you put datagrid attributes to database (like Job Queue for CSV export), it would serialize to JSON and deserialize normally. With ranges it would break:
So I believe, to make it smoother, we need the ability to assign range in the string format as well.
Yeah that is a problem.
That seems too crazy: changing built-in object behavior even in a scope of the library doesn't look good to me. |
The proposed procedure of phases 1--3 sounds definitely ideal! If you introduce a configuration parameter filter(:year, :integer, range: true, new_ranges_behaviour: false){ |record| }
# record is a 2-element Array.
filter(:year, :integer, range: true, new_ranges_behaviour: true){ |record| }
# record is a Range. This seems to me the cleanest way with the 3-phase gradual migration. I didn't think of serialization… Very good point! |
The range filter produced by Datagrid generates a HTML that violates the HTML-5 standards:
(See HTML5 standards about
input
for detail of the specification.)The form in the HTML for a range filter of Datagrid tries to pass a (2-element) Array when submitted, and Rails does interpret them as an Array (and so the filter works). But the HTML standards basically do not allow such pair of fields of input with type=text.
It should be better if the generated HTML for a range filter conforms to the HTML standard.
I asked a question about it in Stackoverflow, and an answer suggests using forms of:
my_model[my_attribute][from]
my_model[my_attribute][to]
as opposed to the current way of multiple
my_model[my_attribute][]
So, this may be a way to implement the (grammatically) correct pair of HTML-form fields for a range filter. Obviously, I suppose there are many other ways.
The text was updated successfully, but these errors were encountered: