-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tasks edit: Merged parent selector feature into subtask list feature
- Loading branch information
1 parent
2a63b04
commit 2d4de66
Showing
4 changed files
with
167 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { TaskType } from "../pim-types"; | ||
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, FormGroup, List, Switch } from "@material-ui/core"; | ||
import React from "react"; | ||
import TaskSelectorListItem from "./TaskSelectorListItem"; | ||
|
||
interface PropsType { | ||
entries: TaskType[]; | ||
orig: string | null; | ||
open: boolean; | ||
onConfirm: (entry: string | null) => void; | ||
onCancel: () => void; | ||
} | ||
|
||
export default function TaskSelector(props: PropsType) { | ||
|
||
const [showHidden, setShowHidden] = React.useState(false); | ||
const [showCompleted, setShowCompleted] = React.useState(false); | ||
|
||
const itemList = props.entries | ||
.filter((e) => !e.relatedTo && (showHidden || !e.hidden) && (showCompleted || !e.finished)) | ||
.map((e) => | ||
<TaskSelectorListItem | ||
showHidden={showHidden} | ||
showCompleted={showCompleted} | ||
key={e.uid} | ||
entries={props.entries} | ||
thisEntry={e} | ||
onClick={props.onConfirm} | ||
/> | ||
); | ||
|
||
return ( | ||
<Dialog open={props.open} onClose={props.onCancel} fullWidth> | ||
<DialogTitle> | ||
Select parent task | ||
</DialogTitle> | ||
<DialogContent> | ||
<FormGroup> | ||
<FormControlLabel | ||
control={ | ||
<Switch | ||
checked={showCompleted} | ||
onChange={(e) => setShowCompleted(e.target.checked)} | ||
/> | ||
} | ||
label="Show completed" | ||
/> | ||
<FormControlLabel | ||
control={ | ||
<Switch | ||
checked={showHidden} | ||
onChange={(e) => setShowHidden(e.target.checked)} | ||
/> | ||
} | ||
label="Show hidden" | ||
/> | ||
</FormGroup> | ||
<List> | ||
{itemList} | ||
</List> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button color="primary" onClick={() => props.onConfirm(null)}> | ||
Clear | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
} |
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,34 @@ | ||
import { TaskType } from "../pim-types"; | ||
import { ListItem } from "../widgets/List"; | ||
import React from "react"; | ||
|
||
interface PropsType { | ||
entries: TaskType[]; | ||
showHidden: boolean; | ||
showCompleted: boolean; | ||
onClick: (uid: string) => void; | ||
thisEntry: TaskType; | ||
} | ||
|
||
export default function TaskSelectorListItem(props: PropsType) { | ||
const tasks = props.entries | ||
.filter((e) => e.relatedTo === props.thisEntry.uid && (props.showHidden || !e.hidden) && (props.showCompleted || !e.finished)); | ||
|
||
return ( | ||
<ListItem | ||
primaryText={props.thisEntry.title} | ||
key={props.thisEntry.uid} | ||
onClick={() => props.onClick(props.thisEntry.uid)} | ||
nestedItems={tasks.map((e) => | ||
<TaskSelectorListItem | ||
showHidden={props.showHidden} | ||
showCompleted={props.showCompleted} | ||
key={e.uid} | ||
entries={props.entries} | ||
onClick={props.onClick} | ||
thisEntry={e} | ||
/> | ||
)} | ||
/> | ||
); | ||
} |