-
Notifications
You must be signed in to change notification settings - Fork 0
DEMOS-975: Minimal centralized date picker, and seeder stuff #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d697441
DEMOS-975: made a centralized date picker.
dustbuster 1dac099
DEMOS-975: Removed all the comments
dustbuster 9847014
DEMOS-975: removing the ... spread operator
dustbuster c4f1c38
Merge branch 'main' into DEMOS-975-date-picker-problems
dustbuster 61f2957
DEMOS-975: Reduced the footprint of DatePicker
dustbuster 3338234
DEMOS-975: merged my doc seeder with exists.
dustbuster 3eacad7
DEMOS-975: removed complexity, and remove ...props
dustbuster 22d501b
DEMOS-975: removed comment
dustbuster 02be1f5
DEMOS-975: simplest possibel verison
dustbuster e17278b
DEMOS-975: reduction in comp to make simple
dustbuster 374209d
DEMOS-975: adjusted so we do not have dupe docs
dustbuster 5abc984
DEMOS-975: missed a doc addition
dustbuster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 React from "react"; | ||
| import { Input } from "components/input/Input"; | ||
|
|
||
| export interface DatePickerProps | ||
| extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "onChange"> { | ||
| label: string; | ||
| required?: boolean; | ||
| value?: string; | ||
| onValueChange?: (newDate: string) => void; | ||
| } | ||
|
|
||
| export const DatePicker: React.FC<DatePickerProps> = ({ | ||
| label, | ||
| name, | ||
| id, | ||
| required, | ||
| value, | ||
| onValueChange, | ||
| }) => { | ||
| const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| onValueChange?.(e.target.value); | ||
| }; | ||
|
|
||
| return ( | ||
| <Input | ||
| type="date" | ||
| label={label} | ||
| name={name ?? id ?? ""} | ||
| isRequired={required ?? false} | ||
| value={value} | ||
| onChange={handleChange} | ||
| /> | ||
| ); | ||
| }; | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -3,7 +3,8 @@ import { Table } from "@tanstack/react-table"; | |
| import { TextInput } from "components/input"; | ||
| import { AutoCompleteMultiselect } from "components/input/select/AutoCompleteMultiselect"; | ||
| import { Option, Select } from "components/input/select/Select"; | ||
| import { parseISO } from "date-fns"; | ||
| import { parseISO, format } from "date-fns"; | ||
| import { DatePicker } from "components/input/date/DatePicker"; | ||
|
|
||
| export interface ColumnMetaFilterConfig { | ||
| filterConfig?: | ||
|
|
@@ -97,32 +98,27 @@ export function ColumnFilter<T>({ table }: { table: Table<T> }) { | |
| return ( | ||
| <> | ||
| <div> | ||
| <label | ||
| className="block text-sm font-bold mb-1" | ||
| htmlFor="date-filter-start" | ||
| >{`${columnDisplayName} Start`}</label> | ||
| <input | ||
| <DatePicker | ||
| label={`${columnDisplayName} Start`} | ||
| id="date-filter-start" | ||
| name="date-filter-start" | ||
| type="date" | ||
| className="w-full border border-border-fields px-1 py-1 text-sm rounded" | ||
| onChange={(e) => { | ||
| const value = e.target.value; | ||
| onRangeChange(parseISO(value), filterRangeValue.end); | ||
| }} | ||
| placeholder="Start date" | ||
| value={filterRangeValue.start ? format(filterRangeValue.start, "yyyy-MM-dd") : ""} | ||
| onValueChange={(val) => | ||
| onRangeChange(val ? parseISO(val) : null, filterRangeValue.end) | ||
| } | ||
| /> | ||
| </div> | ||
| <div> | ||
| <label | ||
| className="block text-sm font-bold mb-1" | ||
| htmlFor="date-filter-end" | ||
| >{`${columnDisplayName} End`}</label> | ||
| <input | ||
| <DatePicker | ||
| label={`${columnDisplayName} End`} | ||
| id="date-filter-end" | ||
| name="date-filter-end" | ||
| type="date" | ||
| onChange={(e) => onRangeChange(filterRangeValue.start, parseISO(e.target.value))} | ||
| className="w-full border border-border-fields px-1 py-1 text-sm rounded" | ||
| placeholder="End date" | ||
| value={filterRangeValue.end ? format(filterRangeValue.end, "yyyy-MM-dd") : ""} | ||
| onValueChange={(val) => | ||
| onRangeChange(filterRangeValue.start, val ? parseISO(val) : null) | ||
|
Comment on lines
+101
to
+120
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All this does is implement the DatePicker. Everyting works as before. |
||
| } | ||
| /> | ||
| </div> | ||
| </> | ||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is like as simple as i could make and still work with ColumnFilter