- Fix dynamic filter error #349.
- Use new Rails 7.1
localsnotation in ERB partials. - The
FormBuilder#datagrid_filter_inputmethod now acceptsselect_choicesandselect_optionsoptions for theselecttag. - Rename the
Datagrid#select_optionsmethod to#select_choices. - Added a partial for the dynamic filter allowing to customize the UI #347.
<%# locals: (filter:, form:, field_options:, operation_options:, value_options:) -%>
<%= form.datagrid_filter_input(
filter,
**field_options,
class: [*field_options[:class], "datagrid-dynamic-field"]
) %>
<%= form.datagrid_filter_input(
filter,
**operation_options,
class: [*operation_options[:class], "datagrid-dynamic-operation"]
) %>
<%= form.datagrid_filter_input(
filter,
**value_options,
class: [*value_options[:class], "datagrid-dynamic-value"]
) %>- Rescue StatementInvalid when guessing column type from a query
- Prevent typecasting of date into timestamp when
:datefilter has a block
class MyGrid < Datagrid::Base
scope { User }
filter(:created_at, :date) do |scope, value|
value.is_a?(Date) # => true
scope.joins(:registration).where(registrations: { registration_date: value })
end
end- Raise
Datagrid::ConfigurationErrorwhen column or filter name specified inbeforeorafteroption not found. - Fixed
as_querymethod when dynamic filter is used. Fixes #344
grid = ProductsGrid.new(category: 'dresses', available: true, condition: ["price", ">=", 25])
# Before
grid.as_query
# => {
# category: 'dresses',
# available: true,
# condition: #<Object>
# }
# After
grid.as_query
# => {
# "category" => 'dresses',
# "available" => true,
# "condition" => { "field" => "price", "operation" => ">=", "value" => "25" }
# }- Validate dummy filter can not accept block
- Add support for timestamptz ActiveRecord column type
- Fixed
searchfield type support #330
class UsersGrid < Datagrid::Base
scope { User }
filter(
:query, :string, input_options: { type: "search" }
) do |value, scope|
scope.magic_search(value)
end
endRenders filter as:
<input type="search" name="users_grid[query]" id="users_grid_query"/>- Added support for
default_filter_optionsand added lambda support fordefault_column_options#333 by @tmikoss.
class UsersGrid < Datagrid::Base
scope { User }
self.default_column_options = -> (column) {
{header: I18n.t("datagrid.keywords.#{column.name}")}
}
self.default_filter_options = -> (filter) {
{
header: I18n.t("datagrid.keywords.user.#{filter.name}"),
input_options: filter.type == :string ? {type: "textarea"} : {},
}
}
filter(:first_name, :string)
filter(:last_name, :string)
column(:first_name)
column(:last_name)
endVersion 2 is a major update implementing a lot of major improvements at the cost of backward compatibility.
- Fix rails hooking for version 7.1. #327
- Fix formatting of value for
dateanddatetime-localinput types
- Treat true/false as YES/NO when assigned as strings for xboolean filter.
- Support infinite ranges for date, datetime and integer filters.
- Treat
ActiveRecord::Resultclass asArraydriver. - Add
Datagrid#resetmethod to reset a column cache. - Drop support of Rails 6.0 #326
- Prioritize
input_optionsover generated by default. #319
- Support
input_options: {type: "textarea"}as<textarea/>tag - Remove deprecated
ebooleanfilter - Fixed scope wrapping to be universal
- Deprecated
integer_range_filtersanddate_range_filters. Usefilter(name, type, range: true)instead. - Add
original_scopemethod that returns scope as it was defined without any wrapping #313 - Add ability to specify
columnsoption fordatagrid_row. #314
- Depend on
railtiesinstead ofrailsto prevent loading of unnecessary frameworks - Bugfix
File.exist?usage for Ruby 3.0 #307 - Drop support of old Ruby versions (< 2.7) #305
- Drop support of old Rails versions (< 6.0) #305
- Fix usage of options spread operator for Ruby 3.0 #296
- Add
input_optionsandlabel_optionstofiltermethod #294 - Fix
<option>tag rendering for Rails 6.0
Changes are not tracked