solidus_product_assembly 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +35 -0
  3. data/.gem_release.yml +5 -0
  4. data/.github/dependabot.yml +7 -0
  5. data/.github/stale.yml +17 -0
  6. data/.gitignore +14 -2
  7. data/.rspec +2 -2
  8. data/.rubocop.yml +4 -0
  9. data/.rubocop_todo.yml +192 -0
  10. data/CHANGELOG.md +19 -0
  11. data/Gemfile +21 -9
  12. data/LICENSE +26 -0
  13. data/README.md +52 -18
  14. data/Rakefile +4 -19
  15. data/app/controllers/spree/admin/parts_controller.rb +13 -11
  16. data/app/decorators/controllers/solidus_product_assembly/spree/checkout_controller_decorator.rb +13 -0
  17. data/app/decorators/helpers/solidus_product_assembly/spree/admin/orders_helper_decorator.rb +19 -0
  18. data/app/decorators/models/solidus_product_assembly/spree/inventory_unit_decorator.rb +19 -0
  19. data/app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb +52 -0
  20. data/app/decorators/models/solidus_product_assembly/spree/product_decorator.rb +70 -0
  21. data/app/decorators/models/solidus_product_assembly/spree/return_item_decorator.rb +15 -0
  22. data/app/decorators/models/solidus_product_assembly/spree/shipment_decorator.rb +55 -0
  23. data/app/decorators/models/solidus_product_assembly/spree/stock/availability_validator_decorator.rb +37 -0
  24. data/app/decorators/models/solidus_product_assembly/spree/stock/inventory_unit_builder_decorator.rb +39 -0
  25. data/app/decorators/models/solidus_product_assembly/spree/stock/inventory_units_finalizer_decorator.rb +33 -0
  26. data/app/decorators/models/solidus_product_assembly/spree/stock/inventory_validator_decorator.rb +22 -0
  27. data/app/decorators/models/solidus_product_assembly/spree/variant_decorator.rb +26 -0
  28. data/app/models/spree/assemblies_part.rb +6 -4
  29. data/app/models/spree/calculator/returns/assemblies_default_refund_amount.rb +17 -0
  30. data/app/models/spree/order_inventory_assembly.rb +11 -2
  31. data/app/overrides/add_admin_product_form_fields.rb +7 -5
  32. data/app/overrides/add_admin_tabs.rb +7 -5
  33. data/app/overrides/add_line_item_description.rb +7 -5
  34. data/app/overrides/spree/admin/orders/_carton_manifest/_assembly_parts_price.html.erb.deface +9 -0
  35. data/app/overrides/spree/admin/orders/_carton_manifest/_assembly_parts_total_price.html.erb.deface +9 -0
  36. data/app/overrides/spree/admin/orders/_shipment/stock_contents.html.erb.deface +7 -1
  37. data/app/overrides/spree/products/show/add_links_to_parts.html.erb.deface +2 -2
  38. data/app/views/spree/admin/orders/_assemblies.html.erb +8 -17
  39. data/app/views/spree/admin/orders/_stock_contents.html.erb +2 -62
  40. data/app/views/spree/admin/orders/_stock_contents_2_3.html.erb +69 -0
  41. data/app/views/spree/admin/orders/_stock_contents_2_4.html.erb +70 -0
  42. data/app/views/spree/admin/orders/_stock_item.html.erb +13 -10
  43. data/app/views/spree/admin/parts/_parts_table.html.erb +17 -11
  44. data/app/views/spree/admin/parts/available.html.erb +10 -8
  45. data/app/views/spree/admin/parts/available.js.erb +9 -7
  46. data/app/views/spree/admin/parts/index.html.erb +1 -1
  47. data/app/views/spree/admin/products/_product_assembly_fields.html.erb +2 -2
  48. data/app/views/spree/admin/shared/_product_assembly_product_tabs.html.erb +1 -1
  49. data/app/views/spree/api/line_items/show.v1.rabl +27 -0
  50. data/app/views/spree/checkout/_line_item_manifest.html.erb +3 -1
  51. data/bin/console +17 -0
  52. data/bin/rails +12 -4
  53. data/bin/setup +8 -0
  54. data/config/routes.rb +2 -2
  55. data/db/migrate/20091028152124_add_many_to_many_relation_to_products.rb +7 -5
  56. data/db/migrate/20091029165620_add_parts_fields_to_products.rb +18 -16
  57. data/db/migrate/20120316141830_namespace_product_assembly_for_spree_one.rb +3 -1
  58. data/db/migrate/20140620223938_add_id_to_spree_assemblies_parts.rb +4 -2
  59. data/lib/generators/solidus_product_assembly/install/install_generator.rb +13 -8
  60. data/lib/solidus_product_assembly/engine.rb +11 -8
  61. data/lib/solidus_product_assembly/testing_support/factories.rb +4 -0
  62. data/lib/solidus_product_assembly/version.rb +3 -1
  63. data/lib/solidus_product_assembly.rb +5 -1
  64. data/lib/tasks/spree2_upgrade.rake +12 -12
  65. data/solidus_product_assembly.gemspec +25 -20
  66. data/spec/features/admin/orders_spec.rb +114 -16
  67. data/spec/features/admin/parts_spec.rb +5 -3
  68. data/spec/features/admin/return_items_spec.rb +151 -0
  69. data/spec/features/checkout_spec.rb +103 -21
  70. data/spec/models/spree/assemblies_part_spec.rb +3 -1
  71. data/spec/models/spree/inventory_unit_spec.rb +15 -6
  72. data/spec/models/spree/line_item_spec.rb +6 -4
  73. data/spec/models/spree/order_contents_spec.rb +6 -5
  74. data/spec/models/spree/order_inventory_assembly_spec.rb +8 -6
  75. data/spec/models/spree/order_inventory_spec.rb +7 -3
  76. data/spec/models/spree/product_spec.rb +15 -14
  77. data/spec/models/spree/shipment_spec.rb +20 -13
  78. data/spec/models/spree/stock/availability_validator_spec.rb +22 -33
  79. data/spec/models/spree/stock/coordinator_spec.rb +11 -3
  80. data/spec/models/spree/stock/inventory_unit_builder_spec.rb +5 -7
  81. data/spec/models/spree/variant_spec.rb +3 -1
  82. data/spec/spec_helper.rb +18 -47
  83. data/spec/support/shared_contexts/order_with_bundle.rb +2 -0
  84. metadata +80 -102
  85. data/.travis.yml +0 -21
  86. data/LICENSE.md +0 -13
  87. data/app/controllers/spree/checkout_controller_decorator.rb +0 -9
  88. data/app/helpers/spree/admin/orders_helper_decorator.rb +0 -9
  89. data/app/models/spree/inventory_unit_decorator.rb +0 -13
  90. data/app/models/spree/line_item_decorator.rb +0 -44
  91. data/app/models/spree/product_decorator.rb +0 -56
  92. data/app/models/spree/shipment_decorator.rb +0 -50
  93. data/app/models/spree/stock/availability_validator.rb +0 -28
  94. data/app/models/spree/stock/inventory_unit_builder_decorator.rb +0 -30
  95. data/app/models/spree/stock/inventory_validator_decorator.rb +0 -12
  96. data/app/models/spree/variant_decorator.rb +0 -13
