spree_backend 3.3.6 → 3.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend/checkouts/edit.js +1 -8
  3. data/app/assets/javascripts/spree/backend/handlebar_extensions.js +3 -0
  4. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +1 -1
  5. data/app/assets/javascripts/spree/backend/shipments.js +8 -25
  6. data/app/assets/javascripts/spree/backend/taxons.js.coffee +1 -6
  7. data/app/assets/stylesheets/spree/backend/sections/_account.scss +8 -4
  8. data/app/controllers/spree/admin/adjustments_controller.rb +0 -2
  9. data/app/controllers/spree/admin/base_controller.rb +5 -5
  10. data/app/controllers/spree/admin/countries_controller.rb +1 -2
  11. data/app/controllers/spree/admin/customer_returns_controller.rb +4 -5
  12. data/app/controllers/spree/admin/general_settings_controller.rb +1 -0
  13. data/app/controllers/spree/admin/log_entries_controller.rb +0 -1
  14. data/app/controllers/spree/admin/option_types_controller.rb +10 -10
  15. data/app/controllers/spree/admin/orders_controller.rb +30 -21
  16. data/app/controllers/spree/admin/payment_methods_controller.rb +5 -7
  17. data/app/controllers/spree/admin/payments_controller.rb +3 -3
  18. data/app/controllers/spree/admin/product_properties_controller.rb +7 -6
  19. data/app/controllers/spree/admin/products_controller.rb +8 -9
  20. data/app/controllers/spree/admin/promotion_actions_controller.rb +4 -4
  21. data/app/controllers/spree/admin/promotion_rules_controller.rb +4 -4
  22. data/app/controllers/spree/admin/promotions_controller.rb +22 -21
  23. data/app/controllers/spree/admin/properties_controller.rb +2 -2
  24. data/app/controllers/spree/admin/prototypes_controller.rb +0 -1
  25. data/app/controllers/spree/admin/reports_controller.rb +17 -10
  26. data/app/controllers/spree/admin/resource_controller.rb +6 -15
  27. data/app/controllers/spree/admin/shipping_methods_controller.rb +5 -5
  28. data/app/controllers/spree/admin/states_controller.rb +9 -9
  29. data/app/controllers/spree/admin/stock_items_controller.rb +10 -9
  30. data/app/controllers/spree/admin/stock_movements_controller.rb +2 -2
  31. data/app/controllers/spree/admin/stock_transfers_controller.rb +20 -15
  32. data/app/controllers/spree/admin/store_credits_controller.rb +1 -1
  33. data/app/controllers/spree/admin/taxons_controller.rb +9 -18
  34. data/app/controllers/spree/admin/users_controller.rb +7 -7
  35. data/app/controllers/spree/admin/variants_controller.rb +1 -1
  36. data/app/controllers/spree/admin/variants_including_master_controller.rb +2 -3
  37. data/app/controllers/spree/admin/zones_controller.rb +11 -11
  38. data/app/helpers/spree/admin/adjustments_helper.rb +8 -10
  39. data/app/helpers/spree/admin/base_helper.rb +43 -49
  40. data/app/helpers/spree/admin/general_settings_helper.rb +1 -1
  41. data/app/helpers/spree/admin/images_helper.rb +0 -1
  42. data/app/helpers/spree/admin/navigation_helper.rb +39 -45
  43. data/app/helpers/spree/admin/orders_helper.rb +42 -43
  44. data/app/helpers/spree/admin/payments_helper.rb +1 -1
  45. data/app/helpers/spree/admin/promotion_rules_helper.rb +2 -2
  46. data/app/helpers/spree/admin/stock_locations_helper.rb +1 -1
  47. data/app/helpers/spree/admin/stock_movements_helper.rb +1 -1
  48. data/app/helpers/spree/admin/taxons_helper.rb +1 -1
  49. data/app/models/spree/admin/resource.rb +4 -4
  50. data/app/views/spree/admin/products/_autocomplete.js.erb +1 -1
  51. data/app/views/spree/admin/return_authorizations/_form.html.erb +1 -1
  52. data/app/views/spree/admin/shared/_account_nav.html.erb +59 -0
  53. data/app/views/spree/admin/shared/_header.html.erb +3 -1
  54. data/app/views/spree/admin/shared/_main_menu.html.erb +0 -6
  55. data/app/views/spree/admin/shared/_version.html.erb +5 -0
  56. data/app/views/spree/admin/stock_transfers/new.html.erb +1 -1
  57. data/app/views/spree/admin/stock_transfers/show.html.erb +1 -1
  58. data/app/views/spree/admin/users/index.html.erb +1 -1
  59. data/app/views/spree/layouts/admin.html.erb +2 -0
  60. data/config/initializers/assets.rb +1 -1
  61. data/config/initializers/form_builder.rb +2 -3
  62. data/config/routes.rb +5 -5
  63. data/lib/spree/backend/action_callbacks.rb +0 -1
  64. data/lib/spree/backend/callbacks.rb +3 -5
  65. data/lib/spree/backend/engine.rb +4 -4
  66. metadata +11 -9
@@ -12,12 +12,12 @@ module Spree
12
12
  if report_description_key.nil?
13
13
  report_description_key = "#{report_key}_description"
14
14
  end
15
- @@available_reports[report_key] = {name: Spree.t(report_key), description: Spree.t(report_description_key)}
15
+ @@available_reports[report_key] = { name: Spree.t(report_key), description: Spree.t(report_description_key) }
16
16
  end
17
17
  end
18
18
 
19
19
  def initialize
20
- super
20
+ super
21
21
  ReportsController.add_available_report!(:sales_total)
22
22
  end
23
23
 
@@ -28,17 +28,25 @@ module Spree
28
28
  def sales_total
29
29
  params[:q] = {} unless params[:q]
30
30
 
31
- if params[:q][:completed_at_gt].blank?
32
- params[:q][:completed_at_gt] = Time.zone.now.beginning_of_month
33
- else
34
- params[:q][:completed_at_gt] = Time.zone.parse(params[:q][:completed_at_gt]).beginning_of_day rescue Time.zone.now.beginning_of_month
35
- end
31
+ params[:q][:completed_at_gt] = if params[:q][:completed_at_gt].blank?
32
+ Time.zone.now.beginning_of_month
33
+ else
34
+ begin
35
+ Time.zone.parse(params[:q][:completed_at_gt]).beginning_of_day
36
+ rescue
37
+ Time.zone.now.beginning_of_month
38
+ end
39
+ end
36
40
 
37
41
  if params[:q] && !params[:q][:completed_at_lt].blank?
38
- params[:q][:completed_at_lt] = Time.zone.parse(params[:q][:completed_at_lt]).end_of_day rescue ""
42
+ params[:q][:completed_at_lt] = begin
43
+ Time.zone.parse(params[:q][:completed_at_lt]).end_of_day
44
+ rescue
45
+ ''
46
+ end
39
47
  end
40
48
 
41
- params[:q][:s] ||= "completed_at desc"
49
+ params[:q][:s] ||= 'completed_at desc'
42
50
 
43
51
  @search = Order.complete.ransack(params[:q])
44
52
  @orders = @search.result
@@ -59,7 +67,6 @@ module Spree
59
67
  end
60
68
 
61
69
  @@available_reports = {}
62
-
63
70
  end
64
71
  end
65
72
  end
@@ -11,18 +11,14 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
11
11
  invoke_callbacks(:new_action, :before)
12
12
  respond_with(@object) do |format|
13
13
  format.html { render layout: !request.xhr? }
14
- if request.xhr?
15
- format.js { render layout: false }
16
- end
14
+ format.js { render layout: false } if request.xhr?
17
15
  end
18
16
  end
19
17
 
20
18
  def edit
21
19
  respond_with(@object) do |format|
22
20
  format.html { render layout: !request.xhr? }
23
- if request.xhr?
24
- format.js { render layout: false }
25
- end
21
+ format.js { render layout: false } if request.xhr?
26
22
  end
27
23
  end
28
24
 
@@ -117,9 +113,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
117
113
 
118
114
  def resource
119
115
  return @resource if @resource
120
- if parent_data
121
- parent_model_name = parent_data[:model_name]
122
- end
116
+ parent_model_name = parent_data[:model_name] if parent_data
123
117
  @resource = Spree::Admin::Resource.new controller_path, controller_name, parent_model_name, object_name
124
118
  end
125
119
 
@@ -158,11 +152,9 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
158
152
  def parent
159
153
  if parent_data.present?
160
154
  @parent ||= parent_data[:model_class].
161
- # Don't use `find_by_attribute_name` to workaround globalize/globalize#423 bug
162
- send(:find_by, parent_data[:find_by].to_s => params["#{resource.model_name}_id"])
155
+ # Don't use `find_by_attribute_name` to workaround globalize/globalize#423 bug
156
+ send(:find_by, parent_data[:find_by].to_s => params["#{resource.model_name}_id"])
163
157
  instance_variable_set("@#{resource.model_name}", @parent)
164
- else
165
- nil
166
158
  end
167
159
  end
168
160
 
@@ -237,8 +229,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
237
229
  end
238
230
 
239
231
  # This method should be overridden when object_name does not match the controller name
240
- def object_name
241
- end
232
+ def object_name; end
242
233
 
243
234
  # Allow all attributes to be updatable.
244
235
  #
@@ -12,22 +12,22 @@ module Spree
12
12
 
13
13
  respond_with(@object) do |format|
14
14
  format.html { redirect_to collection_url }
15
- format.js { render_js_for_destroy }
15
+ format.js { render_js_for_destroy }
16
16
  end
17
17
  end
18
18
 
19
19
  private
20
20
 
21
21
  def set_shipping_category
22
- return true if params["shipping_method"][:shipping_categories] == ""
23
- @shipping_method.shipping_categories = Spree::ShippingCategory.where(id: params["shipping_method"][:shipping_categories])
22
+ return true if params['shipping_method'][:shipping_categories] == ''
23
+ @shipping_method.shipping_categories = Spree::ShippingCategory.where(id: params['shipping_method'][:shipping_categories])
24
24
  @shipping_method.save
25
25
  params[:shipping_method].delete(:shipping_categories)
26
26
  end
27
27
 
28
28
  def set_zones
29
- return true if params["shipping_method"][:zones] == ""
30
- @shipping_method.zones = Spree::Zone.where(id: params["shipping_method"][:zones])
29
+ return true if params['shipping_method'][:zones] == ''
30
+ @shipping_method.zones = Spree::Zone.where(id: params['shipping_method'][:zones])
31
31
  @shipping_method.save
32
32
  params[:shipping_method].delete(:zones)
33
33
  end
@@ -13,17 +13,17 @@ module Spree
13
13
 
14
14
  protected
15
15
 
16
- def location_after_save
17
- admin_country_states_url(@country)
18
- end
16
+ def location_after_save
17
+ admin_country_states_url(@country)
18
+ end
19
19
 
20
- def collection
21
- super.order(:name)
22
- end
20
+ def collection
21
+ super.order(:name)
22
+ end
23
23
 
24
- def load_data
25
- @countries = Country.order(:name)
26
- end
24
+ def load_data
25
+ @countries = Country.order(:name)
26
+ end
27
27
  end
28
28
  end
29
29
  end
@@ -35,17 +35,18 @@ module Spree
35
35
  end
36
36
 
37
37
  private
38
- def stock_movement_params
39
- params.require(:stock_movement).permit(permitted_stock_movement_attributes)
40
- end
41
38
 
42
- def stock_item
43
- @stock_item ||= StockItem.find(params[:id])
44
- end
39
+ def stock_movement_params
40
+ params.require(:stock_movement).permit(permitted_stock_movement_attributes)
41
+ end
45
42
 
46
- def determine_backorderable
47
- stock_item.backorderable = params[:stock_item].present? && params[:stock_item][:backorderable].present?
48
- end
43
+ def stock_item
44
+ @stock_item ||= StockItem.find(params[:id])
45
+ end
46
+
47
+ def determine_backorderable
48
+ stock_item.backorderable = params[:stock_item].present? && params[:stock_item][:backorderable].present?
49
+ end
49
50
  end
50
51
  end
51
52
  end
@@ -6,8 +6,8 @@ module Spree
6
6
 
7
7
  def index
8
8
  @stock_movements = stock_location.stock_movements.recent.
9
- includes(stock_item: { variant: :product }).
10
- page(params[:page])
9
+ includes(stock_item: { variant: :product }).
10
+ page(params[:page])
11
11
  end
12
12
 
13
13
  def new
@@ -7,9 +7,9 @@ module Spree
7
7
  @q = StockTransfer.ransack(params[:q])
8
8
 
9
9
  @stock_transfers = @q.result.
10
- includes(stock_movements: { stock_item: :stock_location }).
11
- order(created_at: :desc).
12
- page(params[:page])
10
+ includes(stock_movements: { stock_item: :stock_location }).
11
+ order(created_at: :desc).
12
+ page(params[:page])
13
13
  end
14
14
 
15
15
  def show
@@ -19,27 +19,32 @@ module Spree
19
19
  def new; end
20
20
 
21
21
  def create
22
- variants = Hash.new(0)
23
- params[:variant].each_with_index do |variant_id, i|
24
- variants[variant_id] += params[:quantity][i].to_i
22
+ if params[:variant].nil?
23
+ flash[:error] = Spree.t('stock_transfer.errors.must_have_variant')
24
+ render :new
25
+ else
26
+ variants = Hash.new(0)
27
+ params[:variant].each_with_index do |variant_id, i|
28
+ variants[variant_id] += params[:quantity][i].to_i
29
+ end
30
+ stock_transfer = StockTransfer.create(reference: params[:reference])
31
+ stock_transfer.transfer(source_location,
32
+ destination_location,
33
+ variants)
34
+
35
+ flash[:success] = Spree.t(:stock_successfully_transferred)
36
+ redirect_to admin_stock_transfer_path(stock_transfer)
25
37
  end
26
-
27
- stock_transfer = StockTransfer.create(reference: params[:reference])
28
- stock_transfer.transfer(source_location,
29
- destination_location,
30
- variants)
31
-
32
- flash[:success] = Spree.t(:stock_successfully_transferred)
33
- redirect_to admin_stock_transfer_path(stock_transfer)
34
38
  end
35
39
 
36
40
  private
41
+
37
42
  def load_stock_locations
38
43
  @stock_locations = Spree::StockLocation.active.order_default
39
44
  end
40
45
 
41
46
  def source_location
42
- @source_location ||= params.has_key?(:transfer_receive_stock) ? nil :
47
+ @source_location ||= params.key?(:transfer_receive_stock) ? nil :
43
48
  StockLocation.find(params[:transfer_source_location_id])
44
49
  end
45
50
 
@@ -87,7 +87,7 @@ module Spree
87
87
 
88
88
  def ensure_unused_store_credit
89
89
  unless @store_credit.amount_used.zero?
90
- raise StoreCreditError.new(Spree.t('store_credit.errors.cannot_change_used_store_credit'))
90
+ raise StoreCreditError, Spree.t('store_credit.errors.cannot_change_used_store_credit')
91
91
  end
92
92
  end
93
93
  end
@@ -1,14 +1,12 @@
1
1
  module Spree
2
2
  module Admin
3
3
  class TaxonsController < Spree::Admin::BaseController
4
-
5
4
  before_action :load_taxonomy, only: [:create, :edit, :update]
6
5
  before_action :load_taxon, only: [:edit, :update]
7
6
  before_action :set_permalink_part, only: [:edit, :update]
8
7
  respond_to :html, :js
9
8
 
10
- def index
11
- end
9
+ def index; end
12
10
 
13
11
  def create
14
12
  @taxon = @taxonomy.taxons.build(params[:taxon])
@@ -24,12 +22,10 @@ module Spree
24
22
  end
25
23
  end
26
24
 
27
- def edit
28
- end
25
+ def edit; end
29
26
 
30
27
  def update
31
28
  successful = @taxon.transaction do
32
-
33
29
  parent_id = params[:taxon][:parent_id]
34
30
  set_position
35
31
  set_parent(parent_id)
@@ -41,16 +37,15 @@ module Spree
41
37
 
42
38
  set_permalink_params
43
39
 
44
- #check if we need to rename child taxons if parent name or permalink changes
40
+ # check if we need to rename child taxons if parent name or permalink changes
45
41
  @update_children = true if params[:taxon][:name] != @taxon.name || params[:taxon][:permalink] != @taxon.permalink
