Skip to content

Commit ee51609

Browse files
committed
Tasks edit: Simplified task selection
1 parent f245798 commit ee51609

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

src/Tasks/TaskEdit.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default class TaskEdit extends React.PureComponent<PropsType> {
8080
constructor(props: PropsType) {
8181
super(props);
8282
this.state = {
83-
parentEntry: "",
83+
parentEntry: props.item?.relatedTo ?? "",
8484
uid: "",
8585
title: "",
8686
status: TaskStatusType.NeedsAction,
@@ -552,8 +552,8 @@ export default class TaskEdit extends React.PureComponent<PropsType> {
552552
entries={this.filterChildren()}
553553
orig={this.state.parentEntry}
554554
open={this.state.showSelectorDialog}
555-
onConfirm={(entry) => console.log(entry)}
556-
onCancel={() => this.setState({ openSelector: false })}
555+
onConfirm={(entry) => this.setState({ showSelectorDialog: false, parentEntry: entry })}
556+
onCancel={() => this.setState({ showSelectorDialog: false })}
557557
/>
558558
</React.Fragment>
559559
);

src/Tasks/TaskSelector.tsx

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useState } from "react";
21
import { TaskType } from "../pim-types";
32
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, List } from "@material-ui/core";
43
import React from "react";
@@ -13,22 +12,14 @@ interface PropsType {
1312
}
1413

1514
export default function TaskSelector(props: PropsType) {
16-
const [itemId, setItemId] = useState<string | null>(props.orig);
17-
18-
const select = () => {
19-
if (itemId) {
20-
props.onConfirm(itemId);
21-
}
22-
};
2315

2416
const itemList = props.entries.filter((e) => !e.relatedTo)
2517
.map((e) =>
2618
<TaskSelectorListItem
2719
key={e.uid}
2820
entries={props.entries}
2921
thisEntry={e}
30-
onClick={setItemId}
31-
selected={itemId}
22+
onClick={props.onConfirm}
3223
/>
3324
);
3425

@@ -43,15 +34,9 @@ export default function TaskSelector(props: PropsType) {
4334
</List>
4435
</DialogContent>
4536
<DialogActions>
46-
<Button color="primary" onClick={props.onCancel}>
47-
Cancel
48-
</Button>
4937
<Button color="primary" onClick={() => props.onConfirm(null)}>
5038
Clear
5139
</Button>
52-
<Button color="primary" onClick={select}>
53-
Select
54-
</Button>
5540
</DialogActions>
5641
</Dialog>
5742
);

src/Tasks/TaskSelectorListItem.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import React from "react";
55
interface PropsType {
66
entries: TaskType[];
77
onClick: (uid: string) => void;
8-
selected: string | null;
98
thisEntry: TaskType;
109
}
1110

@@ -15,15 +14,13 @@ export default function TaskSelectorListItem(props: PropsType) {
1514
return (
1615
<ListItem
1716
primaryText={props.thisEntry.title}
18-
selected={props.selected === props.thisEntry.uid}
1917
key={props.thisEntry.uid}
2018
onClick={() => props.onClick(props.thisEntry.uid)}
2119
nestedItems={tasks.map((e) =>
2220
<TaskSelectorListItem
2321
key={e.uid}
2422
entries={props.entries}
2523
onClick={props.onClick}
26-
selected={props.selected}
2724
thisEntry={e}
2825
/>
2926
)}

0 commit comments

Comments
 (0)