@@ -0,0 +1,69 @@
1
+ <%= render 'stock_item', shipment: shipment %>
2
+
3
+ <% unless shipment.shipped? %>
4
+ <tr class="edit-method hidden total">
5
+ <td colspan="5">
6
+ <div class="field alpha five columns">
7
+ <%= label_tag 'selected_shipping_rate_id', t('spree.shipping_method') %>
8
+ <%= select_tag :selected_shipping_rate_id,
9
+ options_for_select(shipment.shipping_rates.map {|sr| ["#{sr.name} #{sr.display_price}", sr.id] }, shipment.selected_shipping_rate_id),
10
+ {:class => 'select2 fullwidth', :data => {'shipment-number' => shipment.number } } %>
11
+ </div>
12
+ </td>
13
+ <td class="actions">
14
+ <% if can? :update, shipment %>
15
+ <%= link_to '', '#', :class => 'save-method fa fa-ok no-text with-tip',
16
+ :data => {'shipment-number' => shipment.number, :action => 'save'}, title: t('spree.actions.save') %>
17
+ <%= link_to '', '#', :class => 'cancel-method fa fa-cancel no-text with-tip',
18
+ :data => {:action => 'cancel'}, :title => t('spree.actions.cancel') %>
19
+ <% end %>
20
+ </td>
21
+ </tr>
22
+ <% end %>
23
+
24
+ <tr class="show-method total">
25
+ <% if shipment.shipping_method %>
26
+ <td colspan="4">
27
+ <strong><%= shipment.shipping_method.name %></strong>
28
+ </td>
29
+ <td class="total" align="center">
30
+ <span><%= shipment.display_cost %></span>
31
+ </td>
32
+ <% else %>
33
+ <td colspan='5'><%= t('spree.no_shipping_method_selected') %></td>
34
+ <% end %>
35
+
36
+ <td class="actions">
37
+ <% if can? :update, shipment %>
38
+ <%= link_to '', '#', :class => 'edit-method fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => t('spree.actions.edit') %>
39
+ <% end %>
40
+ </td>
41
+ </tr>
42
+
43
+ <tr class="edit-tracking hidden total">
44
+ <td colspan="5">
45
+ <label><%= t('spree.tracking_number') %>:</label>
46
+ <%= text_field_tag :tracking, shipment.tracking %>
47
+ </td>
48
+ <td class="actions">
49
+ <% if can? :update, shipment %>
50
+ <%= link_to '', '#', :class => 'save-tracking fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, :action => 'save'}, :title => t('spree.actions.save') %>
51
+ <%= link_to '', '#', :class => 'cancel-tracking fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => t('spree.actions.cancel') %>
52
+ <% end %>
53
+ </td>
54
+ </tr>
55
+
56
+ <tr class="show-tracking total">
57
+ <td colspan="5" class="tracking-value">
58
+ <% if shipment.tracking.present? %>
59
+ <%= shipment.tracking %>
60
+ <% else %>
61
+ <%= t('spree.no_tracking_present') %>
62
+ <% end %>
63
+ </td>
64
+ <td class="actions">
65
+ <% if can? :update, shipment %>
66
+ <%= link_to '', '#', :class => 'edit-tracking fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => t('spree.actions.edit') %>
67
+ <% end %>
68
+ </td>
69
+ </tr>
@@ -0,0 +1,70 @@
1
+ <%= render 'stock_item', shipment: shipment %>
2
+
3
+ <% unless shipment.shipped? %>
4
+ <tr class="edit-method hidden total">
5
+ <td colspan="5">
6
+ <div class="field alpha five columns">
7
+ <%= label_tag 'selected_shipping_rate_id', t('spree.shipping_method') %>
8
+ <%= select_tag :selected_shipping_rate_id,
9
+ options_for_select(shipment.shipping_rates.map {|sr| ["#{sr.name} #{sr.display_price}", sr.id] }, shipment.selected_shipping_rate_id),
10
+ {:class => 'select2 fullwidth', :data => {'shipment-number' => shipment.number } } %>
11
+ </div>
12
+ </td>
13
+ <td class="actions">
14
+ <% if can? :update, shipment %>
15
+ <%= button_tag '', :class => 'save-method fa fa-ok no-text with-tip',
16
+ :data => {'shipment-number' => shipment.number, :action => 'save'}, title: t('spree.actions.save') %>
17
+ <%= button_tag '', :class => 'cancel-method fa fa-cancel no-text with-tip',
18
+ :data => {:action => 'cancel'}, :title => t('spree.actions.cancel') %>
19
+ <% end %>
20
+ </td>
21
+ </tr>
22
+ <% end %>
23
+
24
+ <tr class="show-method total">
25
+ <% if shipment.shipping_method %>
26
+ <td colspan="4">
27
+ <strong><%= shipment.shipping_method.name %></strong>
28
+ </td>
29
+ <td class="total" align="center">
30
+ <span><%= shipment.display_cost %></span>
31
+ </td>
32
+ <% else %>
33
+ <td colspan='5'><%= t('spree.no_shipping_method_selected') %></td>
34
+ <% end %>
35
+
36
+ <td class="actions">
37
+ <% if can? :update, shipment %>
38
+ <%= button_tag '', :class => 'edit-method fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => t('spree.actions.edit') %>
39
+ <% end %>
40
+ </td>
41
+ </tr>
42
+
43
+ <tr class="edit-tracking hidden total">
44
+ <td colspan="5">
45
+ <label><%= t('spree.tracking_number') %>:</label>
46
+ <%= text_field_tag :tracking, shipment.tracking %>
47
+ </td>
48
+ <td class="actions">
49
+ <% if can? :update, shipment %>
50
+ <%= button_tag '', :class => 'save-tracking fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, :action => 'save'}, :title => t('spree.actions.save') %>
51
+ <%= button_tag '', :class => 'cancel-tracking fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => t('spree.actions.cancel') %>
52
+ <% end %>
53
+ </td>
54
+ </tr>
55
+
56
+ <tr class="show-tracking total">
57
+ <th><%= Spree::Shipment.human_attribute_name(:tracking) %></th>
58
+ <td colspan="4" class="tracking-value">
59
+ <% if shipment.tracking.present? %>
60
+ <%= shipment.tracking %>
61
+ <% else %>
62
+ <i><%= t('spree.no_tracking_present') %></i>
63
+ <% end %>
64
+ </td>
65
+ <td class="actions">
66
+ <% if can? :update, shipment %>
67
+ <%= button_tag '', class: 'edit-tracking fa fa-edit no-text with-tip', data: {action: 'edit'}, title: t('spree.actions.edit'), type: :button %>
68
+ <% end %>
69
+ </td>
70
+ </tr>
@@ -1,10 +1,14 @@
1
1
  <% shipment.manifest.each do |item| %>