46
42
 
47
43
  @taxon.update_attributes(taxon_params)
48
-
49
44
  end
50
45
  if successful
51
46
  flash[:success] = flash_message_for(@taxon, :successfully_updated)
52
47
 
53
- #rename child taxons
48
+ # rename child taxons
54
49
  rename_child_taxons if @update_children
55
50
 
56
51
  respond_with(@taxon) do |format|
@@ -85,21 +80,17 @@ module Spree
85
80
 
86
81
  def set_position
87
82
  new_position = params[:taxon][:position]
88
- if new_position
89
- @taxon.child_index = new_position.to_i
90
- end
83
+ @taxon.child_index = new_position.to_i if new_position
91
84
  end
92
85
 
93
86
  def set_parent(parent_id)
94
- if parent_id
95
- @taxon.parent = Taxon.find(parent_id.to_i)
96
- end
87
+ @taxon.parent = Taxon.find(parent_id.to_i) if parent_id
97
88
  end
98
89
 
99
90
  def set_permalink_params
100
- if params.key? "permalink_part"
101
- parent_permalink = @taxon.permalink.split("/")[0...-1].join("/")
102
- parent_permalink += "/" unless parent_permalink.blank?
91
+ if params.key? 'permalink_part'
92
+ parent_permalink = @taxon.permalink.split('/')[0...-1].join('/')
93
+ parent_permalink += '/' unless parent_permalink.blank?
103
94
  params[:taxon][:permalink] = parent_permalink + params[:permalink_part]
104
95
  end
105
96
  end
@@ -77,12 +77,12 @@ module Spree
77
77
 
78
78
  protected
79
79
 
80
- def collection
81
- return @collection if @collection.present?
82
- @collection = super
83
- @search = @collection.ransack(params[:q])
84
- @collection = @search.result.page(params[:page]).per(Spree::Config[:admin_users_per_page])
85
- end
80
+ def collection
81
+ return @collection if @collection.present?
82
+ @collection = super
83
+ @search = @collection.ransack(params[:q])
84
+ @collection = @search.result.page(params[:page]).per(Spree::Config[:admin_users_per_page])
85
+ end
86
86
 
87
87
  private
88
88
 
@@ -96,7 +96,7 @@ module Spree
96
96
  # handling raise from Spree::Admin::ResourceController#destroy
97
97
  def user_destroy_with_orders_error
98
98
  invoke_callbacks(:destroy, :fails)
99
- render status: :forbidden, text: Spree.t(:error_user_destroy_with_orders)
99
+ render status: :forbidden, plain: Spree.t(:error_user_destroy_with_orders)
100
100
  end
101
101
 
102
102
  def sign_in_if_change_own_password
@@ -38,7 +38,7 @@ module Spree
38
38
  end
39
39
 
40
40
  def collection
41
- @deleted = (params.key?(:deleted) && params[:deleted] == "on") ? "checked" : ""
41
+ @deleted = params.key?(:deleted) && params[:deleted] == 'on' ? 'checked' : ''
42
42
 
43
43
  @collection ||=
44
44
  if @deleted.blank?
@@ -1,16 +1,15 @@
1
1
  module Spree
2
2
  module Admin
3
3
  class VariantsIncludingMasterController < VariantsController
4
- belongs_to "spree/product", find_by: :slug
4
+ belongs_to 'spree/product', find_by: :slug
5
5
 
6
6
  def model_class
7
7
  Spree::Variant
8
8
  end
9
9
 
10
10
  def object_name
11
- "variant"
11
+ 'variant'
12
12
  end
13
-
14
13
  end
15
14
  end
16
15
  end
@@ -9,18 +9,18 @@ module Spree
9
9
 
10
10
  protected
11
11
 
12
- def collection
13
- params[:q] ||= {}
14
- params[:q][:s] ||= "name asc"
15
- @search = super.ransack(params[:q])
16
- @zones = @search.result.page(params[:page]).per(params[:per_page])
17
- end
12
+ def collection
13
+ params[:q] ||= {}
14
+ params[:q][:s] ||= 'name asc'
15
+ @search = super.ransack(params[:q])
16
+ @zones = @search.result.page(params[:page]).per(params[:per_page])
17
+ end
18
18
 
