From 6ead42b2c70fd018c67a8a49c8a1f58d5ff8e2b8 Mon Sep 17 00:00:00 2001 From: Brandon Nicholls Date: Tue, 15 Dec 2015 20:57:58 -0700 Subject: [PATCH] Improved accuracy of the admin status filter --- CHANGELOG.md | 1 + .../Admin/DisclosureFilterByStatus.jsx | 80 +++++++++---------- client/scripts/stores/AdminStore.js | 8 +- server/db/DisclosureDB.js | 16 ++-- 4 files changed, 54 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dd2155c..1f6315ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ V1.0.3 * Fixed bugs with the next step button not enabling/disabling at the correct times * Now shows the revised date (and labels it as such) on the admin list view for revised disclosures. Un-revised disclosures still show the submitted date. +* Improved accuracy of the admin status filter V1.0.2 diff --git a/client/scripts/components/Admin/DisclosureFilterByStatus.jsx b/client/scripts/components/Admin/DisclosureFilterByStatus.jsx index 09365055..58f2ad2d 100644 --- a/client/scripts/components/Admin/DisclosureFilterByStatus.jsx +++ b/client/scripts/components/Admin/DisclosureFilterByStatus.jsx @@ -21,6 +21,8 @@ import {GreyButton} from '../GreyButton'; import {AdminActions} from '../../actions/AdminActions'; import DisclosureFilter from './DisclosureFilter'; import DoneWithFilterButton from './DoneWithFilterButton'; +import {COIConstants} from '../../../../COIConstants'; +const APPROVED = COIConstants.DISCLOSURE_STATUS.UP_TO_DATE; import {merge} from '../../merge'; export class DisclosureFilterByStatus extends DisclosureFilter { @@ -40,16 +42,13 @@ export class DisclosureFilterByStatus extends DisclosureFilter { toggleFilter(evt) { const code = Number(evt.target.id.replace('statFilt', '')); - const theStatus = this.props.possibleStatuses.find(status => { - return status.code === code; - }); + const theStatus = this.props.possibleStatuses + .find(status => status.code === code); AdminActions.toggleStatusFilter(theStatus); } isChecked(value) { - return this.props.activeFilters.find(filter => { - return filter === value; - }) !== undefined; + return this.props.activeFilters.some(filter => filter === value); } // render() is implemented in DisclosureFilter, which will call renderFilter @@ -86,41 +85,40 @@ export class DisclosureFilterByStatus extends DisclosureFilter { } }; - const options = this.props.possibleStatuses.filter(status => { - return status.code !== 3; - }).sort((a, b) => { - return a.label.localeCompare(b.label); - }).map((status) => { - const id = `statFilt${status.code}`; - return ( -
- - -
- ); - }); - - const approved = this.props.possibleStatuses.filter(status => { - return status.code === 3; - }).map(status => { - const id = `statFilt${status.code}`; - return ( -
- - -
- ); - }); + const options = this.props.possibleStatuses + .filter(status => status.code !== APPROVED) + .sort((a, b) => a.label.localeCompare(b.label)) + .map((status) => { + const id = `statFilt${status.code}`; + return ( +
+ + +
+ ); + }); + + const approved = this.props.possibleStatuses + .filter(status => status.code === APPROVED) + .map(status => { + const id = `statFilt${status.code}`; + return ( +
+ + +
+ ); + }); return (
diff --git a/client/scripts/stores/AdminStore.js b/client/scripts/stores/AdminStore.js index 0a396f58..8b50359c 100644 --- a/client/scripts/stores/AdminStore.js +++ b/client/scripts/stores/AdminStore.js @@ -25,6 +25,10 @@ import ConfigActions from '../actions/ConfigActions'; const PAGE_SIZE = 40; +function defaultStatusFilters() { + return [2, 4, 5, 6]; +} + class _AdminStore extends AutoBindingStore { constructor() { super(AdminActions); @@ -38,7 +42,7 @@ class _AdminStore extends AutoBindingStore { end: undefined }, submittedBy: undefined, - status: [2, 4, 5, 6], + status: defaultStatusFilters(), type: [], search: '' }, @@ -267,7 +271,7 @@ class _AdminStore extends AutoBindingStore { } clearStatusFilter() { - this.applicationState.filters.status = []; + this.applicationState.filters.status = defaultStatusFilters(); this.refreshDisclosures(); } diff --git a/server/db/DisclosureDB.js b/server/db/DisclosureDB.js index b1207b83..0a2fdf52 100644 --- a/server/db/DisclosureDB.js +++ b/server/db/DisclosureDB.js @@ -723,12 +723,12 @@ export const getSummariesForReviewCount = (dbInfo, filters) => { }); } } - if (filters.status && filters.status.length > 0) { + if (filters.status) { query.whereIn('disclosure.status_cd', filters.status); } - if (filters.type && filters.type.length > 0) { - query.whereIn('disclosure_type.description', filters.type); - } + // if (filters.type) { + // query.whereIn('disclosure_type.description', filters.type); + // } if (filters.submittedBy) { query.where('submitted_by', filters.submittedBy); } @@ -788,12 +788,12 @@ export const getSummariesForReview = (dbInfo, sortColumn, sortDirection, start, }); } } - if (filters.status && filters.status.length > 0) { + if (filters.status) { query.whereIn('disclosure.status_cd', filters.status); } - if (filters.type && filters.type.length > 0) { - query.whereIn('disclosure_type.description', filters.type); - } + // if (filters.type) { + // query.whereIn('disclosure_type.description', filters.type); + // } if (filters.submittedBy) { query.where('submitted_by', filters.submittedBy); }