-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathtask-repeat-cfg.model.ts
92 lines (81 loc) · 2.16 KB
/
task-repeat-cfg.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
import { EntityState } from '@ngrx/entity';
import { MODEL_VERSION_KEY } from '../../app.constants';
import { TaskReminderOptionId } from '../tasks/task.model';
export const TASK_REPEAT_WEEKDAY_MAP: (keyof TaskRepeatCfg)[] = [
'sunday',
'monday',
'tuesday',
'wednesday',
'thursday',
'friday',
'saturday',
];
export type RepeatCycleOption = 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
export type RepeatQuickSetting =
| 'DAILY'
| 'WEEKLY_CURRENT_WEEKDAY'
| 'MONTHLY_CURRENT_DATE'
| 'MONDAY_TO_FRIDAY'
| 'YEARLY_CURRENT_DATE'
| 'CUSTOM';
export interface TaskRepeatCfgCopy {
id: string;
parentId: string | null;
projectId: string | null;
lastTaskCreation: number;
title: string | null;
defaultEstimate: number | undefined;
startTime: string | undefined;
remindAt: TaskReminderOptionId | undefined;
tagIds: string[];
order: number;
// actual repeat cfg fields
isPaused: boolean;
// has no direct effect, but is used to update values inside form
quickSetting: RepeatQuickSetting;
repeatCycle: RepeatCycleOption;
// worklog string; only in effect for monthly/yearly
startDate: string | undefined;
repeatEvery: number;
monday: boolean;
tuesday: boolean;
wednesday: boolean;
thursday: boolean;
friday: boolean;
saturday: boolean;
sunday: boolean;
// advanced
notes: string | undefined;
// ... possible sub tasks & attachments
}
export type TaskRepeatCfg = Readonly<TaskRepeatCfgCopy>;
export interface TaskRepeatCfgState extends EntityState<TaskRepeatCfg> {
// additional entities state properties
[MODEL_VERSION_KEY]?: number;
}
export const DEFAULT_TASK_REPEAT_CFG: Omit<TaskRepeatCfgCopy, 'id'> = {
lastTaskCreation: Date.now(),
title: null,
defaultEstimate: undefined,
// id: undefined,
parentId: null,
projectId: null,
// lastTaskCreation: Date.now() - 24 * 60 * 60 * 1000,
startTime: undefined,
startDate: undefined,
repeatEvery: 1,
remindAt: undefined,
isPaused: false,
quickSetting: 'DAILY',
repeatCycle: 'WEEKLY',
monday: true,
tuesday: true,
wednesday: true,
thursday: true,
friday: true,
saturday: false,
sunday: false,
tagIds: [],
order: 0,
notes: undefined,
};