Task edit: fix task edit (setting the collection).
parent
9077f3878e
commit
d5a582e842
|
@ -30,14 +30,9 @@ import ConfirmationDialog from "../widgets/ConfirmationDialog";
|
||||||
import TimezonePicker from "../widgets/TimezonePicker";
|
import TimezonePicker from "../widgets/TimezonePicker";
|
||||||
import Toast from "../widgets/Toast";
|
import Toast from "../widgets/Toast";
|
||||||
|
|
||||||
import { Location } from "history";
|
|
||||||
import { withRouter } from "react-router";
|
|
||||||
|
|
||||||
import * as uuid from "uuid";
|
import * as uuid from "uuid";
|
||||||
import * as ICAL from "ical.js";
|
import * as ICAL from "ical.js";
|
||||||
|
|
||||||
import * as EteSync from "etesync";
|
|
||||||
|
|
||||||
import { getCurrentTimezone, mapPriority } from "../helpers";
|
import { getCurrentTimezone, mapPriority } from "../helpers";
|
||||||
|
|
||||||
import { TaskType, TaskStatusType, timezoneLoadFromName, TaskPriorityType, TaskTags } from "../pim-types";
|
import { TaskType, TaskStatusType, timezoneLoadFromName, TaskPriorityType, TaskTags } from "../pim-types";
|
||||||
|
@ -46,19 +41,19 @@ import { History } from "history";
|
||||||
|
|
||||||
import ColoredRadio from "../widgets/ColoredRadio";
|
import ColoredRadio from "../widgets/ColoredRadio";
|
||||||
import RRule, { RRuleOptions } from "../widgets/RRule";
|
import RRule, { RRuleOptions } from "../widgets/RRule";
|
||||||
|
import { CachedCollection } from "../Pim/helpers";
|
||||||
|
|
||||||
interface PropsType {
|
interface PropsType {
|
||||||
collections: EteSync.CollectionInfo[];
|
collections: CachedCollection[];
|
||||||
initialCollection?: string;
|
initialCollection?: string;
|
||||||
item?: TaskType;
|
item?: TaskType;
|
||||||
onSave: (item: TaskType, journalUid: string, originalItem?: TaskType) => Promise<void>;
|
onSave: (item: TaskType, collectionUid: string, originalItem?: TaskType) => Promise<void>;
|
||||||
onDelete: (item: TaskType, journalUid: string) => void;
|
onDelete: (item: TaskType, collectionUid: string) => void;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
location: Location;
|
|
||||||
history: History<any>;
|
history: History<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TaskEdit extends React.PureComponent<PropsType> {
|
export default class TaskEdit extends React.PureComponent<PropsType> {
|
||||||
public state: {
|
public state: {
|
||||||
uid: string;
|
uid: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -72,13 +67,13 @@ class TaskEdit extends React.PureComponent<PropsType> {
|
||||||
location: string;
|
location: string;
|
||||||
description: string;
|
description: string;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
journalUid: string;
|
collectionUid: string;
|
||||||
|
|
||||||
error?: string;
|
error?: string;
|
||||||
showDeleteDialog: boolean;
|
showDeleteDialog: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props: any) {
|
constructor(props: PropsType) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
uid: "",
|
uid: "",
|
||||||
|
@ -91,7 +86,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
|
||||||
tags: [],
|
tags: [],
|
||||||
timezone: null,
|
timezone: null,
|
||||||
|
|
||||||
journalUid: "",
|
collectionUid: "",
|
||||||
showDeleteDialog: false,
|
showDeleteDialog: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,9 +122,9 @@ class TaskEdit extends React.PureComponent<PropsType> {
|
||||||
this.state.timezone = this.state.timezone || getCurrentTimezone();
|
this.state.timezone = this.state.timezone || getCurrentTimezone();
|
||||||
|
|
||||||
if (props.initialCollection) {
|
if (props.initialCollection) {
|
||||||
this.state.journalUid = props.initialCollection;
|
this.state.collectionUid = props.initialCollection;
|
||||||
} else if (props.collections[0]) {
|
} else if (props.collections[0]) {
|
||||||
this.state.journalUid = props.collections[0].uid;
|
this.state.collectionUid = props.collections[0].collection.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onSubmit = this.onSubmit.bind(this);
|
this.onSubmit = this.onSubmit.bind(this);
|
||||||
|
@ -245,11 +240,11 @@ class TaskEdit extends React.PureComponent<PropsType> {
|
||||||
|
|
||||||
task.component.updatePropertyWithValue("last-modified", ICAL.Time.now());
|
task.component.updatePropertyWithValue("last-modified", ICAL.Time.now());
|
||||||
|
|
||||||
this.props.onSave(task, this.state.journalUid, this.props.item)
|
this.props.onSave(task, this.state.collectionUid, this.props.item)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const nextTask = task.finished && task.getNextOccurence();
|
const nextTask = task.finished && task.getNextOccurence();
|
||||||
if (nextTask) {
|
if (nextTask) {
|
||||||
return this.props.onSave(nextTask, this.state.journalUid);
|
return this.props.onSave(nextTask, this.state.collectionUid);
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
@ -316,13 +311,13 @@ class TaskEdit extends React.PureComponent<PropsType> {
|
||||||
Saving to
|
Saving to
|
||||||
</InputLabel>
|
</InputLabel>
|
||||||
<Select
|
<Select
|
||||||
name="journalUid"
|
name="collectionUid"
|
||||||
value={this.state.journalUid}
|
value={this.state.collectionUid}
|
||||||
disabled={this.props.item !== undefined}
|
disabled={this.props.item !== undefined}
|
||||||
onChange={this.handleInputChange}
|
onChange={this.handleInputChange}
|
||||||
>
|
>
|
||||||
{this.props.collections.map((x) => (
|
{this.props.collections.map((x) => (
|
||||||
<MenuItem key={x.uid} value={x.uid}>{x.displayName}</MenuItem>
|
<MenuItem key={x.collection.uid} value={x.collection.uid}>{x.metadata.name}</MenuItem>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
@ -506,5 +501,3 @@ class TaskEdit extends React.PureComponent<PropsType> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(TaskEdit);
|
|
||||||
|
|
Loading…
Reference in New Issue