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.43 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.42 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.41 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.40 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.39 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.38 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.37 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.36 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.35 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.34 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.33 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.32 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.31 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.30 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.29 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.28 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.27 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.26 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.25 app/views/caboose_store/products/admin_edit_categories.html.erb
caboose-store-0.0.24 app/views/caboose_store/products/admin_edit_categories.html.erb