You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support Active Admin 4 with a vanilla JavaScript rewrite - #24
Makes the plugin run on Active Admin 3 and 4 from one plain JavaScript file with no jQuery. Active Admin 4 has no jQuery or Sprockets, so the old plugin did not load there.
Decisions
One file, no duplicated logic: vendor/assets/javascripts/active_admin_date_range_preset.js is a classic script with no imports or exports. Sprockets loads it through the existing //= require. On v4 the engine pins it into ActiveAdmin.importmap, and an ES module with no exports runs the same code. Both expose window.ActiveAdminDateRangePreset (init, defaults).
On v4, hosts import the module with javascript_import_module_tag in an _html_head override, or via ActiveAdminTheme.javascripts. When javascript_modules (Add javascript_modules setting to import modules on every page activeadmin/activeadmin#9148) exists, the gem registers itself. CSS is now plain CSS with .dark support. Hosts link it with stylesheet_link_tag (Propshaft serves it) or @import it into their Tailwind entry.
The value format follows input.type: YYYY-MM-DD for date, YYYY-MM-DDTHH:MM for datetime-local, unchanged for text inputs. This matches active_admin_datetimepicker#97 (div.filter_date_time_range).
A .datetime_preset_pair wrapper holding both inputs fills its own first and last input.
New hooks: data-date-range-preset-toggle, -menu, data-date-range-preset="<key>".
Release impact: major (1.0.0).$.fn.date_range_ext_preset is removed. README and CHANGELOG show the replacement, including show_time.
Verified: full suite on AA 3.2/Rails 8.1, 3.5/8.0, 4.0.0.beta23/8.0 and 8.1, all green.
One classic script with no imports or exports, so Sprockets and an
import map can both load it. $.fn.date_range_ext_preset becomes
ActiveAdminDateRangePreset.init and .defaults; options keep their names.
Native date and datetime-local inputs get the ISO value their type needs.
Co-Authored-By: Clanker
The engine pins the module into ActiveAdmin.importmap. The suite now
also runs on Active Admin 4.0.0.beta23 with a Tailwind build that
imports the gem's CSS.
Co-Authored-By: Clanker
On Active Admin 4 the module's auto-init runs before a host module that
imports it, so defaults set there never reached auto-initialised pairs.
Co-Authored-By: Clanker
With date_to_human_readable the end is 23:59:59, and cutting it to 23:59
dropped the last minute from an inclusive lteq filter. Seconds are only
written when the input's step permits them, since the default 60-second
step rejects such a value and blocks the submit.
Co-Authored-By: Clanker
Only a .datetime_preset_pair looks for its end input in the next
sibling again, as before the rewrite, so init() on any other element
cannot write into an unrelated field. Tabbing out closes the menu,
ArrowUp with no preset focused starts at the bottom, a replaced
defaults object and jQuery input options are honoured, and the npm
build puts the CSS where package.json's style field points.
Co-Authored-By: Clanker
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The date-range preset can generate values that violate native input step constraints and block submission, while suppressed compiler stderr hides the cause of pre-suite build failures.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve compiler stderr when the Tailwind build fails
spec/support/tailwind.rb:34
Redirecting the compiler's stderr to File::NULL discards the diagnostic explaining a failed build. Since this runs before the suite, CI then stops with only tailwindcss build failed, hiding the missing import, CSS error, or other cause. Please preserve stderr or capture it and include it in the exception.
Review effort: Balanced
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
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.
Makes the plugin run on Active Admin 3 and 4 from one plain JavaScript file with no jQuery. Active Admin 4 has no jQuery or Sprockets, so the old plugin did not load there.
Decisions
vendor/assets/javascripts/active_admin_date_range_preset.jsis a classic script with no imports or exports. Sprockets loads it through the existing//= require. On v4 the engine pins it intoActiveAdmin.importmap, and an ES module with no exports runs the same code. Both exposewindow.ActiveAdminDateRangePreset(init,defaults).javascript_import_module_tagin an_html_headoverride, or viaActiveAdminTheme.javascripts. Whenjavascript_modules(Add javascript_modules setting to import modules on every page activeadmin/activeadmin#9148) exists, the gem registers itself. CSS is now plain CSS with.darksupport. Hosts link it withstylesheet_link_tag(Propshaft serves it) or@importit into their Tailwind entry.input.type:YYYY-MM-DDfordate,YYYY-MM-DDTHH:MMfordatetime-local, unchanged for text inputs. This matches active_admin_datetimepicker#97 (div.filter_date_time_range)..datetime_preset_pairwrapper holding both inputs fills its own first and last input.data-date-range-preset-toggle,-menu,data-date-range-preset="<key>".Release impact: major (1.0.0).
$.fn.date_range_ext_presetis removed. README and CHANGELOG show the replacement, includingshow_time.Verified: full suite on AA 3.2/Rails 8.1, 3.5/8.0, 4.0.0.beta23/8.0 and 8.1, all green.