openaustralia/publicwhip

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

Summary

Maintainability
Test Coverage
- content_for :title, @house ? members_type(@house) : members_type("all")
- set_meta_tags description: "A list of the people who vote on your behalf in Parliament."

- content_for :header do
  .section-header.clearfix
    .page-header.container
      %h1= yield :title
      %p.lead
        The people who vote on your behalf in Parliament

.list-filters.clearfix
  %nav.list-house-switcher.btn-group
    = nav_button_link("All", {house: nil, sort: @sort}, members_type_long("all"), @house.nil?)
    = nav_button_link("Representatives", {house: "representatives", sort: @sort}, members_type_long("representatives"), @house == "representatives")
    = nav_button_link("Senate", {house: "senate", sort: @sort}, members_type_long("senate"), @house == 'senate')

  .list-sorter.dropdown
    %button.btn.btn-sm.btn-default.dropdown-toggle{type: "button", id: "dropdownMenu1", data: {toggle: "dropdown"}}
      - if @sort.nil?
        Sorted by Name
      - elsif @sort == "constituency"
        Sorted by
        = electorate_label(@house)
      - elsif @sort == "party"
        Sorted by Party
      - elsif @sort == "rebellions"
        Sorted by Rebellions
      - elsif @sort == "attendance"
        Sorted by Attendance
      %span.caret

    %ul.dropdown-menu{role: "menu", "aria-labelledby" => "dropdownMenu1"}
      %li{role: "presentation", class: "#{'disabled' if @sort.nil?}"}
        = link_to "Name", {sort: nil, house: @house}, role: "menuitem", tabindex: "-1"
      %li{role: "presentation", class: "#{'disabled' if @sort == 'constituency'}"}
        = link_to electorate_label(@house), {sort: "constituency", house: @house}, role: "menuitem", tabindex: "-1"
      %li{role: "presentation", class: "#{'disabled' if @sort == 'party'}"}
        = link_to "Party", {sort: "party", house: @house}, role: "menuitem", tabindex: "-1"
      %li{role: "presentation", class: "#{'disabled' if @sort == 'rebellions'}"}
        = link_to "Rebellions", {sort: "rebellions", house: @house}, role: "menuitem", tabindex: "-1"
      %li{role: "presentation", class: "#{'disabled' if @sort == 'attendance'}"}
        = link_to "Attendance", {sort: "attendance", house: @house}, role: "menuitem", tabindex: "-1"

= render "people", people: @people, house: @house