Skip to content
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

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/app/helpers/spree/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def link_to_add_fields(name, target, options = {})
css_classes = options[:class] ? options[:class] + " spree_add_fields" : "spree_add_fields"
link_to_with_icon('plus', name, 'javascript:', data: { target: target }, class: css_classes)
end
deprecate link_to_add_fields: "Please use button_tag instead, Example: \n" \
"button_tag \"Name\", type: \"button\", data: { target: \"tbody#div\" }", deprecator: Spree::Deprecation

# renders hidden field and link to remove record using nested_attributes
def link_to_remove_fields(name, form, options = {})
Expand Down
4 changes: 3 additions & 1 deletion backend/app/views/spree/admin/option_types/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<% content_for :page_actions do %>
<li>
<span id="new_add_option_value" data-hook>
<%= link_to_add_fields t('spree.add_option_value'), "tbody#option_values", class: 'btn btn-primary' %>
<%= button_tag t('spree.add_option_value'), type: 'button',
data: { target: 'tbody#option_values' },
class: 'btn btn-primary spree_add_fields' %>
</span>
</li>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<% if can?(:create, Spree::ProductProperty) %>
<ul class="tollbar inline-menu">
<li>
<%= link_to_add_fields t('spree.add_product_properties'), 'tbody#product_properties', class: 'plus btn btn-primary' %>
<%= button_tag t('spree.add_product_properties'), type: 'button',
data: { target: 'tbody#product_properties' },
class: 'btn btn-primary spree_add_fields' %>
</li>
</ul>
<% end %>
Expand Down Expand Up @@ -55,7 +57,9 @@
<div class="form-buttons filter-actions actions">
<%= button_tag t('spree.filter_results'), class: 'btn btn-primary' %>
<% if @option_value_ids.present? %>
<%= link_to_add_fields t('spree.add_variant_properties'), 'tbody#variant_property_values', class: 'plus button' %>
<%= button_tag t('spree.add_variant_properties'), type: 'button',
data: { target: 'tbody#variant_property_values' },
class: 'button spree_add_fields' %>
<% end %>
</div>
</fieldset>
Expand Down
2 changes: 1 addition & 1 deletion backend/spec/features/admin/products/option_types_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
expect(page).to have_css("tbody#option_values tr", count: 1)

# Add a new option type
click_link "Add Option Value"
click_button "Add Option Value"
expect(page).to have_css("tbody#option_values tr", count: 2)

# Remove default option type
Expand Down