From 766f8ab4077cad6a0f6111ff179e0d338a6b79d0 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sun, 15 Dec 2019 16:28:36 +0000 Subject: [PATCH 1/3] Add partial needed in payment and shipping methods --- .../admin/shared/_calculator_fields.html.erb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/views/spree/admin/shared/_calculator_fields.html.erb diff --git a/app/views/spree/admin/shared/_calculator_fields.html.erb b/app/views/spree/admin/shared/_calculator_fields.html.erb new file mode 100644 index 0000000000..13233bae78 --- /dev/null +++ b/app/views/spree/admin/shared/_calculator_fields.html.erb @@ -0,0 +1,22 @@ +
+ <%= Spree.t(:calculator) %> + +
+
+ <%= f.label(:calculator_type, Spree.t(:calculator), :for => 'calc_type') %> + <%= f.select(:calculator_type, @calculators.map { |c| [c.description, c.name] }, {}, {:id => 'calc_type', :class => 'select2 fullwidth'}) %> +
+ <% if !@object.new_record? %> +
+
+ <%= f.fields_for :calculator do |calculator_form| %> + <%= preference_fields(@object.calculator, calculator_form) %> + <% end %> +
+ <% if @object.calculator.respond_to?(:preferences) %> + <%= Spree.t(:calculator_settings_warning) %> + <% end %> +
+ <% end %> +
+
From 67526df420375ae30abdf90ad303ad36453da14b Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sun, 15 Dec 2019 21:32:31 +0000 Subject: [PATCH 2/3] Convert calculator fields partial to haml --- .../admin/shared/_calculator_fields.html.erb | 22 ------------------- .../admin/shared/_calculator_fields.html.haml | 13 +++++++++++ 2 files changed, 13 insertions(+), 22 deletions(-) delete mode 100644 app/views/spree/admin/shared/_calculator_fields.html.erb create mode 100644 app/views/spree/admin/shared/_calculator_fields.html.haml diff --git a/app/views/spree/admin/shared/_calculator_fields.html.erb b/app/views/spree/admin/shared/_calculator_fields.html.erb deleted file mode 100644 index 13233bae78..0000000000 --- a/app/views/spree/admin/shared/_calculator_fields.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -
- <%= Spree.t(:calculator) %> - -
-
- <%= f.label(:calculator_type, Spree.t(:calculator), :for => 'calc_type') %> - <%= f.select(:calculator_type, @calculators.map { |c| [c.description, c.name] }, {}, {:id => 'calc_type', :class => 'select2 fullwidth'}) %> -
- <% if !@object.new_record? %> -
-
- <%= f.fields_for :calculator do |calculator_form| %> - <%= preference_fields(@object.calculator, calculator_form) %> - <% end %> -
- <% if @object.calculator.respond_to?(:preferences) %> - <%= Spree.t(:calculator_settings_warning) %> - <% end %> -
- <% end %> -
-
diff --git a/app/views/spree/admin/shared/_calculator_fields.html.haml b/app/views/spree/admin/shared/_calculator_fields.html.haml new file mode 100644 index 0000000000..20fed93cb3 --- /dev/null +++ b/app/views/spree/admin/shared/_calculator_fields.html.haml @@ -0,0 +1,13 @@ +%fieldset#calculator_fields.no-border-bottom + %legend{align: "center"}= Spree.t(:calculator) + #preference-settings + .field + = f.label(:calculator_type, Spree.t(:calculator), for: 'calc_type') + = f.select(:calculator_type, @calculators.map { |c| [c.description, c.name] }, {}, {id: 'calc_type', class: 'select2 fullwidth'}) + - if !@object.new_record? + .field + .calculator-settings + = f.fields_for :calculator do |calculator_form| + = preference_fields(@object.calculator, calculator_form) + - if @object.calculator.respond_to?(:preferences) + %span.calculator-settings-warning.info.warning= Spree.t(:calculator_settings_warning) From 9df9061ec18b03adbf0498ba25744b9bbfce9c81 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sun, 15 Dec 2019 21:39:26 +0000 Subject: [PATCH 3/3] Bring missing translation from spree and use root namespace for translations instead of the spre namespace --- app/views/spree/admin/shared/_calculator_fields.html.haml | 6 +++--- config/locales/en.yml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/spree/admin/shared/_calculator_fields.html.haml b/app/views/spree/admin/shared/_calculator_fields.html.haml index 20fed93cb3..062503c8d6 100644 --- a/app/views/spree/admin/shared/_calculator_fields.html.haml +++ b/app/views/spree/admin/shared/_calculator_fields.html.haml @@ -1,8 +1,8 @@ %fieldset#calculator_fields.no-border-bottom - %legend{align: "center"}= Spree.t(:calculator) + %legend{align: "center"}= t(:calculator) #preference-settings .field - = f.label(:calculator_type, Spree.t(:calculator), for: 'calc_type') + = f.label(:calculator_type, t(:calculator), for: 'calc_type') = f.select(:calculator_type, @calculators.map { |c| [c.description, c.name] }, {}, {id: 'calc_type', class: 'select2 fullwidth'}) - if !@object.new_record? .field @@ -10,4 +10,4 @@ = f.fields_for :calculator do |calculator_form| = preference_fields(@object.calculator, calculator_form) - if @object.calculator.respond_to?(:preferences) - %span.calculator-settings-warning.info.warning= Spree.t(:calculator_settings_warning) + %span.calculator-settings-warning.info.warning= t(:calculator_settings_warning) diff --git a/config/locales/en.yml b/config/locales/en.yml index f1945520a0..8fe83583a3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2081,6 +2081,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using tax_category: "Tax Category" calculator: "Calculator" calculator_values: "Calculator values" + calculator_settings_warning: "If you are changing the calculator type, you must save first before you can edit the calculator settings" flat_percent_per_item: "Flat Percent (per item)" flat_rate_per_item: "Flat Rate (per item)" flat_rate_per_order: "Flat Rate (per order)"