Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 14, 2024
1 parent c153d67 commit 5a0d966
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 2 additions & 3 deletions app/views/datagrid/_range_filter.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<%= form.datagrid_filter_input(filter, class: 'datagrid-range-from', **from_options) %>
<span class="datagrid-range-separator"><%= I18n.t('datagrid.filters.range.separator') %></span>
<%# Generating id only for "from" input to make sure
# there is no duplicate id in DOM and click on label focuses the first input -%>
<%= form.datagrid_filter_input(filter, class: 'datagrid-range-to', **to_options, id: nil) %>
<%# Generating id only for "from" input to make sure -%>
<%# there is no duplicate id in DOM and click on label focuses the first input -%> <%= form.datagrid_filter_input(filter, class: 'datagrid-range-to', **to_options, id: nil) %>
9 changes: 3 additions & 6 deletions lib/datagrid/filters/date_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def default_input_options
end

def apply(grid_object, scope, value)
value = value.begin&.beginning_of_day..value.end&.end_of_day if value.is_a?(Range)
if value.is_a?(Range) && driver.timestamp_column?(scope, name)
value = value.begin&.beginning_of_day..value.end&.end_of_day
end
super
end

Expand All @@ -28,11 +30,6 @@ def format(value)
end
end

def default_filter_where(scope, value)
value = Datagrid::Utils.format_date_as_timestamp(value) if driver.timestamp_column?(scope, name)
super
end

protected

def formats
Expand Down

0 comments on commit 5a0d966

Please sign in to comment.