@aneuhold/core-ts-db-lib 1.0.43 → 1.0.44
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.
|
@@ -356,7 +356,7 @@ describe('DashboardTaskService', () => {
|
|
|
356
356
|
const task4 = tasksList[2];
|
|
357
357
|
const task5 = tasksList[3];
|
|
358
358
|
task1.tags = {
|
|
359
|
-
[sortSettings.userId]: ['tagWithoutPriority']
|
|
359
|
+
[sortSettings.userId]: ['tagWithoutPriority', 'tag3']
|
|
360
360
|
};
|
|
361
361
|
task2.tags = {
|
|
362
362
|
[sortSettings.userId]: ['tag3', 'tag4', 'tag1']
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DashboardTaskMap } from '../../../documents/dashboard/Task';
|
|
2
2
|
import { DashboardTaskListSortSettings, DashboardTaskSortDirection } from '../../../embedded-types/dashboard/task/SortSettings';
|
|
3
3
|
import { DashboardTagSettings } from '../../../embedded-types/dashboard/userConfig/Tags';
|
|
4
4
|
/**
|
|
@@ -24,6 +24,7 @@ export default class DashboardTaskSortService {
|
|
|
24
24
|
/**
|
|
25
25
|
* Gets the highest priority tag value for the provided task.
|
|
26
26
|
*/
|
|
27
|
-
static getHighestPriorityTagValue
|
|
27
|
+
private static getHighestPriorityTagValue;
|
|
28
|
+
private static getPriorityTagForTask;
|
|
28
29
|
}
|
|
29
30
|
//# sourceMappingURL=TaskSortService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskSortService.d.ts","sourceRoot":"","sources":["../../../../src/services/dashboard/Task/TaskSortService.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"TaskSortService.d.ts","sourceRoot":"","sources":["../../../../src/services/dashboard/Task/TaskSortService.ts"],"names":[],"mappings":"AAAA,OAAsB,EACpB,gBAAgB,EACjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,6BAA6B,EAE7B,0BAA0B,EAC3B,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAEzF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAwB;IAC3C;;OAEG;IACH,MAAM,CAAC,IAAI,CACT,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,MAAM,EAAE,EACjB,YAAY,EAAE,6BAA6B,EAC3C,WAAW,EAAE,oBAAoB;IA0BnC;;;;OAIG;IACH,MAAM,CAAC,eAAe,CACpB,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,oBAAoB,EACjC,uBAAuB,EAAE,MAAM,EAC/B,aAAa,EAAE,0BAA0B,GACxC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAkCzB,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAkElC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAepC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAezC,OAAO,CAAC,MAAM,CAAC,qBAAqB;CAgCrC"}
|
|
@@ -114,44 +114,40 @@ class DashboardTaskSortService {
|
|
|
114
114
|
* or if there are no tags with a priority, then this will return null.
|
|
115
115
|
*/
|
|
116
116
|
static getHighestPriorityTag(task, userId, tagSettings, sortDirection) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
return null;
|
|
120
|
-
let highestPriorityTag = null;
|
|
121
|
-
let highestPriority = 0;
|
|
122
|
-
const sortDirectionIsAscending = sortDirection === SortSettings_1.DashboardTaskSortDirection.ascending;
|
|
123
|
-
// If the sort direction is descending, then we want to start with the
|
|
124
|
-
// lowest priority number.
|
|
125
|
-
if (sortDirectionIsAscending) {
|
|
126
|
-
highestPriority = Number.MAX_SAFE_INTEGER;
|
|
127
|
-
}
|
|
128
|
-
tags.forEach((tag) => {
|
|
129
|
-
const priority = tagSettings[tag]?.priority;
|
|
130
|
-
if (priority &&
|
|
131
|
-
((sortDirectionIsAscending && priority < highestPriority) ||
|
|
132
|
-
(!sortDirectionIsAscending && priority > highestPriority))) {
|
|
133
|
-
highestPriorityTag = tag;
|
|
134
|
-
highestPriority = priority;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
return highestPriorityTag;
|
|
117
|
+
const priorityTag = this.getPriorityTagForTask(task, userId, tagSettings, sortDirection);
|
|
118
|
+
return priorityTag ? priorityTag.tag : null;
|
|
138
119
|
}
|
|
139
120
|
/**
|
|
140
121
|
* Gets the highest priority tag value for the provided task.
|
|
141
122
|
*/
|
|
142
123
|
static getHighestPriorityTagValue(task, userId, tagSettings, sortDirection) {
|
|
124
|
+
const priorityTag = this.getPriorityTagForTask(task, userId, tagSettings, sortDirection);
|
|
125
|
+
return priorityTag ? priorityTag.priority : 0;
|
|
126
|
+
}
|
|
127
|
+
static getPriorityTagForTask(task, userId, tagSettings, sortDirection) {
|
|
128
|
+
let priorityTag = null;
|
|
143
129
|
const tags = task.tags[userId];
|
|
144
130
|
if (!tags || tags.length === 0)
|
|
145
|
-
return
|
|
131
|
+
return priorityTag;
|
|
132
|
+
let highestPriority = 0;
|
|
146
133
|
const isAscending = sortDirection === SortSettings_1.DashboardTaskSortDirection.ascending;
|
|
147
|
-
|
|
134
|
+
// If the sort direction is descending, then we want to start with the
|
|
135
|
+
// lowest priority number.
|
|
136
|
+
if (isAscending) {
|
|
137
|
+
highestPriority = Number.MAX_SAFE_INTEGER;
|
|
138
|
+
}
|
|
139
|
+
tags.forEach((tag) => {
|
|
148
140
|
const priority = tagSettings[tag]?.priority ?? 0;
|
|
149
141
|
if ((isAscending && priority < highestPriority) ||
|
|
150
142
|
(!isAscending && priority > highestPriority)) {
|
|
151
|
-
|
|
143
|
+
highestPriority = priority;
|
|
144
|
+
priorityTag = { tag, priority };
|
|
152
145
|
}
|
|
153
|
-
|
|
154
|
-
|
|
146
|
+
});
|
|
147
|
+
if (highestPriority === 0) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return priorityTag;
|
|
155
151
|
}
|
|
156
152
|
}
|
|
157
153
|
exports.default = DashboardTaskSortService;
|