2
- <tr class="stock-item" data-item-quantity="<%= item.quantity %>">
3
- <td class="item-image"><%= mini_image(item.variant) %></td>
2
+ <tr class="stock-item" data-item-quantity="<%= item.quantity %>" data-variant-id="<%= item.variant.id %>">
3
+ <td class="item-image"><%= render 'spree/shared/image',
4
+ image: (item.variant.gallery.images.first || item.variant.product.gallery.images.first),
5
+ size: :mini %></td>
4
6
  <td class="item-name">
5
- <%= item.variant.product.name %><br><%= "(" + variant_options(item.variant) + ")" unless item.variant.option_values.empty? %>
7
+ <%= link_to item.variant.product.name, edit_admin_product_path(item.variant.product) %><br><%= "(" + variant_options(item.variant) + ")" unless item.variant.option_values.empty? %>
6
8
  <% if item.part && item.line_item %>
7
- <i><%= Spree.t(:part_of_bundle, sku: item.product.sku) %></i>
9
+ <i><%= t('spree.part_of_bundle', sku: item.product.sku) %></i>
10
+ <% elsif item.variant.sku.present? %>
11
+ <strong><%= Spree::Variant.human_attribute_name(:sku) %>:</strong> <%= item.variant.sku %>
8
12
  <% end %>
9
13
  </td>
10
14
  <td class="item-price align-center">
@@ -32,13 +36,12 @@
32
36
  <% end %>
33
37
  </td>
34
38
  <td class="cart-item-delete actions" data-hook="cart_item_delete">
35
- <% if !shipment.shipped? && !item.part %>
39
+ <% if !shipment.shipped? %>
36
40
  <% if can? :update, item %>
37
- <%= link_to '', '#', :class => 'save-item fa fa-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' %>
38
- <%= link_to '', '#', :class => 'cancel-item fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' %>
39
- <%= link_to '', '#', :class => 'edit-item fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %>
40
- <%= link_to '', '#', :class => 'split-item fa fa-arrows-h no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') %>
41
- <%= link_to '', '#', :class => 'delete-item fa fa-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => Spree.t('actions.delete') %>
41
+ <%= button_tag '', :class => 'save-item fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => t('spree.actions.save'), :style => 'display: none' %>
42
+ <%= link_to '', :class => 'cancel-item fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => t('spree.actions.cancel'), :style => 'display: none' %>
43
+ <%= button_tag '', :class => 'split-item fa fa-arrows-h no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => t('spree.actions.split') %>
44
+ <%= button_tag '', :class => 'delete-item fa fa-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => t('spree.actions.delete') %>
42
45
  <% end %>
43
46
  <% end %>
44
47
  </td>
@@ -1,10 +1,11 @@
1
1
  <table class="index">
2
2
  <thead>
3
3
  <tr>
4
- <th><%= Spree.t(:sku) %></th>
5
- <th><%= Spree.t(:name) %></th>
6
- <th><%= Spree.t(:options) %></th>
7
- <th><%= Spree.t(:qty) %></th>
4
+ <th><%= t('spree.sku') %></th>
5
+ <th><%= t('spree.name') %></th>
6
+ <th><%= t('spree.available_on') %></th>
7
+ <th><%= t('spree.options') %></th>
8
+ <th><%= t('spree.qty') %></th>
8
9
  </tr>
9
10
  </thead>
10
11
  <tbody>
@@ -12,21 +13,26 @@
12
13
  <tr id="<%= dom_id(part, :sel)%>">
13
14
  <td><%= part.sku %></td>
14
15
  <td><%= part.product.name %></td>
16
+ <td><%= part.product.available_on %></td>
15
17
  <td><%= variant_options part %></td>
16
18
  <td><%= text_field_tag :count, @product.count_of(part) %></td>
17
19
  <td class="actions">
18
- <%= link_to(icon('edit'),
19
- set_count_admin_product_part_url(@product, part),
20
- :class => "set_count_admin_product_part_link save-line-item fa fa-ok no-text") %>
20
+ <%= link_to_with_icon(
21
+ 'edit',
22
+ t('spree.actions.edit'),
23
+ set_count_admin_product_part_url(@product, part),
24
+ :class => "set_count_admin_product_part_link save-line-item") %>
21
25
 
22
- <%= link_to(icon('delete'),
23
- remove_admin_product_part_url(@product, part),
24
- :class => "remove_admin_product_part_link delete-line-item fa fa-trash no-text") %>
26
+ <%= link_to_with_icon(
27
+ 'delete',
28
+ t('spree.actions.delete'),
29
+ remove_admin_product_part_url(@product, part),
30
+ class: "remove_admin_product_part_link delete-line-item") %>
25
31
  </td>
26
32
  </tr>
27
33
  <% end %>
28
34
  <% if parts.empty? %>
29
- <tr><td colspan="5"><%= Spree.t(:none) %>.</td></tr>
35
+ <tr><td colspan="5"><%= t('spree.none') %>.</td></tr>
30
36
  <% end %>
31
37
  </tbody>
32
38
  </table>
@@ -6,13 +6,14 @@
6
6
  }
7
7
  </script>
8
8
 
9
- <h4><%= Spree.t(:available_parts) %></h4>
9
+ <h4><%= t('spree.available_parts') %></h4>
10
10
  <table class="index">
11
11
  <thead>
12
12
  <tr>
13
- <th><%= Spree.t(:name) %></th>
14
- <th><%= Spree.t(:options) %></th>
15
- <th><%= Spree.t(:qty) %></th>
13
+ <th><%= t('spree.name') %></th>
14
+ <th><%= t('spree.available_on') %></th>
15
+ <th><%= t('spree.options') %></th>
16
+ <th><%= t('spree.qty') %></th>
16
17
  <th></th>
17
18
  </tr>
18
19
  </thead>
@@ -21,25 +22,26 @@
21
22
  <tr id="<%= dom_id(product) %>">
22
23
 
23
24
  <td><%= product.name %></td>
25
+ <td><%= product.available_on %></td>
24
26
  <td>
25
27
  <% if product.has_variants? %>
26
28
  <%= select_tag "part[id]",
27
29
  options_for_select(product.variants.map { |v| [variant_options(v), v.id] }) %>
28
30
  <% else %>
29
31
  <%= hidden_field_tag "part[id]", product.master.id %>
30
- <%= Spree.t(:no_variants) %>
32
+ <%= t(:no_variants) %>
31
33
  <% end %>
32
34
  </td>
33
35
  <td><%= text_field_tag "part[count]", 1 %></td>
34
36
  <td class="actions">
35
- <%= link_to(icon('add') + ' ' + Spree.t(:select),
37
+ <%= link_to(t('spree.select'),
36
38
  admin_product_parts_path(@product),
37
- :class => "add_product_part_link") %>
39
+ :class => "add_product_part_link btn btn-primary") %>
38
40
  </td>
39
41
  </tr>
40
42
  <% end %>
41
43
  <% if @available_products.empty? %>
42
- <tr><td colspan="3"><%= Spree.t(:no_match_found) %>.</td></tr>
44
+ <tr><td colspan="3"><%= t('spree.no_match_found') %>.</td></tr>
43
45
  <% end %>
44
46
  </tbody>
45
47
  </table>
@@ -5,13 +5,14 @@
5
5
  else row.style.display = '';
6
6
  }
7
7
  </script>
8
- <h4><%= Spree.t(:available_parts) %></h4>
8
+ <h4><%= t('spree.available_parts') %></h4>
9
9
  <table class="index">
10
10
  <thead>
11
11
  <tr>
12
- <th><%= Spree.t(:name) %></th>
13
- <th><%= Spree.t(:options) %></th>
14
- <th><%= Spree.t(:qty) %></th>
12
+ <th><%= t('spree.name') %></th>
13
+ <th><%= t('spree.available_on') %></th>
14
+ <th><%= t('spree.options') %></th>
15
+ <th><%= t('spree.qty') %></th>
15
16
  <th></th>
16
17
  </tr>
17
18
  </thead>
@@ -20,25 +21,26 @@
20
21
  <tr id="<%= dom_id(product) %>">
21
22
 
22
23
  <td><%= product.name %></td>
24
+ <td><%= product.available_on %></td>
23
25
  <td>
24
26
  <% if product.has_variants? %>
25
27
  <%= select_tag "part[id]",
26
28
  options_for_select(product.variants.map { |v| [variant_options(v), v.id] }) %>
27
29
  <% else %>
28
30
  <%= hidden_field_tag "part[id]", product.master.id %>
29
- <%= Spree.t(:no_variants) %>
31
+ <%= t('spree.no_variants') %>
30
32
  <% end %>
31
33
  </td>
32
34
  <td><%= text_field_tag "part[count]", 1 %></td>
33
35
  <td class="actions">
34
- <%= link_to(icon('add') + ' ' + Spree.t(:select),
36
+ <%= link_to(icon('add') + ' ' + t('spree.select'),
35
37
  admin_product_parts_path(@product),
36
38
  :class => "add_product_part_link") %>
37
39
  </td>
38
40
  </tr>
39
41
  <% end %>
40
42
  <% if @available_products.empty? %>
41
- <tr><td colspan="3"><%= Spree.t(:no_match_found) %>.</td></tr>
43
+ <tr><td colspan="3"><%= t('spree.no_match_found') %>.</td></tr>
42
44
  <% end %>
43
45
  </tbody>
44
46
  </table>
@@ -7,7 +7,7 @@
7
7
  </div>
8
8
 
9
9
  <%= form_tag('#') do %>
10
- <label><%= Spree.t(:search) %>:</label>
10
+ <label><%= t('spree.search') %>:</label>
11
11
  <input id="searchtext" size="25">
12
12
  <button id="search_parts_button" class="fa fa-search button" name="button">Search</button>
13
13
  <% end %>
@@ -1,12 +1,12 @@
1
1
  <div class="left six columns alpha">
2
2
  <div class="field">
3
- <%= f.label :can_be_part, Spree.t(:can_be_part)%>
3
+ <%= f.label :can_be_part, t('spree.can_be_part')%>
4
4
  <%= f.check_box(:can_be_part) %>
5
5
  </div>
6
6
  </div>
7
7
  <div class="right six columns omega">
8
8
  <div class="field">
9
- <%= f.label :individual_sale, Spree.t(:individual_sale)%>
9
+ <%= f.label :individual_sale, t('spree.individual_sale')%>
10
10
  <%= f.check_box(:individual_sale) %>
11
11
  </div>
12
12
  </div>
@@ -1,3 +1,3 @@
1
1
  <li<%= ' class="active"' if current == "Parts" %>>
2
- <%= link_to_with_icon 'sitemap', Spree.t(:parts), admin_product_parts_url(@product) %>
2
+ <%= link_to_with_icon 'sitemap', t('spree.parts'), admin_product_parts_url(@product) %>
3
3
  </li>
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @line_item
4
+ cache [I18n.locale, root_object]
5
+ attributes *line_item_attributes
6
+ node(:single_display_amount) { |li| li.single_display_amount.to_s }
7
+ node(:display_amount) { |li| li.display_amount.to_s }
8
+ node(:total, &:total)
9
+ glue variant: :parts do
10
+ glue :product do
11
+ child parts: :parts do
12
+ extends "spree/api/variants/small"
13
+ attributes :product_id
14
+
15
+ child(images: :images) { extends "spree/api/images/show" }
16
+ end
17
+ end
18
+ end
19
+ child :variant do
20
+ extends "spree/api/variants/small"
21
+ attributes :product_id
22
+ child(images: :images) { extends "spree/api/images/show" }
23
+ end
24
+
25
+ child adjustments: :adjustments do
26
+ extends "spree/api/adjustments/show"
27
+ end
@@ -1,6 +1,8 @@
1
1
  <% ship_form.object.line_item_manifest.each do |item| %>
2
2
  <tr class="stock-item">
3
- <td class="item-image"><%= mini_image(item.variant) %></td>
3
+ <td class="item-image"><%= render 'spree/shared/image',
4
+ image: (item.variant.gallery.images.first || item.variant.product.gallery.images.first),
5
+ size: :mini %></td>
4
6
  <td class="item-name">
5
7
  <%= item.variant.name %>
6
8
  <%= render 'spree/orders/cart_description', variant: item.variant, line_item: item.line_item %>
data/bin/console ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require "bundler/setup"
6
+ require "solidus_product_assembly"
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+ $LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
11
+
12
+ # (If you use this, don't forget to add pry to your Gemfile!)
13
+ # require "pry"
14
+ # Pry.start
15
+
16
+ require "irb"
17
+ IRB.start(__FILE__)
data/bin/rails CHANGED
@@ -1,7 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
- ENGINE_PATH = File.expand_path('../../lib/solidus_product_assembly/engine', __FILE__)
3
+ # frozen_string_literal: true
5
4
 
6
- require 'rails/all'
7
- require 'rails/engine/commands'
5
+ app_root = 'spec/dummy'
6
+
7
+ unless File.exist? "#{app_root}/bin/rails"
8
+ system "bin/rake", app_root or begin # rubocop:disable Style/AndOr
9
+ warn "Automatic creation of the dummy app failed"
10
+ exit 1
11
+ end
12
+ end
13
+
14
+ Dir.chdir app_root
15
+ exec 'bin/rails', *ARGV
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ gem install bundler --conservative
7
+ bundle update
8
+ bundle exec rake clobber
data/config/routes.rb CHANGED
@@ -1,5 +1,6 @@
1
- Spree::Core::Engine.add_routes do
1
+ # frozen_string_literal: true
2
2
 
3
+ Spree::Core::Engine.routes.draw do
3
4
  namespace :admin do
4
5
  resources :products do
5
6
  resources :parts do
@@ -15,5 +16,4 @@ Spree::Core::Engine.add_routes do
15
16
  end
16
17
  end
17
18
  end
18
-
19
19
  end
@@ -1,9 +1,11 @@
1
- class AddManyToManyRelationToProducts < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddManyToManyRelationToProducts < SolidusSupport::Migration[4.2]
2
4
  def self.up
3
- create_table :assemblies_parts, :id => false do |t|
4
- t.integer "assembly_id", :null => false
5
- t.integer "part_id", :null => false
6
- t.integer "count", :null => false, :default => 1
5
+ create_table :assemblies_parts, id: false do |t|
6
+ t.integer "assembly_id", null: false
7
+ t.integer "part_id", null: false
8
+ t.integer "count", null: false, default: 1
7
9
  end
8
10
  end
9
11
 
@@ -1,24 +1,26 @@
1
- class AddPartsFieldsToProducts < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddPartsFieldsToProducts < SolidusSupport::Migration[4.2]
2
4
  def self.up
3
- table = if table_exists?(:products)
4
- 'products'
5
- elsif table_exists?(:spree_products)
6
- 'spree_products'
7
- end
8
-
5
+ table = if data_source_exists?(:products)
6
+ 'products'
7
+ elsif data_source_exists?(:spree_products)
8
+ 'spree_products'
9
+ end
10
+
9
11
  change_table(table) do |t|
10
- t.column :can_be_part, :boolean, :default => false, :null => false
11
- t.column :individual_sale, :boolean, :default => true, :null => false
12
- end
12
+ t.column :can_be_part, :boolean, default: false, null: false
13
+ t.column :individual_sale, :boolean, default: true, null: false
14
+ end
13
15
  end
14
16
 
15
17
  def self.down
16
- table = if table_exists?(:products)
17
- 'products'
18
- elsif table_exists?(:spree_products)
19
- 'spree_products'
20
- end
21
-
18
+ table = if data_source_exists?(:products)
19
+ 'products'
20
+ elsif data_source_exists?(:spree_products)
21
+ 'spree_products'
22
+ end
23
+
22
24
  change_table(table) do |t|
23
25
  t.remove :can_be_part
24
26
  t.remove :individual_sale
@@ -1,4 +1,6 @@
1
- class NamespaceProductAssemblyForSpreeOne < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class NamespaceProductAssemblyForSpreeOne < SolidusSupport::Migration[4.2]
2
4
  def up
3
5
  rename_table :assemblies_parts, :spree_assemblies_parts
4
6
  end
@@ -1,9 +1,11 @@
1
- class AddIdToSpreeAssembliesParts < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddIdToSpreeAssembliesParts < SolidusSupport::Migration[4.2]
2
4
  def up
3
5
  add_column :spree_assemblies_parts, :id, :primary_key
4
6
  end
5
7
 
6
8
  def down
7
- add_column :spree_assemblies_parts, :id
9
+ remove_column :spree_assemblies_parts, :id
8
10
  end
9
11
  end
@@ -1,23 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusProductAssembly
2
4
  module Generators
3
5
  class InstallGenerator < Rails::Generators::Base
4
- class_option :auto_run_migrations, :type => :boolean, :default => false
6
+ class_option :auto_run_migrations, type: :boolean, default: false
5
7
 
6
8
  def add_migrations
7
- run 'rake railties:install:migrations FROM=solidus_product_assembly'
9
+ run 'bundle exec rake railties:install:migrations FROM=solidus_product_assembly'
8
10
  end
9
11
 
10
12
  def add_javascripts
11
- append_file "vendor/assets/javascripts/spree/backend/all.js", "//= require spree/backend/solidus_product_assembly\n"
13
+ append_file(
14
+ 'vendor/assets/javascripts/spree/backend/all.js',
15
+ "//= require spree/backend/solidus_product_assembly\n"
16
+ )
12
17
  end
13
18
 
14
19
  def run_migrations
15
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
20
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
16
21
  if run_migrations
17
- run 'rake db:migrate'
18
- else
19
- puts "Skiping rake db:migrate, don't forget to run it!"
20
- end
22
+ run 'bundle exec rake db:migrate'
23
+ else
24
+ puts 'Skipping rake db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
25
+ end
21
26
  end
22
27
  end
23
28
  end
@@ -1,15 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spree/core'
4
+
1
5
  module SolidusProductAssembly
2
6
  class Engine < Rails::Engine
3
- engine_name 'solidus_product_assembly'
7
+ include SolidusSupport::EngineExtensions
4
8
 
5
- config.autoload_paths += %W(#{config.root}/lib)
9
+ isolate_namespace ::Spree
6
10
 
7
- def self.activate
8
- Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator.rb")) do |c|
9
- Rails.configuration.cache_classes ? require(c) : load(c)
10
- end
11
- end
11
+ engine_name 'solidus_product_assembly'
12
12
 
13
- config.to_prepare &method(:activate).to_proc
13
+ # use rspec for tests
14
+ config.generators do |g|
15
+ g.test_framework :rspec
16
+ end
14
17
  end
15
18
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusProductAssembly
2
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
3
5
  end
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'solidus_core'
2
- require 'solidus_product_assembly/engine'
4
+ require 'solidus_support'
3
5
  require 'solidus_product_assembly/version'
6
+ require 'solidus_product_assembly/engine'
7
+ require 'deface'