Tasks: adds tags

master
Andrew P Maney 5 years ago committed by Tom Hacohen
parent 93f06f81cd
commit fe8fbfdfd8

@ -47,7 +47,7 @@ const muiTheme = createMuiTheme({
light: lightBlue.A200, light: lightBlue.A200,
main: lightBlue.A400, main: lightBlue.A400,
dark: lightBlue.A700, dark: lightBlue.A700,
contrastText: 'white', contrastText: '#fff',
}, },
}, },
}); });

@ -18,6 +18,8 @@ import * as colors from '@material-ui/core/colors';
import FormLabel from '@material-ui/core/FormLabel'; import FormLabel from '@material-ui/core/FormLabel';
import RadioGroup from '@material-ui/core/RadioGroup'; import RadioGroup from '@material-ui/core/RadioGroup';
import Autocomplete from '@material-ui/lab/Autocomplete';
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';
import IconSave from '@material-ui/icons/Save'; import IconSave from '@material-ui/icons/Save';
@ -37,7 +39,7 @@ import * as EteSync from 'etesync';
import { getCurrentTimezone, mapPriority } from '../../helpers'; import { getCurrentTimezone, mapPriority } from '../../helpers';
import { TaskType, TaskStatusType, timezoneLoadFromName, TaskPriorityType } from '../../pim-types'; import { TaskType, TaskStatusType, timezoneLoadFromName, TaskPriorityType, TaskTags } from '../../pim-types';
import { History } from 'history'; import { History } from 'history';
@ -66,6 +68,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
timezone: string | null; timezone: string | null;
location: string; location: string;
description: string; description: string;
tags: string[];
journalUid: string; journalUid: string;
error?: string; error?: string;
@ -82,6 +85,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
allDay: false, allDay: false,
location: '', location: '',
description: '', description: '',
tags: [],
timezone: null, timezone: null,
journalUid: '', journalUid: '',
@ -105,6 +109,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
this.state.location = task.location ? task.location : ''; this.state.location = task.location ? task.location : '';
this.state.description = task.description ? task.description : ''; this.state.description = task.description ? task.description : '';
this.state.timezone = task.timezone; this.state.timezone = task.timezone;
this.state.tags = task.tags;
} else { } else {
this.state.uid = uuid.v4(); this.state.uid = uuid.v4();
} }
@ -139,7 +144,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
} }
} }
public handleChange(name: string, value: string | number) { public handleChange(name: string, value: string | number | string[]) {
this.setState({ this.setState({
[name]: value, [name]: value,
}); });
@ -193,6 +198,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
task.summary = this.state.title; task.summary = this.state.title;
task.status = this.state.status; task.status = this.state.status;
task.priority = this.state.priority; task.priority = this.state.priority;
task.tags = this.state.tags;
if (startDate) { if (startDate) {
task.startDate = startDate; task.startDate = startDate;
} }
@ -379,6 +385,22 @@ class TaskEdit extends React.PureComponent<PropsType> {
onChange={this.handleInputChange} onChange={this.handleInputChange}
/> />
<Autocomplete
style={styles.fullWidth}
multiple
options={TaskTags}
value={this.state.tags}
onChange={(_e, value) => this.handleChange('tags', value)}
renderInput={(params) => (
<TextField
{...params}
variant="standard"
label="Tags"
fullWidth
/>
)}
/>
<div style={styles.submit}> <div style={styles.submit}>
<Button <Button
variant="contained" variant="contained"

@ -142,6 +142,8 @@ export enum TaskPriorityType {
Low = 9 Low = 9
} }
export const TaskTags = ['Work', 'Home'];
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'));
@ -181,6 +183,15 @@ export class TaskType extends EventType {
return this.component.getFirstPropertyValue('priority'); return this.component.getFirstPropertyValue('priority');
} }
set tags(tags: string[]) {
this.component.updatePropertyWithValue('categories', tags.join(','));
}
get tags() {
const tags = this.component.getFirstPropertyValue('categories');
return tags ? tags.split(',') : [];
}
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