<%= title l(:field_category) %>
<div class="wk-contextual" style="float: right;">
	<%= render :partial => 'sidebar' %>
</div>
<%= render partial: "wkproduct/render_inventory_tabs" %>
<%= form_tag({:controller => "wkproduct", :action => 'updateCategory', :tab => 'wkproduct'}, :method => :get, :id => 'query_form') do %>
<table class="list" id="commit-keywords">
  <thead>
    <tr>
	  <th></th>
      <th><%= l(:field_name) %></th>
      <th><%= l(:field_description) %></th>
      <th class="buttons"></th>
    </tr>
  </thead>
  <tbody>
	<% unless @productEntries.blank? %>
		<% @productEntries.each do |entry| %>
			<tr class="commit-keywords">
				<td>
					<%= hidden_field_tag "category_id[]",  entry.id  %>
				</td>
			   <td>
				<%= text_field_tag("name[]", entry.name, :id => nil, :style => "width:200px;", :required => true) %>
			  </td>
			   <td>
				<%= text_field_tag("description[]", entry.description, :id => nil, :style => "width:500px;", :maxlength => 255, :required => false) %>
			  </td>

			  <td class="buttons">
			    <% if controller.hasDeletePermission %>
				<%= link_to(l(:button_delete), '#',
							:class => 'delete-commit-keywords icon-only icon-del',
							:title => l(:button_delete)) %>
				<% end %>
			  </td>
			</tr>
		<% end %>
	<% else %>
		<tr class="commit-keywords">
		<td>
			<%= hidden_field_tag "category_id[]",  ""  %>
		</td>
			   <td>
				<%= text_field_tag("name[]", '', :id => nil, :style => "width:200px;", :required => true) %>
			  </td>
			   <td>
				<%= text_area_tag("description[]", '', :id => nil, :style => "width:200px;", :required => false) %>
			  </td>
		<td class="buttons">
				<%= link_to(l(:button_delete), '#',
							:class => 'delete-commit-keywords icon-only icon-del',
							:title => l(:button_delete)) %>
			  </td>
		</tr>
	<% end %>
    <tr>
	  <td></td>
      <td></td>
      <td></td>
      <td class="buttons">
        <%= link_to(l(:button_add), '#',
                    :class => 'add-commit-keywords icon-only icon-add',
                    :title => l(:button_add)) %>
      </td>
    </tr>
  </tbody>
</table>
<span class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></span>
<p><%= submit_tag l(:button_save) %></p>
<% end %>

<%= javascript_tag do %>
$('#commit-keywords').on('click', 'a.delete-commit-keywords', function(e){
  e.preventDefault();
  if ($('#commit-keywords tbody tr.commit-keywords').length > 1) {
    $(this).parents('#commit-keywords tr').remove();
  } else {
    $('#commit-keywords tbody tr.commit-keywords').find('input, select').val('');
  }
});
$('#commit-keywords').on('click', 'a.add-commit-keywords', function(e){
  e.preventDefault();
  var row = $('#commit-keywords tr.commit-keywords:last');
  row.clone().insertAfter(row).find('input, select').val('');
});
<% end %>
