Sha256: 04d3b2d7ba8ec2c8e5f4a9ad4cbdac262d179d336f7b3033a0f8b8cd5aa9aa97

Contents?: true

Size: 1.85 KB

Versions: 33

Compression:

Stored size: 1.85 KB

Contents

<%
p = @product
%>
<%= render :partial => 'caboose_store/products/admin_header' %>

<div id='categories'>
<table>
  <tr>
    <% @top_categories.each do |cat| %>
      <% next if cat.children && cat.children.count > 0 %>
      <td valign='top'><%= raw category_checkboxes([cat], @selected_ids) %></td>
    <% end %>
  </tr>
  <tr>
    <% @top_categories.each do |cat| %>
      <% next if cat.children.nil? || cat.children.count == 0 %>
      <td valign='top'><%= raw category_checkboxes([cat], @selected_ids) %></td>
    <% end %>
  </tr>
</table>
</div>

<%= render :partial => 'caboose_store/products/admin_footer' %>

<% content_for :caboose_css do %>
<style type='text/css'>
#categories input[type='checkbox'] { position: relative; }
#categories ul { list-style: none; margin: 0; padding: 0; }
#categories ul ul ul { margin-left: 20px; }
#categories li { list-style: none; }
#categories h3 { margin: 0; padding: 0; font-weight: bold; display: inline; }
#categories td { padding: 10px; }
</style>
<% end %>
<% content_for :caboose_js do %>
<script type='text/javascript'>

$(document).ready(function() {
  $('#categories input').click(function() {
    var cat_id = $(this).attr('id').split('_')[1];
    if ($(this).is(':checked'))
      add_product_to_category(<%= p.id %>, cat_id);
    else
      remove_product_from_category(<%= p.id %>, cat_id);        
  });  
});

var modal = false;
$(window).load(function() {
  modal = new CabooseModal(800);
});

function add_product_to_category(product_id, cat_id)
{
  $.ajax({
    url: '/admin/products/' + product_id + '/categories',
    type: 'post',
    data: { category_id: cat_id },
    success: function(resp) {}
  });
}

function remove_product_from_category(product_id, cat_id)
{
  $.ajax({
    url: '/admin/products/' + product_id + '/categories/' + cat_id,
    type: 'delete',
    success: function(resp) {}
  });
}

</script>
<% end %>

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
caboose-store-0.0.23 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.22 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.21 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.20 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.19 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.18 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.17 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.16 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.15 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.14 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.13 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.12 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.11 app/views/caboose_store/products/admin_edit_categories.html.erb