-
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.
perf: Updated schema generator to fit the new datastructure
- Loading branch information
1 parent
f854de3
commit b04fa91
Showing
36 changed files
with
1,020 additions
and
667 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import Button from '@material-ui/core/Button'; | ||
import Dialog from '@material-ui/core/Dialog'; | ||
import DialogActions from '@material-ui/core/DialogActions'; | ||
import DialogContent from '@material-ui/core/DialogContent'; | ||
import DialogTitle from '@material-ui/core/DialogTitle'; | ||
import { DialogContentText } from '@material-ui/core'; | ||
|
||
type ConfirmDialogProps = { | ||
title: string; | ||
text: string; | ||
open: boolean; | ||
setOpen: (v: boolean) => unknown; | ||
onConfirm: () => unknown; | ||
onReject: () => unknown; | ||
}; | ||
|
||
const ConfirmDialog = (props: ConfirmDialogProps) => { | ||
const { title, text, open, setOpen, onConfirm, onReject } = props; | ||
return ( | ||
<Dialog | ||
open={open} | ||
onClose={() => setOpen(false)} | ||
aria-labelledby="confirm-dialog" | ||
> | ||
<DialogTitle id="confirm-dialog">{title}</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText>{text}</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button | ||
onClick={() => { | ||
setOpen(false); | ||
onConfirm(); | ||
}} | ||
color="primary" | ||
autoFocus | ||
> | ||
Yes | ||
</Button> | ||
<Button | ||
onClick={() => { | ||
setOpen(false); | ||
onReject(); | ||
}} | ||
color="primary" | ||
> | ||
No | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; | ||
export default ConfirmDialog; |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import React from 'react'; | ||
import SchemeGenerator from '../features/schema-generator/SchemeGenerator'; | ||
|
||
export default function SchemeGeneratorPage(props) { | ||
return <SchemeGenerator {...props} />; | ||
export default function SchemeGeneratorPage() { | ||
return <SchemeGenerator />; | ||
} |
This file was deleted.
Oops, something went wrong.
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,111 @@ | ||
import React, { ChangeEvent } from 'react'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import { Card, InputAdornment } from '@material-ui/core'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import styles from './TaskScheme.css'; | ||
import { | ||
schemaSetSelectedTask, | ||
schemaUpdateTask, | ||
selectSchemaSelectedTaskId, | ||
} from '../../model/SchemaSlice'; | ||
import ParentTask from '../../model/ParentTask'; | ||
import Rating from '../../model/Rating'; | ||
import { | ||
getMaxValueForTasks, | ||
getRatingValueForTasks, | ||
} from '../../utils/Formatter'; | ||
import { hasTasksWithZeroMax } from '../../utils/TaskUtil'; | ||
|
||
type SchemaParentTaskProps = { | ||
task: ParentTask; | ||
ratings: Rating[]; | ||
depth: number; | ||
type: string; | ||
}; | ||
|
||
export default function SchemaParentTask(props: SchemaParentTaskProps) { | ||
const { task, ratings, depth, type } = props; | ||
|
||
const dispatch = useDispatch(); | ||
const selectedTaskId: string | undefined = useSelector( | ||
selectSchemaSelectedTaskId | ||
); | ||
const selected: boolean = | ||
selectedTaskId !== undefined && selectedTaskId === task.id; | ||
|
||
const sumValue = getRatingValueForTasks(task.tasks, ratings); | ||
const sumMax = getMaxValueForTasks(task.tasks); | ||
|
||
const INDENT_SIZE = 25; | ||
const marginLeft = `${depth * INDENT_SIZE}pt`; | ||
|
||
function onChangeName(e: ChangeEvent<{ value: unknown }>) { | ||
dispatch( | ||
schemaUpdateTask({ | ||
id: task.id, | ||
changes: { | ||
name: e.target.value as string, | ||
}, | ||
}) | ||
); | ||
} | ||
|
||
function onSelection() { | ||
if (!selected) { | ||
dispatch(schemaSetSelectedTask(task.id)); | ||
} | ||
} | ||
|
||
return ( | ||
<Card | ||
style={{ marginLeft }} | ||
raised={selected} | ||
className={styles.card} | ||
onClick={onSelection} | ||
onKeyDown={onSelection} | ||
> | ||
<TextField | ||
id="outlined-number" | ||
label="Task name" | ||
multiline | ||
name="name" | ||
value={task.name} | ||
onChange={onChangeName} | ||
className={styles.fields} | ||
variant="outlined" | ||
size="small" | ||
/> | ||
<TextField | ||
label="Inital" | ||
id="value" | ||
name="value" | ||
style={{ width: `${type.length * 0.6 + 6}em` }} | ||
type="number" | ||
value={sumValue} | ||
className={styles.fields} | ||
InputProps={{ | ||
readOnly: true, | ||
endAdornment: <InputAdornment position="end">{type}</InputAdornment>, | ||
}} | ||
size="small" | ||
variant="outlined" | ||
/> | ||
<TextField | ||
label="Max" | ||
id="max" | ||
name="max" | ||
style={{ width: `${type.length * 0.6 + 6}em` }} | ||
type="number" | ||
className={styles.fields} | ||
value={sumMax} | ||
InputProps={{ | ||
readOnly: true, | ||
endAdornment: <InputAdornment position="end">{type}</InputAdornment>, | ||
}} | ||
size="small" | ||
variant="outlined" | ||
error={hasTasksWithZeroMax(task.tasks)} | ||
/> | ||
</Card> | ||
); | ||
} |
Oops, something went wrong.