-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
5070 - Update banner creation UX #5090
Conversation
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.
Nice work! I have a couple comments/questions
static values = { checked: Boolean } | ||
|
||
connect () { | ||
this.checked = this.hasCheckboxTarget && this.checkboxTarget.checked |
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.
What's the benefit of maintaining this state? I think you could look at this.checkboxTarget.checked
inside of toggle
and not have to worry about maintaining this state.
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.
It appears to be unnecessary! Thanks!
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.
Might be worth trying to do this with just the stimulus-reveal-controller. Feels like you could put the action directly on the checkbox.
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.
@schoork Good catch! I'm pretty sure I can remove checkbox_controller
since the logic for when to show/hide ended up living outside of it.
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.
@schoork @kcdragon
I'd like some input on these tests if you can offer it. A few questions:
- Are these necessary? I figured they couldn't hurt, but I don't want to bloat the test suite.
- Should I pretty much copy these into an
edit.html.erb_spec.rb
file? I have one written, but I wasn't sure if that was necessary, given bothnew
andedit
render the same form. - I didn't seem to have access to the same actions like
click_on
,fill_in
, etc. within theviews
specs, so I'm passing a banner in with theactive
field set already to what we want. This doesn't exactly text whether the view is responsive, but it's at least checking the conditions to show/hide the warning. Is there a way I can improve this?
Anybody know what might be going on with the docker check? |
@@ -11,34 +11,44 @@ def new | |||
authorize :application, :admin_or_supervisor? | |||
|
|||
@banner = Banner.new | |||
@org_has_alternate_active_banner = current_organization.banners.where(active: true).where.not(id: @banner.id).exists? |
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.
You could also consider making this a method:
@org_has_alternate_active_banner = current_organization.has_active_banner?(@banner.id)
# app/models/casa_org
class CasaOrg
...
def has_active_banner?(current_banner_id)
banners.where(active: true).where.not(id: current_banner_id).exists?
end
end
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.
Also if you make it a method, you could probably get away without passing the instance variable around, and just call the method on line 25 of app/views/banners/_form.html.erb
@compwron @littleforest @FireLemons I think this one sort of fell below the pack because it was a draft for so long. Would any of you have time to take a look at this? |
@carrollsa we have actually been talking with the stakeholders about allowing multiple active banners 😬 . They are interested in having an admin-wide banner that shows up to everyone, and allowing smaller supervisor-level banners that would just show to a supervisor's volunteers. You've put in a lot of work on this PR, so I hate to put the kibosh on it, but I'm worried we are going to want to modify this functionality really soon. |
@littleforest that's a bummer, but I understand. Thanks for letting me know! |
🥇 |
What github issue is this PR for, if any?
Resolves #5070
First time using Stimulus. Open to any suggestions, and I'm fairly new at most of this!
What changed, and why?
Adds 2 UX improvements:
Active?
on a new or edited banner form if alternate active banner exists.Active?
checked.How will this affect user permissions?
How is this tested? (please write tests!) 💖💪
Screenshots please :)
Feelings gif (optional)
What gif best describes your feeling working on this issue? https://giphy.com/

Not a gif, but sort of this guy because I created this issue, and this felt like a lot of conditional stuff to add for a fairly minor improvement.
Feedback please? (optional)
We are very interested in your feedback! Please give us some :) https://forms.gle/1D5ACNgTs2u9gSdh9