19
- def load_data
20
- @countries = Country.order(:name)
21
- @states = State.order(:name)
22
- @zones = Zone.order(:name)
23
- end
19
+ def load_data
20
+ @countries = Country.order(:name)
21
+ @states = State.order(:name)
22
+ @zones = Zone.order(:name)
23
+ end
24
24
  end
25
25
  end
26
26
  end
@@ -1,17 +1,15 @@
1
1
  module Spree
2
2
  module Admin
3
3
  module AdjustmentsHelper
4
-
5
4
  def display_adjustable(adjustable)
6
5
  case adjustable
7
- when Spree::LineItem
8
- display_line_item(adjustable)
9
- when Spree::Shipment
10
- display_shipment(adjustable)
11
- when Spree::Order
12
- display_order(adjustable)
6
+ when Spree::LineItem
7
+ display_line_item(adjustable)
8
+ when Spree::Shipment
9
+ display_shipment(adjustable)
10
+ when Spree::Order
11
+ display_order(adjustable)
13
12
  end
14
-
15
13
  end
16
14
 
17
15
  private
@@ -22,14 +20,14 @@ module Spree
22
20
  parts << variant.product.name
23
21
  parts << "(#{variant.options_text})" if variant.options_text.present?
24
22
  parts << line_item.display_total
25
- safe_join(parts, "<br />".html_safe)
23
+ safe_join(parts, '<br />'.html_safe)
26
24
  end
27
25
 
28
26
  def display_shipment(shipment)
29
27
  "#{Spree.t(:shipment)} ##{shipment.number}<br>#{shipment.display_cost}".html_safe
30
28
  end
31
29
 
32
- def display_order(order)
30
+ def display_order(_order)
33
31
  Spree.t(:order)
34
32
  end
35
33
  end
@@ -1,15 +1,15 @@
1
1
  module Spree
2
2
  module Admin
3
3
  module BaseHelper
4
- def flash_alert flash
4
+ def flash_alert(flash)
5
5
  if flash.present?
6
6
  close_button = button_tag(class: 'close', 'data-dismiss' => 'alert', 'aria-label' => Spree.t(:close)) do
7
7
  content_tag('span', '&times;'.html_safe, 'aria-hidden' => true)
8
8
  end
9
9
  message = flash[:error] || flash[:notice] || flash[:success]
10
- flash_class = "danger" if flash[:error]
11
- flash_class = "info" if flash[:notice]
12
- flash_class = "success" if flash[:success]
10
+ flash_class = 'danger' if flash[:error]
11
+ flash_class = 'info' if flash[:notice]
12
+ flash_class = 'success' if flash[:success]
13
13
  flash_div = content_tag(:div, (close_button + message), class: "alert alert-#{flash_class} alert-auto-disappear")
14
14
  content_tag(:div, flash_div, class: 'col-xs-12')
15
15
  end
@@ -18,16 +18,14 @@ module Spree
18
18
  def field_container(model, method, options = {}, &block)
19
19
  css_classes = options[:class].to_a
20
20
  css_classes << 'field'
21
- if error_message_on(model, method).present?
22
- css_classes << 'withError'
23
- end
21
+ css_classes << 'withError' if error_message_on(model, method).present?
24
22
  content_tag(
25
23
  :div, capture(&block),
26
24
  options.merge(class: css_classes.join(' '), id: "#{model}_#{method}_field")
27
25
  )
28
26
  end
29
27
 
30
- def error_message_on(object, method, options = {})
28
+ def error_message_on(object, method, _options = {})
31
29
  object = convert_to_model(object)
32
30
  obj = object.respond_to?(:errors) ? object : instance_variable_get("@#{object}")
33
31
 
@@ -42,8 +40,6 @@ module Spree
42
40
  def datepicker_field_value(date)
43
41
  unless date.blank?
44
42
  l(date, format: Spree.t('date_picker.format', default: '%Y/%m/%d'))
45
- else
46
- nil
47
43
  end
48
44
  end
49
45
 
@@ -53,7 +49,7 @@ module Spree
53
49
  text_field_tag(name, value, preference_field_options(options))
54
50
  when :boolean
55
51
  hidden_field_tag(name, 0, id: "#{name}_hidden") +
