caboose-cms 0.4.151 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/admin_products.js +79 -0
- data/app/assets/javascripts/caboose/application.js +2 -1
- data/app/assets/javascripts/caboose/cart.js +168 -0
- data/app/assets/javascripts/caboose/checkout.js +151 -0
- data/app/assets/javascripts/caboose/checkout_module.js +312 -0
- data/app/assets/javascripts/caboose/checkout_step1.js +179 -0
- data/app/assets/javascripts/caboose/checkout_step2.js +39 -0
- data/app/assets/javascripts/caboose/checkout_step3.js +34 -0
- data/app/assets/javascripts/caboose/checkout_step4.js +97 -0
- data/app/assets/javascripts/caboose/main.js +99 -8
- data/app/assets/javascripts/caboose/product.js +284 -0
- data/app/assets/stylesheets/caboose/admin_products.css +86 -0
- data/app/assets/templates/caboose/cart/add_to_cart.jst.ejs +7 -0
- data/app/assets/templates/caboose/cart/line_items.jst.ejs +41 -0
- data/app/assets/templates/caboose/checkout/address.jst.ejs +53 -0
- data/app/assets/templates/caboose/checkout/forms/guest.jst.ejs +8 -0
- data/app/assets/templates/caboose/checkout/forms/register.jst.ejs +11 -0
- data/app/assets/templates/caboose/checkout/forms/signin.jst.ejs +7 -0
- data/app/assets/templates/caboose/checkout/line_items.jst.ejs +31 -0
- data/app/assets/templates/caboose/checkout/login.jst.ejs +21 -0
- data/app/assets/templates/caboose/checkout/payment.jst.ejs +5 -0
- data/app/assets/templates/caboose/checkout/shipping.jst.ejs +18 -0
- data/app/assets/templates/caboose/product/images.jst.ejs +8 -0
- data/app/assets/templates/caboose/product/options.jst.ejs +19 -0
- data/app/controllers/caboose/application_controller.rb +29 -1
- data/app/controllers/caboose/cart_controller.rb +52 -0
- data/app/controllers/caboose/categories_controller.rb +108 -0
- data/app/controllers/caboose/checkout_controller.rb +325 -0
- data/app/controllers/caboose/orders_controller.rb +439 -0
- data/app/controllers/caboose/product_images_controller.rb +38 -0
- data/app/controllers/caboose/products_controller.rb +737 -0
- data/app/controllers/caboose/reviews_controller.rb +15 -0
- data/app/controllers/caboose/variants_controller.rb +218 -0
- data/app/controllers/caboose/vendors_controller.rb +73 -0
- data/app/helpers/caboose/application_helper.rb +4 -0
- data/app/helpers/caboose/categories_helper.rb +82 -0
- data/app/helpers/caboose/checkout_helper.rb +20 -0
- data/app/helpers/caboose/products_helper.rb +8 -0
- data/app/mailers/caboose/orders_mailer.rb +30 -0
- data/app/models/caboose/address.rb +26 -0
- data/app/models/caboose/category.rb +89 -0
- data/app/models/caboose/category_membership.rb +10 -0
- data/app/models/caboose/core_plugin.rb +15 -37
- data/app/models/caboose/customization_membership.rb +10 -0
- data/app/models/caboose/discount.rb +16 -0
- data/app/models/caboose/line_item.rb +81 -0
- data/app/models/caboose/message.rb +20 -0
- data/app/models/caboose/order.rb +191 -0
- data/app/models/caboose/order_discount.rb +10 -0
- data/app/models/caboose/order_pdf.rb +78 -0
- data/app/models/caboose/payment_processors/authorizenet.rb +53 -0
- data/app/models/caboose/payment_processors/base.rb +39 -0
- data/app/models/caboose/payment_processors/payscape.rb +94 -0
- data/app/models/caboose/product.rb +145 -0
- data/app/models/caboose/product_image.rb +62 -0
- data/app/models/caboose/product_image_variant.rb +10 -0
- data/app/models/caboose/review.rb +13 -0
- data/app/models/caboose/schema.rb +205 -1
- data/app/models/caboose/search_filter.rb +191 -0
- data/app/models/caboose/shipping_calculator.rb +81 -0
- data/app/models/caboose/states.rb +61 -52
- data/app/models/caboose/tax_calculator.rb +23 -0
- data/app/models/caboose/tax_line.rb +9 -0
- data/app/models/caboose/variant.rb +99 -0
- data/app/models/caboose/vendor.rb +22 -0
- data/app/views/caboose/cart/index.html.erb +8 -0
- data/app/views/caboose/categories/admin_edit.html.erb +79 -0
- data/app/views/caboose/categories/admin_index.html.erb +11 -0
- data/app/views/caboose/categories/admin_new.html.erb +62 -0
- data/app/views/caboose/checkout/_address_form.html.erb +111 -0
- data/app/views/caboose/checkout/_billing_form.html.erb +47 -0
- data/app/views/caboose/checkout/_cart.html.erb +52 -0
- data/app/views/caboose/checkout/_confirm.html.erb +61 -0
- data/app/views/caboose/checkout/_order_discount.html.erb +40 -0
- data/app/views/caboose/checkout/_shipping_address.html.erb +10 -0
- data/app/views/caboose/checkout/_shipping_method.html.erb +2 -0
- data/app/views/caboose/checkout/_shipping_method_form.html.erb +21 -0
- data/app/views/caboose/checkout/billing.html.erb +11 -0
- data/app/views/caboose/checkout/discount.html.erb +11 -0
- data/app/views/caboose/checkout/empty.html.erb +2 -0
- data/app/views/caboose/checkout/error.html.erb +2 -0
- data/app/views/caboose/checkout/index.html.erb +43 -0
- data/app/views/caboose/checkout/login.html.erb +2 -0
- data/app/views/caboose/checkout/payment.html.erb +79 -0
- data/app/views/caboose/checkout/relay.html.erb +23 -0
- data/app/views/caboose/checkout/relay_old.html.erb +12 -0
- data/app/views/caboose/checkout/relay_postMessage.html.erb +19 -0
- data/app/views/caboose/checkout/shipping.html.erb +15 -0
- data/app/views/caboose/checkout/step_four.html.erb +93 -0
- data/app/views/caboose/checkout/step_one.html.erb +56 -0
- data/app/views/caboose/checkout/step_one_old.html.erb +13 -0
- data/app/views/caboose/checkout/step_three.html.erb +23 -0
- data/app/views/caboose/checkout/step_two.html.erb +52 -0
- data/app/views/caboose/checkout/step_two_old.html.erb +14 -0
- data/app/views/caboose/checkout/thanks.html.erb +5 -0
- data/app/views/caboose/orders/_admin_footer.html.erb +2 -0
- data/app/views/caboose/orders/_admin_header.html.erb +31 -0
- data/app/views/caboose/orders/_quickbooks_order.html.erb +0 -0
- data/app/views/caboose/orders/admin_delete_form.html.erb +21 -0
- data/app/views/caboose/orders/admin_edit.html.erb +271 -0
- data/app/views/caboose/orders/admin_index.html.erb +89 -0
- data/app/views/caboose/orders/admin_new.html.erb +42 -0
- data/app/views/caboose/orders/admin_print.html.erb +72 -0
- data/app/views/caboose/orders_mailer/customer_new_order.html.erb +1 -0
- data/app/views/caboose/orders_mailer/customer_status_updated.html.erb +1 -0
- data/app/views/caboose/orders_mailer/fulfillment_new_order.html.erb +1 -0
- data/app/views/caboose/orders_mailer/shipping_order_ready.html.erb +1 -0
- data/app/views/caboose/products/_admin_footer.html.erb +2 -0
- data/app/views/caboose/products/_admin_header.html.erb +32 -0
- data/app/views/caboose/products/_sort_options.html.erb +19 -0
- data/app/views/caboose/products/admin_add_upcs.html.erb +58 -0
- data/app/views/caboose/products/admin_delete_form.html.erb +21 -0
- data/app/views/caboose/products/admin_edit_categories.html.erb +73 -0
- data/app/views/caboose/products/admin_edit_category_images.html.erb +233 -0
- data/app/views/caboose/products/admin_edit_description.html.erb +38 -0
- data/app/views/caboose/products/admin_edit_general.html.erb +104 -0
- data/app/views/caboose/products/admin_edit_images.html.erb +236 -0
- data/app/views/caboose/products/admin_edit_options.html.erb +51 -0
- data/app/views/caboose/products/admin_edit_seo.html.erb +37 -0
- data/app/views/caboose/products/admin_edit_variant_columns.html.erb +75 -0
- data/app/views/caboose/products/admin_edit_variant_sort_order.html.erb +63 -0
- data/app/views/caboose/products/admin_edit_variants.html.erb +171 -0
- data/app/views/caboose/products/admin_edit_variants_single.html.erb +68 -0
- data/app/views/caboose/products/admin_group_variants.html.erb +433 -0
- data/app/views/caboose/products/admin_index.html.erb +95 -0
- data/app/views/caboose/products/admin_new.html.erb +41 -0
- data/app/views/caboose/products/admin_sort.html copy.erb +155 -0
- data/app/views/caboose/products/admin_sort.html.erb +254 -0
- data/app/views/caboose/products/details.html.erb +438 -0
- data/app/views/caboose/products/index.html.erb +46 -0
- data/app/views/caboose/products/not_available.html.erb +35 -0
- data/app/views/caboose/variants/admin_edit.html.erb +82 -0
- data/app/views/caboose/variants/admin_group.html.erb +184 -0
- data/app/views/caboose/variants/admin_new.html.erb +59 -0
- data/app/views/caboose/vendors/admin_edit.html.erb +24 -0
- data/app/views/caboose/vendors/admin_index.html.erb +30 -0
- data/app/views/caboose/vendors/admin_new.html.erb +34 -0
- data/app/views/layouts/caboose/store/_banner.html.erb +10 -0
- data/app/views/layouts/caboose/store/_banner2.html.erb +10 -0
- data/app/views/layouts/caboose/store/_footer.html.erb +55 -0
- data/app/views/layouts/caboose/store/_header.html.erb +69 -0
- data/app/views/layouts/caboose/store/_sidebar.html.erb +27 -0
- data/app/views/layouts/caboose/store/application.html.erb +33 -0
- data/app/views/layouts/caboose/store/authorize_net.erb +18 -0
- data/app/views/layouts/caboose/store/layout_about.html.erb +42 -0
- data/app/views/layouts/caboose/store/layout_blog.html.erb +159 -0
- data/app/views/layouts/caboose/store/layout_confirm.html.erb +85 -0
- data/app/views/layouts/caboose/store/layout_contact.html.erb +38 -0
- data/app/views/layouts/caboose/store/layout_default.html.erb +10 -0
- data/app/views/layouts/caboose/store/layout_detail.html.erb +114 -0
- data/app/views/layouts/caboose/store/layout_order.html.erb +77 -0
- data/app/views/layouts/caboose/store/layout_pricing.html.erb +182 -0
- data/app/views/layouts/caboose/store/layout_product.html.erb +110 -0
- data/app/views/layouts/caboose/store/layout_profile.html.erb +55 -0
- data/app/views/layouts/caboose/store/layout_single.html.erb +3 -0
- data/app/views/layouts/caboose/store/layout_testimonial.html.erb +110 -0
- data/app/views/layouts/caboose/store/layout_testing.html.erb +4 -0
- data/config/routes.rb +126 -0
- data/lib/caboose.rb +46 -1
- data/lib/caboose/engine.rb +39 -1
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +12 -0
- metadata +151 -4
- data/app/assets/javascripts/caboose/admin_page_edit_content_bak.js +0 -164
- data/app/assets/javascripts/caboose/model/#Untitled-1# +0 -2
@@ -0,0 +1,72 @@
|
|
1
|
+
<%
|
2
|
+
sa = @order.shipping_address
|
3
|
+
shipping_address = sa.address1
|
4
|
+
shipping_address << "<br />#{sa.address2}" if sa.address2 && sa.address2.length > 0
|
5
|
+
shipping_address << "<br />#{sa.city}, #{sa.state} #{sa.zip}"
|
6
|
+
%>
|
7
|
+
<p align='center'><img src='https://dmwwflw4i3miv.cloudfront.net/logo.png' /></p>
|
8
|
+
|
9
|
+
<h1>Order #<%= @order.id %></h1>
|
10
|
+
|
11
|
+
<table class='data'>
|
12
|
+
<tr>
|
13
|
+
<th>Customer</th>
|
14
|
+
<th>Shipping Address</th>
|
15
|
+
<th>Payment Status</th>
|
16
|
+
</tr>
|
17
|
+
<tr>
|
18
|
+
<td valign='top'>
|
19
|
+
<%= "#{@order.customer.first_name} #{@order.customer.last_name}" %><br />
|
20
|
+
<a href='mailto:<%= "#{@order.customer.email}" %>'><%= "#{@order.customer.email}" %></a><br />
|
21
|
+
<%= @order.customer.phone %>
|
22
|
+
</td>
|
23
|
+
<td valign='top'>
|
24
|
+
<%= "#{@order.shipping_address.name}" %><br />
|
25
|
+
<%= raw shipping_address %>
|
26
|
+
</td>
|
27
|
+
<td valign='top'>
|
28
|
+
<%= @order.financial_status %>
|
29
|
+
</td>
|
30
|
+
</tr>
|
31
|
+
</table><br />
|
32
|
+
|
33
|
+
<table class='data' width='100%'>
|
34
|
+
<tr>
|
35
|
+
<th>Item</th>
|
36
|
+
<th>Status</th>
|
37
|
+
<th>Tracking Number</th>
|
38
|
+
<th>Quantity</th>
|
39
|
+
<th>Subtotal</th>
|
40
|
+
</tr>
|
41
|
+
<% @order.line_items.each do |li| %>
|
42
|
+
<tr>
|
43
|
+
<td>
|
44
|
+
<%= li.variant.product.title %><br />
|
45
|
+
<%= li.variant.sku %><br />
|
46
|
+
<%= li.variant.title %>
|
47
|
+
</td>
|
48
|
+
<td ><%= li.status %></td>
|
49
|
+
<td ><%= li.tracking_number %></td>
|
50
|
+
<td align='right'><%= li.quantity %></td>
|
51
|
+
<td align='right'><%= number_to_currency(li.subtotal) %></td>
|
52
|
+
</tr>
|
53
|
+
<% end %>
|
54
|
+
<tr><td colspan='4' align='right'>Subtotal </td><td align='right'><%= number_to_currency(@order.subtotal ) %></td></tr>
|
55
|
+
<tr><td colspan='4' align='right'>Tax </td><td align='right'><%= number_to_currency(@order.tax ) %></td></tr>
|
56
|
+
<tr><td colspan='4' align='right'><%= @order.shipping_method %> Shipping </td><td align='right'><%= number_to_currency(@order.shipping ) %></td></tr>
|
57
|
+
<tr><td colspan='4' align='right'>Handling </td><td align='right'><%= number_to_currency(@order.handling ) %></td></tr>
|
58
|
+
<tr><td colspan='4' align='right'>Discount </td><td align='right'><%= number_to_currency(@order.discount ) %></td></tr>
|
59
|
+
<tr><td colspan='4' align='right'>Total </td><td align='right'><%= number_to_currency(@order.total ) %></td></tr>
|
60
|
+
</table>
|
61
|
+
|
62
|
+
<% content_for :caboose_js do %>
|
63
|
+
<%= javascript_include_tag 'caboose/model/all' %>
|
64
|
+
<script type='text/javascript'>
|
65
|
+
|
66
|
+
var modal = false;
|
67
|
+
$(window).load(function() {
|
68
|
+
modal = new CabooseModal('100%');
|
69
|
+
});
|
70
|
+
|
71
|
+
</script>
|
72
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Thank you for your order!</h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Your order has been udpated</h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>New Order Received</h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Order is ready for shipping</h1>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<% content_for :caboose_css do %>
|
2
|
+
<%= stylesheet_link_tag "caboose/admin_products" %>
|
3
|
+
<% end %>
|
4
|
+
<% content_for :caboose_js do %>
|
5
|
+
<%= javascript_include_tag "caboose/model/all" %>
|
6
|
+
<%= javascript_include_tag "caboose/admin_products" %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<h1>Edit Product - <%= @product.title %></h1>
|
10
|
+
<ul id='modal_tabs'>
|
11
|
+
<%
|
12
|
+
tabs = {
|
13
|
+
"/admin/products/#{@product.id}/general" => 'Product details',
|
14
|
+
"/admin/products/#{@product.id}/description" => 'Long Description',
|
15
|
+
"/admin/products/#{@product.id}/categories" => 'Categories'
|
16
|
+
}
|
17
|
+
|
18
|
+
tabs["/admin/products/#{@product.id}/options" ] = 'Options <span style="font-size: 65%">(size, color, style, etc.)</span>' if @product.options && @product.options.count > 0
|
19
|
+
tabs["/admin/products/#{@product.id}/variants/sort-order" ] = 'Sort Option Values' if @product.options && @product.options.count > 0
|
20
|
+
tabs["/admin/products/#{@product.id}/variants" ] = 'Inventory & Variants'
|
21
|
+
tabs["/admin/products/#{@product.id}/images" ] = 'Images'
|
22
|
+
tabs["/admin/products/#{@product.id}/delete" ] = 'Delete Product'
|
23
|
+
|
24
|
+
#tabs["/admin/products/#{@product.id}/seo" ] = 'SEO'
|
25
|
+
|
26
|
+
%>
|
27
|
+
<% tabs.each do |href,text| %>
|
28
|
+
<li<%= raw request.fullpath == href ? " class='selected'" : '' %>><a href='<%= href %>'><%= raw text %></a></li>
|
29
|
+
<% end %>
|
30
|
+
<li class='back'><input type='button' value='< Back' onclick="window.location='/admin/products';" /></li>
|
31
|
+
</ul>
|
32
|
+
<div id='modal_content2'>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<label>
|
2
|
+
<span for="product-sort">Sort by:</span>
|
3
|
+
|
4
|
+
<select id="product-sort" style="margin: 0 !important">
|
5
|
+
<% @sort_options.each do |sort_option| %>
|
6
|
+
<option value="<%= sort_option[:value] %>" <%= 'selected' if params[:sort] == sort_option[:value] %>><%= sort_option[:name] %></option>
|
7
|
+
<% end %>
|
8
|
+
</select>
|
9
|
+
</label>
|
10
|
+
|
11
|
+
<% content_for :caboose_js do %>
|
12
|
+
<script>
|
13
|
+
$(document).ready(function() {
|
14
|
+
$('#product-sort').on('change', function(event) {
|
15
|
+
window.location = '/products?sort=' + $(this).val();
|
16
|
+
});
|
17
|
+
});
|
18
|
+
</script>
|
19
|
+
<% end %>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<h1>Unmatched Products</h1>
|
2
|
+
|
3
|
+
<p style="margin: 0 0 6px"><a href="/admin/products">All Products</a></p>
|
4
|
+
|
5
|
+
<br />
|
6
|
+
<form method="get" action="/admin/products/add-upcs">
|
7
|
+
<select name="vendor_id">
|
8
|
+
<option value="">Choose Vendor</option>
|
9
|
+
|
10
|
+
<% Caboose::Vendor.all.each do |vendor| %>
|
11
|
+
<option value="<%= vendor.id %>"
|
12
|
+
<%= 'selected' if params[:vendor_id] and params[:vendor_id].to_i == vendor.id %>
|
13
|
+
><%= vendor.name %></option>
|
14
|
+
<% end %>
|
15
|
+
</select>
|
16
|
+
|
17
|
+
<input type="submit" value="Filter">
|
18
|
+
</form><br />
|
19
|
+
|
20
|
+
<% content_for :caboose_js do %>
|
21
|
+
<script>
|
22
|
+
$(document).ready(function() {
|
23
|
+
$('form').one('submit', function(event) {
|
24
|
+
event.preventDefault();
|
25
|
+
|
26
|
+
// Prevent the form from being submitted by button click
|
27
|
+
$('form input[type=submit]').attr('disabled', true);
|
28
|
+
|
29
|
+
// If the vendor id has a value send it through; otherwise reload the page
|
30
|
+
if ($('form select').val() != "") {
|
31
|
+
$('form').submit();
|
32
|
+
} else {
|
33
|
+
window.location.href = '/admin/products/add-upcs';
|
34
|
+
}
|
35
|
+
});
|
36
|
+
});
|
37
|
+
</script>
|
38
|
+
<% end %>
|
39
|
+
|
40
|
+
<% if @products.count > 0 %>
|
41
|
+
<table class='data' id='properties_table'>
|
42
|
+
<tr>
|
43
|
+
<th>ID</th>
|
44
|
+
<th>Title</th>
|
45
|
+
<th>Vendor</th>
|
46
|
+
</tr>
|
47
|
+
|
48
|
+
<% @products.each do |product| %>
|
49
|
+
<tr onclick="window.location='/admin/products/<%= product.id %>/general';">
|
50
|
+
<td><%= raw product.id %></td>
|
51
|
+
<td><%= raw product.title %></td>
|
52
|
+
<td><%= raw product.vendor.nil? ? 'Unknown' : product.vendor.name %></td>
|
53
|
+
</tr>
|
54
|
+
<% end %>
|
55
|
+
</table>
|
56
|
+
<% else %>
|
57
|
+
<p>There are no products right now.</p>
|
58
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%
|
2
|
+
p = @product
|
3
|
+
%>
|
4
|
+
<%= render :partial => 'caboose/products/admin_header' %>
|
5
|
+
|
6
|
+
<div id='message'>
|
7
|
+
<p><input type='button' value='Delete this product' onclick='delete_product(<%= p.id %>);' /></p>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<%= render :partial => 'caboose/products/admin_footer' %>
|
11
|
+
|
12
|
+
<% content_for :caboose_js do %>
|
13
|
+
<script type='text/javascript'>
|
14
|
+
|
15
|
+
var modal = false;
|
16
|
+
$(window).load(function() {
|
17
|
+
modal = new CabooseModal(800);
|
18
|
+
});
|
19
|
+
|
20
|
+
</script>
|
21
|
+
<% end %>
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<%
|
2
|
+
p = @product
|
3
|
+
%>
|
4
|
+
<%= render :partial => 'caboose/products/admin_header' %>
|
5
|
+
|
6
|
+
<div id='categories'>
|
7
|
+
<table>
|
8
|
+
<tr>
|
9
|
+
<% @top_categories.each do |cat| %>
|
10
|
+
<% next if cat.children && cat.children.count > 0 %>
|
11
|
+
<td valign='top'><%= raw category_checkboxes([cat], @selected_ids) %></td>
|
12
|
+
<% end %>
|
13
|
+
</tr>
|
14
|
+
<tr>
|
15
|
+
<% @top_categories.each do |cat| %>
|
16
|
+
<% next if cat.children.nil? || cat.children.count == 0 %>
|
17
|
+
<td valign='top'><%= raw category_checkboxes([cat], @selected_ids) %></td>
|
18
|
+
<% end %>
|
19
|
+
</tr>
|
20
|
+
</table>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<%= render :partial => 'caboose/products/admin_footer' %>
|
24
|
+
|
25
|
+
<% content_for :caboose_css do %>
|
26
|
+
<style type='text/css'>
|
27
|
+
#categories input[type='checkbox'] { position: relative; }
|
28
|
+
#categories ul { list-style: none; margin: 0; padding: 0; }
|
29
|
+
#categories ul ul ul { margin-left: 20px; }
|
30
|
+
#categories li { list-style: none; }
|
31
|
+
#categories h3 { margin: 0; padding: 0; font-weight: bold; display: inline; }
|
32
|
+
#categories td { padding: 10px; }
|
33
|
+
</style>
|
34
|
+
<% end %>
|
35
|
+
<% content_for :caboose_js do %>
|
36
|
+
<script type='text/javascript'>
|
37
|
+
|
38
|
+
$(document).ready(function() {
|
39
|
+
$('#categories input').click(function() {
|
40
|
+
var cat_id = $(this).attr('id').split('_')[1];
|
41
|
+
if ($(this).is(':checked'))
|
42
|
+
add_product_to_category(<%= p.id %>, cat_id);
|
43
|
+
else
|
44
|
+
remove_product_from_category(<%= p.id %>, cat_id);
|
45
|
+
});
|
46
|
+
});
|
47
|
+
|
48
|
+
var modal = false;
|
49
|
+
$(window).load(function() {
|
50
|
+
modal = new CabooseModal(800);
|
51
|
+
});
|
52
|
+
|
53
|
+
function add_product_to_category(product_id, cat_id)
|
54
|
+
{
|
55
|
+
$.ajax({
|
56
|
+
url: '/admin/products/' + product_id + '/categories',
|
57
|
+
type: 'post',
|
58
|
+
data: { category_id: cat_id },
|
59
|
+
success: function(resp) {}
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
63
|
+
function remove_product_from_category(product_id, cat_id)
|
64
|
+
{
|
65
|
+
$.ajax({
|
66
|
+
url: '/admin/products/' + product_id + '/categories/' + cat_id,
|
67
|
+
type: 'delete',
|
68
|
+
success: function(resp) {}
|
69
|
+
});
|
70
|
+
}
|
71
|
+
|
72
|
+
</script>
|
73
|
+
<% end %>
|
@@ -0,0 +1,233 @@
|
|
1
|
+
<%
|
2
|
+
p = @product
|
3
|
+
%>
|
4
|
+
<%= render :partial => 'caboose/products/admin_header' %>
|
5
|
+
|
6
|
+
<form action='/admin/products/<%= p.id %>/images' method='post' enctype='multipart/form-data' id='new_image_form' target='new_image_iframe'>
|
7
|
+
<input type='hidden' name='authenticity_token' value="<%= form_authenticity_token %>" />
|
8
|
+
<p><input type='file' name='new_image' id='new_image' />
|
9
|
+
<input type='submit' value='Add Image' onclick='add_image();' /></p>
|
10
|
+
</form>
|
11
|
+
<div id='new_image_message'></div>
|
12
|
+
<iframe id='new_image_iframe' name='new_image_iframe' style='display: none;'></iframe>
|
13
|
+
<div id='message'></div>
|
14
|
+
|
15
|
+
<div id='images'>
|
16
|
+
<% if p.product_images.count > 0 %>
|
17
|
+
<% p.product_images.each do |img| %>
|
18
|
+
<%
|
19
|
+
#url = "https://s3.amazonaws.com/tuskwear/products/#{img.product_id}_#{img.id}_tiny.jpg"
|
20
|
+
url = img.image.url(:tiny)
|
21
|
+
%>
|
22
|
+
<div id='img_<%= img.id %>_container'><a href="javascript:select_image(<%= img.id %>);"><img src='<%= url %>' width='75' /></a></div>
|
23
|
+
<% end %>
|
24
|
+
<% else %>
|
25
|
+
<p>This product doesn't have any images yet.</p>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
28
|
+
<div id='variants'></div>
|
29
|
+
|
30
|
+
<%= render :partial => 'caboose/products/admin_footer' %>
|
31
|
+
|
32
|
+
<% content_for :caboose_css do %>
|
33
|
+
<style type='text/css'>
|
34
|
+
#variants input[type='checkbox'] { position: relative; margin: 0; padding: 0; }
|
35
|
+
#variants table td { border: 0; font-size: 85%; margin: 0; padding: 0px 8px; }
|
36
|
+
#variants label { padding: 0; }
|
37
|
+
#images div { display: inline-block; }
|
38
|
+
#images div img { border: #000 4px solid; }
|
39
|
+
#images div.selected img { border: #ff3333 4px solid; }
|
40
|
+
</style>
|
41
|
+
<% end %>
|
42
|
+
<% content_for :caboose_js do %>
|
43
|
+
<script type='text/javascript'>
|
44
|
+
|
45
|
+
var modal = false;
|
46
|
+
$(window).load(function() {
|
47
|
+
modal.autosize();
|
48
|
+
});
|
49
|
+
|
50
|
+
$(document).ready(function() {
|
51
|
+
modal = new CabooseModal(900);
|
52
|
+
<% if p.product_images.count > 0 %>
|
53
|
+
select_image(<%= p.product_images[0].id %>);
|
54
|
+
<% end %>
|
55
|
+
});
|
56
|
+
|
57
|
+
variants = false;
|
58
|
+
image_variant_ids = {};
|
59
|
+
|
60
|
+
function variant_option_value(variant_id, option_index)
|
61
|
+
{
|
62
|
+
var val = false;
|
63
|
+
$.each(variants, function(i, v) {
|
64
|
+
if (v.id == variant_id)
|
65
|
+
{
|
66
|
+
if (option_index == 1) val = v.option1;
|
67
|
+
if (option_index == 2) val = v.option2;
|
68
|
+
if (option_index == 3) val = v.option3;
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
});
|
72
|
+
return val;
|
73
|
+
}
|
74
|
+
|
75
|
+
function select_image(image_id, confirm)
|
76
|
+
{
|
77
|
+
if (!variants)
|
78
|
+
{
|
79
|
+
modal.autosize("<p class='loading'>Getting attached product variants...</p>", 'variants');
|
80
|
+
$.ajax({
|
81
|
+
url: '/admin/products/<%= p.id %>/variants/json',
|
82
|
+
success: function(resp) { variants = resp; select_image(image_id); }
|
83
|
+
});
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
if (!confirm)
|
87
|
+
{
|
88
|
+
$.ajax({
|
89
|
+
url: '/admin/product-images/' + image_id + '/variant-ids',
|
90
|
+
success: function(resp) { image_variant_ids = resp; select_image(image_id, true); }
|
91
|
+
});
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
|
95
|
+
$('#images div').removeClass('selected');
|
96
|
+
$('#img_' + image_id + '_container').addClass('selected');
|
97
|
+
|
98
|
+
var x = Math.ceil(variants.length/3);
|
99
|
+
var tbl1 = variants_subtable(image_id, 0, x);
|
100
|
+
var tbl2 = variants_subtable(image_id, x, x*2);
|
101
|
+
var tbl3 = variants_subtable(image_id, x*2, variants.length);
|
102
|
+
|
103
|
+
var tr = $('<tr/>');
|
104
|
+
tr.append($('<td/>').attr('valign','top').append(tbl1));
|
105
|
+
tr.append($('<td/>').attr('valign','top').append(tbl2));
|
106
|
+
tr.append($('<td/>').attr('valign','top').append(tbl3));
|
107
|
+
var tbl = $('<table/>').append($('<tbody/>').append(tr));
|
108
|
+
|
109
|
+
$('#variants').empty().append('<br/>');
|
110
|
+
$('#variants').append($('<div/>').attr('id','delete_message'));
|
111
|
+
$('#variants').append($('<input/>').attr('type','button').val('Delete Image').click(function() { delete_image(image_id); }));
|
112
|
+
$('#variants').append(tbl);
|
113
|
+
modal.autosize();
|
114
|
+
}
|
115
|
+
|
116
|
+
function variants_subtable(image_id, x, y)
|
117
|
+
{
|
118
|
+
var tbody = $('<tbody/>');
|
119
|
+
for (var i=x; i<y; i++)
|
120
|
+
{
|
121
|
+
var v = variants[i];
|
122
|
+
checked = image_is_attached_to_variant(v.id);
|
123
|
+
|
124
|
+
//var a = $('<a/>')
|
125
|
+
// .attr('href', '#')
|
126
|
+
// .attr('id', 'v_' + v.id)
|
127
|
+
// .html(variant_title(v))
|
128
|
+
// .click(function(e) {
|
129
|
+
// e.preventDefault();
|
130
|
+
// variant_id = $(this).attr('id').split('_')[1];
|
131
|
+
// var attach = false;
|
132
|
+
// if ($(this).hasClass('selected')) { attach = false; $(this).removeClass('selected'); }
|
133
|
+
// else { attch = true; $(this).addClass('selected'); }
|
134
|
+
// attach_image_to_variant(image_id, variant_id, attach);
|
135
|
+
// });
|
136
|
+
//tbody.append($('<tr/>').append($('<td/>').append(a)));
|
137
|
+
|
138
|
+
tbody.append($('<tr/>')
|
139
|
+
.append($('<td/>')
|
140
|
+
.append($('<input/>')
|
141
|
+
.attr('type','checkbox')
|
142
|
+
.attr('id', 'v_' + v.id)
|
143
|
+
.attr('checked', checked)
|
144
|
+
.css('position','relative')
|
145
|
+
.val('1')
|
146
|
+
.click(function() {
|
147
|
+
variant_id = $(this).attr('id').split('_')[1];
|
148
|
+
attach_image_to_variant(image_id, variant_id, $(this).is(':checked'));
|
149
|
+
})
|
150
|
+
)
|
151
|
+
)
|
152
|
+
.append($('<td/>').append($('<label/>').attr('for','v_' + v.id).html(variant_title(v))))
|
153
|
+
);
|
154
|
+
}
|
155
|
+
return $('<table/>').append(tbody);
|
156
|
+
}
|
157
|
+
|
158
|
+
function image_is_attached_to_variant(variant_id)
|
159
|
+
{
|
160
|
+
has_value = false;
|
161
|
+
$.each(image_variant_ids, function(i, vid) { if (vid == variant_id) { has_value = true; return; }});
|
162
|
+
return has_value;
|
163
|
+
}
|
164
|
+
|
165
|
+
function variant_title(v)
|
166
|
+
{
|
167
|
+
arr = [];
|
168
|
+
if (v.option1) arr[arr.length] = v.option1;
|
169
|
+
if (v.option2) arr[arr.length] = v.option2;
|
170
|
+
if (v.option3) arr[arr.length] = v.option3;
|
171
|
+
return arr.join(' / ');
|
172
|
+
}
|
173
|
+
|
174
|
+
function attach_image_to_variant(image_id, variant_id, attach = true)
|
175
|
+
{
|
176
|
+
if (attach)
|
177
|
+
image_variant_ids[image_variant_ids.length] = variant_id;
|
178
|
+
else
|
179
|
+
{
|
180
|
+
var i = image_variant_ids.indexOf(variant_id);
|
181
|
+
image_variant_ids.splice(i, 1);
|
182
|
+
}
|
183
|
+
$.ajax({
|
184
|
+
url: '/admin/variants/' + variant_id + '/' + (attach ? 'attach-to-image' : 'unattach-from-image'),
|
185
|
+
type: 'put',
|
186
|
+
data: { product_image_id: image_id },
|
187
|
+
success: function(resp) {}
|
188
|
+
});
|
189
|
+
}
|
190
|
+
|
191
|
+
function add_image()
|
192
|
+
{
|
193
|
+
$('#new_image_message').html("<p class='loading'>Adding image...</p>");
|
194
|
+
modal.autosize();
|
195
|
+
}
|
196
|
+
|
197
|
+
function delete_image(image_id, confirm)
|
198
|
+
{
|
199
|
+
if (!confirm)
|
200
|
+
{
|
201
|
+
var p = $('<p/>').addClass('note error').css('margin-bottom', '10px')
|
202
|
+
.append("Are you sure you want to delete the image?<br />This can't be undone.<br /><br />")
|
203
|
+
.append($('<input/>').attr('type', 'button').val('Yes').click(function() { delete_image(image_id, true); })).append(' ')
|
204
|
+
.append($('<input/>').attr('type', 'button').val('No').click(function() { $('#delete_message').empty(); modal.autosize(); }));
|
205
|
+
modal.autosize(p, 'delete_message');
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
modal.autosize("<p class='loading'>Deleting the image...</p>", 'delete_message');
|
209
|
+
$.ajax({
|
210
|
+
url: '/admin/product-images/' + image_id,
|
211
|
+
type: 'delete',
|
212
|
+
success: function(resp) {
|
213
|
+
if (resp.error)
|
214
|
+
modal.autosize("<p class='note error'>" + resp.error + "</p>", 'delete_message');
|
215
|
+
else
|
216
|
+
window.location.reload(true);
|
217
|
+
}
|
218
|
+
});
|
219
|
+
}
|
220
|
+
|
221
|
+
function array_unique(a)
|
222
|
+
{
|
223
|
+
b = [];
|
224
|
+
$.each(a, function(i, x) {
|
225
|
+
var e = false;
|
226
|
+
$.each(b, function(j, y) { if (x == y) { e = true; return; }});
|
227
|
+
if (!e) b[b.length] = x;
|
228
|
+
});
|
229
|
+
return b;
|
230
|
+
}
|
231
|
+
|
232
|
+
</script>
|
233
|
+
<% end %>
|