<commit_before>:css
  #items_table .input{
    margin: 2px 0px;
  }

= simple_form_for(@inventory_operation) do |f|
  = bonsai_form_error(f)
  .main.bg_light_grey
    .input
      = f.input :ref_number, :input_html => {:size => 20}
      = f.input :date

    = f.association :contact, :collection => @inventory_operation.get_contact_list, :label => @inventory_operation.contact_label
    .clear

  = f.input :description, :as => :text, :input_html => {:rows => 4, :cols => 40}
  .clear

  %table.decorated#items_table
    %tr
      %th Item
      %th Cantidad
      - if @inventory_operation.operation == "in"
        %th Costo<br/>unitario 
      %th Inventario
      %th

    - @items = Item.inventory
    - f.simple_fields_for :inventory_operation_details do |fd|
      %tr.item
        %td.cur
          = fd.input :item_id, :label => false, :collection => @items, :input_html => {:class => 'item', 'data-new_url' => new_item_path(:scope => 'inventory'), 'data-title' => 'Nuevo producto/servicio', 'data-trigger' => 'new_client'}
        %td= fd.input :quantity, :label => false, :input_html => { :size => 8, :class => 'quantity', :type => 'decimal' }

        - if @inventory_operation.operation == "in"
          %td= fd.input :unitary_cost, :label => false, :input_html => { :size => 8, :class => 'unitary_cost', :type => 'decimal' }

        %td.cur.inventory
        %td.del <a href="javascript:" class="destroy" title="Borrar">&nbsp;</a>
  %p
    <a href="javascript:" id="add_item" class="add">Adicionar ítem</a>
  .actions
    = f.submit 'Salvar'

:javascript
  head.ready(function() {
    $('#add_item').live('click', function() {
      var t = (new Date() ).getTime();
      tr = $('#items_table tr.item:first').clone();
      tr.find("input, select").each(function(i, el) {
        var name = $(el).attr("name").replace(/\d+/, t);
        $(el).attr("name", name);
      });
      tr.appendTo("#items_table");
    });
  });<commit_msg>Improving items new_item<commit_after>:css
  #items_table .input{
    margin: 2px 0px;
  }

= simple_form_for(@inventory_operation) do |f|
  = bonsai_form_error(f)
  .main.bg_light_grey
    .input
      = f.input :ref_number, :input_html => {:size => 20}
      = f.input :date

    = f.association :contact, :collection => @inventory_operation.get_contact_list, :label => @inventory_operation.contact_label
    .clear

  = f.input :description, :as => :text, :input_html => {:rows => 4, :cols => 40}
  .clear

  %table.decorated#items_table
    %tr
      %th Item
      %th Cantidad
      - if @inventory_operation.operation == "in"
        %th Costo<br/>unitario 
      %th Inventario
      %th

    - @items = Item.inventory
    - f.simple_fields_for :inventory_operation_details do |fd|
      %tr.item
        %td.cur
          = fd.input :item_id, :label => false, :collection => @items, :input_html => {:class => 'item', 'data-new_url' => new_item_path(:scope => 'inventory'), 'data-title' => 'Nuevo producto/servicio', 'data-trigger' => 'new_item'}
        %td= fd.input :quantity, :label => false, :input_html => { :size => 8, :class => 'quantity', :type => 'decimal' }

        - if @inventory_operation.operation == "in"
          %td= fd.input :unitary_cost, :label => false, :input_html => { :size => 8, :class => 'unitary_cost', :type => 'decimal' }

        %td.cur.inventory
        %td.del <a href="javascript:" class="destroy" title="Borrar">&nbsp;</a>
  %p
    <a href="javascript:" id="add_item" class="add">Adicionar ítem</a>
  .actions
    = f.submit 'Salvar'

:javascript
  head.ready(function() {
    $('#add_item').live('click', function() {
      var t = (new Date() ).getTime();
      tr = $('#items_table tr.item:first').clone();
      tr.find("input, select").each(function(i, el) {
        var name = $(el).attr("name").replace(/\d+/, t);
        $(el).attr("name", name);
      });
      tr.appendTo("#items_table");
    });

    // Remember the row for the clicked new item
    $('#items_table a.add').live(click, function() {
      $('#items_table').data('row', $(this).parents('tr:first') );
    });

    // Delete an item from an inventory
    $('#items_table a.destroy').live('click', function() {
      if( $('tr.item').length <= 1 ) {
        alert("Debe existir al menos un ítem");
        return false;
      }else{
        $(this).parents('tr:first').remove();
      }
    });

    // new_item trigger
    $('body').live('new_item', function(e, resp) {
      var tr = $('#items_table').data('row');
      $('#items_table select').each(function(i, el) {

        $(el).append([ '<option value="', el.id ,'">', el.name , '</option>' ].join("") );
      });
    });
  });
{'fraction_non_alphanumeric': 0.1947605754777754, 'fraction_numerical': 0.0040798797509126045, 'mean_word_length': 2.9541595925297113, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4034066', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1584, 'n_words': 333}