mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 23:24:03 +00:00
Merge pull request #1346 from strapi/fix-filters
Remove unappropriate filters according to field type
This commit is contained in:
commit
414cb9dc4a
@ -1,36 +1,86 @@
|
||||
const FILTER_TYPES = [
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES.=',
|
||||
value: '=',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._ne',
|
||||
value: '_ne',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._lt',
|
||||
value: '_lt',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._lte',
|
||||
value: '_lte',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._gt',
|
||||
value: '_gt',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._gte',
|
||||
value: '_gte',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._contains',
|
||||
value: '_contains',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._containss',
|
||||
value: '_containss',
|
||||
},
|
||||
];
|
||||
const getFilters = (type) => {
|
||||
switch(type) {
|
||||
case 'string':
|
||||
case 'text':
|
||||
case 'password':
|
||||
case 'email':
|
||||
return [
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES.=',
|
||||
value: '=',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._ne',
|
||||
value: '_ne',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._lt',
|
||||
value: '_lt',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._lte',
|
||||
value: '_lte',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._gt',
|
||||
value: '_gt',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._gte',
|
||||
value: '_gte',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._contains',
|
||||
value: '_contains',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._containss',
|
||||
value: '_containss',
|
||||
},
|
||||
];
|
||||
case 'integer':
|
||||
case 'float':
|
||||
case 'decimal':
|
||||
case 'date':
|
||||
return [
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES.=',
|
||||
value: '=',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._ne',
|
||||
value: '_ne',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._lt',
|
||||
value: '_lt',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._lte',
|
||||
value: '_lte',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._gt',
|
||||
value: '_gt',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._gte',
|
||||
value: '_gte',
|
||||
},
|
||||
];
|
||||
default:
|
||||
return [
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES.=',
|
||||
value: '=',
|
||||
},
|
||||
{
|
||||
id: 'content-manager.components.FilterOptions.FILTER_TYPES._ne',
|
||||
value: '_ne',
|
||||
},
|
||||
];
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export default FILTER_TYPES;
|
||||
export default getFilters;
|
||||
@ -17,7 +17,7 @@ import InputWithAutoFocus from './InputWithAutoFocus';
|
||||
import Remove from './Remove';
|
||||
import styles from './styles.scss';
|
||||
|
||||
import FILTER_TYPES from './filterTypes';
|
||||
import getFilters from './filterTypes';
|
||||
|
||||
const defaultInputStyle = { width: '210px', marginRight: '10px', paddingTop: '4px' };
|
||||
const midSelectStyle = { minWidth: '130px', maxWidth: '200px', marginLeft: '10px', marginRight: '10px' };
|
||||
@ -51,7 +51,7 @@ function FilterOptions({ filter, filterToFocus, index, onChange, onClickAdd, onC
|
||||
onChange={onChange}
|
||||
name={`${index}.filter`}
|
||||
value={get(filter, 'filter', '=')}
|
||||
selectOptions={FILTER_TYPES}
|
||||
selectOptions={getFilters(attrType)}
|
||||
style={midSelectStyle}
|
||||
/>
|
||||
<div className={cn(isDate ? styles.filterOptionsInputWrapper : '')}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user