File size: 542 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
const KNOWN_FILTER_OPTIONS = [
'action',
'after',
'aggregate',
'before',
'by',
'dateRange',
'group',
'name',
'notGroup',
'number',
'on',
'sortOrder',
'textSearch',
];
export function getFilterKey( filter ) {
return KNOWN_FILTER_OPTIONS.filter( ( opt ) => filter[ opt ] !== undefined )
.map( ( opt ) => {
const optionValue = filter[ opt ];
const cacheKeyValue = Array.isArray( optionValue )
? optionValue.slice().sort().join( ',' )
: optionValue;
return `${ opt }=${ cacheKeyValue }`;
} )
.join( '-' );
}
|