forked from super-productivity/super-productivity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.model.ts
More file actions
233 lines (195 loc) · 6.03 KB
/
task.model.ts
File metadata and controls
233 lines (195 loc) · 6.03 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import { IssueProviderKey } from '../issue/issue.model';
import { EntityState } from '@ngrx/entity';
import { TaskAttachment } from './task-attachment/task-attachment.model';
// Import the unified Task type from plugin-api
import { Task as PluginTask } from '@super-productivity/plugin-api';
export enum HideSubTasksMode {
// Show is undefined
HideDone = 1,
HideAll = 2,
}
export enum TaskDetailTargetPanel {
Default = 'Default',
Attachments = 'Attachments',
Notes = 'Notes',
DONT_OPEN_PANEL = 'DONT_OPEN_PANEL',
}
export type DropListModelSource =
| 'UNDONE'
| 'DONE'
| 'BACKLOG'
| 'ADD_TASK_PANEL'
| 'OVERDUE'
| 'LATER_TODAY';
// 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[];
}
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;
// TODO remove null again
issueLastUpdated?: number | null;
issueAttachmentNr?: number;
issueTimeTracked?: IssueTaskTimeTracked;
issuePoints?: number;
issueLastSyncedValues?: Record<string, unknown>;
}
// Extend the plugin Task type with app-specific fields
// Omit issue fields from PluginTask to avoid conflict with IssueFieldsForTask
export interface TaskCopy
extends
Omit<
PluginTask,
| 'issueId'
| 'issueProviderId'
| 'issueType'
| 'issueWasUpdated'
| 'issueLastUpdated'
| 'issueAttachmentNr'
| 'issuePoints'
>,
IssueFieldsForTask {
// Override required fields that are optional in plugin type
projectId: string;
timeSpentOnDay: TimeSpentOnDay;
// Additional app-specific fields
/**
* Scheduled time as Unix timestamp (ms). For tasks scheduled with a specific time.
*
* IMPORTANT: dueWithTime and dueDay follow a mutual exclusivity pattern:
* - When dueWithTime is set, dueDay MUST be undefined/null (not both set)
* - When reading, check dueWithTime FIRST (it takes priority over dueDay)
*
* @see docs/ai/dueDay-dueWithTime-mutual-exclusivity.md
*/
dueWithTime?: number | null;
/**
* Scheduled date as ISO date string (YYYY-MM-DD). For tasks scheduled for all-day (no specific time).
*
* IMPORTANT: dueDay and dueWithTime follow a mutual exclusivity pattern:
* - When dueDay is set, dueWithTime should be undefined/null (for new data)
* - When dueWithTime is set, dueDay MUST be undefined/null (not both set)
* - When reading, check dueWithTime FIRST (it takes priority over dueDay)
* - Legacy data may have both fields set; handle via priority pattern
*
* @see docs/ai/dueDay-dueWithTime-mutual-exclusivity.md
*/
dueDay?: string | null;
hasPlannedTime?: boolean;
/**
* Deadline date as ISO string (YYYY-MM-DD). For deadlines without a specific time.
* Follows mutual exclusivity with deadlineWithTime (same pattern as dueDay/dueWithTime).
*/
deadlineDay?: string | null;
/**
* Deadline as Unix timestamp (ms). For deadlines with a specific time.
* When set, deadlineDay MUST be cleared.
*/
deadlineWithTime?: number | null;
/** Reminder timestamp for the deadline. */
deadlineRemindAt?: number | null;
attachments: TaskAttachment[];
reminderId?: string | null;
// Ensure type compatibility for internal fields
modified?: number;
doneOn?: number;
parentId?: string;
remindAt?: number;
repeatCfgId?: string;
_hideSubTasksMode?: HideSubTasksMode;
}
/**
* 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: { remindAt: number };
readonly parentData?: Task;
readonly isDeadlineReminder?: boolean;
}
export interface TaskWithReminder extends Task {
remindAt: number;
}
export interface TaskWithDueTime extends Task {
dueWithTime: number;
}
export interface TaskWithDueDay extends Task {
dueDay: string;
}
export type TaskPlannedWithDayOrTime = TaskWithDueTime | TaskWithDueDay;
export interface TaskWithDeadlineDay extends Task {
deadlineDay: string;
}
export interface TaskWithDeadlineTime extends Task {
deadlineWithTime: number;
}
export type TaskWithDeadline = TaskWithDeadlineDay | TaskWithDeadlineTime;
export interface TaskWithoutReminder extends Task {
remindAt: undefined;
}
export interface TaskWithPlannedForDayIndication extends TaskWithoutReminder {
plannedForDay: string;
}
export interface TaskWithSubTasks extends Task {
readonly subTasks: Task[];
}
// make title required and add optional property for possible related (parent) task
export type IssueTask = Partial<Task> & {
title: string;
related_to?: string;
};
export const DEFAULT_TASK: Omit<TaskCopy, 'projectId'> = {
id: '',
subTaskIds: [],
timeSpentOnDay: {},
timeSpent: 0,
timeEstimate: 0,
isDone: false,
title: '',
tagIds: [],
created: Date.now(),
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;
}
export interface WorklogTask extends Task {
dateStr: string;
}
export type SubmitTrigger = 'blur' | 'escape' | 'enter' | 'modEnter';