-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDE/PKFE-16 custom editor column menu aggregation item implementation
- Loading branch information
1 parent
6bfde87
commit 5c2b6a1
Showing
3 changed files
with
91 additions
and
2 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
63 changes: 63 additions & 0 deletions
63
app/front-end/src/features/editor/components/editorView/editorColumnMenuAggregationItem.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,63 @@ | ||
import { EditorColumnMenuAggregationActions } from '@/features/editor/types'; | ||
import { Functions as FunctionsIcon } from '@mui/icons-material'; | ||
import { Box, FormControl, InputLabel, MenuItem, Select, SelectChangeEvent, useTheme } from '@mui/material'; | ||
import { MouseEvent, useState } from 'react'; | ||
|
||
export interface EditorColumnMenuAggregationItemProps { | ||
initialValue: EditorColumnMenuAggregationActions; | ||
onClick: (event: MouseEvent) => void; | ||
onAction: (action: EditorColumnMenuAggregationActions) => void; | ||
} | ||
|
||
export const EditorColumnMenuAggregationItem: React.FC<EditorColumnMenuAggregationItemProps> = ({ | ||
initialValue, | ||
onClick, | ||
onAction, | ||
}) => { | ||
const Theme = useTheme(); | ||
const [value, setValue] = useState<EditorColumnMenuAggregationActions>(initialValue); | ||
|
||
const handleChange = (event: SelectChangeEvent) => { | ||
const action = event.target.value as EditorColumnMenuAggregationActions; | ||
setValue(action); | ||
onAction(action); | ||
}; | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
gap: '1rem', | ||
alignItems: 'center', | ||
px: '0.85rem', | ||
py: '1rem', | ||
}} | ||
> | ||
<FunctionsIcon sx={{ color: Theme.palette.text.secondary }} /> | ||
<FormControl fullWidth> | ||
<InputLabel sx={{ color: Theme.palette.text.primary }}>Aggregation</InputLabel> | ||
<Select id={'aggregation-select'} label={'Aggregation'} value={value} onChange={handleChange}> | ||
<MenuItem value={EditorColumnMenuAggregationActions.NONE} onClick={onClick}> | ||
... | ||
</MenuItem> | ||
<MenuItem value={EditorColumnMenuAggregationActions.SUM} onClick={onClick}> | ||
Sum | ||
</MenuItem> | ||
<MenuItem value={EditorColumnMenuAggregationActions.AVG} onClick={onClick}> | ||
Average | ||
</MenuItem> | ||
<MenuItem value={EditorColumnMenuAggregationActions.MIN} onClick={onClick}> | ||
Minimum | ||
</MenuItem> | ||
<MenuItem value={EditorColumnMenuAggregationActions.MAX} onClick={onClick}> | ||
Maximum | ||
</MenuItem> | ||
<MenuItem value={EditorColumnMenuAggregationActions.COUNT} onClick={onClick}> | ||
Count | ||
</MenuItem> | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
); | ||
}; |
4 changes: 4 additions & 0 deletions
4
app/front-end/src/features/editor/components/editorView/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,7 @@ | ||
export { EditorColumnMenu } from './editorColumnMenu'; | ||
export { EditorColumnMenuAggregationItem } from './editorColumnMenuAggregationItem'; | ||
export type { EditorColumnMenuAggregationItemProps } from './editorColumnMenuAggregationItem'; | ||
export { EditorHeader } from './editorHeader'; | ||
export type { EditorHeaderProps } from './editorHeader'; | ||
export { EditorToolbar } from './editorToolbar'; | ||
export { EditorView } from './editorView'; |