-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admins hear success/error sounds when adding items to a pickup for a …
…reservation (#1827) # 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](http://localhost:3000/admin/reservations/2/items) and clicking on "Start Building". - for the "neutral" sound, add an item that is not part of the reservation - for the "success" sound, add an item that is part of the reservation - for the "failure" sound, add an item that does not exist - for the "removed" sound, remove something that you've already added # Implementation notes I added a custom turbo stream action called `playSound`. Right now it should only play sounds if the `audio` 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.
- Loading branch information
Showing
14 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Sounds | ||
extend self | ||
|
||
ALL = [ | ||
SUCCESS = "success", | ||
NEUTRAL = "neutral", | ||
FAILURE = "failure", | ||
REMOVED = "removed" | ||
] | ||
|
||
ALL.each do |sound| | ||
define_method(:"#{sound}_sound_path") do | ||
"/sounds/#{sound}.wav" | ||
end | ||
end | ||
|
||
def all_sound_paths | ||
ALL.map { |sound| "/sounds/#{sound}.wav" } | ||
end | ||
end |
This file contains 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
This file contains 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
5 changes: 5 additions & 0 deletions
5
app/views/admin/reservations/pending_reservation_items/update.turbo_stream.erb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= turbo_stream.action(:redirect, admin_reservation_loans_path(@pending_reservation_item.reservation)) %> | ||
|
||
<% if @sound_type %> | ||
<turbo-stream action="playSound" sound_type="<%= @sound_type %>"></turbo-stream> | ||
<% end %> |
This file contains 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
9 changes: 9 additions & 0 deletions
9
app/views/admin/reservations/reservation_loans/create_error.turbo_stream.erb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<turbo-stream action="replace" target="reservation-loan-form"> | ||
<template> | ||
<%= render partial: "admin/reservations/reservation_loans/form", formats: [:html], locals: {reservation: @reservation, reservation_loan: @reservation_loan} %> | ||
</template> | ||
</turbo-stream> | ||
|
||
<% if @sound_type %> | ||
<turbo-stream action="playSound" sound_type="<%= @sound_type %>"></turbo-stream> | ||
<% end %> |
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.