From b6b46d2b24fa4baf40cf6533041b8054b4051e0f Mon Sep 17 00:00:00 2001 From: Andrew P Maney Date: Thu, 26 Mar 2020 15:07:07 -0700 Subject: [PATCH] Task edit: change "All Day" to "Include Time" --- src/components/Tasks/TaskEdit.tsx | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/Tasks/TaskEdit.tsx b/src/components/Tasks/TaskEdit.tsx index 3dc7f87..0157239 100644 --- a/src/components/Tasks/TaskEdit.tsx +++ b/src/components/Tasks/TaskEdit.tsx @@ -62,7 +62,7 @@ class TaskEdit extends React.PureComponent { title: string; status: TaskStatusType; priority: TaskPriorityType; - allDay: boolean; + includeTime: boolean; start?: Date; due?: Date; timezone: string | null; @@ -82,7 +82,7 @@ class TaskEdit extends React.PureComponent { title: '', status: TaskStatusType.NeedsAction, priority: TaskPriorityType.Undefined, - allDay: false, + includeTime: false, location: '', description: '', tags: [], @@ -100,7 +100,7 @@ class TaskEdit extends React.PureComponent { this.state.status = task.status ?? TaskStatusType.NeedsAction; this.state.priority = task.priority ?? TaskPriorityType.Undefined; if (task.startDate) { - this.state.allDay = task.startDate.isDate; + this.state.includeTime = !task.startDate.isDate; this.state.start = task.startDate.convertToZone(ICAL.Timezone.localTimezone).toJSDate(); } if (task.dueDate) { @@ -125,7 +125,7 @@ class TaskEdit extends React.PureComponent { this.onSubmit = this.onSubmit.bind(this); this.handleChange = this.handleChange.bind(this); this.handleInputChange = this.handleInputChange.bind(this); - this.toggleAllDay = this.toggleAllDay.bind(this); + this.toggleTime = this.toggleTime.bind(this); this.onDeleteRequest = this.onDeleteRequest.bind(this); } @@ -157,29 +157,29 @@ class TaskEdit extends React.PureComponent { this.handleChange(name, value); } - public toggleAllDay() { - this.setState({ allDay: !this.state.allDay }); + public toggleTime() { + this.setState({ includeTime: !this.state.includeTime }); } public onSubmit(e: React.FormEvent) { e.preventDefault(); - function fromDate(date: Date | undefined, allDay: boolean) { + function fromDate(date: Date | undefined, includeTime: boolean) { if (!date) { return undefined; } const ret = ICAL.Time.fromJSDate(date, false); - if (!allDay) { + if (includeTime) { return ret; } else { const data = ret.toJSON(); - data.isDate = allDay; + data.isDate = false; return ICAL.Time.fromData(data); } } - const startDate = fromDate(this.state.start, this.state.allDay); - const dueDate = fromDate(this.state.due, this.state.allDay); + const startDate = fromDate(this.state.start, this.state.includeTime); + const dueDate = fromDate(this.state.due, this.state.includeTime); if (startDate && dueDate) { if (startDate.compare(dueDate) >= 0) { @@ -327,7 +327,7 @@ class TaskEdit extends React.PureComponent { Hide until this.setState({ start: date })} @@ -340,7 +340,7 @@ class TaskEdit extends React.PureComponent { Due this.setState({ due: date })} @@ -354,17 +354,17 @@ class TaskEdit extends React.PureComponent { } - label="All Day" + label="Include time" /> - {(!this.state.allDay) && ( + {(this.state.includeTime) && ( this.setState({ timezone: zone })} /> )}