anthonymidili/EasyKeep

View on GitHub
app/views/inventory_items/index.html.haml

Summary

Maintainability
Test Coverage
- provide(:title, 'Inventory Items')

.row
  .small-12.columns
    .pad-top
      %ul.inline-list
        %li= link_to 'New Inventory Item', new_inventory_item_path, class: 'small button radius'
        - if params[:tag]
          %li= link_to 'Clear Search', inventory_items_path, class: 'small button radius alert'

    #tag_cloud
      - tag_cloud current_company.tag_counts, %w[s m l] do |tag, css_class|
        = link_to tag.name, tag_path(tag.name), class: css_class

    %h1.main_page_header= "#{current_company.name} Inventory Items"

    .scroll_overflow-x
      %table
        %thead
          %tr
            %th Description
            %th Quantity
            %th Serial number
            %th Tags
            %th Edit
            %th Destroy

        %tbody
          - @inventory_items.each do |inventory_item|
            %tr
              %td= link_to inventory_item.description, inventory_item_path(inventory_item)
              %td= sprintf('%g' % inventory_item.quantity)
              %td= inventory_item.serial_number
              %td= raw inventory_item.tags.map(&:name).map { |t| link_to t, tag_path(t) }.join(', ')
              %td.center_cell
                = link_to edit_inventory_item_path(inventory_item) do
                  %i.fas.fa-edit
              %td.center_cell
                = link_to inventory_item, class: 'red_link', method: :delete,
                data: { confirm: t(:confirm_delete_inventory_item) } do
                  %i.fas.fa-trash

    = paginate @inventory_items