Skip to content

Commit

Permalink
Add operators to filter summary
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Mar 18, 2024
1 parent c3c2b0d commit 1158623
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/dataviews/src/filter-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
OPERATOR_IS_NOT,
OPERATOR_IS_ANY,
OPERATOR_IS_NONE,
OPERATOR_IS_ALL,
OPERATOR_IS_NOT_ALL,
} from './constants';

const FilterText = ( { activeElements, filterInView, filter } ) => {
Expand Down Expand Up @@ -66,6 +68,30 @@ const FilterText = ( { activeElements, filterInView, filter } ) => {
);
}

if ( filterInView?.operator === OPERATOR_IS_ALL ) {
return createInterpolateElement(
sprintf(
/* translators: 1: Filter name. 3: Filter value. e.g.: "Author is all: Admin, Editor". */
__( '<Name>%1$s is all: </Name><Value>%2$s</Value>' ),
filter.name,
activeElements.map( ( element ) => element.label ).join( ', ' )
),
filterTextWrappers
);
}

if ( filterInView?.operator === OPERATOR_IS_NOT_ALL ) {
return createInterpolateElement(
sprintf(
/* translators: 1: Filter name. 3: Filter value. e.g.: "Author is not all: Admin, Editor". */
__( '<Name>%1$s is not all: </Name><Value>%2$s</Value>' ),
filter.name,
activeElements.map( ( element ) => element.label ).join( ', ' )
),
filterTextWrappers
);
}

if ( filterInView?.operator === OPERATOR_IS ) {
return createInterpolateElement(
sprintf(
Expand Down

0 comments on commit 1158623

Please sign in to comment.