Skip to content

Commit

Permalink
AssignMultipleVolunteersAtOnce //
Browse files Browse the repository at this point in the history
response to test issues and code climate
  • Loading branch information
Sam Williams committed Jan 13, 2024
1 parent 409aedc commit f15d1ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 14 additions & 8 deletions app/javascript/controllers/select_all_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@ export default class extends Controller {
if (this.hasButtonTarget) {
const numChecked = this.getNumberChecked()
if (numChecked > 0) {
if (this.hasButtonLabelTarget) {
let label = this.buttonLabelValue
if (numChecked > 1) {
label += 's'
}
label += ' (' + numChecked + ')'
this.buttonLabelTarget.innerHTML = label
}
this.setButtonLabel(numChecked)

this.buttonTarget.classList.remove(this.hiddenClass)
} else {
Expand All @@ -59,6 +52,19 @@ export default class extends Controller {
}
}

setButtonLabel (numChecked) {
if (this.hasButtonLabelTarget) {
let label = this.buttonLabelValue

if (numChecked > 1) {
label += 's'
}
label += ' (' + numChecked + ')'

this.buttonLabelTarget.innerHTML = label
}
}

getNumberChecked () {
return this.checkboxTargets.filter((checkbox) => checkbox.checked).length
}
Expand Down
1 change: 1 addition & 0 deletions spec/system/volunteers/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
before do
sign_in admin
visit volunteers_path
find("#supervisor_volunteer_volunteer_ids_#{volunteer.id}")
find("#supervisor_volunteer_volunteer_ids_#{volunteer.id}").click
find("[data-select-all-target='button']").click
end
Expand Down

0 comments on commit f15d1ec

Please sign in to comment.