pushtype/push_type

View on GitHub
admin/app/views/push_type/fields/_repeater.html.haml

Summary

Maintainability
Test Coverage
%repeater-field{ :':row-count' => field.rows.size, :'inline-template' => true }
  .repeater-field
    %table
      %tbody.rows
        // Static existing rows
        - field.rows.each do |row|
          = f.fields_for field.name, row do |r|
            %tr
              %td= render_field row.f, r, name: "#{ f.object_name }[#{ field.name }][]", id: nil
              %td.remove
                %a.alert{ :'v-remove-row' => true }= ficon(:x)
        
        // Dynamic rows
        = f.fields_for field.name, field.structure do |r|
          %tr{ :'v-for' => 'row in rows', :'track-by' => 'id' }
            %td= render_field field.structure.f, r, name: "#{ f.object_name }[#{ field.name }][]", id: nil
            %td.remove
              %a.alert{ :'v-on:click.prevent' => 'removeRow(row)' }= ficon(:x)

    .plus
      %a.button.success.tiny.radius{ :'v-on:click.prevent' => 'addRow()' }
        = ficon :plus, 'Add row'