saasbook/esaas-engagements

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

Summary

Maintainability
Test Coverage
!!!
%html
  %head
    = stylesheet_link_tag "apps"

#notifications
  - unless current_user.student?
    = render 'notification'

.page-header
  %h1
    My Projects
  .help-block Click an App name to see more information

  - content_for :filters do
    - $filters = ""
    = form_tag "/my_projects", :method => :get do
      %div#deploy
        %strong Deployment Status:
        %em #{" (" + @total_deploy.to_s + ")"}
        %br
        .checkbox-inline
          - App.getAllDeploymentStatuses.each do |status|
            - if @deployment_statuses.key? status
              - $filters = $filters + "&" + status.to_s + "=1"
              = check_box_tag status, 1, true, :class => 'filter'
            - else
              = check_box_tag status, 1, false, :class => 'no_filter'
            = label_tag status do
              %span{:class => status}
                = status.to_s.humanize
            %em (#{@deployment_map[status.to_s].to_i})
            %br
      %br
      %div#vetting
        %strong Vetting Status:
        %em #{" (" + @total_vet.to_s + ")"}
        %br
        .checkbox-inline
          - App.getAllVettingStatuses.each do |status|
            - if @vetting_statuses.key? status
              - $filters = $filters + "&" + status.to_s + "=1"
              = check_box_tag status, 1, true, :class => 'filter'
            - else
              = check_box_tag status, 1, false, :class => 'no_filter'
            = label_tag status do
              %span{:class => status}
                = status.to_s.humanize
            %em (#{@vetting_map[status.to_s].to_i})
            %br
        %br
        = submit_tag 'Apply Filters', :class => "btn btn-dark btn-sm mt-2"
        #{@filtered_count.to_s + ' results'}

%ul{:class => 'pagination'}
  %li{:class=>'each_page'} 
    %a{:class=>"page_link"} Apps per page
  - %w(10 50 100 All).each do |num_per_page|
    - if @each_page == @page_dict[num_per_page]
      %li{:class=>'each_page active'} 
        %a{:class=>"page-link", :href=>"?myprojects_each_page=#{num_per_page}"}=num_per_page
    - else
      %li{:class=>'each_page'}
        %a{:class=>"page-link", :href=>"?myprojects_each_page=#{num_per_page}"}=num_per_page

%ul{:class => 'pagination pull-right'}
  - ["First","Previous","Current","Next","Last"].each do |action|
    - if action == "First" || action == "Last" then
      %li{:class=>'page_num'}
        %a{:class=>"page-link", :href=>"?myprojects_page_action=#{action}&prev=#{@page_num}" + $filters}=action
    - elsif action == "Previous" then
      - unless @page_num <= 1 then 
        %li{:class=>'page_num'}
          %a{:class=>"page-link", :href=>"?myprojects_page_action=#{action}&prev=#{@page_num}" + $filters} #{@page_num-1}
    - elsif action == "Next" then
      - unless @page_num >= @max_page_num then
        %li{:class=>'page_num'}
          %a{:class=>"page-link", :href=>"?myprojects_page_action=#{action}&prev=#{@page_num}" + $filters} #{@page_num+1}
    - else
      %li{:class=>"page-num active"}
        %a{:class=>'page_link'} #{[1,@page_num].max}

%table.table.table-condensed#apps_table
  %thead
    %tr
      %th ID
      %th Name
      %th Organization
      %th Description
      %th
  %tbody
    - @apps.each do |app|
      - if @deployment_statuses.key? app.status.to_sym
        %tr{:class => [app.status.to_s]}
          %td
            = app.id
          %td
            = link_to app.name, app_path(app.id)
          %td
            = link_to app.org.name, app.org
          %td
            = sanitize app.description
            %br
            - app.engagements.each do |engagement|
              %span #{engagement.id} (#{engagement.team_number}): #{engagement.student_names}
              %br
          %td{style: 'white-space: nowrap'}
            - if current_user.coach? || current_user.client?
              = link_to ApplicationHelper.edit_request_button_text(app), new_my_project_edit_path(app_id: app.id), :class => 'btn btn-primary'