Filter resources - #44
Draft
blocknotes wants to merge 3 commits into
Draft
Conversation
blocknotes
force-pushed
the
filter_resources
branch
from
April 24, 2025 06:41
ad5f1d5 to
2cb1372
Compare
filter_resources instead of scoped_resource
blocknotes
force-pushed
the
filter_resources
branch
6 times, most recently
from
May 12, 2025 06:59
f155adf to
b7e91e2
Compare
blocknotes
force-pushed
the
filter_resources
branch
from
September 4, 2026 20:30
b7e91e2 to
1e6171c
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The updated filters rendering introduces multiple runtime-breaking issues (undefined namespace, missing fallback type handling, incorrect date/datetime value binding, and leftover debug JS output).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates AdministrateRansack to hook into Administrate’s filter_resources flow (rather than scoped_resource) and revises the filtering UI/rendering to be driven by per-dashboard RANSACK_SEARCH configuration, aligning with Administrate v0.18+ behavior.
Changes:
- Move Ransack integration to
filter_resourcesand add parsing for structuredsearch_terminput (key:value) inAdministrateRansack::Searchable. - Replace the legacy
_filters.html.erbwith a new_filters.erband update filter field component partials to use normalizedtype/optionsdata. - Update system specs and the dummy app views/dashboards to reflect the new filter UI and configuration.
File summaries
| File | Description |
|---|---|
| spec/system/string_filter_spec.rb | Click the “Search” button via the new .filters-buttons container instead of submitting the first submit input. |
| spec/system/select_filter_spec.rb | Update submission interaction to match the new filter controls markup. |
| spec/system/scope_filter_spec.rb | Update submission interaction to match the new filter controls markup. |
| spec/system/number_filter_spec.rb | Update submission interaction to match the new filter controls markup. |
| spec/system/has_many_filter_spec.rb | Update submission interaction to match the new filter controls markup (two scenarios). |
| spec/system/date_filter_spec.rb | Update submission interaction to match the new filter controls markup. |
| spec/system/boolean_filter_spec.rb | Update submission interaction to match the new filter controls markup. |
| spec/system/belongs_to_filter_spec.rb | Update submission interaction to match the new filter controls markup. |
| spec/support/capybara.rb | Adjust Cuprite driver options (logging, headless toggle, js_errors, etc.). |
| spec/dummy/app/views/layouts/mailer.text.erb | Remove dummy mailer layout. |
| spec/dummy/app/views/layouts/mailer.html.erb | Remove dummy mailer layout. |
| spec/dummy/app/views/layouts/application.html.erb | Remove dummy app layout. |
| spec/dummy/app/views/administrate/application/_search.html.erb | Render AdministrateRansack filters when @ransack_results is present. |
| spec/dummy/app/views/admin/tags/index.html.erb | Remove custom dummy tags index view that embedded filters. |
| spec/dummy/app/views/admin/posts/index.html.erb | Remove custom dummy posts index view that embedded filters and custom CSS. |
| spec/dummy/app/views/admin/application/_stylesheet.html.erb | Remove dummy stylesheet partial customization. |
| spec/dummy/app/views/admin/application/_javascript.html.erb | Remove dummy javascript partial customization. |
| spec/dummy/app/dashboards/tag_dashboard.rb | Add searchable fields via RANSACK_SEARCH and expand collection attributes. |
| spec/dummy/app/dashboards/post_dashboard.rb | Add RANSACK_SEARCH configuration for multiple field types/options. |
| Makefile | Seed during db_reset and remove implicit seeding for console/server. |
| lib/administrate_ransack/searchable.rb | Implement filter_resources integration and build view data (@fields/@model) from dashboard configuration. |
| lib/administrate_ransack/filters.rb | Change FILTERS mapping from component names to normalized filter type symbols. |
| Gemfile | Remove rubocop-rspec_rails. |
| app/views/administrate_ransack/components/_filter_buttons.html.erb | Update submit/clear controls markup and behavior. |
| app/views/administrate_ransack/components/_field_string.html.erb | Switch to normalized options[:label]/options[:param] rendering. |
| app/views/administrate_ransack/components/_field_select.html.erb | Support callable collections and normalized option access. |
| app/views/administrate_ransack/components/_field_other.html.erb | Normalize rendering and add wrapper markup consistent with other fields. |
| app/views/administrate_ransack/components/_field_number.html.erb | Normalize rendering and add wrapper markup consistent with other fields. |
| app/views/administrate_ransack/components/_field_has_many.html.erb | Normalize options handling (select, param, label) and wrapper markup. |
| app/views/administrate_ransack/components/_field_datetime.html.erb | Normalize options handling and support range vs single predicate inputs. |
| app/views/administrate_ransack/components/_field_date.html.erb | Normalize options handling and support range vs single predicate inputs. |
| app/views/administrate_ransack/components/_field_boolean.html.erb | Normalize options handling and wrapper markup. |
| app/views/administrate_ransack/components/_field_belongs_to.html.erb | Normalize options handling and wrapper markup. |
| app/views/administrate_ransack/_javascript.html.erb | Update JS behavior for selectize initialization (and add debug output). |
| app/views/administrate_ransack/_filters.html.erb | Remove legacy filters partial that accepted locals like attribute_types/search_path/namespace. |
| app/views/administrate_ransack/_filters.erb | Add new filters partial driven by instance variables prepared during filter_resources. |
Review details
- Files reviewed: 36/36 changed files
- Comments generated: 7
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+40
to
+42
| <div class="ransack-search"> | ||
| <% form_path = [namespace, @ransack_results] %> | ||
| <%= search_form_for(form_path, html: { 'data-administrate-ransack-filters': '1' }) do |f| %> |
Comment on lines
+6
to
+8
| <% else %> | ||
| <%= form.date_field(options[:param], value: form.object.send(field)) %> | ||
| <% end %> |
Comment on lines
+6
to
+8
| <% else %> | ||
| <%= form.datetime_field(options[:param], value: form.object.send(field)) %> | ||
| <% end %> |
Comment on lines
+44
to
+46
| <% type = data.delete(:type) %> | ||
| <% attrs = { form: f, model: @model, field: field, type: type, options: data[:options] } %> | ||
| <%= render "administrate_ransack/components/field_#{type}", attrs %> |
Comment on lines
1
to
+5
| <% content_for :javascript do %> | ||
| <!-- [JS] --> | ||
| <script> | ||
| console.error('JS error!'); | ||
|
|
Comment on lines
+79
to
+82
| if conf.blank? | ||
| field_type = dashboard.attribute_type_for(field).to_s | ||
| AdministrateRansack::FILTERS[field_type] | ||
| elsif conf.is_a?(Hash) |
Comment on lines
+72
to
+81
| RANSACK_SEARCH = { | ||
| posts: :has_many, | ||
| created_at: { | ||
| type: :date | ||
| }, | ||
| updated_at: { | ||
| type: :date, | ||
| range: false | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #35