Replace Chosen.js with TomSelect for meeting invitations#2566
Open
mroderick wants to merge 1 commit intocodebar:masterfrom
Open
Replace Chosen.js with TomSelect for meeting invitations#2566mroderick wants to merge 1 commit intocodebar:masterfrom
mroderick wants to merge 1 commit intocodebar:masterfrom
Conversation
- Replace Chosen.js dropdown with TomSelect for member lookup - Load members dynamically via /admin/members/search endpoint - Add select_from_tom_select helper for Capybara tests - Update tests for remote data loading - Exclude #meeting_invitations_member from Chosen.js initialization Reuses /admin/members/search endpoint from PR codebar#2562. Fixes performance issue loading 28k+ members on every page render.
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
The
/admin/meetings/:idinvitation management page loads all members into a dropdown usingMember.all, identical to the anti-pattern fixed in PR #2562:What
Replace Chosen.js with TomSelect for the member lookup field in meeting invitations, using remote data loading:
/admin/members/searchendpointChanges
Frontend:
app/views/admin/meetings/_invitation_management.html.haml- removedMember.all, changed class totom-selectapp/views/admin/meetings/show.html.haml- added TomSelect CDN viacontent_for :headJavaScript:
#meeting_invitations_memberinapp/assets/javascripts/application.js#meeting_invitations_memberfrom Chosen.js initializationTests:
spec/support/select_from_tom_select.rb- Capybara helper for TomSelect dropdownsspec/features/admin/managing_meeting_invitations_spec.rb- changed fromselecttoselect_from_tom_select, added:jsmetadataHow to Verify Locally
1. Run migrations and seed (if needed)
bundle exec rails db:migrate db:seed2. Start the server
bundle exec rails server3. Ensure you have an admin user
Or log in via GitHub OAuth and visit
/admin/membersto verify admin access.4. Create test data (if not exists)
5. Test the member search
/admin/meetings/:slug(replace:slugwith the meeting slug from step 4)6. Run the tests
bundle exec rspec spec/features/admin/managing_meeting_invitations_spec.rbAll 3 tests should pass:
creating a new meeting invitation for a member that is not already attending(JS)creating a new meeting invitation for a member that is already attending(JS)Updating the attendance of an invitation7. Verify TomSelect tests still work
bundle exec rspec spec/features/admin/tom_select_member_lookup_spec.rbBoth tests should pass (the
/admin/memberspage TomSelect functionality).Related
/admin/members/searchendpoint from PR Replace Chosen.js with TomSelect for member lookup #2562Member.alland Chosen.js removal effortFuture Work
Remaining
Member.allscalability issues:app/views/admin/meetings/_form.html.hamlline 20 usesMember.allfor the organisers multi-select (same issue, different page)Other Chosen.js uses (small datasets, low priority):
@workshop.invitations.not_accepted(local data, ~dozens of records)@coaches(workshop's coaches, ~5-20) andTutorial.all(small dataset)@chapters(small dataset, ~10-20)Final cleanup: