Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated for spree 1.0.x

  • Loading branch information...
commit 8cab7515cf8db6c75c6110845fd48d4e20cdf892 1 parent dd296fb
@joeyjoejoejr joeyjoejoejr authored jumph4x committed
View
12 app/controllers/spree/admin/parts_controller.rb
@@ -9,13 +9,13 @@ def index
def remove
@part = Spree::Variant.find(params[:id])
@product.remove_part(@part)
- render :template => 'admin/parts/update_parts_table'
+ render :template => 'spree/admin/parts/update_parts_table'
end
def set_count
@part = Spree::Variant.find(params[:id])
@product.set_part_count(@part, params[:count].to_i)
- render :template => 'admin/parts/update_parts_table'
+ render :template => 'spree/admin/parts/update_parts_table'
end
def available
@@ -23,12 +23,12 @@ def available
@available_products = []
else
query = "%#{params[:q]}%"
- @available_products = Spree::Product.not_deleted.available.joins(:master).where("(products.name #{LIKE} ? OR variants.sku #{LIKE} ?) AND can_be_part = ?", query, query, true).limit(30)
-
+ @available_products = Spree::Product.not_deleted.available.joins(:master).where("(spree_products.name #{LIKE} ? OR spree_variants.sku #{LIKE} ?) AND can_be_part = ?", query, query, true).limit(30)
+
@available_products.uniq!
end
respond_to do |format|
- format.html
+ format.html {render :layout => false}
format.js {render :layout => false}
end
end
@@ -37,7 +37,7 @@ def create
@part = Spree::Variant.find(params[:part_id])
qty = params[:part_count].to_i
@product.add_part(@part, qty) if qty > 0
- render :template => 'admin/parts/update_parts_table'
+ render :template => 'spree/admin/parts/update_parts_table'
end
private
View
2  app/overrides/add_admin_product_form_fields.rb
@@ -1,4 +1,4 @@
-Deface::Override.new(:virtual_path => "admin/products/_form",
+Deface::Override.new(:virtual_path => "spree/admin/products/_form",
:name => "product_assembly_admin_product_form_right",
:insert_after => "[data-hook='admin_product_form_right'], #admin_product_form_right[data-hook]",
:partial => "spree/admin/products/product_assembly_fields",
View
2  app/overrides/add_admin_tabs.rb
@@ -1,4 +1,4 @@
-Deface::Override.new(:virtual_path => "admin/shared/_product_tabs",
+Deface::Override.new(:virtual_path => "spree/admin/shared/_product_tabs",
:name => "product_assembly_admin_product_tabs",
:insert_bottom => "[data-hook='admin_product_tabs']",
:partial => "spree/admin/shared/product_assembly_product_tabs",
View
2  app/overrides/add_line_item_description.rb
@@ -1,4 +1,4 @@
-Deface::Override.new(:virtual_path => "orders/_line_item",
+Deface::Override.new(:virtual_path => "spree/orders/_line_item",
:name => "product_assembly_cart_item_description",
:insert_bottom => "[data-hook='cart_item_description']",
:partial => "spree/orders/cart_description",
View
56 app/views/spree/admin/parts/available.html.erb
@@ -0,0 +1,56 @@
+<script type="text/javascript">
+ function displayRow(){
+ var row = document.getElementById("captionRow");
+ if (row.style.display == '') row.style.display = 'none';
+ else row.style.display = '';
+ }
+</script>
+
+<h4><%= t('available_parts') %></h4>
+<table class="index">
+ <thead>
+ <tr>
+ <th><%= t("name") %></th>
+ <th><%= t("options") %></th>
+ <th><%= t("qty") %></th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @available_products.each do |product| %>
+ <tr id="<%= dom_id(product) %>">
+
+ <td><%= product.name %></td>
+ <td>
+ <% if product.has_variants? %>
+ <%= select_tag "part[id]",
+ options_for_select(product.variants.map { |v| [variant_options(v), v.id] }) %>
+ <% else %>
+ <%= hidden_field_tag "part[id]", product.master.id %>
+ <%= t :no_variants %>
+ <% end %>
+ </td>
+ <td><%= text_field_tag "part[count]", 1 %></td>
+ <td class="actions">
+ <%= image_tag "spinner.gif", :style => "display:none", :class => "spinner" %>
+ <%= link_to(icon('add') + ' ' + t('select'),
+ admin_product_parts_path(@product),
+ :class => "add_product_part_link") %>
+ </td>
+ </tr>
+ <% end %>
+ <% if @available_products.empty? %>
+ <tr><td colspan="3"><%= t('no_match_found') %>.</td></tr>
+ <% end %>
+ </tbody>
+</table>
+
+<%= javascript_tag do %>
+ $("a.add_product_part_link").click(function(){
+ part_id_val = $('select option:selected', $(this).parent().parent()).val() ||
+ $('input:first', $(this).parent().parent()).val();
+ params = { part_count : $('input:last', $(this).parent().parent()).val(),
+ part_id : part_id_val};
+ return make_post_request($(this), params);
+ });
+<% end %>
View
16 app/views/spree/admin/parts/index.html.erb
@@ -1,30 +1,30 @@
-<%= render :partial => 'admin/shared/product_sub_menu' %>
+<%= render :partial => 'spree/admin/shared/product_sub_menu' %>
-<%= render :partial => 'admin/shared/product_tabs', :locals => {:current => "Parts"} %>
+<%= render :partial => 'spree/admin/shared/product_tabs', :locals => {:current => "Parts"} %>
<div id="product_parts">
<%= render :partial => "parts_table", :locals => {:parts => @parts} %>
</div>
-<% form_tag('#') do %>
+<%= form_tag('#') do %>
<label><%= t('search') %>:</label>
<input id="searchtext" size="25">
<% end %>
<br/>
<div id="search_hits"></div>
-<% javascript_tag do %>
+<%= javascript_tag do %>
function search_for_parts(){
$.ajax({
data: {q: $("#searchtext").val() },
+ dataType: 'html',
success: function(request){
- $('#search_hits').html(request);
+ jQuery('#search_hits').html(request);
$('#search_hits').show();
},
- type: 'post',
- dataType: 'script',
+ type: 'POST',
url: '<%= available_admin_product_parts_url(@product) %>'
});
}
<% end -%>
-<%= javascript_include_tag 'product_assembly' %>
+<%= javascript_include_tag 'admin/product_assembly' %>
View
6 app/views/spree/orders/_cart_description.html.erb
@@ -2,7 +2,9 @@
if product.assembly? %>
<ul class='assembly_parts'>
<% product.parts.each do |v| %>
- <li>(<%= product.count_of(v) %>) <%= v.name %> (<%= v.sku %>)</li>
+ <li>(<%= product.count_of(v) %>) <%= link_to v.name, product_path(v.product) %> (<%= v.sku %>)</li>
<% end %>
</ul>
-<% end %>
+<% end %>
+
+
View
2  config/routes.rb
@@ -1,4 +1,4 @@
-Rails.application.routes.draw do
+Spree::Core::Engine.routes.prepend do
namespace :admin do
resources :products do
Please sign in to comment.
Something went wrong with that request. Please try again.