opengovernment/askthem

View on GitHub
app/views/pages/locator.html.erb

Summary

Maintainability
Test Coverage
<nav class="questions-or-officials">
  <ul class="level">
    <%- unless @has_partner %>
      <li<%= raw(' class="active"') if !@only_show || @only_show == "questions" -%>>
        <a href="#" id="questions-near">See Questions Near You</a>
        <i class="icon-angle-down"></i>
      </li>
    <%- end %>
  <li<%= raw(' class="active"') if @only_show && @only_show == "people" -%>>
    <%- elected_text = "See Your Elected Officials" %>

    <%- if @has_partner %>
      <%- elected_text = "#{elected_text} and Candidates" %>
    <%- end %>

    <%- if @governor %>
      <%- elected_text = "#{elected_text} in #{@governor.metadatum.name}" %>
    <%- end %>

    <a href="#" id="officials-near"><%= elected_text -%></a>
    <% if @federal_people && @federal_people.count > 0 -%>
      <%= cdn_image_tag(@federal_people.first.image, size: '30x30', alt: '', class: 'preview-avatar') %>
    <% end -%>
    <i class="icon-angle-down"></i></li>
  <%= generic_ask_question 'Ask a Question', { class: 'cta-pill'} unless @only_show %>
  </ul>
</nav>

<section class="questions locator"<%= raw(' style="display:none;"') if @only_show && @only_show != "questions" -%>>
  <ol class="question-list locator-question-list">
    <%= render @questions if @questions %>

    <% if @questions.blank? %>
      <li>
        <%= render partial: "shared/no_questions" %>
      </li>
    <%- end %>
  </ol>
</section>

<section class="officials locator"<%= raw(' style="display:none;"') if !@only_show || @only_show != "people" -%>>
  <%= render partial: "people_for_location",
    locals: { municipality: @municipality,  municipal_people: @municipal_people,
    federal_people: @federal_people, governor: @governor,
    state_people: @state_people } %>
</section>

<%- if @has_partner %>
  <div class="more-candidates-info">
    <p>Select a politician above to ask the <%= session[:referring_partner_info][:name] -%> question.</p>
    <p>For a full list of candidates you can question, <a href="http://www.participatorypolitics.org/crowdsource-questions-to-candidates-during-election-season/">visit here</a>. For a full list of elected officials, visit our <a href="/map">national map</a>.</p>
    <p>To ask a question to someone you don't see here, just email us and we'll get it asked right away: <%= mail_to("maryam@askthem.io", "maryam -at- askthem.io") -%>.</p>
  </div>
<%- end %>