Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ import { Controller } from "@hotwired/stimulus"
// Connects to data-controller="scholarship-status-toggle"
// Shows or hides every recipient's scholarship status (awarded amount + whether
// the tasks are completed) across all recipient cards at once, keeping the
// switch's label, track, knob, and aria-checked state in sync.
// switch's track, knob, and aria-checked state in sync. The label stays fixed.
export default class extends Controller {
static targets = ["status", "label", "switch", "track", "knob"]
static values = { shown: { type: Boolean, default: false } }
static targets = ["status", "switch", "track", "knob"]
static values = { shown: { type: Boolean, default: true } }

toggle() {
this.shownValue = !this.shownValue
}

shownValueChanged() {
this.statusTargets.forEach((el) => el.classList.toggle("hidden", !this.shownValue))
if (this.hasLabelTarget) {
this.labelTarget.textContent = this.shownValue ? "Hide scholarship status" : "Show scholarship status"
}
if (this.hasSwitchTarget) {
this.switchTarget.setAttribute("aria-checked", this.shownValue)
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/events/recipients.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<span class="inline-block h-4 w-4 translate-x-[1.125rem] transform rounded-full bg-white shadow transition-transform"
data-scholarship-status-toggle-target="knob"></span>
</span>
<span data-scholarship-status-toggle-target="label">Hide scholarship status</span>
<span>Show scholarship status</span>
</button>
<%# Expand / collapse all %>
<button type="button" data-action="expandable-cards#toggleAll"
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ def ce_chip_text
expect(response.body).to include('data-controller="expandable-cards scholarship-status-toggle"')
expect(response.body).to include('data-action="scholarship-status-toggle#toggle"')
expect(response.body).to include('data-scholarship-status-toggle-shown-value="true"')
expect(response.body).to include("Hide scholarship status")
expect(response.body).to include("Show scholarship status")
end

it "renders the Recipients and Statistics section headers with placeholder breakdowns" do
Expand Down