spree_backend 3.4.6 → 3.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/app/assets/javascripts/spree/backend.js +1 -1
  3. data/app/assets/javascripts/spree/backend/shipments.js +24 -3
  4. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +10 -6
  5. data/app/assets/javascripts/spree/backend/users/edit.js +18 -0
  6. data/app/assets/stylesheets/spree/backend/components/_buttons.scss +7 -3
  7. data/app/assets/stylesheets/spree/backend/components/_taxon_products_view.scss +2 -0
  8. data/app/assets/stylesheets/spree/backend/global/_variables.scss +2 -2
  9. data/app/controllers/spree/admin/adjustments_controller.rb +1 -1
  10. data/app/controllers/spree/admin/general_settings_controller.rb +0 -14
  11. data/app/controllers/spree/admin/orders_controller.rb +15 -1
  12. data/app/controllers/spree/admin/products_controller.rb +4 -4
  13. data/app/controllers/spree/admin/promotions_controller.rb +16 -1
  14. data/app/controllers/spree/admin/shipping_methods_controller.rb +2 -2
  15. data/app/controllers/spree/admin/stock_locations_controller.rb +4 -3
  16. data/app/controllers/spree/admin/stores_controller.rb +79 -0
  17. data/app/controllers/spree/admin/users_controller.rb +8 -6
  18. data/app/controllers/spree/admin/variants_controller.rb +6 -1
  19. data/app/helpers/spree/admin/navigation_helper.rb +18 -2
  20. data/app/models/spree/backend_configuration.rb +2 -1
  21. data/app/views/spree/admin/general_settings/edit.html.erb +0 -50
  22. data/app/views/spree/admin/orders/_store_form.html.erb +18 -0
  23. data/app/views/spree/admin/orders/index.html.erb +11 -4
  24. data/app/views/spree/admin/orders/store.html.erb +7 -0
  25. data/app/views/spree/admin/products/_form.html.erb +7 -7
  26. data/app/views/spree/admin/products/edit.html.erb +3 -0
  27. data/app/views/spree/admin/promotions/_form.html.erb +7 -0
  28. data/app/views/spree/admin/promotions/_promotion_action.html.erb +1 -1
  29. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +1 -1
  30. data/app/views/spree/admin/promotions/actions/_free_shipping.html.erb +0 -0
  31. data/app/views/spree/admin/promotions/index.html.erb +1 -0
  32. data/app/views/spree/admin/shared/_destroy.js.erb +1 -0
  33. data/app/views/spree/admin/shared/_order_tabs.html.erb +6 -0
  34. data/app/views/spree/admin/shared/_update_store_credit.js.erb +1 -0
  35. data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +1 -1
  36. data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
  37. data/app/views/spree/admin/shipping_methods/index.html.erb +1 -1
  38. data/app/views/spree/admin/stores/_form.html.erb +48 -0
  39. data/app/views/spree/admin/{trackers → stores}/edit.html.erb +5 -5
  40. data/app/views/spree/admin/stores/index.html.erb +38 -0
  41. data/app/views/spree/admin/stores/new.html.erb +11 -0
  42. data/app/views/spree/admin/users/_addresses_form.html.erb +7 -0
  43. data/app/views/spree/admin/users/_lifetime_stats.html.erb +2 -2
  44. data/config/routes.rb +11 -1
  45. data/vendor/assets/javascripts/handlebars.js +7 -2724
  46. data/vendor/assets/javascripts/modernizr.js +3 -4
  47. data/vendor/assets/javascripts/underscore-min.js +3 -4
  48. metadata +20 -16
  49. data/app/controllers/spree/admin/trackers_controller.rb +0 -6
  50. data/app/views/spree/admin/trackers/_form.html.erb +0 -36
  51. data/app/views/spree/admin/trackers/index.html.erb +0 -44
  52. data/app/views/spree/admin/trackers/new.html.erb +0 -13
  53. data/vendor/assets/javascripts/underscore-min.map +0 -1
  54. data/vendor/assets/javascripts/velocity.js +0 -3831
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 738c4ddb399d96fed16d125559d5af5c12b5ff32734a818e1c25f1f58cc115c8
4
- data.tar.gz: 14ffa9d8c57ef5565fe37dc31a4b45154d13e60ebf5a62329cc07e20d7ac15fc
2
+ SHA1:
3
+ metadata.gz: 2abaf3f1c27f9be3bee8cafdca91363f6535665a
4
+ data.tar.gz: 63934daca736fc690be8336282148c18c8cfab3e
5
5
  SHA512:
6
- metadata.gz: 3a8b40ac8f20c72311738581672e38c9f0131006a77b5d0f8339391c795397e1cb113df13ca3434c8671ac8c5f82b7d32b699eaca7a46aee155e986877b098e3
7
- data.tar.gz: 51648867cd3293ac615d3213b03b8f33256a48e3cc497f9718d2499900f10005aafac9ec0588963fe0d9c9cd2317dc62f40f79916d44ed47e7704ed17cf2d2c0
6
+ metadata.gz: 8137421d3c391e21e44dba3e38fff09e51698e0b68c484d21104a7809e0fac8101b6e3c892e486dd70aee55766252d4aead2dbe8946319a697a36185f3570475
7
+ data.tar.gz: 2206c3665bff0cead6c01309c0f0844f0938ae0fa2ae22491b48ac4cc89713751f1efb1437897f532f6eed313686743be68ec39cf8618c7c3b0e249c7c3c0931
@@ -10,7 +10,6 @@
10
10
  //= require jquery-ui/widgets/autocomplete
11
11
  //= require select2
12
12
  //= require underscore-min.js
13
- //= require velocity
14
13
 
15
14
  //= require spree
16
15
  //= require spree/backend/spree-select2
@@ -45,6 +44,7 @@
45
44
  //= require spree/backend/taxon_tree_menu
46
45
  //= require spree/backend/taxonomy
47
46
  //= require spree/backend/taxons
47
+ //= require spree/backend/users/edit
48
48
  //= require spree/backend/user_picker
49
49
  //= require spree/backend/tag_picker
50
50
  //= require spree/backend/variant_autocomplete
@@ -125,6 +125,19 @@ $(document).ready(function () {
125
125
  $('a.edit-tracking').click(toggleTrackingEdit);
126
126
  $('a.cancel-tracking').click(toggleTrackingEdit);
127
127
 
128
+ var createTrackingValueContent = function (data) {
129
+ var selected_shipping_method = data.shipping_methods.filter(function (method) {
130
+ return method.id === data.selected_shipping_rate.shipping_method_id;
131
+ })[0];
132
+
133
+ if (selected_shipping_method && selected_shipping_method.tracking_url) {
134
+ var shipmentTrackingUrl = selected_shipping_method.tracking_url.replace(/:tracking/, data.tracking);
135
+ return '<a target="_blank" href="' + shipmentTrackingUrl + '">' + data.tracking + '<a>';
136
+ }
137
+
138
+ return data.tracking;
139
+ }
140
+
128
141
  // handle tracking save
129
142
  $('[data-hook=admin_shipment_form] a.save-tracking').on('click', function (event) {
130
143
  event.preventDefault();
@@ -148,7 +161,12 @@ $(document).ready(function () {
148
161
 
149
162
  var show = link.parents('tbody').find('tr.show-tracking');
150
163
  show.toggle();
151
- show.find('.tracking-value').html($("<strong>").html(Spree.translations.tracking + ": ")).append(data.tracking);
164
+
165
+ if (data.tracking) {
166
+ show.find('.tracking-value').html($("<strong>").html(Spree.translations.tracking + ": ")).append(createTrackingValueContent(data));
167
+ } else {
168
+ show.find('.tracking-value').html(Spree.translations.no_tracking_present);
169
+ }
152
170
  });
153
171
  });
154
172
  });
@@ -212,6 +230,9 @@ toggleItemEdit = function(){
212
230
 
213
231
  startItemSplit = function(event){
214
232
  event.preventDefault();
233
+ $('.cancel-split').each(function(){
234
+ $(this).click()
235
+ })
215
236
  var link = $(this);
216
237
  link.parent().find('a.edit-item').toggle();
217
238
  link.parent().find('a.split-item').toggle();
@@ -279,7 +300,7 @@ completeItemSplit = function(event) {
279
300
  token: Spree.api_key
280
301
  }
281
302
  }).error(function(msg) {
282
- alert(msg.responseJSON['message']);
303
+ alert(msg.responseJSON.exception);
283
304
  }).done(function(msg) {
284
305
  window.location.reload();
285
306
  });
@@ -297,7 +318,7 @@ completeItemSplit = function(event) {
297
318
  token: Spree.api_key
298
319
  }
299
320
  }).error(function(msg) {
300
- alert(msg.responseJSON['message']);
321
+ alert(msg.responseJSON.exception);
301
322
  }).done(function(msg) {
302
323
  window.location.reload();
303
324
  });
@@ -1,6 +1,6 @@
1
- handle_ajax_error = (XMLHttpRequest, textStatus, errorThrown) ->
1
+ handle_ajax_error = (last_rollback) ->
2
2
  $.jstree.rollback(last_rollback)
3
- $("#ajax_error").show().html("<strong>" + Spree.translations.server_error + "</strong><br />" + Spree.translations.taxonomy_tree_error)
3
+ show_flash("error", "<strong>" + Spree.translations.server_error + "</strong><br />" + Spree.translations.taxonomy_tree_error)
4
4
 
5
5
  handle_move = (e, data) ->
6
6
  last_rollback = data.rlbk
@@ -20,7 +20,8 @@ handle_move = (e, data) ->
20
20
  "taxon[child_index]": position,
21
21
  token: Spree.api_key
22
22
  },
23
- error: handle_ajax_error
23
+ error: (XMLHttpRequest, textStatus, errorThrown) ->
24
+ handle_ajax_error(last_rollback)
24
25
 
25
26
  true
26
27
 
@@ -41,7 +42,8 @@ handle_create = (e, data) ->
41
42
  "taxon[child_index]": position,
42
43
  token: Spree.api_key
43
44
  },
44
- error: handle_ajax_error,
45
+ error: (XMLHttpRequest, textStatus, errorThrown) ->
46
+ handle_ajax_error(last_rollback)
45
47
  success: (data,result) ->
46
48
  node.prop('id', data.id)
47
49
 
@@ -62,7 +64,8 @@ handle_rename = (e, data) ->
62
64
  "taxon[name]": name,
63
65
  token: Spree.api_key
64
66
  },
65
- error: handle_ajax_error
67
+ error: (XMLHttpRequest, textStatus, errorThrown) ->
68
+ handle_ajax_error(last_rollback)
66
69
 
67
70
  handle_delete = (e, data) ->
68
71
  last_rollback = data.rlbk
@@ -79,7 +82,8 @@ handle_delete = (e, data) ->
79
82
  _method: "delete",
80
83
  token: Spree.api_key
81
84
  },
82
- error: handle_ajax_error
85
+ error: (XMLHttpRequest, textStatus, errorThrown) ->
86
+ handle_ajax_error(last_rollback)
83
87
  else
84
88
  $.jstree.rollback(last_rollback)
85
89
  last_rollback = null
@@ -0,0 +1,18 @@
1
+ $( document ).ready(function() {
2
+ var use_billing = $('#user_use_billing');
3
+
4
+ if(use_billing.is(':checked')) {
5
+ $('#shipping').hide();
6
+ }
7
+
8
+ use_billing.change(function() {
9
+ if(this.checked){
10
+ $('#shipping').hide();
11
+ return $('#shipping input, #shipping select').prop('disabled', true);
12
+ }
13
+ else {
14
+ $('#shipping').show();
15
+ $('#shipping input, #shipping select').prop('disabled', false);
16
+ }
17
+ });
18
+ });
@@ -1,4 +1,5 @@
1
- .btn, .nav-pills > li > a {
1
+ .btn,
2
+ .nav-pills > li > a {
2
3
  letter-spacing: 1px;
3
4
  vertical-align: middle;
4
5
  transition: color 0.1s linear 0s,background-color 0.1s linear 0s,opacity 0.2s linear 0s !important;
@@ -9,25 +10,28 @@
9
10
  -webkit-font-feature-settings: "kern" 1;
10
11
  -moz-font-feature-settings: "kern" 1;
11
12
  }
13
+
12
14
  .btn {
13
15
  text-align: center;
14
16
 
15
17
  &:focus {
16
18
  outline: 0 !important;
17
19
  }
18
-
20
+
19
21
  &:hover,
20
22
  &:focus,
21
23
  &:active,
22
24
  &.active,
23
25
  &.disabled,
24
26
  &[disabled] {
25
- box-shadow: none;
27
+ box-shadow: none;
26
28
  }
27
29
 
28
30
  .glyphicon {
29
31
  padding-right: 3px;
30
32
  }
33
+
34
+ .ship { color: $btn-success-color; }
31
35
  }
32
36
 
33
37
  .btn-sm .glyphicon { padding: 0; }
@@ -41,7 +41,9 @@
41
41
  }
42
42
  }
43
43
  .image {
44
+ height: 191px;
44
45
  .thumbnail {
46
+ max-height: 180px;
45
47
  margin-bottom: 8px;
46
48
  display: inline-block;
47
49
  width: 100%;
@@ -19,7 +19,7 @@
19
19
  /*------------------------------------------
20
20
  Fonts
21
21
  -----------------------------------------*/
22
- $headings-font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
22
+ $headings-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
23
23
  $headings-font-weight: 300;
24
24
 
25
25
  /*------------------------------------------
@@ -34,4 +34,4 @@
34
34
  /*------------------------------------------
35
35
  Wells
36
36
  -----------------------------------------*/
37
- $well-bg: #fbfbfb;
37
+ $well-bg: #fbfbfb;
@@ -12,7 +12,7 @@ module Spree
12
12
  before_action :find_adjustment, only: [:destroy, :edit, :update]
13
13
 
14
14
  def index
15
- @adjustments = @order.all_adjustments.order(created_at: :asc)
15
+ @adjustments = @order.all_adjustments.eligible.order(created_at: :asc)
16
16
  end
17
17
 
18
18
  private
@@ -3,8 +3,6 @@ module Spree
3
3
  class GeneralSettingsController < Spree::Admin::BaseController
4
4
  include Spree::Backend::Callbacks
5
5
 
6
- before_action :set_store
7
-
8
6
  def edit
9
7
  @preferences_security = []
10
8
  end
@@ -15,8 +13,6 @@ module Spree
15
13
  Spree::Config[name] = value
16
14
  end
17
15
 
18
- current_store.update_attributes store_params
19
-
20
16
  flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:general_settings))
21
17
  redirect_to edit_admin_general_settings_path
22
18
  end
@@ -26,16 +22,6 @@ module Spree
26
22
  invoke_callbacks(:clear_cache, :after)
27
23
  head :no_content
28
24
  end
29
-
30
- private
31
-
32
- def store_params
33
- params.require(:store).permit(permitted_store_attributes)
34
- end
35
-
36
- def set_store
37
- @store = current_store
38
- end
39
25
  end
40
26
  end
41
27
  end
@@ -2,7 +2,7 @@ module Spree
2
2
  module Admin
3
3
  class OrdersController < Spree::Admin::BaseController
4
4
  before_action :initialize_order_events
