Emancipation checklist page: convert case_emancipation.js to Stimulus + fetch

Open
#7,315 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript, ruby
Domain
frontend

Research direction

Start by reading app/javascript/src/case_emancipation.js alongside the page it drives, app/views/emancipations/show.html.erb, and the existing controllers in app/javascript/controllers/ to see the Stimulus conventions. Port the checkbox save, category toggle and status reporting to a new emancipation_checklist_controller.js using fetch, then remove the old file and its require. Done means the system specs in spec/system/emancipations/show_spec.rb and spec/system/casa_cases/emancipation/show_spec.rb pass, npm run test passes with the rewritten tests/case_emancipations.test.js, and notifier.js is left in place for patch_notes.js.

Written by the indexing model from the issue text.

Description

Difficulty: Advanced Help Wanted javascript

What

The emancipation checklist page for a case (app/views/emancipations/show.html.erb, at /casa_cases/:id/emancipation) is driven by app/javascript/src/case_emancipation.js. It's about 230 lines of jQuery: it saves each checkbox with $.post, expands and collapses categories, and reports save status through notifier.js. Convert it to a Stimulus controller that uses fetch.

Checklist

  • Add app/javascript/controllers/emancipation_checklist_controller.js with the same behavior: check or uncheck a category or option saves right away, child options are shown or hidden, and errors are visible to the user
  • Replace the jQuery Notifier with the design-system flash (shared/_flashes, alert_classes) or a small inline status. Note that notifier.js is also used by patch_notes.js, so don't delete it here
  • Delete app/javascript/src/case_emancipation.js and its require. Rewrite __tests__/case_emancipations.test.js
  • bundle exec rspec spec/system/emancipations/show_spec.rb spec/system/casa_cases/emancipation/show_spec.rb passes

Before you start

  • Comment here to be assigned. Setup is bin/setup, then bin/dev. Logins are in the README.
  • JS tests: npm run test. Lint: bin/lint.
  • Part of #7301 (removing jQuery). Keep this PR to just this file.
Dominant language
Ruby
Stars
384
Forks
558
Avg merge
1d 7h
Merged PRs (30d)
63

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rubyforgood/casa

All issues in rubyforgood/casa

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.