Tasks: adds mapPriority helper function
handles any possible issues with priorities that aren't 1, 5, or 9master
parent
bdd89fb533
commit
29d1e5cfe5
|
@ -35,7 +35,7 @@ import * as ICAL from 'ical.js';
|
|||
|
||||
import * as EteSync from 'etesync';
|
||||
|
||||
import { getCurrentTimezone } from '../../helpers';
|
||||
import { getCurrentTimezone, mapPriority } from '../../helpers';
|
||||
|
||||
import { TaskType, TaskStatusType, timezoneLoadFromName, TaskPriorityType } from '../../pim-types';
|
||||
|
||||
|
@ -308,7 +308,7 @@ class TaskEdit extends React.PureComponent<PropsType> {
|
|||
|
||||
<RadioGroup
|
||||
row
|
||||
value={this.state.priority}
|
||||
value={mapPriority(this.state.priority)}
|
||||
onChange={(e) => this.handleChange('priority', Number(e.target.value))}
|
||||
>
|
||||
<ColoredRadio value={TaskPriorityType.Undefined} label="None" color={colors.grey[600]} />
|
||||
|
|
|
@ -19,6 +19,8 @@ const checkboxColor = {
|
|||
|
||||
import moment from 'moment';
|
||||
|
||||
import { mapPriority } from '../../helpers';
|
||||
|
||||
interface PropsType {
|
||||
entry: TaskType;
|
||||
onClick: (task: TaskType) => void;
|
||||
|
@ -49,7 +51,7 @@ export default React.memo(function TaskListItem(props: PropsType) {
|
|||
onClick={(e) => e.stopPropagation()}
|
||||
onChange={toggleComplete}
|
||||
checked={task.finished}
|
||||
icon={<CheckBoxOutlineBlankIcon style={{ color: checkboxColor[task.priority] }} />}
|
||||
icon={<CheckBoxOutlineBlankIcon style={{ color: checkboxColor[mapPriority(task.priority)] }} />}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import * as React from 'react';
|
||||
import * as ICAL from 'ical.js';
|
||||
import moment from 'moment';
|
||||
import { TaskPriorityType } from './pim-types';
|
||||
|
||||
// Generic handling of input changes
|
||||
export function handleInputChange(self: React.Component, part?: string) {
|
||||
|
@ -107,3 +108,15 @@ export function formatOurTimezoneOffset() {
|
|||
export function getCurrentTimezone() {
|
||||
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
}
|
||||
|
||||
export function mapPriority(priority: number): TaskPriorityType {
|
||||
if (priority > 0 && priority < 5) {
|
||||
return TaskPriorityType.High;
|
||||
} else if (priority === 5) {
|
||||
return TaskPriorityType.Medium;
|
||||
} else if (priority > 5 && priority < 10) {
|
||||
return TaskPriorityType.Low;
|
||||
} else {
|
||||
return TaskPriorityType.Undefined;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue