-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
replace link_to_add_fields usage and deprecate helper function #3547
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.
Thanks, I left some comments on the implementation, let me know your thoughts.
i guess the specs also need a rewrite, click_button instead of click link. will do that later. |
81a7594
to
23b716f
Compare
ok. all works fine now |
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.
Just a comment on the erb indentation, the rest is 👍
backend/app/views/spree/admin/product_properties/index.html.erb
Outdated
Show resolved
Hide resolved
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.
Thanks!
@hefan thanks for working on this! I was thinking, what about adding a new helper method? It would allow to DRY-up a bit your solution, as very similar ERB code is repeated 3 times. |
@spaghetticode I'm 👎for creating a new helper. We can change a use the one we already have (removing the deprecation) but I personally think we should move to less custom helpers and more what's already provided by Rails, at least in backend views. |
@kennyadsl I would like to better understand your opinion, can you explain to me more in detail the reason for this sentence? |
Aren't there many helper functions in base_helper and navigation_helper for creating Buttons or Links which couldn't be done also with the normal Rails helper Functions? i found them confusing and they seem to do nearly the same thing. Also they do things no longer needed (the icons on buttons for example seem to be removed). |
I don't think a wrapper that only adds a couple of attributes to an existing Rails helper is worth keeping, here's why:
Personally, and for consistency, I'd deprecate |
@kennyadsl when a store needs to change the behavior, a helper would be helpful in not making necessary to change any views (the occurences are 3 in 2 view files this time). Decorating the helper would do... that's the main benefit I see about using a helper here. Then there is reusability, when one wants to add a similar button somewhere else. Three instances is the bare minimum number of occurrences to consider DRYing up the code, so I don't see any problem in postponing this later if it will ever make more sense. Also, taking in account how simple is the code (it's a bit verbose on 3 lines, but no |
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.
@hefan thank you 👍
So i would do a PR removing and deprecating link_to_remove_fields, ok? there is only one occurence. |
@hefan if you have time, a PR to remove |
Description
Problem:
The link_to_add_fields function will (when used for buttons) create the following markup
<a ...> <span class="text">Add Option Value</span> </a>
The span with class text will be removed when the menu is minimized.
So we only see the plus icon with no text when the menu is minimized.
This happens in the option type edit screen and in the product properties index screen.
/admin/option_types/1/edit
/admin/products/ruby-hoodie/product_properties (2 occurrences)
See Screenshot:
Solution:
This PR removes the symbols from the buttons just by using link_to instead of link_to_add_fields.
The Buttons will have no more symbol but the text stays when the menu is minimized.
These three buttons where the only buttons with symbols in the Backend.
The helper function is also deprecated
See also #3544