Skip to content

Custom options for the dynamic select filter #343

@CharlieWinkwaves

Description

@CharlieWinkwaves

By default the dynamic filter uses the column names of the model as its options.
This can be overwritten by

filter(:condition, :dynamic,
         header: _('Dynamic condition'),
         operations: %w[= =~ >= <= !=],
         select: [[_('Title'), :title],
                  [_('Text'), :text],
                  [_('Author'), 'users.screenname']])

# this fails when using associated models with the LIKE_OPERATION.
if column_type(field) == :string
  driver.contains(scope, field, value)
else
  value = Datagrid::Utils.format_date_as_timestamp(value) if date_conversion
  driver.where(scope, field, value)
end

in that case the column_type(field) returns nil and thus driver.where(scope, field, value) is called, which does not partial match.

Is it an option to also run the contain when the column_type(field) returns nil?
I tested this locally and it works

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions