SUSE/hackweek

View on GitHub
app/views/projects/_index.html.haml

Summary

Maintainability
Test Coverage
- content_for :title do
  = action_name.humanize unless action_name === "index"
  Projects
  = "(#{@projects.length})"

.row
  .col-sm-12
    - if @keyword
      .row
        .col-sm-2
          - if @keyword.avatar.attached?
            = image_tag(url_for(@keyword.avatar), width: '150', class: 'img-responsive center-block')
          - else
            %img{"data-src": "holder.js/150x150?text=#{@keyword.name}", class: 'center-block'}
        .col-sm-10
          %h1
            Projects in the topic #{@keyword.name}
            =link_to edit_keyword_path(@keyword.name) do
              %i{title: 'Edit topic', class: 'fas fa-pencil-alt fa-xs', style: "font-size: 1.5rem;"}
            %br
            %small
              = @keyword.description
      .row
        %hr
    = render :partial => "projects/tabs" unless @keyword
    .tab-content{style: 'padding-top: 10px;'}
      - if @projects.length > 0
        .tab-pane.active
          .row.project-list-pills{style: 'padding-bottom: 10px;'}
            .col-sm-6
              %ul.nav.nav-pills
                %li{role: 'presentation'}
                  = link_to 'Per Page:', '#', style: 'pointer-events: none; cursor: default;', class: 'text-muted'
                %li{role: 'presentation', class: active_page_size(10, params[:page_size])}
                  = link_to '10', :page_size => '10', :episode => params[:episode], :remote => true
                %li{role: 'presentation', class: active_page_size(50, params[:page_size])}
                  = link_to '50', :page_size => '50', :episode => params[:episode], :remote => true
                %li{role: 'presentation', class: active_page_size(100, params[:page_size])}
                  = link_to '100', :page_size => '100', :episode => params[:episode], :remote => true
                %li{role: 'presentation', class: active_page_size(@projects.total_count, params[:page_size])}
                  = link_to 'All', :page_size => @projects.total_count, :episode => params[:episode], :remote => true
            .col-sm-6
              %ul.nav.nav-pills.pull-right
                %li{role: "presentation"}
                  = link_to 'Type:', '#', style: 'pointer-events: none; cursor: default;', class: 'text-muted'
                %li.active#all-pill
                  %a{:href =>'#', :id=>'all', :title=> 'Show everything'}
                    All
                %li#ideas-pill
                  %a{:href =>'#', :id=>'ideas', :title => 'Show only projects nobody is working on'}
                    %i.fas.fa-lightbulb
                    Ideas
                %li#projects-pill
                  %a{:href =>'#', :id=>'projects', :title => 'Show only projects people are working on'}
                    %i.fas.fa-puzzle-piece
                    Projects
          .row
            .col-sm-12
              %table.table.project-style#project_table
                %thead
                - @projects.each_with_index do |project, index|
                  %tr
                    %td{:class => "#{project.aasm_state}"}
                      = render :partial => "projects/list_item", :locals => {:project => project, :index => index }
          .row
            .col-md-12
              .text-center
                = paginate @projects, :remote => true
      - else
        %h3
          No projects.
          - unless action_name == :finished or :archived
            How about you
            = link_to "add one!", new_project_path