-
Notifications
You must be signed in to change notification settings - Fork 123
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
feat: add alert when missing attachment #1220 #1273
base: main
Are you sure you want to change the base?
feat: add alert when missing attachment #1220 #1273
Conversation
Need to tinker with this a bit more, should've ran the tests locally - looks like having my method as a before_action for those actions is breaking some stuff. |
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.
Looks good! Just a couple small comments.
Run rails standard:fix
to fix the Standard pipeline failure
@kasugaijin this is ready for a re-review. The In a live environment for some reason they're populated with an empty string, so they become an array of I figured instead of adding empty strings to the test environment it'd be cleaner to just remove those empty strings in the method. Let me know if this works, or if I should implement it differently. |
render turbo_stream: turbo_stream.replace("flash", partial: "layouts/shared/flash_messages") | ||
end | ||
|
||
def show_alert_if_attachment_missing | ||
if !params[:pet][:images].nil? |
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.
I think it would be more idiomatic to use
if params[:pet][:images].present?
rather than a double negative
same for the other condition for files
|
||
def show_alert_if_attachment_missing | ||
if !params[:pet][:images].nil? | ||
no_empty_images = params[:pet][:images].reject { |image| image == "" } |
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.
no_empty_images
could just be renamed images
, same for files
.
if !params[:pet][:images].nil? | ||
no_empty_images = params[:pet][:images].reject { |image| image == "" } | ||
elsif !params[:pet][:files].nil? | ||
no_empty_files = params[:pet][:files].reject { |image| image == "" } |
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.
I'd also add a comment on why we are rejecting the ""
🔗 Issue
#1221
✍️ Description
Adds an alert when a staff user attempts to upload 0 files or images
📷 Screenshots/Demos
bin/dev
, log in as Staff, head to http://localhost:3000/alta/staff/pets/2?active_tab=photosClick Attach without any photo uploaded, and see the new alert.
Add an image and check that the success alert pops up as it was intended.
Do the same for Files