5
- before_action :load_order, only: [:edit, :update, :cancel, :resume, :approve, :resend, :open_adjustments, :close_adjustments, :cart]
5
+ before_action :load_order, only: [:edit, :update, :cancel, :resume, :approve, :resend, :open_adjustments, :close_adjustments, :cart, :store, :set_store]
6
6
 
7
7
  respond_to :html
8
8
 
@@ -75,6 +75,10 @@ module Spree
75
75
  end
76
76
  end
77
77
 
78
+ def store
79
+ @stores = Spree::Store.all
80
+ end
81
+
78
82
  def update
79
83
  if @order.update_attributes(params[:order]) && @order.line_items.present?
80
84
  @order.update_with_updater!
@@ -130,6 +134,16 @@ module Spree
130
134
  respond_with(@order) { |format| format.html { redirect_back fallback_location: spree.admin_order_adjustments_url(@order) } }
131
135
  end
132
136
 
137
+ def set_store
138
+ if @order.update_attributes(store_id: params[:order][:store_id])
139
+ flash[:success] = flash_message_for(@order, :successfully_updated)
140
+ else
141
+ flash[:error] = @order.errors.full_messages.join(', ')
142
+ end
143
+
144
+ redirect_to store_admin_order_url(@order)
145
+ end
146
+
133
147
  private
134
148
 
135
149
  def order_params
@@ -50,7 +50,7 @@ module Spree
50
50
  if @product.destroy
51
51
  flash[:success] = Spree.t('notice_messages.product_deleted')
52
52
  else
53
- flash[:error] = Spree.t('notice_messages.product_not_deleted', error: @product.errors.full_messages.join(', '))
53
+ flash[:error] = Spree.t('notice_messages.product_not_deleted', error: @product.errors.full_messages.to_sentence)
54
54
  end
55
55
  rescue ActiveRecord::RecordNotDestroyed => e
56
56
  flash[:error] = Spree.t('notice_messages.product_not_deleted', error: e.message)
@@ -69,12 +69,12 @@ module Spree
69
69
  flash[:success] = Spree.t('notice_messages.product_cloned')
70
70
  redirect_to edit_admin_product_url(@new)
71
71
  else
72
- flash[:error] = Spree.t('notice_messages.product_not_cloned')
72
+ flash[:error] = Spree.t('notice_messages.product_not_cloned', error: @new.errors.full_messages.to_sentence)
73
73
  redirect_to admin_products_url
74
74
  end
75
- rescue ActiveRecord::RecordInvalid
75
+ rescue ActiveRecord::RecordInvalid => e
76
76
  # Handle error on uniqueness validation on product fields
77
- flash[:error] = Spree.t('notice_messages.product_not_cloned')
77
+ flash[:error] = Spree.t('notice_messages.product_not_cloned', error: e.message)
78
78
  redirect_to admin_products_url
79
79
  end
80
80
 
@@ -1,10 +1,25 @@
1
1
  module Spree
2
2
  module Admin
3
3
  class PromotionsController < ResourceController
4
- before_action :load_data
4
+ before_action :load_data, except: :clone
5
5
 
6
6
  helper 'spree/admin/promotion_rules'
7
7
 
8
+ def clone
9
+ promotion = Spree::Promotion.find(params[:id])
10
+ duplicator = Spree::PromotionHandler::PromotionDuplicator.new(promotion)
11
+
12
+ @new_promo = duplicator.duplicate
13
+
14
+ if @new_promo.errors.empty?
15
+ flash[:success] = Spree.t('promotion_cloned')
16
+ redirect_to edit_admin_promotion_url(@new_promo)
17
+ else
18
+ flash[:error] = Spree.t('promotion_not_cloned', error: @new_promo.errors.full_messages.to_sentence)
19
+ redirect_to admin_promotions_url(@new_promo)
20
+ end
21
+ end
22
+
8
23
  protected
9
24
 
10
25
  def location_after_save
@@ -19,14 +19,14 @@ module Spree
19
19
  private
20
20
 
21
21
  def set_shipping_category
22
- return true if params['shipping_method'][:shipping_categories] == ''
22
+ return true if params['shipping_method'][:shipping_categories].blank?
23
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] == ''
29
+ return true if params['shipping_method'][:zones].blank?
30
30
  @shipping_method.zones = Spree::Zone.where(id: params['shipping_method'][:zones])
31
31
  @shipping_method.save
32
32
  params[:shipping_method].delete(:zones)
@@ -7,9 +7,10 @@ module Spree
7
7
 
8
8
  def set_country
9
9
  @stock_location.country = Spree::Country.default
10
- rescue ActiveRecord::RecordNotFound
11
- flash[:error] = Spree.t(:stock_locations_need_a_default_country)
12
- redirect_to admin_stock_locations_path
10
+ unless @stock_location.country
11
+ flash[:error] = Spree.t(:stock_locations_need_a_default_country)
12
+ redirect_to admin_stock_locations_path
13
+ end
13
14
  end
14
15
  end
15
16
  end
@@ -0,0 +1,79 @@
1
+ module Spree
2
+ module Admin
3
+ class StoresController < Spree::Admin::BaseController
4
+ before_action :load_store, only: [:new, :edit, :update]
5
+
6
+ def index
7
+ @stores = Spree::Store.all
8
+ end
9
+
10
+ def create
11
+ @store = Spree::Store.new(permitted_store_params)
12
+
13
+ if @store.save
14
+ flash[:success] = flash_message_for(@store, :successfully_created)
15
+ redirect_to admin_stores_path
16
+ else
17
+ flash[:error] = "#{Spree.t('store.errors.unable_to_create')}: #{@store.errors.full_messages.join(', ')}"
18
+ render :new
19
+ end
20
+ end
21
+
22
+ def update
23
+ @store.assign_attributes(permitted_store_params)
24
+
25
+ if @store.save
26
+ flash[:success] = flash_message_for(@store, :successfully_updated)
27
+ redirect_to admin_stores_path
28
+ else
29
+ flash[:error] = "#{Spree.t('store.errors.unable_to_update')}: #{@store.errors.full_messages.join(', ')}"
30
+ render :edit
31
+ end
32
+ end
33
+
34
+ def destroy
35
+ @store = Spree::Store.find(params[:id])
36
+
37
+ if @store.destroy
38
+ flash[:success] = flash_message_for(@store, :successfully_removed)
39
+ respond_with(@store) do |format|
40
+ format.html { redirect_to admin_stores_path }
41
+ format.js { render_js_for_destroy }
42
+ end
43
+ else
44
+ render plain: "#{Spree.t('store.errors.unable_to_delete')}: #{@store.errors.full_messages.join(', ')}", status: :unprocessable_entity
45
+ end
46
+ end
47
+
48
+ def set_default
49
+ store = Spree::Store.find(params[:id])
50
+ stores = Spree::Store.where.not(id: params[:id])
51
+
52
+ ApplicationRecord.transaction do
53
+ store.update(default: true)
54
+ stores.update_all(default: false)
55
+ end
56
+
57
+ if store.errors.empty?
58
+ flash[:success] = Spree.t(:store_set_as_default, store: store.name)
59
+ else
60
+ flash[:error] = "#{Spree.t(:store_not_set_as_default, store: store.name)} #{store.errors.full_messages.join(', ')}"
61
+ end
62
+
63
+ redirect_to admin_stores_path
64
+ end
65
+
66
+ protected
67
+
68
+ def permitted_store_params
69
+ params.require(:store).permit(permitted_store_attributes)
70
+ end
71
+
72
+ private
73
+
74
+ def load_store
75
+ @store = Spree::Store.find_by(id: params[:id]) || Spree::Store.new
76
+ end
77
+ end
78
+ end
79
+ end