saasbook/esaas-engagements

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

Summary

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

.page-header
  %h1
    Listing Apps
    = link_to new_app_path, :class => 'btn btn-success pull-right m-3' do 
      New App
      %i.fas.fa-pencil-alt
  .help-block Click an App name to see more information

  - content_for :filters do
    - $filters = ""
    = form_tag "/", :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
  - ["10","50","100","All"].each do |num_per_page|
    - if @each_page == @page_dict[num_per_page] then
      %li{:class=>'each_page active'}
        %a{:class=>"page-link", :href=>"?app_each_page=#{num_per_page}" + $filters}=num_per_page
    - else
      %li{:class=>'each_page'}
        %a{:class=>"page-link", :href=>"?app_each_page=#{num_per_page}" + $filters}=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=>"?app_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=>"?app_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=>"?app_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 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
            = link_to app.name, app
          %td
            = link_to app.org.name, app.org
          %td
            = sanitize app.description
          %td{style: 'white-space: nowrap'}
            = link_to edit_app_path(app), :title => "Last update: #{app.updated_at.strftime('%c')}", :class => 'btn btn-sm btn-dark m-1' do
              Edit
              %i.far.fa-edit
            = link_to app, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-sm btn-danger m-1' do
              Delete
              %i.far.fa-trash-alt