Skip to content

Commit

Permalink
Merge pull request #3531 from fecgov/feature/3463-update-f3x-to-f24
Browse files Browse the repository at this point in the history
Update F3X to F24 when 24- and 48-Hour Reports selected
  • Loading branch information
lbeaufort authored Feb 13, 2020
2 parents f5c69b2 + ad8383c commit b2797d5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fec/data/templates/macros/filters/ie-reports.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% macro type(id_suffix) %}
<fieldset class="filter toggles toggles--vertical js-filter" data-filter="toggle" data-remove-on-switch="true" id="is_notice-toggle{{id_suffix}}">
<fieldset class="toggles toggles--vertical js-filter" data-filter="toggle" data-remove-on-switch="true" id="is_notice-toggle{{id_suffix}}">
<legend class="label t-inline-block u-float-left">Report type</legend>
<div class="tooltip__container">
<button class="tooltip__trigger" type="button" aria-controls="data-type-tooltip"><span class="u-visually-hidden">Learn more</span></button>
Expand All @@ -24,7 +24,7 @@
{% macro form(id_suffix) %}
<div class="filter">
<fieldset class="filter js-filter" data-filter="checkbox">
<legend class="label">Regularly scheduled report form</legend>
<legend class="label">Report form</legend>
<ul>
<li>
<input id="filing-form-f3x{{id_suffix}}" name="filing_form" type="checkbox" value="F3X">
Expand Down
10 changes: 10 additions & 0 deletions fec/fec/static/js/modules/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,16 @@ DataTable.prototype.fetch = function(data, callback) {
);
return;
}

// If 24- and 48-Hour report is selected, set the filing form to F24.
// Otherwise, it's a regularly scheduled report, keep the filing
// form as F3X
if (self.filters && self.filters.filing_form) {
var F3X_index = self.filters.filing_form.indexOf('F3X');
if (self.filters.is_notice == 'true' && F3X_index > -1) {
self.filters.filing_form[F3X_index] = 'F24';
}
}
}

var url = self.buildUrl(data);
Expand Down
30 changes: 30 additions & 0 deletions fec/fec/tests/js/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,4 +550,34 @@ describe('data table', function() {
).to.be.above(0);
});
});

describe('Update to F24', function() {
beforeEach(function() {
this.table.xhr = null;
$('body').append(
'<div id="is_notice-toggle_processed"><ul class="dropdown__selected"></ul><input id="filing-form-f3x_processed" /></div>'
);
});

it('filing form updates to F24 when is_notice is true', function() {
var serialized = {
is_notice: 'true',
filing_form: ['F3X']
};
this.table.filterSet = {
serialize: function() {
return serialized;
},
fields: ['is_notice', 'filing_form']
};
this.table.filterSet.isValid = true;
var callback = sinon.stub();
this.table.fetch({}, callback);
expect(this.table.filters).to.deep.equal(serialized);
expect(
this.table.filters.filing_form,
'Expected filing form to be F24'
).to.deep.equal(['F24']);
});
});
});

0 comments on commit b2797d5

Please sign in to comment.