Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update F3X to F24 when 24- and 48-Hour Reports selected #3531

Merged
merged 4 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
patphongs marked this conversation as resolved.
Show resolved Hide resolved
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']);
});
});
});