-
Notifications
You must be signed in to change notification settings - Fork 69
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
Admins hear success/error sounds when adding items to a pickup for a reservation #1827
Conversation
9b9b0fb
to
c51e5d3
Compare
c51e5d3
to
d4e1ca1
Compare
admin_reservation_loans_path(@pending_reservation_item.reservation)) | ||
) | ||
@sound_type = success_sound_path | ||
render_turbo_response(:update) |
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.
Adding a file seemed like the easiest way to send down multiple turbo streams.
@reservation_loan = ReservationLoan.new | ||
@reservation_loan.errors.add(:reservable_item_number, message) | ||
render_form | ||
end | ||
|
||
def render_form | ||
render partial: "admin/reservations/reservation_loans/form", locals: {reservation: @reservation, reservation_loan: @reservation_loan}, status: :unprocessable_entity | ||
render_turbo_response :create_error, status: :unprocessable_entity |
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.
This create_error
pattern seemed to be hanging around other parts of the app so I just copied that.
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.
This is awesome!
I tested this out and it's working really well!
I diid notice that sometimes if you enter new items fast, a sound doesn't get played (I imagine because it's already playing?).
We can maybe call fastSeek or load on the audio just before calling play? It's not a big deal if a sound gets interrupted, but that might guarantee we get it to play every time.
In any case, I think we can iterate on the details (and get feedback from staff), but this is an exciting step into a bright multimedia future! 🚀 🔈 🎉
What it does
Adds sounds when adding/removing items to a pickup for a reservation
Why it is important
#1793
Audio Interface Changes
You can test the sounds using the seed data by visiting the approved reservation's page and clicking on "Start Building".
Implementation notes
I added a custom turbo stream action called
playSound
. Right now it should only play sounds if theaudio
tags are loaded on the page.I didn't really add any tests since the general functionality of this part of the app is already tested and the sounds feel like a bonus. System testing this behavior seemed weird (I'm not really sure you can test this sort of thing with them) and so did controller testing controller instance variables or the turbo stream markup.