diff --git a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js index f0c2d3626..73fa30149 100644 --- a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js +++ b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import isString from 'Utilities/String/isString'; -import { IN_LAST, IN_NEXT } from 'Helpers/Props/filterTypes'; +import { IN_LAST, NOT_IN_LAST, IN_NEXT, NOT_IN_NEXT } from 'Helpers/Props/filterTypes'; import NumberInput from 'Components/Form/NumberInput'; import SelectInput from 'Components/Form/SelectInput'; import TextInput from 'Components/Form/TextInput'; @@ -18,7 +18,12 @@ const timeOptions = [ ]; function isInFilter(filterType) { - return filterType === IN_LAST || filterType === IN_NEXT; + return ( + filterType === IN_LAST || + filterType === NOT_IN_LAST || + filterType === IN_NEXT || + filterType === NOT_IN_NEXT + ); } class DateFilterBuilderRowValue extends Component { diff --git a/frontend/src/Helpers/Props/filterBuilderTypes.js b/frontend/src/Helpers/Props/filterBuilderTypes.js index 72722ab63..776ba2afc 100644 --- a/frontend/src/Helpers/Props/filterBuilderTypes.js +++ b/frontend/src/Helpers/Props/filterBuilderTypes.js @@ -24,7 +24,9 @@ export const possibleFilterTypes = { { key: filterTypes.LESS_THAN, value: 'is before' }, { key: filterTypes.GREATER_THAN, value: 'is after' }, { key: filterTypes.IN_LAST, value: 'in the last' }, - { key: filterTypes.IN_NEXT, value: 'in the next' } + { key: filterTypes.NOT_IN_LAST, value: 'not in the last' }, + { key: filterTypes.IN_NEXT, value: 'in the next' }, + { key: filterTypes.NOT_IN_NEXT, value: 'not in the next' } ], [EXACT]: [ diff --git a/frontend/src/Helpers/Props/filterTypes.js b/frontend/src/Helpers/Props/filterTypes.js index 77809b8ce..993e8df57 100644 --- a/frontend/src/Helpers/Props/filterTypes.js +++ b/frontend/src/Helpers/Props/filterTypes.js @@ -3,7 +3,9 @@ export const EQUAL = 'equal'; export const GREATER_THAN = 'greaterThan'; export const GREATER_THAN_OR_EQUAL = 'greaterThanOrEqual'; export const IN_LAST = 'inLast'; +export const NOT_IN_LAST = 'notInLast'; export const IN_NEXT = 'inNext'; +export const NOT_IN_NEXT = 'notInNext'; export const LESS_THAN = 'lessThan'; export const LESS_THAN_OR_EQUAL = 'lessThanOrEqual'; export const NOT_CONTAINS = 'notContains'; @@ -17,5 +19,9 @@ export const all = [ LESS_THAN, LESS_THAN_OR_EQUAL, NOT_CONTAINS, - NOT_EQUAL + NOT_EQUAL, + IN_LAST, + NOT_IN_LAST, + IN_NEXT, + NOT_IN_NEXT ]; diff --git a/frontend/src/Utilities/Date/dateFilterPredicate.js b/frontend/src/Utilities/Date/dateFilterPredicate.js index 2c74f435a..3d1d719ea 100644 --- a/frontend/src/Utilities/Date/dateFilterPredicate.js +++ b/frontend/src/Utilities/Date/dateFilterPredicate.js @@ -21,12 +21,22 @@ export default function(itemValue, filterValue, type) { isBefore(itemValue) ); + case filterTypes.NOT_IN_LAST: + return ( + isBefore(itemValue, { [filterValue.time]: filterValue.value * -1 }) + ); + case filterTypes.IN_NEXT: return ( isAfter(itemValue) && isBefore(itemValue, { [filterValue.time]: filterValue.value }) ); + case filterTypes.NOT_IN_NEXT: + return ( + isAfter(itemValue, { [filterValue.time]: filterValue.value }) + ); + default: return false; }