-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathtask.model.ts
175 lines (142 loc) · 3.88 KB
/
task.model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import { IssueProviderKey } from '../issue/issue.model';
import { Reminder } from '../reminder/reminder.model';
import { EntityState } from '@ngrx/entity';
import { TaskAttachment } from './task-attachment/task-attachment.model';
import { MODEL_VERSION_KEY } from '../../app.constants';
export enum ShowSubTasksMode {
HideAll = 0,
HideDone = 1,
Show = 2,
}
export enum TaskDetailTargetPanel {
Default = 'Default',
Attachments = 'Attachments',
DONT_OPEN_PANEL = 'DONT_OPEN_PANEL',
}
export type DropListModelSource = 'UNDONE' | 'DONE' | 'BACKLOG' | 'ADD_TASK_PANEL';
// NOTE: do not change these, as they are used inside task repeat model directly
// (new can be added though)
export enum TaskReminderOptionId {
DoNotRemind = 'DoNotRemind',
AtStart = 'AtStart',
m5 = 'm5',
m10 = 'm10',
m15 = 'm15',
m30 = 'm30',
h1 = 'h1',
}
export interface TaskReminderOption {
value: TaskReminderOptionId;
label: string;
}
export interface TimeSpentOnDayCopy {
[key: string]: number;
}
export interface TaskArchive extends EntityState<ArchiveTask> {
ids: string[];
// additional entities state properties
[MODEL_VERSION_KEY]?: number;
}
export type TimeSpentOnDay = Readonly<TimeSpentOnDayCopy>;
export interface IssueTaskTimeTracked {
[key: string]: number;
}
export interface IssueFieldsForTask {
// NOTE: keep in mind that the issueId is not unique (especially for github)
issueId?: string;
issueProviderId?: string;
issueType?: IssueProviderKey;
issueWasUpdated?: boolean;
issueLastUpdated?: number;
issueAttachmentNr?: number;
issueTimeTracked?: IssueTaskTimeTracked;
issuePoints?: number;
}
export interface TaskCopy extends IssueFieldsForTask {
id: string;
projectId?: string;
title: string;
unavailable: boolean;
subTaskIds: string[];
timeSpentOnDay: TimeSpentOnDay;
timeSpent: number;
timeEstimate: number;
created: number;
isDone: boolean;
doneOn?: number;
plannedAt?: number;
hasPlannedTime?: boolean;
// remindCfg: TaskReminderOptionId;
notes: string;
parentId?: string;
reminderId?: string;
repeatCfgId?: string;
// NOTE: only main tasks have tagIds set
tagIds: string[];
// attachments
attachments: TaskAttachment[];
// ui model
// 0: show, 1: hide-done tasks, 2: hide all sub tasks
_showSubTasksMode: ShowSubTasksMode;
}
/**
* standard task but with:
* * reminder removed, if any
* * sub tasks not included (but copied)
*/
// attachment data saved to it
export type ArchiveTask = Readonly<TaskCopy>;
export type Task = Readonly<TaskCopy>;
export interface TaskWithReminderData extends Task {
readonly reminderData: Reminder;
readonly parentData?: Task;
}
export interface TaskWithReminder extends Task {
reminderId: string;
plannedAt: number;
}
export interface TaskPlanned extends Task {
plannedAt: number;
}
export interface TaskWithPlannedDay extends Task {
plannedDay: string;
}
export interface TaskWithoutReminder extends Task {
reminderId: undefined;
plannedAt: undefined;
}
export interface TaskWithPlannedForDayIndication extends TaskWithoutReminder {
plannedForDay: string;
}
export interface TaskWithSubTasks extends Task {
readonly subTasks: Task[];
}
export const DEFAULT_TASK: Task = {
id: '',
subTaskIds: [],
timeSpentOnDay: {},
timeSpent: 0,
timeEstimate: 0,
isDone: false,
title: '',
notes: '',
tagIds: [],
created: Date.now(),
unavailable: false,
_showSubTasksMode: ShowSubTasksMode.Show,
attachments: [],
};
export interface TaskState extends EntityState<Task> {
// overwrite entity model to avoid problems with typing
ids: string[];
// additional entities state properties
currentTaskId: string | null;
selectedTaskId: string | null;
taskDetailTargetPanel: TaskDetailTargetPanel | null;
lastCurrentTaskId: string | null;
isDataLoaded: boolean;
[MODEL_VERSION_KEY]?: number;
}
export interface WorklogTask extends Task {
dateStr: string;
}