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

Support of Stimulus change action for Tramway Multiselect #86

Merged
merged 20 commits into from
Jan 14, 2025

Conversation

kalashnikovisme
Copy link
Member

What's changed basically?

  • Added support of Stimulus change action for Tramway Multiselect

What's changed for tramway drivers?

Before

IT DIDN'T WORK

= tramway_form_for @user do |f|
  = f.multiselect :role, data: { action: 'change->user-form#updateForm' }

After

Now! It works!

AI Generated description for this PR

This pull request includes several updates to the Gemfile, JavaScript multiselect controller, form components, and tests. The changes enhance functionality, improve integration with Stimulus controllers, and update tests for better coverage.

Gemfile updates:

  • Added sqlite3 to the development group.
  • Added a new development, :test group with the debug gem.

JavaScript multiselect controller enhancements:

  • Added onChange attribute to the Multiselect controller.
  • Modified the initialization logic to parse JSON values and update item selection state.
  • Implemented onChange event handling to call specified Stimulus controller actions.

Form component updates:

  • Updated multiselect method to handle the full value array instead of just the first element.
  • Enhanced multiselect_component to include on_change and handle external actions. [1] [2]

Stimulus controller integration:

  • Removed redundant Stimulus application initialization files. [1] [2]
  • Updated index.js to initialize Stimulus application and register controllers.
  • Added a new UserForm Stimulus controller with a connect method and an updateForm action.

Test updates:

  • Refactored multiselect_input_spec.rb to include setup steps in a before block and added a new scenario to test the onchange Stimulus action. [1] [2] [3] [4] [5]

def on_change
return unless external_action&.start_with?('change')

external_action.split('->').last
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have potential bugs with using .last? not so clear as for me

@kalashnikovisme kalashnikovisme merged commit 08d8a28 into main Jan 14, 2025
15 checks passed
@kalashnikovisme kalashnikovisme deleted the multiselect-change-action branch January 14, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants