Skip to content
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

dynamic_filter type: :date_time (not linked to an existing field) #3180

Closed
pjmuller opened this issue Aug 23, 2024 · 3 comments
Closed

dynamic_filter type: :date_time (not linked to an existing field) #3180

pjmuller opened this issue Aug 23, 2024 · 3 comments

Comments

@pjmuller
Copy link

pjmuller commented Aug 23, 2024

Feature

If you want to create a dynamic filter for type=date_time for a non existing field an error (see screenshot below).
However, date_time is already implemented because if you reference an existing field (e.g. created_at it shows up nicely, see example code below)

def fields
   field :created_at, as: :date_time
end

def filters
   dynamic_filter :created_at # works
   dynamic_filter :non_defined_field, type: :date_time, conditions: {...}, query: ... # fails
end

Current workarounds

when using type: :date it works, but then I don't have the time component...

Screenshots or screen recordings

Screenshot 2024-08-23 at 14 16 11

@Paul-Bob
Copy link
Contributor

Hey @pjmuller.

date_time is not a valid dynamic filter type. All the possible filter types are specified on the documentation on the type section (here)

Enabling the time picker on a date filter is only possible (for now) if the filter is defined in a date_time or time field.

The filter is using flatpickr behind the scenes, to fully customize the picker we can add the picker_options option where you could configure flatpick options.

Something like:

    dynamic_filter :only_time_example,
      type: :date,
      picker_options: {
        enableTime: true,
        noCalendar: true
      }

    dynamic_filter :date_time_example,
      type: :date,
      picker_options: {
        enableTime: true
      }

@pjmuller
Copy link
Author

Hi @Paul-Bob yes, allowing to set picker_options on a dynamic_filter of type = date will do the trick for me.
I guess we can close this one? and just have issue #3182 ?

@Paul-Bob
Copy link
Contributor

Yes, closing in favor of #3182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants