spree_backend 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0423c9ed97ff3f9cdaf5320fbad1e2c1edcacf27
4
+ data.tar.gz: 271f3c36169eeefa5ab4463913a0df48c56333fb
5
+ SHA512:
6
+ metadata.gz: 938a189fc6a083123d838d649a4587f633dda9c62e97340d8ebff7b24a10a937deb09434fd1da1a4c4f7fd1e43c9db185732da88473cb7b3f114c2fc46512a42
7
+ data.tar.gz: bb905d0d2053784fbf0ce2ba66ec8d6ede87813121f3540cf2d6eb69c1a0d62d09e70f2f1a4ab14f567fd80cb3a19de3421e7d51fb819819a4732dad0f286a88
@@ -35,6 +35,9 @@ $(document).ready(function() {
35
35
  //handle cancel click
36
36
  $('a.cancel-item').click(toggleItemEdit);
37
37
 
38
+ //handle split click
39
+ $('a.split-item').click(startItemSplit);
40
+
38
41
  //handle save click
39
42
  $('a.save-item').click(function(){
40
43
  var save = $(this);
@@ -46,7 +49,7 @@ $(document).ready(function() {
46
49
  toggleItemEdit();
47
50
 
48
51
  adjustItems(shipment_number, variant_id, quantity);
49
-
52
+ return false;
50
53
  });
51
54
 
52
55
  //handle delete click
@@ -79,7 +82,6 @@ adjustItems = function(shipment_number, variant_id, quantity){
79
82
  }
80
83
  url += '.json';
81
84
 
82
-
83
85
  if(new_quantity!=0){
84
86
  $.ajax({
85
87
  type: "PUT",
@@ -87,8 +89,6 @@ adjustItems = function(shipment_number, variant_id, quantity){
87
89
  data: { variant_id: variant_id, quantity: new_quantity }
88
90
  }).done(function( msg ) {
89
91
  window.location.reload();
90
- }).error(function( msg ) {
91
- console.log(msg);
92
92
  });
93
93
  }
94
94
  }
@@ -109,10 +109,107 @@ toggleItemEdit = function(){
109
109
  var link = $(this);
110
110
  link.parent().find('a.edit-item').toggle();
111
111
  link.parent().find('a.cancel-item').toggle();
112
+ link.parent().find('a.split-item').toggle();
112
113
  link.parent().find('a.save-item').toggle();
113
114
  link.parent().find('a.delete-item').toggle();
114
115
  link.parents('tr').find('td.item-qty-show').toggle();
115
116
  link.parents('tr').find('td.item-qty-edit').toggle();
117
+
118
+ return false;
119
+ }
120
+
121
+ startItemSplit = function(event){
122
+ event.preventDefault();
123
+ var link = $(this);
124
+ link.parent().find('a.edit-item').toggle();
125
+ link.parent().find('a.split-item').toggle();
126
+ link.parent().find('a.delete-item').toggle();
127
+ var variant_id = link.data('variant-id');
128
+
129
+ var variant = {};
130
+ $.ajax({
131
+ type: "GET",
132
+ async: false,
133
+ url: Spree.url("/api/variants.json"),
134
+ data: {
135
+ q: {
136
+ "id_eq": variant_id
137
+ }
138
+ }
139
+ }).success(function( data ) {
140
+ variant = data['variants'][0];
141
+ }).error(function( msg ) {
142
+ console.log(msg);
143
+ });
144
+
145
+ var max_quantity = link.closest('tr').data('item-quantity');
146
+ var split_item_template = Handlebars.compile($('#variant_split_template').text());
147
+ link.closest('tr').after(split_item_template({ variant: variant, shipments: shipments, max_quantity: max_quantity }));
148
+ $('a.cancel-split').click(cancelItemSplit);
149
+ $('a.save-split').click(completeItemSplit);
150
+
151
+ // Add some tips
152
+ $('.with-tip').powerTip({
153
+ smartPlacement: true,
154
+ fadeInTime: 50,
155
+ fadeOutTime: 50,
156
+ intentPollInterval: 300
157
+ });
158
+ $('#item_stock_location').select2({ width: 'resolve', placeholder: 'Choose Location' });
159
+ }
160
+
161
+ completeItemSplit = function(event) {
162
+ event.preventDefault();
163
+ var link = $(this);
164
+ var order_number = link.closest('tbody').data('order-number');
165
+ var stock_item_row = link.closest('tr');
166
+ var variant_id = stock_item_row.data('variant-id');
167
+ var quantity = stock_item_row.find('#item_quantity').val();
168
+
169
+ var stock_location_id = stock_item_row.find('#item_stock_location').val();
170
+ var original_shipment_number = link.closest('tbody').data('shipment-number');
171
+
172
+ var selected_shipment = stock_item_row.find($('#item_stock_location').select2('data').element);
173
+ var target_shipment_number = selected_shipment.data('shipment-number');
174
+ var new_shipment = selected_shipment.data('new-shipment');
175
+
176
+ if (stock_location_id != 'new_shipment') {
177
+ // first remove item(s) from original shipment
178
+ $.ajax({
179
+ type: "PUT",
180
+ async: false,
181
+ url: Spree.url("/api/orders/" + order_number + "/shipments/" + original_shipment_number + "/remove.json"),
182
+ data: { variant_id: variant_id, quantity: quantity }
183
+ }).done(function(msg) {
184
+ window.location.reload();
185
+ });
186
+
187
+ if (new_shipment != undefined) {
188
+ $.ajax({
189
+ type: "POST",
190
+ async: false,
191
+ url: Spree.url("/api/orders/" + order_number + "/shipments.json"),
192
+ data: { variant_id: variant_id, quantity: quantity, stock_location_id: stock_location_id }
193
+ });
194
+ } else {
195
+ $.ajax({
196
+ type: "PUT",
197
+ async: false,
198
+ url: Spree.url("/api/orders/" + order_number + "/shipments/" + target_shipment_number + "/add.json"),
199
+ data: { variant_id: variant_id, quantity: quantity }
200
+ });
201
+ }
202
+ }
203
+ }
204
+
205
+ cancelItemSplit = function(event) {
206
+ event.preventDefault();
207
+ var link = $(this);
208
+ var prev_row = link.closest('tr').prev();
209
+ link.closest('tr').remove();
210
+ prev_row.find('a.edit-item').toggle();
211
+ prev_row.find('a.split-item').toggle();
212
+ prev_row.find('a.delete-item').toggle();
116
213
  }
117
214
 
118
215
  addVariantFromStockLocation = function() {
@@ -18,8 +18,7 @@ module Spree
18
18
  options[:route] ||= "admin_#{args.first}"
19
19
 
20
20
  destination_url = options[:url] || spree.send("#{options[:route]}_path")
21
-
22
- titleized_label = Spree.t(options[:label], :default => options[:label]).titleize
21
+ titleized_label = Spree.t(options[:label], :default => options[:label], :scope => [:admin, :tab]).titleize
23
22
 
24
23
  css_classes = []
25
24
 
@@ -37,7 +37,7 @@
37
37
  var shipments = [];
38
38
 
39
39
  <% @order.shipments.each do |shipment| %>
40
- shipments.push(<%== shipment.to_json(:root => false, :include => :inventory_units) %>);
40
+ shipments.push(<%== shipment.to_json(:root => false, :include => [:inventory_units, :stock_location]) %>);
41
41
  <% end %>
42
42
 
43
43
  <%= render :partial => 'spree/admin/shared/update_order_state', :handlers => [:js] %>
@@ -1,3 +1,4 @@
1
+ <%= render :partial => "spree/admin/variants/split", :formats => :js %>
1
2
  <fieldset class="no-border-bottom">
2
3
  <legend align="center" class="stock-location" data-hook="stock-location">
3
4
  <span class="shipment-number"><%= shipment.number %></span>
@@ -30,11 +31,11 @@
30
31
  <th class="orders-actions actions" data-hook="admin_order_form_line_items_header_actions"></th>
31
32
  </thead>
32
33
 
33
- <tbody>
34
+ <tbody data-shipment-number="<%= shipment.number %>" data-order-number="<%= order.number %>">
34
35
  <% shipment.manifest.each do |item| %>
35
36
  <% line_item = order.find_line_item_by_variant(item.variant) %>
36
37
 
37
- <tr class="stock-item">
38
+ <tr class="stock-item" data-item-quantity="<%= item.quantity %>">
38
39
  <td class="item-image"><%= mini_image(item.variant) %></td>
39
40
  <td class="item-name">
40
41
  <%= item.variant.product.name %><br><%= "(" + variant_options(item.variant) + ")" unless item.variant.option_values.empty? %>
@@ -57,7 +58,8 @@
57
58
  <%= link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' %>
58
59
  <%= link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' %>
59
60
  <%= link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %>
60
- <%= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => Spree.t(:delete) %>
61
+ <%= link_to '', '#', :class => 'split-item icon_link icon-resize-horizontal no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') %>
62
+ <%= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => Spree.t('delete') %>
61
63
  <% end %>
62
64
  </td>
63
65
  <% end %>
@@ -98,7 +100,7 @@
98
100
  <tr class="show-method total">
99
101
  <td colspan="4">
100
102
  <% if shipment.adjustment.present? %>
101
- <strong><%= shipment.adjustment.label %>:</strong>
103
+ <strong><%= shipment.adjustment.label %>: <%= shipment.shipping_method.name %></strong>
102
104
  <% else %>
103
105
  <%= Spree.t(:cannot_set_shipping_method_without_address) %>
104
106
  <% end %>
@@ -0,0 +1,29 @@
1
+ <script type='text/template' id='variant_split_template'>
2
+ <tr class='stock-item-split' data-variant-id='{{variant.id}}'>
3
+ <td colspan='2'>
4
+ Move {{variant.name}} to:
5
+ </td>
6
+ <td colspan='2'>
7
+ <select name="item_stock_location" id='item_stock_location' style='width:100%;'>
8
+ <option></option>
9
+ <optgroup label="Existing Shipments">
10
+ {{#each shipments}}
11
+ <option data-shipment-number='{{this.number}}' value='{{this.stock_location_id}}'>{{this.stock_location.name}}({{this.number}})</option>
12
+ {{/each}}
13
+ </optgroup>
14
+ <optgroup label="New Shipment At Location">
15
+ {{#each variant.stock_items}}
16
+ <option data-new-shipment='true' value='{{this.stock_location_id}}'>{{this.stock_location_name}}</option>
17
+ {{/each}}
18
+ </optgroup>
19
+ </select>
20
+ </td>
21
+ <td>
22
+ <input class="quantity" id="item_quantity" type="number" min="1" value="1" max="{{max_quantity}}">
23
+ </td>
24
+ <td class='actions'>
25
+ <a href='#' class='save-split icon_link icon-ok no-text with-tip' title='Save'></a>
26
+ <a href='#' class='cancel-split icon_link icon-cancel no-text with-tip' title='Cancel'></a>
27
+ </td>
28
+ </tr>
29
+ </script>
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
5
- prerelease:
4
+ version: 2.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sean Schofield
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-04 00:00:00.000000000 Z
11
+ date: 2013-06-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: spree_core
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '='
20
18
  - !ruby/object:Gem::Version
21
- version: 2.0.1
19
+ version: 2.0.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '='
28
25
  - !ruby/object:Gem::Version
29
- version: 2.0.1
26
+ version: 2.0.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: spree_api
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - '='
36
32
  - !ruby/object:Gem::Version
37
- version: 2.0.1
33
+ version: 2.0.2
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - '='
44
39
  - !ruby/object:Gem::Version
45
- version: 2.0.1
40
+ version: 2.0.2
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: jquery-rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: select2-rails
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - '='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - '='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rails
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,23 +83,20 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: deface
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: 0.9.0
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: 0.9.0
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: email_spec
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -430,6 +415,7 @@ files:
430
415
  - app/views/spree/admin/trackers/new.html.erb
431
416
  - app/views/spree/admin/variants/_autocomplete.js.erb
432
417
  - app/views/spree/admin/variants/_form.html.erb
418
+ - app/views/spree/admin/variants/_split.js.erb
433
419
  - app/views/spree/admin/variants/edit.html.erb
434
420
  - app/views/spree/admin/variants/index.html.erb
435
421
  - app/views/spree/admin/variants/new.html.erb
@@ -499,30 +485,26 @@ files:
499
485
  - vendor/assets/stylesheets/responsive-tables.css
500
486
  homepage: http://spreecommerce.com
501
487
  licenses: []
488
+ metadata: {}
502
489
  post_install_message:
503
490
  rdoc_options: []
504
491
  require_paths:
505
492
  - lib
506
493
  required_ruby_version: !ruby/object:Gem::Requirement
507
- none: false
508
494
  requirements:
509
- - - ! '>='
495
+ - - '>='
510
496
  - !ruby/object:Gem::Version
511
497
  version: 1.9.3
512
498
  required_rubygems_version: !ruby/object:Gem::Requirement
513
- none: false
514
499
  requirements:
515
- - - ! '>='
500
+ - - '>='
516
501
  - !ruby/object:Gem::Version
517
502
  version: '0'
518
- segments:
519
- - 0
520
- hash: 89217670578797386
521
503
  requirements:
522
504
  - none
523
505
  rubyforge_project: spree_backend
524
- rubygems_version: 1.8.25
506
+ rubygems_version: 2.0.0
525
507
  signing_key:
526
- specification_version: 3
508
+ specification_version: 4
527
509
  summary: backend e-commerce functionality for the Spree project.
528
510
  test_files: []