Repository navigation
Add a tom_select generator and run it from core_setup - #210
Open
OutlawAndy wants to merge 6 commits into
Open
OutlawAndy wants to merge 6 commits into
OutlawAndy wants to merge 6 commits into
Conversation
bundle_command already runs in Bundler.with_original_env. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Installs tom-select, its stylesheet, and a Stimulus controller that tears Tom Select down before a Turbo morph and rebuilds it after, so the selected values survive. When SimpleForm is present it also installs the tom_select and grouped_tom_select inputs, both wired to those morph actions. core_setup runs it right after simple_form. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The controller binds to the select itself instead of a target, takes a create value from the input's allow_create option, keeps commas in values, clears the search text after a pick, and drops the dropdown_input plugin so the rspec SelectHelper can type into the control. The per-element morph actions stay. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The all generator spec now derives the expected generators from lib/generators/rolemodel, delegating to a directory's all generator when it has one, minus a named exclusion list. That surfaced rolemodel:all never running rolemodel:turbo:all, which core_setup does, so it runs it now and its README lists the Turbo generators in place of a dead Modals link. The core_setup ordering spec goes away. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Why?
No generator sets up Tom Select, even though the rspec generator's
SelectHelperalready drives it. Apps copy the input and Stimulus controller from each other by hand. fujifilm_cimba's copy has Stimulus actions that keep Tom Select's selected values through a Turbo morph. tarsco_bolted_tank's has the better settings. Turbo morphs are now routine because turbo_form re-renders dynamic forms by morphing. This PR combines the two and makes that the default.What Changed
rolemodel:tom_selectgenerator, modeled onrolemodel:tailored_select:tom-selectpackage and importstom-select/dist/css/tom-select.csstom-selectStimulus controller, bound to the<select>itself, and updates the manifest. Its settings come from tarsco_bolted_tank:createfrom the input'sallow_create:option,delimiter: null, the search text clears after a pick, andremove_buttononly for multiple selects. There's nodropdown_inputplugin, so the rspecSelectHelpercan type into the control.turbo:before-morph-elementsaves the current markup into Tom Select's revert settings and destroys the instance.turbo:morph-elementrebuilds it. Both are:selfactions on the select, so nothing depends on a page-wide morph handler.tom_selectandgrouped_tom_selectinputs that attach the controller and both morph actions. The grouped input gets the morph actions too.superwith the Stimulus options merged intowrapper_options, instead of re-implementing SimpleForm'sinput. Rendered in tarsco_bolted_tank, the HTML matches tarsco's input for plain,allow_create:and customdata:cases, apart from the added morph actions.rolemodel:core_setupandrolemodel:allrunrolemodel:tom_selectright afterrolemodel:simple_formlib/generators/rolemodelinstead of a hard-coded list. It expects a directory's own all generator when it has one, and keeps a named exclusion list (core_setup,tailored_select). That showedrolemodel:allnever ranrolemodel:turbo:all, so it does now, and therolemodel:allREADME lists the Turbo generators in place of a dead./modalslink.rolemodel:simple_formdrops itsBundler.with_unbundled_envwrapper.bundle_commandalready runs inBundler.with_original_env.Pre-merge checklist
Notes
syncaction, which re-syncs every tom-select 100ms after any Turbo Stream renders. It's left over from turbo_fetch. A stream that replaces the select reconnects the controller anyway.Screenshots
N/A — no UI changes in this gem
🤖 Generated with Claude Code