Skip to content

Commit 86c3bd2

Browse files
authored
Merge branch 'basic-task-sorting' into task-sorting
2 parents 2e363b2 + c6080a5 commit 86c3bd2

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

config/default/app_settings.json

Lines changed: 5 additions & 3 deletions
Large diffs are not rendered by default.

config/default/tasks.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,15 @@ module.exports = [
304304
const endTime = addDays(dueDate, event.end).getTime();
305305
return isFormArraySubmittedInWindow(contact.reports, ['pnc_danger_sign_follow_up_baby'], startTime, endTime);
306306
},
307+
priority: function(contact, report, event, dueDate) {
308+
console.warn(contact);
309+
console.warn(event);
310+
console.warn(dueDate);
311+
return {
312+
level: 10,
313+
label: 'High',
314+
};
315+
},
307316
actions: [
308317
{
309318
type: 'report',
@@ -342,6 +351,15 @@ module.exports = [
342351
const endTime = addDays(dueDate, event.end + 1).getTime();
343352
return isFormArraySubmittedInWindow(contact.reports, ['pnc_danger_sign_follow_up_baby'], startTime, endTime);
344353
},
354+
priority: function(contact, report, event, dueDate) {
355+
console.warn(contact);
356+
console.warn(event);
357+
console.warn(dueDate);
358+
return {
359+
level: 10,
360+
label: 'High',
361+
};
362+
},
345363
actions: [
346364
{
347365
type: 'report',

webapp/src/ts/reducers/tasks.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@ const initialState = {
1414
},
1515
};
1616

17-
1817
const orderByDueDateAndPriority1 = (t1, t2) => {
18+
1919
const lhs = t1?.dueDate;
2020
const rhs = t2?.dueDate;
21+
22+
const lhsPriority = t1?.priority;
23+
const rhsPriority = t2?.priority;
24+
25+
if ((lhsPriority && !rhsPriority) || lhsPriority > rhsPriority) {
26+
return -1;
27+
}
28+
29+
if ((!lhsPriority && rhsPriority) || lhsPriority < rhsPriority) {
30+
return 1;
31+
}
32+
2133
if (!lhs && !rhs) {
2234
return 0;
2335
}

0 commit comments

Comments
 (0)