Skip to content

Commit

Permalink
Simplify candidate/committee 2-year-select macros
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeaufort committed Aug 29, 2018
1 parent 909c1b1 commit a9c5787
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 23 deletions.
17 changes: 1 addition & 16 deletions fec/data/templates/macros/cycle-select.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,7 @@
{% endif %}
{% endmacro %}

{% macro candidate_cycle_select(cycles, cycle=none, id='') %}
{% set cycle = cycle | int %}
<div class="content__section">
<label for="{{id}}-cycle" class="label cycle-select__label">Election</label>
<select id="{{id}}-cycle" class="js-cycle" name="cycle" data-cycle-location="query" data-election-full="False">
{% for each in cycles | sort(reverse=True) %}
<option
value="{{ each }}"
{% if cycle and cycle <= each and cycle > (each - 2) %}selected{% endif %}
>{{ each }}</option>
{% endfor %}
</select>
</div>
{% endmacro %}

{% macro committee_cycle_select(cycles, cycle=none, id='') %}
{% macro two_year_select(cycles, cycle=none, id='') %}
{% set cycle = cycle | int %}
<div class="row content__section">
<div class="cycle-select">
Expand Down
2 changes: 1 addition & 1 deletion fec/data/templates/partials/candidate/raising.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="slab slab--inline slab--neutral u-padding--left u-padding--right">

{{ select.candidate_cycle_select(cycles, cycle, id="cycle-5") }}
{{ select.two_year_select(cycles, cycle, id="cycle-5") }}

{% if committee_groups['P'] or committee_groups['A']%}
<span class="t-sans t-bold">Data is included from these committees:</span>
Expand Down
2 changes: 1 addition & 1 deletion fec/data/templates/partials/candidate/spending.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div class="slab slab--inline slab--neutral u-padding--left u-padding--right">

{{ select.candidate_cycle_select(cycles, cycle, id="cycle-4") }}
{{ select.two_year_select(cycles, cycle, id="cycle-4") }}

{% if committee_groups['P'] or committee_groups['A']%}
<span class="t-sans t-bold">Data is included from these committees:</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<section id="section-2" role="tabpanel" aria-hidden="true" aria-labelledby="section-2-heading">
<h2 id="section-2-heading">About this committee</h2>
<div class="slab slab--inline slab--neutral u-padding--left u-padding--right">
{{ select.committee_cycle_select(cycles, cycle, 'about')}}
{{ select.two_year_select(cycles, cycle, 'about')}}
<div class="entity__figure row">
<h3 class="heading--section">Committee information</h3>
<table class="t-sans usa-width-three-fourths">
Expand Down
2 changes: 1 addition & 1 deletion fec/data/templates/partials/committee/filings.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Committee filings
</h2>
<div class="slab slab--inline slab--neutral u-padding--left u-padding--right">
{{ select.committee_cycle_select(cycles, cycle, 'filings')}}
{{ select.two_year_select(cycles, cycle, 'filings')}}
{% if has_raw_filings %}
{{ entity.raw_filings_table(cycle, committee_id, min_receipt_date) }}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<section id="section-1" role="tabpanel" aria-hidden="true" aria-labelledby="section-1-heading">
<h2 id="section-1-heading">Financial summary</h2>
<div class="slab slab--inline slab--neutral u-padding--left u-padding--right">
{{ select.committee_cycle_select(cycles, cycle, 'summary')}}
{{ select.two_year_select(cycles, cycle, 'summary')}}
{% if reports and totals %}
{% if committee_type == 'I' %}
<div class="entity__figure">
Expand Down
2 changes: 1 addition & 1 deletion fec/data/templates/partials/committee/raising.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<section id="section-3" role="tabpanel" aria-hidden="true" aria-labelledby="section-3-heading">
<h2 id="section-3-heading">Raising</h2>
<div class="slab slab--inline slab--neutral u-padding--left u-padding--right">
{{ select.committee_cycle_select(cycles, cycle, 'receipts')}}
{{ select.two_year_select(cycles, cycle, 'receipts')}}
{% if totals and committee_type not in ['C', 'E', 'I'] %}
<div id="total-receipts" class="entity__figure row">
<div class="heading--section heading--with-action">
Expand Down
2 changes: 1 addition & 1 deletion fec/data/templates/partials/committee/spending.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<section id="section-4" role="tabpanel" aria-hidden="true" aria-labelledby="section-4-heading">
<h2 id="section-4-heading">Spending</h2>
<div class="slab slab--inline slab--neutral u-padding--left u-padding--right">
{{ select.committee_cycle_select(cycles, cycle, 'disbursements')}}
{{ select.two_year_select(cycles, cycle, 'disbursements')}}

{% if totals and committee_type not in ['C', 'E', 'I'] %}
<div id="total-disbursements" class="entity__figure row">
Expand Down

0 comments on commit a9c5787

Please sign in to comment.