-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
Issue 6187 admin new case contacts #6215
base: main
Are you sure you want to change the base?
Issue 6187 admin new case contacts #6215
Conversation
the multiselect rendered in the casa_cases/form partial gets used in both casa_cases/new view and casa_cases/edit view
…vior on new case contact creation page
let orderedOptionVals = this.optionsValue.map(opt => opt.value) | ||
if (showAllOptionCheck) { | ||
// using " " as value instead of "" bc tom-select doesn't init the "" in the item list | ||
orderedOptionVals = [' '].concat(orderedOptionVals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ' '
(space character) here seems to be treated the same as ''
(empty string) when form data gets parsed in the back end. Not sure how empty string values are getting stripped when associating contact type ids with a case, but seems to work as expected since I can create casa cases locally.
What github issue is this PR for, if any?
Resolves #6187
What changed, and why?
This PR updates the case create/edit (
/casa_cases/new
and/casa_cases/:case_id/edit
) pages by adding an option to select and unselect all contact type options and defaults to selecting all options when creating a case. Most of the changes revolve around a view component (app/components/form/multiple_select_component.html.erb
) and its associated template and stimulus controller.I assumed that a case needs to be created with associated contact types to be valid, so if an existing case were to have no contact types (some records in my local set up are like this), we would select all contact types when editing the case.
Also noted that existing functionality seems to be working when logged in as a volunteer and trying to add a new case contact (
/case_contacts/:case_contact_id/form/details
- seems case contact gets created when page is viewed?). If one case is assigned, defaults to that option in the form, if multiple cases are assigned, defaults to no cases being selected.How is this tested? (please write tests!) 💖💪
Note: if you see a flake in your test build in github actions, please post in slack #casa "Flaky test: " :) 💪
Note: We love capybara tests! If you are writing both haml/js and ruby, please try to test your work with tests at every level including system tests like https://github.com/rubyforgood/casa/tree/main/spec/system
Added test cases in
spec/system/casa_cases/new_spec.rb
andspec/system/casa_cases/edit_spec.rb
to check that selecting/unselecting all options works, all options are selected by default when creating a case, and existing contact types are selected when editing a case. Originally I wanted to test this functionality in a jest test for the stimulus controller end but was running into errors setting it up. Not sure if system specs are the best place to test this.Screenshots please :)
Run your local server and take a screenshot of your work! Try to include the URL of the page as well as the contents of the page.
Admin page for creating a new case, all contact type options selected by default
Admin page for editing an existing case, existing contact types are selected by default
Selecting and unselecting all options
Screen.Recording.2025-02-17.at.6.26.34.PM.mov
Feelings gif (optional)
What gif best describes your feeling working on this issue? https://giphy.com/
How to embed:
