-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from UKDanceBlue/sort-filter-people
Add filtering to the people table
- Loading branch information
Showing
9 changed files
with
175 additions
and
58 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
39 changes: 39 additions & 0 deletions
39
packages/portal/src/elements/components/FilterDropdown.tsx
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,39 @@ | ||
import type { StringFilterItemInterface } from "@ukdanceblue/common"; | ||
import { StringComparator } from "@ukdanceblue/common"; | ||
import type { InputRef } from "antd"; | ||
import Search from "antd/es/input/Search"; | ||
|
||
export function FilterSearchDropdown<Field extends string>({ | ||
updateFilter, | ||
clearFilter, | ||
field, | ||
placeholderText = `Search ${field}`, | ||
inputRef, | ||
}: { | ||
updateFilter: ( | ||
field: Field, | ||
filter: StringFilterItemInterface<Field> | ||
) => void; | ||
clearFilter: (field: Field) => void; | ||
field: Field; | ||
placeholderText?: string | undefined | false; | ||
inputRef?: (ref: InputRef) => void; | ||
}) { | ||
return ( | ||
<Search | ||
placeholder={placeholderText || undefined} | ||
onSearch={(value) => { | ||
if (value) { | ||
updateFilter(field, { | ||
comparison: StringComparator.ILIKE, | ||
field, | ||
value: `%${value}%`, | ||
}); | ||
} else { | ||
clearFilter(field); | ||
} | ||
}} | ||
ref={inputRef} | ||
/> | ||
); | ||
} |
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,39 @@ | ||
import { SearchOutlined } from "@ant-design/icons"; | ||
import { FilterSearchDropdown } from "@elements/components/FilterDropdown"; | ||
import type { StringFilterItemInterface } from "@ukdanceblue/common"; | ||
import type { InputRef } from "antd"; | ||
import { useRef } from "react"; | ||
|
||
export function useMakeSearchFilterProps<Field extends string>( | ||
field: Field, | ||
updateFilter: ( | ||
field: Field, | ||
filter: StringFilterItemInterface<Field> | ||
) => void, | ||
clearFilter: (field: Field) => void, | ||
placeholderText?: string | false | ||
) { | ||
const focusRef = useRef<InputRef | undefined>(undefined); | ||
|
||
return { | ||
filterDropdown: () => ( | ||
<FilterSearchDropdown | ||
updateFilter={updateFilter} | ||
clearFilter={clearFilter} | ||
field={field} | ||
placeholderText={placeholderText} | ||
inputRef={(inputRef) => { | ||
focusRef.current = inputRef; | ||
}} | ||
/> | ||
), | ||
filterIcon: (filtered: boolean) => ( | ||
<SearchOutlined style={{ color: filtered ? "#1890ff" : undefined }} /> | ||
), | ||
onFilterDropdownOpenChange: () => { | ||
setTimeout(() => { | ||
focusRef.current?.focus(); | ||
}, 100); | ||
}, | ||
}; | ||
} |
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 |
---|---|---|
|
@@ -780,6 +780,7 @@ enum PersonResolverStringFilterKeys { | |
committeeRole | ||
dbRole | ||
linkblue | ||
name | ||
} | ||
|
||
|
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