-
Notifications
You must be signed in to change notification settings - Fork 142
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
allow blank labels for fae_content_form #360
Conversation
@@ -1,5 +1,6 @@ | |||
ruby: | |||
require_locals ['attribute', 'f'], local_assigns | |||
blank_label = !label || label == '' unless label.nil? | |||
label ||= attribute.to_s.titleize |
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.
@andrewdang17 We're starting to spread the label logic all over this file. The label_adjusted
assignment on line 13 is where the full label get's built, so I think that's where the conditional logic should live. There should be no need to execute that logic if we're just setting it to false later.
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 agree I just did it this way because I didn't want to add more if/unless
statements to lines 12-22 or have to wrap the whole thing in an if statement
@@ -1,5 +1,6 @@ | |||
ruby: | |||
require_locals ['attribute', 'f'], local_assigns | |||
blank_label = !label || label == '' unless label.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 find this line difficult to interpret. If we focus on supporting label: false
, then it could look something like:
has_label = !local_assigns[:label].eql?(false)
This is a pattern we've using in other partials too.
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 that looks better. label: false
was the only way to remove the label for simpleform hence the check for false or an empty string
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.
@jamesmk what do you about using this instead?
has_label = ![false, ''].include?(local_assigns[:label])
The problem with your way is that if label: false
, then !local_assigns[:label]
will return true when really it should be false.
2afe8ec
to
1b18c11
Compare
1b18c11
to
3d0e439
Compare
@jamesmk updated |
This is just a quick fix so I can get ticket done for a client this week. I think later on all that logic in
_content_form.html.slim
should be refactored out to be separate from the partial so that you just have to pass anoptions
in rather than every possible variable since everything is a bit dependent on each other right now and relies on a lot of conditionals.