johnrees/fablabs

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

Summary

Maintainability
Test Coverage
-# cache ["v1", Machine.last_updated_at] do
- title "Machines"
.no-cache
  .subnavbar.border-bottom
    .container
      .row
        .col-md-3.border-right.py-4
          .title Machines

        .col-md-6.border-right.py-4.d-flex.justify-content-start
          .title
            = icon('tags')
            Tags:
            %ul.taglist.list-unstyled.text-small.list-inline.mt-2
              - @machines.each do |machine|
                - if machine.tags.length > 0
                  - machine.tags.each do |tag|
                    %li.gray.list-inline-item.mb-0
                      = link_to "##{tag}", machines_path(tag: tag.name)

        .col-md-3.py-4
          - if current_user && current_user.created_at < 1.months.ago
            = link_to new_machine_path, class: "btn btn-primary" do
              = icon "plus", t(".add_a_machine", default: "Add a new Machine")
          - else
            Active users can add new machines.

  .container
    - if params[:tag].present?
      .row.machines
        = render @machines.tagged_with(params[:tag])
      .row
        = paginate @machines.tagged_with(params[:tag]), theme: 'twitter-bootstrap-4', nav_class: "m-auto pt-3"
    - else
      .row.machines
        = render @machines
      .row
        = paginate @machines, theme: 'twitter-bootstrap-4', nav_class: "m-auto pt-3"