ujh/fountainpencompanion

View on GitHub
app/views/admins/pens/model_variants/index.html.slim

Summary

Maintainability
Test Coverage
= form_tag admins_pens_model_variants_path, method: :get do
  div class="row"
    div class="col-sm-3"
      label for="search" class="visually-hidden"
        | Search for inks
      div.input-group.mb-3
        = text_field_tag :q, params[:q], placeholder: "Search", class: 'form-control', id: 'search'

div class="fpc-table fpc-table--full-width fpc-scroll-shadow"
  = paginate @clusters
  table class="table table-striped"
    thead
      tr
        th
        th Brand
        th Model
        th Color
        th Material
        th Trim Color
        th Filling System
        th
    tbody
      - @clusters.each do |model_variant|
        tr
          td= model_variant.micro_clusters.size
          td= model_variant.brand
          td= model_variant.model
          td= model_variant.color
          td= model_variant.material
          td= model_variant.trim_color
          td= model_variant.filling_system
          td= link_to "Remove",
                      admins_pens_model_variant_path(model_variant),
                      class: "btn btn-sm btn-danger",
                      method: :delete
        - if model_variant.micro_clusters.size > 1
          tr
            td
            td colspan="8"
              table class="table"
                - model_variant.micro_clusters.each do |mc|
                  tr class="pens-admin-micro-cluster-row"
                    td= mc.simplified_brand
                    td= mc.simplified_model
                    td= mc.simplified_color
                    td= mc.simplified_material
                    td= mc.simplified_trim_color
                    td= mc.simplified_filling_system
                    td= link_to "Remove",
                                unassign_admins_pens_micro_cluster_path(mc),
                                class: "btn btn-sm btn-danger",
                                method: :delete
  = paginate @clusters