56
- check_box_tag(name, 1, value, preference_field_options(options))
52
+ check_box_tag(name, 1, value, preference_field_options(options))
57
53
  when :string
58
54
  text_field_tag(name, value, preference_field_options(options))
59
55
  when :password
@@ -84,58 +80,56 @@ module Spree
84
80
 
85
81
  def preference_field_options(options)
86
82
  field_options = case options[:type]
87
- when :integer
88
- {
89
- size: 10,
90
- class: 'input_integer form-control'
91
- }
92
- when :boolean
93
- {}
94
- when :string
95
- {
96
- size: 10,
97
- class: 'input_string form-control'
98
- }
99
- when :password
100
- {
101
- size: 10,
102
- class: 'password_string form-control'
103
- }
104
- when :text
105
- {
106
- rows: 15,
107
- cols: 85,
108
- class: 'form-control'
109
- }
110
- else
111
- {
112
- size: 10,
113
- class: 'input_string form-control'
114
- }
83
+ when :integer
84
+ {
85
+ size: 10,
86
+ class: 'input_integer form-control'
87
+ }
88
+ when :boolean
89
+ {}
90
+ when :string
91
+ {
92
+ size: 10,
93
+ class: 'input_string form-control'
94
+ }
95
+ when :password
96
+ {
97
+ size: 10,
98
+ class: 'password_string form-control'
99
+ }
100
+ when :text
101
+ {
102
+ rows: 15,
103
+ cols: 85,
104
+ class: 'form-control'
105
+ }
106
+ else
107
+ {
108
+ size: 10,
109
+ class: 'input_string form-control'
110
+ }
115
111
  end
116
112
 
117
- field_options.merge!({
118
- readonly: options[:readonly],
119
- disabled: options[:disabled],
120
- size: options[:size]
121
- })
113
+ field_options.merge!(readonly: options[:readonly],
114
+ disabled: options[:disabled],
115
+ size: options[:size])
122
116
  end
123
117
 
124
118
  def preference_fields(object, form)
125
119
  return unless object.respond_to?(:preferences)
126
- fields = object.preferences.keys.map { |key|
120
+ fields = object.preferences.keys.map do |key|
127
121
  if object.has_preference?(key)
128
- form.label("preferred_#{key}", Spree.t(key) + ": ") +
122
+ form.label("preferred_#{key}", Spree.t(key) + ': ') +
129
123
  preference_field_for(form, "preferred_#{key}", type: object.preference_type(key))
130
124
  end
131
- }
125
+ end
132
126
  safe_join(fields, '<br />'.html_safe)
133
127
  end
134
128
 
135
129
  # renders hidden field and link to remove record using nested_attributes
136
130
  def link_to_icon_remove_fields(f)
137
131
  url = f.object.persisted? ? [:admin, f.object] : '#'
138
- link_to_with_icon('delete', '', url, class: "spree_remove_fields btn btn-sm btn-danger", data: {action: 'remove'}, title: Spree.t(:remove)) + f.hidden_field(:_destroy)
132
+ link_to_with_icon('delete', '', url, class: 'spree_remove_fields btn btn-sm btn-danger', data: { action: 'remove' }, title: Spree.t(:remove)) + f.hidden_field(:_destroy)
139
133
  end
140
134
 
141
135
  def spree_dom_id(record)
@@ -148,7 +142,7 @@ module Spree
148
142
  end
149
143
 
150
144
  def order_time(time)
151
- [I18n.l(time.to_date), time.strftime("%l:%M %p").strip].join(' ')
145
+ [I18n.l(time.to_date), time.strftime('%l:%M %p').strip].join(' ')
152
146
  end
153
147
  end
154
148
  end
@@ -2,7 +2,7 @@ module Spree
2
2
  module Admin
3
3
  module GeneralSettingsHelper
4
4
  def currency_options
5
- currencies = ::Money::Currency.table.map do |code, details|
5
+ currencies = ::Money::Currency.table.map do |_code, details|
6
6
  iso = details[:iso_code]
7
7
  [iso, "#{details[:name]} (#{iso})"]
8
8
  end
@@ -15,4 +15,3 @@ module Spree
15
15
  end
16
16
  end
17
17
  end
18
-