@aneuhold/core-ts-db-lib 1.0.28 → 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/documents/dashboard/Task.d.ts +21 -1
- package/lib/documents/dashboard/Task.d.ts.map +1 -1
- package/lib/documents/dashboard/Task.js +17 -2
- package/lib/documents/dashboard/UserConfig.d.ts +9 -0
- package/lib/documents/dashboard/UserConfig.d.ts.map +1 -1
- package/lib/documents/dashboard/UserConfig.js +11 -0
- package/lib/embedded-types/dashboard/task/FilterSettings.d.ts +42 -0
- package/lib/embedded-types/dashboard/task/FilterSettings.d.ts.map +1 -0
- package/lib/embedded-types/dashboard/task/FilterSettings.js +29 -0
- package/lib/embedded-types/dashboard/task/SortSettings.d.ts +54 -0
- package/lib/embedded-types/dashboard/task/SortSettings.d.ts.map +1 -0
- package/lib/embedded-types/dashboard/task/SortSettings.js +52 -0
- package/lib/embedded-types/dashboard/userConfig/Tags.d.ts +11 -0
- package/lib/embedded-types/dashboard/userConfig/Tags.d.ts.map +1 -0
- package/lib/embedded-types/dashboard/userConfig/Tags.js +2 -0
- package/lib/index.d.ts +6 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -2
- package/lib/services/DocumentService.spec.d.ts +2 -0
- package/lib/services/DocumentService.spec.d.ts.map +1 -0
- package/lib/services/DocumentService.spec.js +30 -0
- package/lib/services/dashboard/Task/TaskFilterService.d.ts +21 -0
- package/lib/services/dashboard/Task/TaskFilterService.d.ts.map +1 -0
- package/lib/services/dashboard/Task/TaskFilterService.js +67 -0
- package/lib/services/dashboard/Task/TaskRecurrenceService.d.ts +21 -0
- package/lib/services/dashboard/Task/TaskRecurrenceService.d.ts.map +1 -0
- package/lib/services/dashboard/Task/TaskRecurrenceService.js +137 -0
- package/lib/services/dashboard/Task/TaskService.d.ts +45 -0
- package/lib/services/dashboard/Task/TaskService.d.ts.map +1 -0
- package/lib/services/dashboard/Task/TaskService.js +88 -0
- package/lib/services/dashboard/Task/TaskService.spec.d.ts +2 -0
- package/lib/services/dashboard/Task/TaskService.spec.d.ts.map +1 -0
- package/lib/services/dashboard/Task/TaskService.spec.js +396 -0
- package/lib/services/dashboard/Task/TaskSortService.d.ts +15 -0
- package/lib/services/dashboard/Task/TaskSortService.d.ts.map +1 -0
- package/lib/services/dashboard/Task/TaskSortService.js +92 -0
- package/package.json +1 -1
|
@@ -3,7 +3,15 @@ import BaseDocumentWithType from '../BaseDocumentWithType';
|
|
|
3
3
|
import RequiredUserId from '../../schemas/required-refs/RequiredUserId';
|
|
4
4
|
import { DocumentValidator } from '../../schemas/validators/DocumentValidator';
|
|
5
5
|
import { ParentRecurringTaskInfo, RecurrenceInfo } from '../../embedded-types/dashboard/task/RecurrenceInfo';
|
|
6
|
+
import { DashboardTaskFilterSettings } from '../../embedded-types/dashboard/task/FilterSettings';
|
|
7
|
+
import { DashboardTaskSortSettings } from '../../embedded-types/dashboard/task/SortSettings';
|
|
6
8
|
export declare const validateDashboardTask: DocumentValidator<DashboardTask>;
|
|
9
|
+
/**
|
|
10
|
+
* A utility type for a map of tasks.
|
|
11
|
+
*/
|
|
12
|
+
export type DashboardTaskMap = {
|
|
13
|
+
[taskId: string]: DashboardTask;
|
|
14
|
+
};
|
|
7
15
|
/**
|
|
8
16
|
* When thinking about the logic of tasks, the following thoughts come to mind:
|
|
9
17
|
*
|
|
@@ -82,12 +90,24 @@ export default class DashboardTask extends BaseDocumentWithType implements Requi
|
|
|
82
90
|
/**
|
|
83
91
|
* User-assigned tags for this task.
|
|
84
92
|
*/
|
|
85
|
-
tags:
|
|
93
|
+
tags: {
|
|
94
|
+
[userId: string]: string[];
|
|
95
|
+
};
|
|
86
96
|
/**
|
|
87
97
|
* System-assigned category for this task. This should be used to determine
|
|
88
98
|
* where this task should be displayed.
|
|
89
99
|
*/
|
|
90
100
|
category: string;
|
|
101
|
+
/**
|
|
102
|
+
* The filter settings for subtasks of this task specifically, keyed on
|
|
103
|
+
* each user.
|
|
104
|
+
*/
|
|
105
|
+
filterSettings: DashboardTaskFilterSettings;
|
|
106
|
+
/**
|
|
107
|
+
* The sort settings for subtasks of this task specifically, keyed on
|
|
108
|
+
* each user.
|
|
109
|
+
*/
|
|
110
|
+
sortSettings: DashboardTaskSortSettings;
|
|
91
111
|
constructor(ownerId: ObjectId);
|
|
92
112
|
}
|
|
93
113
|
//# sourceMappingURL=Task.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/documents/dashboard/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,cAAc,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EACL,uBAAuB,EACvB,cAAc,EAEf,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/documents/dashboard/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,cAAc,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EACL,uBAAuB,EACvB,cAAc,EAEf,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oDAAoD,CAAC;AACjG,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAE7F,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,aAAa,CAwBlE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,OAAO,aACnB,SAAQ,oBACR,YAAW,cAAc;IAEzB,MAAM,CAAC,OAAO,SAAU;IAExB,OAAO,SAAyB;IAEhC;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;;;;;;;;;;OAWG;IACH,UAAU,EAAE,QAAQ,EAAE,CAAM;IAE5B;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAElD,KAAK,SAAM;IAEX,SAAS,UAAS;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC;IAExB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,OAAc;IAEzB;;OAEG;IACH,eAAe,OAAc;IAE7B,SAAS,CAAC,EAAE,IAAI,CAAC;IAEjB,OAAO,CAAC,EAAE,IAAI,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAM;IAE1C;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAa;IAE7B;;;OAGG;IACH,cAAc,EAAE,2BAA2B,CAAM;IAEjD;;;OAGG;IACH,YAAY,EAAE,yBAAyB,CAAM;gBAEjC,OAAO,EAAE,QAAQ;CAO9B"}
|
|
@@ -17,13 +17,15 @@ const validateDashboardTask = (task) => {
|
|
|
17
17
|
validate.optionalString('description');
|
|
18
18
|
validate.array('sharedWith', exampleTask.sharedWith);
|
|
19
19
|
validate.optionalObject('recurrenceInfo');
|
|
20
|
-
validate.
|
|
20
|
+
validate.object('tags', {});
|
|
21
21
|
validate.string('category', exampleTask.category);
|
|
22
22
|
validate.object('createdDate', exampleTask.createdDate);
|
|
23
23
|
validate.object('lastUpdatedDate', exampleTask.lastUpdatedDate);
|
|
24
24
|
validate.optionalObject('startDate');
|
|
25
25
|
validate.optionalObject('dueDate');
|
|
26
26
|
validate.optionalObject('parentRecurringTaskInfo');
|
|
27
|
+
validate.object('filterSettings', {});
|
|
28
|
+
validate.object('sortSettings', {});
|
|
27
29
|
(0, RecurrenceInfo_1.validateRecurrenceInfo)(task, errors);
|
|
28
30
|
return { updatedDoc: task, errors };
|
|
29
31
|
};
|
|
@@ -106,15 +108,28 @@ class DashboardTask extends BaseDocumentWithType_1.default {
|
|
|
106
108
|
/**
|
|
107
109
|
* User-assigned tags for this task.
|
|
108
110
|
*/
|
|
109
|
-
tags =
|
|
111
|
+
tags = {};
|
|
110
112
|
/**
|
|
111
113
|
* System-assigned category for this task. This should be used to determine
|
|
112
114
|
* where this task should be displayed.
|
|
113
115
|
*/
|
|
114
116
|
category = 'default';
|
|
117
|
+
/**
|
|
118
|
+
* The filter settings for subtasks of this task specifically, keyed on
|
|
119
|
+
* each user.
|
|
120
|
+
*/
|
|
121
|
+
filterSettings = {};
|
|
122
|
+
/**
|
|
123
|
+
* The sort settings for subtasks of this task specifically, keyed on
|
|
124
|
+
* each user.
|
|
125
|
+
*/
|
|
126
|
+
sortSettings = {};
|
|
115
127
|
constructor(ownerId) {
|
|
116
128
|
super();
|
|
117
129
|
this.userId = ownerId;
|
|
130
|
+
this.tags = {
|
|
131
|
+
[ownerId.toString()]: []
|
|
132
|
+
};
|
|
118
133
|
}
|
|
119
134
|
}
|
|
120
135
|
exports.default = DashboardTask;
|
|
@@ -2,6 +2,9 @@ import { ObjectId } from 'bson';
|
|
|
2
2
|
import BaseDocumentWithType from '../BaseDocumentWithType';
|
|
3
3
|
import RequiredUserId from '../../schemas/required-refs/RequiredUserId';
|
|
4
4
|
import { DocumentValidator } from '../../schemas/validators/DocumentValidator';
|
|
5
|
+
import { DashboardTagSettings } from '../../embedded-types/dashboard/userConfig/Tags';
|
|
6
|
+
import { DashboardTaskListGlobalSortSettings } from '../../embedded-types/dashboard/task/SortSettings';
|
|
7
|
+
import { DashboardTaskListGlobalFilterSettings } from '../../embedded-types/dashboard/task/FilterSettings';
|
|
5
8
|
export declare const validateDashboardUserConfig: DocumentValidator<DashboardUserConfig>;
|
|
6
9
|
export default class DashboardUserConfig extends BaseDocumentWithType implements RequiredUserId {
|
|
7
10
|
static docType: string;
|
|
@@ -19,6 +22,12 @@ export default class DashboardUserConfig extends BaseDocumentWithType implements
|
|
|
19
22
|
* Whether or not to enable dev mode for the user.
|
|
20
23
|
*/
|
|
21
24
|
enableDevMode: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The user's tag settings for the dashboard.
|
|
27
|
+
*/
|
|
28
|
+
tagSettings: DashboardTagSettings;
|
|
29
|
+
taskListSortSettings: DashboardTaskListGlobalSortSettings;
|
|
30
|
+
taskListFilterSettings: DashboardTaskListGlobalFilterSettings;
|
|
22
31
|
constructor(ownerId: ObjectId);
|
|
23
32
|
}
|
|
24
33
|
//# sourceMappingURL=UserConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserConfig.d.ts","sourceRoot":"","sources":["../../../src/documents/dashboard/UserConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,cAAc,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"UserConfig.d.ts","sourceRoot":"","sources":["../../../src/documents/dashboard/UserConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,cAAc,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EACL,mCAAmC,EAEpC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACL,qCAAqC,EAEtC,MAAM,oDAAoD,CAAC;AAE5D,eAAO,MAAM,2BAA2B,EAAE,iBAAiB,CACzD,mBAAmB,CAapB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,mBACnB,SAAQ,oBACR,YAAW,cAAc;IAEzB,MAAM,CAAC,OAAO,SAAgB;IAE9B,OAAO,SAA+B;IAEtC;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;;OAGG;IACH,aAAa,EAAE,QAAQ,EAAE,CAAM;IAE/B;;OAEG;IACH,aAAa,UAAS;IAEtB;;OAEG;IACH,WAAW,EAAE,oBAAoB,CAAM;IAEvC,oBAAoB,EAAE,mCAAmC,CAAM;IAE/D,sBAAsB,EAAE,qCAAqC,CAAM;gBAEvD,OAAO,EAAE,QAAQ;CAI9B"}
|
|
@@ -7,12 +7,17 @@ exports.validateDashboardUserConfig = void 0;
|
|
|
7
7
|
const bson_1 = require("bson");
|
|
8
8
|
const BaseDocumentWithType_1 = __importDefault(require("../BaseDocumentWithType"));
|
|
9
9
|
const ValidateUtil_1 = __importDefault(require("../../schemas/validators/ValidateUtil"));
|
|
10
|
+
const SortSettings_1 = require("../../embedded-types/dashboard/task/SortSettings");
|
|
11
|
+
const FilterSettings_1 = require("../../embedded-types/dashboard/task/FilterSettings");
|
|
10
12
|
const validateDashboardUserConfig = (config) => {
|
|
11
13
|
const errors = [];
|
|
12
14
|
const validate = new ValidateUtil_1.default(config, errors);
|
|
13
15
|
const exampleConfig = new DashboardUserConfig(new bson_1.ObjectId());
|
|
14
16
|
validate.boolean('enableDevMode', exampleConfig.enableDevMode);
|
|
15
17
|
validate.array('collaborators', exampleConfig.collaborators);
|
|
18
|
+
validate.object('tagSettings', {});
|
|
19
|
+
(0, SortSettings_1.validateSortSettings)(validate, config);
|
|
20
|
+
(0, FilterSettings_1.validateFilterSettings)(validate, config);
|
|
16
21
|
return { updatedDoc: config, errors };
|
|
17
22
|
};
|
|
18
23
|
exports.validateDashboardUserConfig = validateDashboardUserConfig;
|
|
@@ -32,6 +37,12 @@ class DashboardUserConfig extends BaseDocumentWithType_1.default {
|
|
|
32
37
|
* Whether or not to enable dev mode for the user.
|
|
33
38
|
*/
|
|
34
39
|
enableDevMode = false;
|
|
40
|
+
/**
|
|
41
|
+
* The user's tag settings for the dashboard.
|
|
42
|
+
*/
|
|
43
|
+
tagSettings = {};
|
|
44
|
+
taskListSortSettings = {};
|
|
45
|
+
taskListFilterSettings = {};
|
|
35
46
|
constructor(ownerId) {
|
|
36
47
|
super();
|
|
37
48
|
this.userId = ownerId;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import DashboardUserConfig from '../../../documents/dashboard/UserConfig';
|
|
2
|
+
import Validate from '../../../schemas/validators/ValidateUtil';
|
|
3
|
+
export declare function getDefaultTaskListFilterSettings(userId: string): DashboardTaskListFilterSettings;
|
|
4
|
+
export declare function validateFilterSettings(validate: Validate, config: DashboardUserConfig): void;
|
|
5
|
+
/**
|
|
6
|
+
* Global task list filter settings. These are created for each user in the
|
|
7
|
+
* Dashboard config.
|
|
8
|
+
*/
|
|
9
|
+
export type DashboardTaskListGlobalFilterSettings = {
|
|
10
|
+
[category: string]: DashboardTaskListFilterSettings;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The filter settings for a particular task. Each user can have their
|
|
14
|
+
* own settings for a task.
|
|
15
|
+
*/
|
|
16
|
+
export type DashboardTaskFilterSettings = {
|
|
17
|
+
[userId: string]: DashboardTaskListFilterSettings;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The filter settings for a list of tasks for a particular user.
|
|
21
|
+
*
|
|
22
|
+
* Any new settings should be made optional so that they can be added
|
|
23
|
+
* without breaking existing users or tasks.
|
|
24
|
+
*/
|
|
25
|
+
export type DashboardTaskListFilterSettings = {
|
|
26
|
+
userId: string;
|
|
27
|
+
completed: StandardFilterSetting;
|
|
28
|
+
grandChildrenTasks: StandardFilterSetting;
|
|
29
|
+
startDate: {
|
|
30
|
+
showFutureTasks: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The default for tags, if not defined, is to show them.
|
|
34
|
+
*/
|
|
35
|
+
tags: {
|
|
36
|
+
[tag: string]: StandardFilterSetting;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type StandardFilterSetting = {
|
|
40
|
+
show: boolean;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=FilterSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterSettings.d.ts","sourceRoot":"","sources":["../../../../src/embedded-types/dashboard/task/FilterSettings.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,yCAAyC,CAAC;AAC1E,OAAO,QAAQ,MAAM,0CAA0C,CAAC;AAEhE,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,GACb,+BAA+B,CAQjC;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,mBAAmB,QAmC5B;AAED;;;GAGG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,CAAC,QAAQ,EAAE,MAAM,GAAG,+BAA+B,CAAC;CACrD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,CAAC,MAAM,EAAE,MAAM,GAAG,+BAA+B,CAAC;CACnD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,qBAAqB,CAAC;IACjC,kBAAkB,EAAE,qBAAqB,CAAC;IAC1C,SAAS,EAAE;QACT,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF;;OAEG;IACH,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAA;KAAE,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,OAAO,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateFilterSettings = exports.getDefaultTaskListFilterSettings = void 0;
|
|
4
|
+
function getDefaultTaskListFilterSettings(userId) {
|
|
5
|
+
return {
|
|
6
|
+
userId,
|
|
7
|
+
completed: { show: true },
|
|
8
|
+
grandChildrenTasks: { show: false },
|
|
9
|
+
startDate: { showFutureTasks: true },
|
|
10
|
+
tags: {}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
exports.getDefaultTaskListFilterSettings = getDefaultTaskListFilterSettings;
|
|
14
|
+
function validateFilterSettings(validate, config) {
|
|
15
|
+
validate.object('taskListFilterSettings', {});
|
|
16
|
+
const categories = Object.keys(config.taskListFilterSettings);
|
|
17
|
+
if (categories.length > 0) {
|
|
18
|
+
const defaultSettings = getDefaultTaskListFilterSettings(config.userId.toString());
|
|
19
|
+
categories.forEach((category) => {
|
|
20
|
+
validate.string(`taskListFilterSettings.${category}.userId`, defaultSettings.userId);
|
|
21
|
+
validate.object(`taskListFilterSettings.${category}.completed`, defaultSettings.completed);
|
|
22
|
+
validate.boolean(`taskListFilterSettings.${category}.completed.show`, defaultSettings.completed.show);
|
|
23
|
+
validate.object(`taskListFilterSettings.${category}.startDate`, defaultSettings.startDate);
|
|
24
|
+
validate.boolean(`taskListFilterSettings.${category}.startDate.showFutureTasks`, defaultSettings.startDate.showFutureTasks);
|
|
25
|
+
validate.object(`taskListFilterSettings.${category}.tags`, defaultSettings.tags);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.validateFilterSettings = validateFilterSettings;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import DashboardUserConfig from '../../../documents/dashboard/UserConfig';
|
|
2
|
+
import Validate from '../../../schemas/validators/ValidateUtil';
|
|
3
|
+
export declare function getDefaultTaskListSortSettings(userId: string): DashboardTaskListSortSettings;
|
|
4
|
+
export declare function validateSortSettings(validate: Validate, config: DashboardUserConfig): void;
|
|
5
|
+
export type DashboardTaskListGlobalSortSettings = {
|
|
6
|
+
[category: string]: DashboardTaskListSortSettings;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The sort settings for a particular task. Each user can have their
|
|
10
|
+
* own settings for a task.
|
|
11
|
+
*/
|
|
12
|
+
export type DashboardTaskSortSettings = {
|
|
13
|
+
[userId: string]: DashboardTaskListSortSettings;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The sort settings for a list of tasks for a particular user.
|
|
17
|
+
*/
|
|
18
|
+
export type DashboardTaskListSortSettings = {
|
|
19
|
+
userId: string;
|
|
20
|
+
sortList: Array<DashboardTaskSortSetting>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The sortBy options for a task list.
|
|
24
|
+
*/
|
|
25
|
+
export declare enum DashboardTaskSortBy {
|
|
26
|
+
/**
|
|
27
|
+
* Tags are special because they depend on the user's global tag settings.
|
|
28
|
+
*/
|
|
29
|
+
tags = "tags",
|
|
30
|
+
title = "title",
|
|
31
|
+
dueDate = "dueDate",
|
|
32
|
+
startDate = "startDate",
|
|
33
|
+
createdDate = "createdDate",
|
|
34
|
+
lastUpdatedDate = "lastUpdatedDate"
|
|
35
|
+
}
|
|
36
|
+
export type DashboardTaskSortSetting = {
|
|
37
|
+
sortBy: DashboardTaskSortBy;
|
|
38
|
+
sortDirection: DashboardTaskSortDirection;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The sort direction for a sorting setting. This is used as a multiplier
|
|
42
|
+
* for the sort function.
|
|
43
|
+
*/
|
|
44
|
+
export declare enum DashboardTaskSortDirection {
|
|
45
|
+
/**
|
|
46
|
+
* Higher as the numbers go down the list.
|
|
47
|
+
*/
|
|
48
|
+
ascending = 1,
|
|
49
|
+
/**
|
|
50
|
+
* Lower as the numbers go down the list.
|
|
51
|
+
*/
|
|
52
|
+
descending = -1
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=SortSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortSettings.d.ts","sourceRoot":"","sources":["../../../../src/embedded-types/dashboard/task/SortSettings.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,yCAAyC,CAAC;AAC1E,OAAO,QAAQ,MAAM,0CAA0C,CAAC;AAEhE,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,GACb,6BAA6B,CAK/B;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,mBAAmB,QAmB5B;AAED,MAAM,MAAM,mCAAmC,GAAG;IAChD,CAAC,QAAQ,EAAE,MAAM,GAAG,6BAA6B,CAAC;CACnD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,CAAC,MAAM,EAAE,MAAM,GAAG,6BAA6B,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,IAAI,SAAS;IACb,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,eAAe,oBAAoB;CACpC;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,aAAa,EAAE,0BAA0B,CAAC;CAC3C,CAAC;AAEF;;;GAGG;AACH,oBAAY,0BAA0B;IACpC;;OAEG;IACH,SAAS,IAAI;IACb;;OAEG;IACH,UAAU,KAAK;CAChB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DashboardTaskSortDirection = exports.DashboardTaskSortBy = exports.validateSortSettings = exports.getDefaultTaskListSortSettings = void 0;
|
|
4
|
+
function getDefaultTaskListSortSettings(userId) {
|
|
5
|
+
return {
|
|
6
|
+
userId,
|
|
7
|
+
sortList: []
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.getDefaultTaskListSortSettings = getDefaultTaskListSortSettings;
|
|
11
|
+
function validateSortSettings(validate, config) {
|
|
12
|
+
validate.object('taskListSortSettings', {});
|
|
13
|
+
const categories = Object.keys(config.taskListSortSettings);
|
|
14
|
+
if (categories.length > 0) {
|
|
15
|
+
const defaultSettings = getDefaultTaskListSortSettings(config.userId.toString());
|
|
16
|
+
categories.forEach((category) => {
|
|
17
|
+
validate.string(`taskListSortSettings.${category}.userId`, defaultSettings.userId);
|
|
18
|
+
validate.array(`taskListSortSettings.${category}.sortList`, defaultSettings.sortList);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.validateSortSettings = validateSortSettings;
|
|
23
|
+
/**
|
|
24
|
+
* The sortBy options for a task list.
|
|
25
|
+
*/
|
|
26
|
+
var DashboardTaskSortBy;
|
|
27
|
+
(function (DashboardTaskSortBy) {
|
|
28
|
+
/**
|
|
29
|
+
* Tags are special because they depend on the user's global tag settings.
|
|
30
|
+
*/
|
|
31
|
+
DashboardTaskSortBy["tags"] = "tags";
|
|
32
|
+
DashboardTaskSortBy["title"] = "title";
|
|
33
|
+
DashboardTaskSortBy["dueDate"] = "dueDate";
|
|
34
|
+
DashboardTaskSortBy["startDate"] = "startDate";
|
|
35
|
+
DashboardTaskSortBy["createdDate"] = "createdDate";
|
|
36
|
+
DashboardTaskSortBy["lastUpdatedDate"] = "lastUpdatedDate";
|
|
37
|
+
})(DashboardTaskSortBy || (exports.DashboardTaskSortBy = DashboardTaskSortBy = {}));
|
|
38
|
+
/**
|
|
39
|
+
* The sort direction for a sorting setting. This is used as a multiplier
|
|
40
|
+
* for the sort function.
|
|
41
|
+
*/
|
|
42
|
+
var DashboardTaskSortDirection;
|
|
43
|
+
(function (DashboardTaskSortDirection) {
|
|
44
|
+
/**
|
|
45
|
+
* Higher as the numbers go down the list.
|
|
46
|
+
*/
|
|
47
|
+
DashboardTaskSortDirection[DashboardTaskSortDirection["ascending"] = 1] = "ascending";
|
|
48
|
+
/**
|
|
49
|
+
* Lower as the numbers go down the list.
|
|
50
|
+
*/
|
|
51
|
+
DashboardTaskSortDirection[DashboardTaskSortDirection["descending"] = -1] = "descending";
|
|
52
|
+
})(DashboardTaskSortDirection || (exports.DashboardTaskSortDirection = DashboardTaskSortDirection = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type DashboardTagSettings = {
|
|
2
|
+
[tag: string]: DashboardTagSetting;
|
|
3
|
+
};
|
|
4
|
+
export type DashboardTagSetting = {
|
|
5
|
+
/**
|
|
6
|
+
* Higher priority value means higher priority.
|
|
7
|
+
*/
|
|
8
|
+
priority: number;
|
|
9
|
+
color?: string;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=Tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tags.d.ts","sourceRoot":"","sources":["../../../../src/embedded-types/dashboard/userConfig/Tags.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAA;CAAE,CAAC;AAE1E,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,13 +2,15 @@ import BaseDocument from './documents/BaseDocument';
|
|
|
2
2
|
import BaseDocumentWithType from './documents/BaseDocumentWithType';
|
|
3
3
|
import ApiKey, { validateApiKey } from './documents/common/ApiKey';
|
|
4
4
|
import User, { UserCTO, validateUser } from './documents/common/User';
|
|
5
|
-
import DashboardTask, { validateDashboardTask } from './documents/dashboard/Task';
|
|
5
|
+
import DashboardTask, { DashboardTaskMap, validateDashboardTask } from './documents/dashboard/Task';
|
|
6
6
|
import DashboardUserConfig, { validateDashboardUserConfig } from './documents/dashboard/UserConfig';
|
|
7
|
+
import { DashboardTaskListGlobalFilterSettings, DashboardTaskFilterSettings, DashboardTaskListFilterSettings, getDefaultTaskListFilterSettings } from './embedded-types/dashboard/task/FilterSettings';
|
|
7
8
|
import { ParentRecurringTaskInfo, RecurrenceBasis, RecurrenceEffect, RecurrenceFrequency, RecurrenceFrequencyType, RecurrenceInfo } from './embedded-types/dashboard/task/RecurrenceInfo';
|
|
9
|
+
import { DashboardTaskListGlobalSortSettings, DashboardTaskListSortSettings, DashboardTaskSortBy, DashboardTaskSortDirection, DashboardTaskSortSettings, DashboardTaskSortSetting, getDefaultTaskListSortSettings } from './embedded-types/dashboard/task/SortSettings';
|
|
8
10
|
import RequiredUserId from './schemas/required-refs/RequiredUserId';
|
|
9
11
|
import { DocumentValidator } from './schemas/validators/DocumentValidator';
|
|
10
12
|
import DocumentService from './services/DocumentService';
|
|
11
|
-
import DashboardTaskService from './services/dashboard/TaskService';
|
|
12
|
-
export { User, validateUser, ApiKey, validateApiKey, DashboardUserConfig, validateDashboardUserConfig, DashboardTask, RecurrenceFrequencyType, RecurrenceBasis, RecurrenceEffect, validateDashboardTask, DashboardTaskService, BaseDocument, BaseDocumentWithType, RequiredUserId, DocumentService };
|
|
13
|
-
export type { DocumentValidator, UserCTO, RecurrenceInfo, RecurrenceFrequency, ParentRecurringTaskInfo };
|
|
13
|
+
import DashboardTaskService from './services/dashboard/Task/TaskService';
|
|
14
|
+
export { User, validateUser, ApiKey, validateApiKey, DashboardUserConfig, validateDashboardUserConfig, DashboardTask, RecurrenceFrequencyType, RecurrenceBasis, RecurrenceEffect, DashboardTaskSortBy, DashboardTaskSortDirection, getDefaultTaskListFilterSettings, getDefaultTaskListSortSettings, validateDashboardTask, DashboardTaskService, BaseDocument, BaseDocumentWithType, RequiredUserId, DocumentService };
|
|
15
|
+
export type { DocumentValidator, UserCTO, RecurrenceInfo, RecurrenceFrequency, ParentRecurringTaskInfo, DashboardTaskMap, DashboardTaskListGlobalFilterSettings, DashboardTaskFilterSettings, DashboardTaskListFilterSettings, DashboardTaskListGlobalSortSettings, DashboardTaskSortSettings, DashboardTaskListSortSettings, DashboardTaskSortSetting };
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,aAAa,EAAE,EACpB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,mBAAmB,EAAE,EAC1B,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACf,MAAM,gDAAgD,CAAC;AACxD,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,oBAAoB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,aAAa,EAAE,EACpB,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,mBAAmB,EAAE,EAC1B,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,qCAAqC,EACrC,2BAA2B,EAC3B,+BAA+B,EAC/B,gCAAgC,EACjC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACf,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,mCAAmC,EACnC,6BAA6B,EAC7B,mBAAmB,EACnB,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC/B,MAAM,8CAA8C,CAAC;AACtD,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,oBAAoB,MAAM,uCAAuC,CAAC;AAGzE,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,2BAA2B,EAC3B,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,0BAA0B,EAC1B,gCAAgC,EAChC,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,eAAe,EAChB,CAAC;AAGF,YAAY,EACV,iBAAiB,EACjB,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,qCAAqC,EACrC,2BAA2B,EAC3B,+BAA+B,EAC/B,mCAAmC,EACnC,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACzB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.DocumentService = exports.RequiredUserId = exports.BaseDocumentWithType = exports.BaseDocument = exports.DashboardTaskService = exports.validateDashboardTask = exports.RecurrenceEffect = exports.RecurrenceBasis = exports.RecurrenceFrequencyType = exports.DashboardTask = exports.validateDashboardUserConfig = exports.DashboardUserConfig = exports.validateApiKey = exports.ApiKey = exports.validateUser = exports.User = void 0;
|
|
29
|
+
exports.DocumentService = exports.RequiredUserId = exports.BaseDocumentWithType = exports.BaseDocument = exports.DashboardTaskService = exports.validateDashboardTask = exports.getDefaultTaskListSortSettings = exports.getDefaultTaskListFilterSettings = exports.DashboardTaskSortDirection = exports.DashboardTaskSortBy = exports.RecurrenceEffect = exports.RecurrenceBasis = exports.RecurrenceFrequencyType = exports.DashboardTask = exports.validateDashboardUserConfig = exports.DashboardUserConfig = exports.validateApiKey = exports.ApiKey = exports.validateUser = exports.User = void 0;
|
|
30
30
|
const BaseDocument_1 = __importDefault(require("./documents/BaseDocument"));
|
|
31
31
|
exports.BaseDocument = BaseDocument_1.default;
|
|
32
32
|
const BaseDocumentWithType_1 = __importDefault(require("./documents/BaseDocumentWithType"));
|
|
@@ -43,13 +43,19 @@ Object.defineProperty(exports, "validateDashboardTask", { enumerable: true, get:
|
|
|
43
43
|
const UserConfig_1 = __importStar(require("./documents/dashboard/UserConfig"));
|
|
44
44
|
exports.DashboardUserConfig = UserConfig_1.default;
|
|
45
45
|
Object.defineProperty(exports, "validateDashboardUserConfig", { enumerable: true, get: function () { return UserConfig_1.validateDashboardUserConfig; } });
|
|
46
|
+
const FilterSettings_1 = require("./embedded-types/dashboard/task/FilterSettings");
|
|
47
|
+
Object.defineProperty(exports, "getDefaultTaskListFilterSettings", { enumerable: true, get: function () { return FilterSettings_1.getDefaultTaskListFilterSettings; } });
|
|
46
48
|
const RecurrenceInfo_1 = require("./embedded-types/dashboard/task/RecurrenceInfo");
|
|
47
49
|
Object.defineProperty(exports, "RecurrenceBasis", { enumerable: true, get: function () { return RecurrenceInfo_1.RecurrenceBasis; } });
|
|
48
50
|
Object.defineProperty(exports, "RecurrenceEffect", { enumerable: true, get: function () { return RecurrenceInfo_1.RecurrenceEffect; } });
|
|
49
51
|
Object.defineProperty(exports, "RecurrenceFrequencyType", { enumerable: true, get: function () { return RecurrenceInfo_1.RecurrenceFrequencyType; } });
|
|
52
|
+
const SortSettings_1 = require("./embedded-types/dashboard/task/SortSettings");
|
|
53
|
+
Object.defineProperty(exports, "DashboardTaskSortBy", { enumerable: true, get: function () { return SortSettings_1.DashboardTaskSortBy; } });
|
|
54
|
+
Object.defineProperty(exports, "DashboardTaskSortDirection", { enumerable: true, get: function () { return SortSettings_1.DashboardTaskSortDirection; } });
|
|
55
|
+
Object.defineProperty(exports, "getDefaultTaskListSortSettings", { enumerable: true, get: function () { return SortSettings_1.getDefaultTaskListSortSettings; } });
|
|
50
56
|
const RequiredUserId_1 = __importDefault(require("./schemas/required-refs/RequiredUserId"));
|
|
51
57
|
exports.RequiredUserId = RequiredUserId_1.default;
|
|
52
58
|
const DocumentService_1 = __importDefault(require("./services/DocumentService"));
|
|
53
59
|
exports.DocumentService = DocumentService_1.default;
|
|
54
|
-
const TaskService_1 = __importDefault(require("./services/dashboard/TaskService"));
|
|
60
|
+
const TaskService_1 = __importDefault(require("./services/dashboard/Task/TaskService"));
|
|
55
61
|
exports.DashboardTaskService = TaskService_1.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentService.spec.d.ts","sourceRoot":"","sources":["../../src/services/DocumentService.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bson_1 = require("bson");
|
|
7
|
+
const DocumentService_1 = __importDefault(require("./DocumentService"));
|
|
8
|
+
describe('DocumentService', () => {
|
|
9
|
+
describe('deepCopy', () => {
|
|
10
|
+
it('should return a deep copy of the object', () => {
|
|
11
|
+
const obj = {
|
|
12
|
+
id: new bson_1.ObjectId(),
|
|
13
|
+
a: 1,
|
|
14
|
+
b: {
|
|
15
|
+
c: 2
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const result = DocumentService_1.default.deepCopy(obj);
|
|
19
|
+
expect(result).toEqual(obj);
|
|
20
|
+
expect(typeof result.id === 'object').toBeTruthy();
|
|
21
|
+
expect(result.id.toString()).toEqual(obj.id.toString());
|
|
22
|
+
expect(result).not.toBe(obj);
|
|
23
|
+
expect(result.b).toEqual(obj.b);
|
|
24
|
+
expect(result.b).not.toBe(obj.b);
|
|
25
|
+
// Change the original object and make sure the copy is not affected
|
|
26
|
+
obj.b.c = 3;
|
|
27
|
+
expect(result.b.c).toEqual(2);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DashboardTaskMap } from '../../../documents/dashboard/Task';
|
|
2
|
+
import { DashboardTaskListFilterSettings } from '../../../embedded-types/dashboard/task/FilterSettings';
|
|
3
|
+
/**
|
|
4
|
+
* A service responsible for filtering
|
|
5
|
+
*/
|
|
6
|
+
export default class DashboardTaskFilterService {
|
|
7
|
+
/**
|
|
8
|
+
* Filters the provided task ids based on the provided filter settings.
|
|
9
|
+
*
|
|
10
|
+
* This should filter first based on the most common cases, or faster-to-check
|
|
11
|
+
* cases, then the less common or more heavy cases later on to increase
|
|
12
|
+
* performance.
|
|
13
|
+
*
|
|
14
|
+
* @param taskMap the map of tasks to use for filtering. This is used so that
|
|
15
|
+
* the task map doesn't need to be generated multiple times.
|
|
16
|
+
* @param parentTaskId determines if the current list is for a parent task
|
|
17
|
+
* or not
|
|
18
|
+
*/
|
|
19
|
+
static filter(taskMap: DashboardTaskMap, taskIds: string[], settings: DashboardTaskListFilterSettings, category: string, parentTaskId?: string): string[];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=TaskFilterService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskFilterService.d.ts","sourceRoot":"","sources":["../../../../src/services/dashboard/Task/TaskFilterService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uDAAuD,CAAC;AAExG;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,CACX,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,EAAE,+BAA+B,EACzC,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM;CA0DxB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* A service responsible for filtering
|
|
5
|
+
*/
|
|
6
|
+
class DashboardTaskFilterService {
|
|
7
|
+
/**
|
|
8
|
+
* Filters the provided task ids based on the provided filter settings.
|
|
9
|
+
*
|
|
10
|
+
* This should filter first based on the most common cases, or faster-to-check
|
|
11
|
+
* cases, then the less common or more heavy cases later on to increase
|
|
12
|
+
* performance.
|
|
13
|
+
*
|
|
14
|
+
* @param taskMap the map of tasks to use for filtering. This is used so that
|
|
15
|
+
* the task map doesn't need to be generated multiple times.
|
|
16
|
+
* @param parentTaskId determines if the current list is for a parent task
|
|
17
|
+
* or not
|
|
18
|
+
*/
|
|
19
|
+
static filter(taskMap, taskIds, settings, category, parentTaskId) {
|
|
20
|
+
return taskIds.filter((taskId) => {
|
|
21
|
+
const task = taskMap[taskId];
|
|
22
|
+
// Category
|
|
23
|
+
if (!task || task.category !== category)
|
|
24
|
+
return false;
|
|
25
|
+
// Parent task
|
|
26
|
+
// (the current list is only children tasks)
|
|
27
|
+
if (parentTaskId) {
|
|
28
|
+
if (!settings.grandChildrenTasks.show &&
|
|
29
|
+
task.parentTaskId &&
|
|
30
|
+
task.parentTaskId.toString() !== parentTaskId) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
// The list is all for a category, so filter out children tasks if needed.
|
|
34
|
+
}
|
|
35
|
+
else if (!settings.grandChildrenTasks.show &&
|
|
36
|
+
task.parentTaskId &&
|
|
37
|
+
taskMap[task.parentTaskId.toString()]) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
// Completed
|
|
41
|
+
if (!settings.completed.show && task.completed) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
// Start date
|
|
45
|
+
if (!settings.startDate.showFutureTasks &&
|
|
46
|
+
task.startDate &&
|
|
47
|
+
task.startDate > new Date()) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
// Tags
|
|
51
|
+
const tags = task.tags[settings.userId];
|
|
52
|
+
if (tags && tags.length > 0) {
|
|
53
|
+
const shouldHide = tags.some((tag) => {
|
|
54
|
+
if (settings.tags[tag] && !settings.tags[tag].show) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
});
|
|
59
|
+
if (shouldHide) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.default = DashboardTaskFilterService;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RecurrenceFrequency } from '../../../embedded-types/dashboard/task/RecurrenceInfo';
|
|
2
|
+
import DashboardTask from '../../../documents/dashboard/Task';
|
|
3
|
+
export default class DashboardTaskRecurrenceService {
|
|
4
|
+
/**
|
|
5
|
+
* Gets the next frequency date from the provided basis date. Returns null
|
|
6
|
+
* if the provided frequency is in an invalid state.
|
|
7
|
+
*/
|
|
8
|
+
static getNextFrequencyDate(basisDate: Date, frequency: RecurrenceFrequency): Date | null;
|
|
9
|
+
/**
|
|
10
|
+
* Moves the start and due date forward by one frequency.
|
|
11
|
+
*
|
|
12
|
+
* This does not take into account the recurrence effect. That should be
|
|
13
|
+
* handled on the frontend.
|
|
14
|
+
*
|
|
15
|
+
* Makes no changes if the state of the task is invalid for recurrence or
|
|
16
|
+
* there isn't recurrence info.
|
|
17
|
+
*/
|
|
18
|
+
static updateDatesForRecurrence(task: DashboardTask): void;
|
|
19
|
+
private static getDiffForDateUpdate;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=TaskRecurrenceService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskRecurrenceService.d.ts","sourceRoot":"","sources":["../../../../src/services/dashboard/Task/TaskRecurrenceService.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EAEpB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,aAAa,MAAM,mCAAmC,CAAC;AAE9D,MAAM,CAAC,OAAO,OAAO,8BAA8B;IACjD;;;OAGG;IACH,MAAM,CAAC,oBAAoB,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,mBAAmB;IAsE3E;;;;;;;;OAQG;IACH,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IA+D1D,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAapC"}
|