Skip to content

Commit

Permalink
Merge pull request #3551 from fecgov/feature/update-most-recent-logic
Browse files Browse the repository at this point in the history
Conditionally disable current version and add report type toggle to raw
  • Loading branch information
patphongs authored Feb 14, 2020
2 parents b2797d5 + 39fd08e commit 6129164
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fec/data/templates/macros/filters/version-status.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{% macro version(id_suffix, methodology) %}
{% macro version(id_suffix, methodology, helper_text=False) %}
<div class="filter">
<fieldset class="js-filter" data-filter="checkbox">
<fieldset class="js-filter" id="version{{ id_suffix }}" data-filter="checkbox">
<legend class="label">Version</legend>
{% if helper_text %}
<label class="label--help u-margin--top">{{ helper_text }}</label>
{% endif %}
<ul>
<li>
<input id="most_recent_true{{ id_suffix }}" name="most_recent" type="checkbox" value="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Filter independent expenditures
<div class="filters__inner">
{{ typeahead.field('committee_id', 'Spender name or ID', id_suffix='_raw') }}
{{ text.field('candidate_search', 'Candidate mentioned', id_suffix='_raw') }}
{{ reports.type(id_suffix='_raw') }}
{{ reports.form(id_suffix='_raw') }}
{{ version_status.version(id_suffix='_raw', methodology='True') }}
</div>
{# Removing these filters for now until the filter count bug can be fixed #}
Expand Down
25 changes: 25 additions & 0 deletions fec/fec/static/js/modules/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,31 @@ DataTable.prototype.fetch = function(data, callback) {
self.filters.filing_form[F3X_index] = 'F24';
}
}

// Regularly scheduled reports only have current versions
// Therefore, we need to check current version by default
// and disable changes.
if (
self.filters &&
self.filters.data_type == 'processed' &&
self.filters.is_notice == 'false'
) {
self.filters.most_recent = 'true';
$('#most_recent_true_processed').prop('checked', true);
$(
'#version_processed legend, #version_processed li, #version_processed label'
)
.removeClass('is-active-filter')
.addClass('is-disabled-filter');
} else if (
self.filters &&
self.filters.data_type == 'processed' &&
self.filters.is_notice == 'true'
) {
$(
'#version_processed legend, #version_processed li, #version_processed label'
).removeClass('is-disabled-filter');
}
}

var url = self.buildUrl(data);
Expand Down

0 comments on commit 6129164

Please sign in to comment.