-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#3]: Add filterValue option for providing initial selected filters
- Loading branch information
1 parent
318a33c
commit 6098607
Showing
7 changed files
with
87 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import _ from 'lodash'; | ||
|
||
export const createTextFilter = (text) => ({ | ||
value: text.toLowerCase(), | ||
label: text.toLowerCase(), | ||
textFilter: true, | ||
className: 'Select-create-option-placeholder', | ||
}); | ||
|
||
export const createValueFilter = (column, value) => { | ||
const { | ||
key, | ||
getValueTitle = () => undefined, | ||
getValueClassName = () => undefined, | ||
getValueLabel = () => { | ||
let labelValue = value; | ||
if (_.isBoolean(value)) { | ||
labelValue = value ? 'Yes' : 'No'; | ||
} | ||
return `${column.header}:${labelValue}`; | ||
}, | ||
} = column; | ||
const title = getValueTitle(value); | ||
const label = getValueLabel(value); | ||
const className = getValueClassName(value); | ||
return { | ||
key, | ||
label, | ||
value, | ||
title, | ||
className, | ||
valueFilter: true, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters