-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
enhancement: allow dynamic content in description
and name
#3693
enhancement: allow dynamic content in description
and name
#3693
Conversation
Code Climate has analyzed commit cabe522 and detected 0 issues on this pull request. View more on Code Climate. |
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.
Thank you for this contribution @marlena-b it's already looking great!
I tried to do the same for name but it cannot have access to the query as it is also used to display the text of the tab (see screenshot).
I understand the challenge. Let's keep it without query
access for now, and we can iterate on it later if needed.
Let's focus on the name_attributes
comment.
Thank you!
lib/avo/fields/base_field.rb
Outdated
if custom_name? | ||
return Avo::ExecutionContext.new( | ||
target: @name, | ||
**name_attributes | ||
).handle | ||
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.
Do we currently have any use for name_attributes
? If not, we should consider removing it
def name
if custom_name?
Avo::ExecutionContext.new(target: @name).handle
elsif translation_key
translated_name default: default_name
else
default_name
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.
I wanted to keep it consistent with how the description attribute is implemented. But I also don't see how this could be used, so I will remove 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.
Got it.
Avo::Concerns::HasDescription
is included in multiple classes, some within the avo
repository and others across private repositories.
Each class that includes Avo::Concerns::HasDescription
can define its own description_attributes
. When description
is called, description_attributes
will vary based on the class from which it is invoked.
For name_attributes
, however, we currently don’t have a similar use case.
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 just added a small tweak suggestion, otherwise, it's ready for documentation and merge!
Thanks again, @marlena-b!
lib/avo/fields/base_field.rb
Outdated
|
||
if translation_key | ||
if custom_name? | ||
return Avo::ExecutionContext.new(target: @name).handle |
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.
return Avo::ExecutionContext.new(target: @name).handle | |
Avo::ExecutionContext.new(target: @name).handle |
We don’t need an explicit return
since everything is already wrapped within the if/else
condition.
description
and name
I added docs: avo-hq/docs.avohq.io#354 |
Awesome!! Thank you! |
Description
Fixes #3596
I'm not sure about this solution as there is a lot of metaprogramming that I don't fully understand.
The description already supported lambdas so I just extended it so it now has access to
query
. I tried to do the same forname
but it cannot have access to the query as it is also used to display the text of the tab (see screenshot). When rendering these tabs we don't have access to the query.I appreciate the feedback, and if this is not the correct way to solve this I don't mind closing this PR :)
Checklist:
Screenshots & recording
Manual review steps