Issue 6187 admin new case contacts#6215
Merged
compwron merged 12 commits intorubyforgood:mainfrom Mar 21, 2025
Merged
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
alex-yi37
commented
Feb 18, 2025
| 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) |
Contributor
Author
There was a problem hiding this comment.
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.
compwron
approved these changes
Mar 21, 2025
Collaborator
compwron
left a comment
There was a problem hiding this comment.
Looks plausible. Let's do it.
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.
What github issue is this PR for, if any?
Resolves #6187
What changed, and why?
This PR updates the case create/edit (
/casa_cases/newand/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.rbandspec/system/casa_cases/edit_spec.rbto 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:
