From 95d750aa60c482de8fda965419edf23127f85ffd Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 13 Mar 2020 01:11:29 +0100 Subject: [PATCH] replace link_to_add_fields usage and deprecate helper function --- backend/app/helpers/spree/admin/base_helper.rb | 2 ++ backend/app/views/spree/admin/option_types/edit.html.erb | 4 +++- .../views/spree/admin/product_properties/index.html.erb | 8 ++++++-- backend/spec/features/admin/products/option_types_spec.rb | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/app/helpers/spree/admin/base_helper.rb b/backend/app/helpers/spree/admin/base_helper.rb index ee0ce8b009a..7df39fe38ff 100644 --- a/backend/app/helpers/spree/admin/base_helper.rb +++ b/backend/app/helpers/spree/admin/base_helper.rb @@ -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 = {}) diff --git a/backend/app/views/spree/admin/option_types/edit.html.erb b/backend/app/views/spree/admin/option_types/edit.html.erb index a8b51132383..69001b6c5e1 100644 --- a/backend/app/views/spree/admin/option_types/edit.html.erb +++ b/backend/app/views/spree/admin/option_types/edit.html.erb @@ -6,7 +6,9 @@ <% content_for :page_actions do %>
  • - <%= 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' %>
  • <% end %> diff --git a/backend/app/views/spree/admin/product_properties/index.html.erb b/backend/app/views/spree/admin/product_properties/index.html.erb index 2d52dcbc574..5c80e373840 100644 --- a/backend/app/views/spree/admin/product_properties/index.html.erb +++ b/backend/app/views/spree/admin/product_properties/index.html.erb @@ -7,7 +7,9 @@ <% if can?(:create, Spree::ProductProperty) %> <% end %> @@ -55,7 +57,9 @@
    <%= 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 %>
    diff --git a/backend/spec/features/admin/products/option_types_spec.rb b/backend/spec/features/admin/products/option_types_spec.rb index 94febcc1ce7..c33dea3ef11 100644 --- a/backend/spec/features/admin/products/option_types_spec.rb +++ b/backend/spec/features/admin/products/option_types_spec.rb @@ -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