- name = '' unless datatable._filters_form_required? - now = Time.zone.now.beginning_of_day = f.select :date_range, opts[:collection], autocomplete: 'off', feedback: false, placeholder: 'All available dates' .mx-2 - start_date = (f.object.start_date || now) - end_date = (f.object.end_date || now) - raise('expected a date start_date') unless start_date.respond_to?(:strftime) - raise('expected a date end_date') unless end_date.respond_to?(:strftime) - path = effective_datatables.datatable_path(datatable) - prev_month = (start_date - 1.month).beginning_of_month - next_month = (start_date + 1.month).beginning_of_month - prev_year = (start_date - 1.year).beginning_of_year - next_year = (start_date + 1.year).beginning_of_year - prev_month_path = effective_datatables.datatable_path(datatable, date_range: :month, start_date: prev_month.strftime('%F'), end_date: prev_month.end_of_month.strftime('%F')) - next_month_path = effective_datatables.datatable_path(datatable, date_range: :month, start_date: next_month.strftime('%F'), end_date: next_month.end_of_month.strftime('%F')) - prev_year_path = effective_datatables.datatable_path(datatable, date_range: :year, start_date: prev_year.strftime('%F'), end_date: prev_year.end_of_year.strftime('%F')) - next_year_path = effective_datatables.datatable_path(datatable, date_range: :year, start_date: next_year.strftime('%F'), end_date: next_year.end_of_month.strftime('%F')) = f.show_if :date_range, :current_month do = f.static_field :month do #{now.beginning_of_month.strftime('%F')} to #{now.strftime('%F')} (today) = f.show_if :date_range, :current_year do = f.static_field :year do #{now.beginning_of_year.strftime('%F')} to #{now.strftime('%F')} (today) = f.show_if :date_range, :year do = f.static_field :year, wrapper: { class: 'effective-datatables-filter' } do - date = start_date.beginning_of_year = link_to '#', 'data-effective-datatables-filter-prev-year': date.advance(years: -1).strftime('%F') do = icon('arrow-left-circle') %span.prev-year= date.advance(years: -1).strftime('%Y') %span.start-date= start_date.strftime('%F') to %span.end-date= end_date.strftime('%F') = link_to '#', 'data-effective-datatables-filter-next-year': date.advance(years: 1).strftime('%F') do = icon('arrow-right-circle') %span.next-year= date.advance(years: 1).strftime('%Y') %div{style: 'display: none;'} = f.date_field :start_date, name: name, autocomplete: 'off', feedback: false = f.date_field :end_date, name: name, autocomplete: 'off', feedback: false = f.show_if :date_range, :month do = f.static_field :month, wrapper: { class: 'effective-datatables-filter' } do - date = start_date.beginning_of_month = link_to '#', 'data-effective-datatables-filter-prev-month': date.advance(months: -1).strftime('%F') do = icon('arrow-left-circle') %span.prev-month= date.advance(months: -1).strftime('%b') %span.start-date= start_date.strftime('%F') to %span.end-date= end_date.strftime('%F') = link_to '#', 'data-effective-datatables-filter-next-month': date.advance(months: 1).strftime('%F') do = icon('arrow-right-circle') %span.next-month= date.advance(months: 1).strftime('%b') %div{style: 'display: none;'} = f.date_field :start_date, name: name, autocomplete: 'off', feedback: false = f.date_field :end_date, name: name, autocomplete: 'off', feedback: false = f.show_if :date_range, :custom do .row .col = f.date_field :start_date, name: name, autocomplete: 'off', feedback: false .col = f.date_field :end_date, name: name, autocomplete: 'off', feedback: false