forked from finos/vuu
-
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.
finos#1073 add ability to switch inferred column type for long columns
- users can now declare the type of long columns as plain number or date/time. - removed isSimpleColumnType as its no longer needed. - added a timestamps (long) column in showcase's instruments-extended table.
- Loading branch information
1 parent
9700546
commit 02c1cc1
Showing
15 changed files
with
145 additions
and
92 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
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
2 changes: 1 addition & 1 deletion
2
...g-settings/DateTimeFormattingSettings.css → ...g-settings/LongTypeFormattingSettings.css
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
58 changes: 58 additions & 0 deletions
58
...i/packages/vuu-table-extras/src/column-formatting-settings/LongTypeFormattingSettings.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,58 @@ | ||
import React, { useCallback } from "react"; | ||
import { | ||
FormField, | ||
FormFieldLabel, | ||
ToggleButton, | ||
ToggleButtonGroup, | ||
} from "@salt-ds/core"; | ||
import { isDateTimeColumn, isTypeDescriptor } from "@finos/vuu-utils"; | ||
import { DateTimeFormattingSettings } from "./DateTimeFormattingSettings"; | ||
import { BaseNumericFormattingSettings } from "./BaseNumericFormattingSettings"; | ||
import { FormattingSettingsProps } from "./types"; | ||
|
||
import "./LongTypeFormattingSettings.css"; | ||
|
||
const classBase = "vuuLongColumnFormattingSettings"; | ||
|
||
export const LongTypeFormattingSettings: React.FC<FormattingSettingsProps> = ( | ||
props | ||
) => { | ||
const { column, onChangeType } = props; | ||
const type = isTypeDescriptor(column.type) ? column.type.name : column.type; | ||
|
||
const handleToggleChange = useCallback( | ||
(event: React.SyntheticEvent<HTMLButtonElement, Event>) => { | ||
const value = event.currentTarget.value as ToggleValue; | ||
onChangeType(value); | ||
}, | ||
[onChangeType] | ||
); | ||
|
||
return ( | ||
<div className={classBase}> | ||
<FormField> | ||
<FormFieldLabel>{"Type inferred as"}</FormFieldLabel> | ||
<ToggleButtonGroup | ||
className="vuuToggleButtonGroup" | ||
onChange={handleToggleChange} | ||
value={type ?? "number"} | ||
> | ||
{toggleValues.map((v) => ( | ||
<ToggleButton key={v} value={v}> | ||
{v.toUpperCase()} | ||
</ToggleButton> | ||
))} | ||
</ToggleButtonGroup> | ||
</FormField> | ||
|
||
{isDateTimeColumn(column) ? ( | ||
<DateTimeFormattingSettings {...props} column={column} /> | ||
) : ( | ||
<BaseNumericFormattingSettings {...props} /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
const toggleValues = ["number", "date/time"] as const; | ||
type ToggleValue = (typeof toggleValues)[number]; |
2 changes: 1 addition & 1 deletion
2
vuu-ui/packages/vuu-table-extras/src/column-formatting-settings/index.ts
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from "./ColumnFormattingPanel"; | ||
export * from "./NumericFormattingSettings"; | ||
export * from "./BaseNumericFormattingSettings"; | ||
export * from "./DateTimeFormattingSettings"; |
13 changes: 10 additions & 3 deletions
13
vuu-ui/packages/vuu-table-extras/src/column-formatting-settings/types.ts
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 |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import { ColumnDescriptor, ColumnTypeFormatting } from "@finos/vuu-table-types"; | ||
import { | ||
ColumnDescriptor, | ||
ColumnTypeFormatting, | ||
ColumnTypeSimple, | ||
} from "@finos/vuu-table-types"; | ||
|
||
export interface FormattingSettingsProps<T extends ColumnDescriptor = ColumnDescriptor> { | ||
export interface FormattingSettingsProps< | ||
T extends ColumnDescriptor = ColumnDescriptor | ||
> { | ||
column: T; | ||
onChange: (formatting: ColumnTypeFormatting) => void; | ||
onChangeFormatting: (formatting: ColumnTypeFormatting) => void; | ||
onChangeType: (type: ColumnTypeSimple) => void; | ||
} |
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
Oops, something went wrong.