Tasks: adds priority to Task type

with ability to edit in form
master
Andrew P Maney 5 years ago committed by Tom Hacohen
parent dc1b17f7f4
commit add95621af

@ -15,6 +15,9 @@ import FormControl from '@material-ui/core/FormControl';
import FormHelperText from '@material-ui/core/FormHelperText'; import FormHelperText from '@material-ui/core/FormHelperText';
import InputLabel from '@material-ui/core/InputLabel'; import InputLabel from '@material-ui/core/InputLabel';
import * as colors from '@material-ui/core/colors'; import * as colors from '@material-ui/core/colors';
import FormLabel from '@material-ui/core/FormLabel';
import RadioGroup from '@material-ui/core/RadioGroup';
import Radio from '@material-ui/core/Radio';
import IconDelete from '@material-ui/icons/Delete'; import IconDelete from '@material-ui/icons/Delete';
import IconCancel from '@material-ui/icons/Clear'; import IconCancel from '@material-ui/icons/Clear';
@ -35,7 +38,7 @@ import * as EteSync from 'etesync';
import { getCurrentTimezone } from '../../helpers'; import { getCurrentTimezone } from '../../helpers';
import { TaskType, TaskStatusType, timezoneLoadFromName } from '../../pim-types'; import { TaskType, TaskStatusType, timezoneLoadFromName, TaskPriorityType } from '../../pim-types';
import { History } from 'history'; import { History } from 'history';
@ -55,6 +58,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
uid: string; uid: string;
title: string; title: string;
status: TaskStatusType; status: TaskStatusType;
priority: TaskPriorityType;
allDay: boolean; allDay: boolean;
start?: Date; start?: Date;
due?: Date; due?: Date;
@ -73,6 +77,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
uid: '', uid: '',
title: '', title: '',
status: TaskStatusType.NeedsAction, status: TaskStatusType.NeedsAction,
priority: TaskPriorityType.Undefined,
allDay: false, allDay: false,
location: '', location: '',
description: '', description: '',
@ -88,6 +93,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
this.state.uid = event.uid; this.state.uid = event.uid;
this.state.title = event.title ? event.title : ''; this.state.title = event.title ? event.title : '';
this.state.status = event.status; this.state.status = event.status;
this.state.priority = event.priority || TaskPriorityType.Undefined;
if (event.startDate) { if (event.startDate) {
this.state.allDay = event.startDate.isDate; this.state.allDay = event.startDate.isDate;
this.state.start = event.startDate.convertToZone(ICAL.Timezone.localTimezone).toJSDate(); this.state.start = event.startDate.convertToZone(ICAL.Timezone.localTimezone).toJSDate();
@ -132,7 +138,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
} }
} }
public handleChange(name: string, value: string) { public handleChange(name: string, value: string | number) {
this.setState({ this.setState({
[name]: value, [name]: value,
}); });
@ -185,6 +191,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
event.uid = this.state.uid; event.uid = this.state.uid;
event.summary = this.state.title; event.summary = this.state.title;
event.status = this.state.status; event.status = this.state.status;
event.priority = this.state.priority;
if (startDate) { if (startDate) {
event.startDate = startDate; event.startDate = startDate;
} }
@ -295,6 +302,21 @@ class TaskEdit extends React.PureComponent<PropsType> {
</Select> </Select>
</FormControl> </FormControl>
<FormControl style={styles.fullWidth}>
<FormLabel>Priority</FormLabel>
<RadioGroup
row
value={this.state.priority}
onChange={(e) => this.handleChange('priority', Number(e.target.value))}
>
<FormControlLabel value={TaskPriorityType.Undefined} control={<Radio />} label="None" />
<FormControlLabel value={TaskPriorityType.Low} control={<Radio />} label="Low" />
<FormControlLabel value={TaskPriorityType.Medium} control={<Radio />} label="Medium" />
<FormControlLabel value={TaskPriorityType.High} control={<Radio />} label="High" />
</RadioGroup>
</FormControl>
<FormControl> <FormControl>
<FormHelperText>Start</FormHelperText> <FormHelperText>Start</FormHelperText>
<DateTimePicker <DateTimePicker

@ -135,6 +135,13 @@ export enum TaskStatusType {
Cancelled = 'CANCELLED', Cancelled = 'CANCELLED',
} }
export enum TaskPriorityType {
Undefined = 0,
High = 1,
Medium = 5,
Low = 9
}
export class TaskType extends EventType { export class TaskType extends EventType {
public static fromVCalendar(comp: ICAL.Component) { public static fromVCalendar(comp: ICAL.Component) {
const task = new TaskType(comp.getFirstSubcomponent('vtodo')); const task = new TaskType(comp.getFirstSubcomponent('vtodo'));
@ -166,6 +173,14 @@ export class TaskType extends EventType {
return this.component.getFirstPropertyValue('status'); return this.component.getFirstPropertyValue('status');
} }
set priority(priority: TaskPriorityType) {
this.component.updatePropertyWithValue('priority', priority);
}
get priority() {
return this.component.getFirstPropertyValue('priority');
}
set dueDate(date: ICAL.Time | undefined) { set dueDate(date: ICAL.Time | undefined) {
if (date) { if (date) {
this.component.updatePropertyWithValue('due', date); this.component.updatePropertyWithValue('due', date);

Loading…
Cancel
Save