@zeniai/client-epic-state 5.1.41-beta1ND → 5.1.41-betaDI3
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/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -1
- package/lib/entity/task/taskPayload.d.ts +2 -1
- package/lib/entity/task/taskPayload.js +8 -1
- package/lib/entity/task/taskReducer.d.ts +8 -1
- package/lib/entity/task/taskReducer.js +29 -4
- package/lib/entity/task/taskState.d.ts +1 -0
- package/lib/entity/tenant/epic/saveExternalConnectionEpic.js +7 -15
- package/lib/epic.d.ts +5 -3
- package/lib/epic.js +5 -3
- package/lib/esm/entity/snackbar/snackbarTypes.js +1 -1
- package/lib/esm/entity/task/taskPayload.js +8 -1
- package/lib/esm/entity/task/taskReducer.js +28 -3
- package/lib/esm/entity/tenant/epic/saveExternalConnectionEpic.js +7 -15
- package/lib/esm/epic.js +5 -3
- package/lib/esm/index.js +3 -3
- package/lib/esm/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +3 -0
- package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +7 -1
- package/lib/esm/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +96 -0
- package/lib/esm/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +53 -0
- package/lib/esm/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +1 -0
- package/lib/esm/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +70 -9
- package/lib/esm/view/taskManager/taskDetailView/taskDetailReducer.js +56 -2
- package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +32 -9
- package/lib/esm/view/taskManager/taskListView/epics/fetchTaskListEpic.js +3 -1
- package/lib/esm/view/taskManager/taskListView/taskList.js +1 -0
- package/lib/esm/view/taskManager/taskListView/taskListReducer.js +240 -12
- package/lib/esm/view/taskManager/taskListView/taskListSelector.js +1 -0
- package/lib/esm/view/taskManager/taskListView/taskListViewHelpers.js +58 -0
- package/lib/index.d.ts +6 -6
- package/lib/index.js +13 -9
- package/lib/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +3 -0
- package/lib/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +7 -1
- package/lib/view/companyView/types/cockpitTypes.d.ts +3 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.d.ts +9 -0
- package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +100 -0
- package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.d.ts +8 -0
- package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +57 -0
- package/lib/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +1 -0
- package/lib/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.d.ts +2 -2
- package/lib/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +69 -8
- package/lib/view/taskManager/taskDetailView/taskDetail.d.ts +15 -0
- package/lib/view/taskManager/taskDetailView/taskDetailReducer.d.ts +14 -2
- package/lib/view/taskManager/taskDetailView/taskDetailReducer.js +57 -3
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.d.ts +2 -1
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +30 -7
- package/lib/view/taskManager/taskListView/epics/fetchTaskListEpic.js +3 -1
- package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
- package/lib/view/taskManager/taskListView/taskList.js +1 -0
- package/lib/view/taskManager/taskListView/taskListPayload.d.ts +4 -0
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +6 -2
- package/lib/view/taskManager/taskListView/taskListReducer.js +241 -13
- package/lib/view/taskManager/taskListView/taskListSelector.js +1 -0
- package/lib/view/taskManager/taskListView/taskListViewHelpers.d.ts +11 -0
- package/lib/view/taskManager/taskListView/taskListViewHelpers.js +60 -1
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearTaskList = exports.removeTaskFromList = exports.updateTaskListOnCreateTaskFromTemplateSuccess = exports.updateTasksListOnUpdateTaskFailure = exports.updateTasksListOnUpdateTaskSuccess = exports.updateTaskFromListView = exports.updateTaskListOnTaskGroupNameUpdate = exports.updateTaskListOnNewTaskCreationSuccess = exports.dragNDropTasks = exports.updateTaskListOnTaskGroupDeletion = exports.updateTaskListLocalData = exports.initiateTaskListLocalData = exports.updateTasksListOnBulkUpdateTasksFailure = exports.updateTasksListOnBulkUpdateTasksSuccess = exports.bulkUpdateTaskList = exports.updateTaskListOnNewGroupCreationSuccess = exports.updateTaskFilters = exports.updateTaskListUIState = exports.updateTaskListSearchText = exports.updateTaskListFetchStatus = exports.updateTaskListTab = exports.updateTaskList = exports.fetchTaskList = exports.fetchTaskListPage = exports.initialState = void 0;
|
|
4
|
+
exports.clearTaskList = exports.removeTaskFromGroupBucket = exports.removeTaskFromList = exports.updateTaskListOnCreateTaskFromTemplateSuccess = exports.updateTasksListOnUpdateTaskFailure = exports.updateTasksListOnUpdateTaskSuccess = exports.updateTaskFromListView = exports.updateTaskListOnTaskGroupNameUpdate = exports.updateTaskListOnNewTaskCreationSuccess = exports.dragNDropTasks = exports.updateTaskListOnTaskGroupDeletion = exports.updateTaskListLocalData = exports.initiateTaskListLocalData = exports.updateTasksListOnBulkUpdateTasksFailure = exports.updateTasksListOnBulkUpdateTasksSuccess = exports.bulkUpdateTaskList = exports.updateTaskListOnNewGroupCreationSuccess = exports.updateTaskFilters = exports.updateTaskListUIState = exports.updateTaskListSearchText = exports.updateTaskListFetchStatus = exports.updateTaskListTab = exports.updateTaskList = exports.fetchTaskList = exports.fetchTaskListPage = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const taskReducer_1 = require("../../../entity/task/taskReducer");
|
|
6
7
|
const taskState_1 = require("../../../entity/task/taskState");
|
|
7
8
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
8
9
|
const taskList_1 = require("./taskList");
|
|
@@ -46,6 +47,7 @@ exports.initialState = {
|
|
|
46
47
|
currentTab: 'live',
|
|
47
48
|
byTab: {
|
|
48
49
|
live: { ...initialTabData },
|
|
50
|
+
completed: { ...initialTabData },
|
|
49
51
|
archived: { ...initialTabData },
|
|
50
52
|
deleted: { ...initialTabData },
|
|
51
53
|
snoozed: { ...initialTabData },
|
|
@@ -67,14 +69,12 @@ exports.initialState = {
|
|
|
67
69
|
},
|
|
68
70
|
filters: {
|
|
69
71
|
categoryCombinationOperator: 'AND',
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
],
|
|
72
|
+
// Default to no filters. The Completed tab now owns the "hide resolved
|
|
73
|
+
// tasks from the live list" responsibility via the byTab split in
|
|
74
|
+
// updateTaskList / updateTaskFromListView / the updateTasks
|
|
75
|
+
// extraReducer. Keeping the historical `status != resolved` filter
|
|
76
|
+
// here would empty out the Completed tab.
|
|
77
|
+
categories: [],
|
|
78
78
|
},
|
|
79
79
|
hasValidState() {
|
|
80
80
|
return this.fetchState == 'Completed';
|
|
@@ -106,13 +106,16 @@ const taskList = (0, toolkit_1.createSlice)({
|
|
|
106
106
|
draft.error = undefined;
|
|
107
107
|
},
|
|
108
108
|
updateTaskList(draft, action) {
|
|
109
|
-
const { data, archived, deleted, snoozed } = action.payload;
|
|
109
|
+
const { data, archived, completed, deleted, snoozed } = action.payload;
|
|
110
110
|
draft.fetchState = 'Completed';
|
|
111
111
|
draft.error = undefined;
|
|
112
112
|
// Group live tasks
|
|
113
113
|
const liveGrouped = getGroupedTaskIds(data);
|
|
114
114
|
draft.byTab.live = toTabData(liveGrouped);
|
|
115
115
|
// Group other tabs if provided
|
|
116
|
+
if (completed != null) {
|
|
117
|
+
draft.byTab.completed = toTabData(getGroupedTaskIds(completed));
|
|
118
|
+
}
|
|
116
119
|
if (archived != null) {
|
|
117
120
|
draft.byTab.archived = toTabData(getGroupedTaskIds(archived));
|
|
118
121
|
}
|
|
@@ -358,9 +361,26 @@ const taskList = (0, toolkit_1.createSlice)({
|
|
|
358
361
|
draft.taskIdsByAssignees[assigneeKey] = draft.taskIdsByAssignees[assigneeKey].filter((taskId) => taskId !== currentTaskState.id);
|
|
359
362
|
draft.taskIdsByTags[tagsKey] = draft.taskIdsByTags[tagsKey].filter((taskId) => taskId !== currentTaskState.id);
|
|
360
363
|
draft.taskIdsByDueDate[dueDateKey] = draft.taskIdsByDueDate[dueDateKey].filter((taskId) => taskId !== currentTaskState.id);
|
|
361
|
-
|
|
364
|
+
// Remove from EVERY previous group bucket the task lived in, not
|
|
365
|
+
// just the destination bucket. Otherwise a detail-page save that
|
|
366
|
+
// moves a task from group A to group B leaves the row listed
|
|
367
|
+
// under both A and B until refetch.
|
|
368
|
+
const previousGroupIds = currentTaskState.taskGroupIds ?? [];
|
|
369
|
+
const allGroupIdsToClean = new Set([
|
|
370
|
+
...previousGroupIds,
|
|
371
|
+
taskGroupId,
|
|
372
|
+
]);
|
|
373
|
+
allGroupIdsToClean.forEach((gid) => {
|
|
374
|
+
if (draft.taskIdsByGroupsIds[gid] != null) {
|
|
375
|
+
draft.taskIdsByGroupsIds[gid] = draft.taskIdsByGroupsIds[gid].filter((id) => id !== currentTaskState.id);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
362
378
|
}
|
|
363
379
|
doUpdateTaskList(draft, task, taskGroupId);
|
|
380
|
+
// Mirror top-level grouping into the active tab's byTab snapshot,
|
|
381
|
+
// otherwise the next updateTaskListTab call copies stale byTab data
|
|
382
|
+
// back over this optimistic update.
|
|
383
|
+
syncTopLevelToActiveTab(draft);
|
|
364
384
|
},
|
|
365
385
|
updateTaskListOnCreateTaskFromTemplateSuccess(draft, action) {
|
|
366
386
|
const { tasks } = action.payload;
|
|
@@ -384,6 +404,7 @@ const taskList = (0, toolkit_1.createSlice)({
|
|
|
384
404
|
const taskId = task.id;
|
|
385
405
|
draft.updateTasksFetchState.fetchState = 'In-Progress';
|
|
386
406
|
draft.updateTasksFetchState.error = undefined;
|
|
407
|
+
let didMigrateTab = false;
|
|
387
408
|
if (updates.priority != null) {
|
|
388
409
|
const prevPriorityCode = (0, taskState_1.toPriorityCodeType)(task.priority.code);
|
|
389
410
|
draft.taskIdsByPriority[prevPriorityCode] = draft.taskIdsByPriority[prevPriorityCode].filter((id) => id != taskId);
|
|
@@ -395,6 +416,25 @@ const taskList = (0, toolkit_1.createSlice)({
|
|
|
395
416
|
draft.taskIdsByStatus[prevStatusCode] = draft.taskIdsByStatus[prevStatusCode].filter((id) => id != taskId);
|
|
396
417
|
const newStatusCode = (0, taskState_1.toTaskStatusCodeType)(updates.status.code);
|
|
397
418
|
draft.taskIdsByStatus[newStatusCode].push(taskId);
|
|
419
|
+
// Optimistically re-bucket between the live and completed tabs
|
|
420
|
+
// when status transitions in/out of "resolved", so the task
|
|
421
|
+
// moves to the Completed tab without waiting for the next
|
|
422
|
+
// fetch. Mirrors backend split in task_handler.py: only
|
|
423
|
+
// `resolved` counts as completed; `done` stays Active.
|
|
424
|
+
//
|
|
425
|
+
// Subtasks travel with their parent — they appear nested under
|
|
426
|
+
// the parent row, not as standalone entries in byTab.taskIds.
|
|
427
|
+
// So we only rebucket parent tasks (tasks with no parentTaskId).
|
|
428
|
+
const isTopLevelTask = task.parentTaskId == null;
|
|
429
|
+
const wasCompleted = prevStatusCode === 'resolved';
|
|
430
|
+
const isCompleted = newStatusCode === 'resolved';
|
|
431
|
+
if (isTopLevelTask && wasCompleted !== isCompleted) {
|
|
432
|
+
const from = isCompleted ? 'live' : 'completed';
|
|
433
|
+
const to = isCompleted ? 'completed' : 'live';
|
|
434
|
+
const updatedTask = { ...task, ...updates };
|
|
435
|
+
migrateTaskBetweenTabs(draft, taskId, updatedTask, from, to);
|
|
436
|
+
didMigrateTab = true;
|
|
437
|
+
}
|
|
398
438
|
}
|
|
399
439
|
if (updates.assignees != null) {
|
|
400
440
|
const prevGroupId = getAssigneesGroupKey(task.assignees);
|
|
@@ -434,7 +474,18 @@ const taskList = (0, toolkit_1.createSlice)({
|
|
|
434
474
|
};
|
|
435
475
|
}
|
|
436
476
|
}
|
|
437
|
-
|
|
477
|
+
if (didMigrateTab) {
|
|
478
|
+
// The migration moved the task out of the source byTab and into
|
|
479
|
+
// the destination byTab. The active tab's grouping arrays are
|
|
480
|
+
// now authoritative — mirror them back to the top-level so the
|
|
481
|
+
// UI sees the task gone from Live (or freshly arrived in
|
|
482
|
+
// Completed). Inverse of syncTopLevelToActiveTab, used only on
|
|
483
|
+
// this path.
|
|
484
|
+
copyTabDataToTopLevel(draft, draft.byTab[draft.currentTab]);
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
syncTopLevelToActiveTab(draft);
|
|
488
|
+
}
|
|
438
489
|
},
|
|
439
490
|
updateTasksListOnUpdateTaskSuccess(draft) {
|
|
440
491
|
draft.updateTasksFetchState.fetchState = 'Completed';
|
|
@@ -447,12 +498,80 @@ const taskList = (0, toolkit_1.createSlice)({
|
|
|
447
498
|
removeTaskFromList(draft, action) {
|
|
448
499
|
removeTaskIds(draft, [action.payload]);
|
|
449
500
|
},
|
|
501
|
+
/**
|
|
502
|
+
* Remove a task id from a single group bucket without touching tab
|
|
503
|
+
* membership or other groupings. Used when the user clears a task's
|
|
504
|
+
* group on the Detail page so the row stops appearing under the old
|
|
505
|
+
* group while saveTaskDetailEpic skips the standard list re-insert.
|
|
506
|
+
*/
|
|
507
|
+
removeTaskFromGroupBucket(draft, action) {
|
|
508
|
+
const { taskId, taskGroupId } = action.payload;
|
|
509
|
+
if (draft.taskIdsByGroupsIds[taskGroupId] != null) {
|
|
510
|
+
draft.taskIdsByGroupsIds[taskGroupId] = draft.taskIdsByGroupsIds[taskGroupId].filter((id) => id !== taskId);
|
|
511
|
+
}
|
|
512
|
+
// Mirror to the active tab's grouping so the UI re-renders.
|
|
513
|
+
const activeTab = draft.byTab[draft.currentTab];
|
|
514
|
+
if (activeTab.taskIdsByGroupsIds[taskGroupId] != null) {
|
|
515
|
+
activeTab.taskIdsByGroupsIds[taskGroupId] =
|
|
516
|
+
activeTab.taskIdsByGroupsIds[taskGroupId].filter((id) => id !== taskId);
|
|
517
|
+
}
|
|
518
|
+
},
|
|
450
519
|
clearTaskList(draft) {
|
|
451
520
|
Object.assign(draft, exports.initialState);
|
|
452
521
|
},
|
|
453
522
|
},
|
|
523
|
+
extraReducers: (builder) => {
|
|
524
|
+
// When the entity store receives updated tasks (e.g. from task detail
|
|
525
|
+
// save, snooze/archive/unarchive, etc.), re-bucket parent tasks between
|
|
526
|
+
// the live and completed tabs based on the new status. Mirrors the
|
|
527
|
+
// backend split in task_handler.py: only `resolved` parents count as
|
|
528
|
+
// completed. Subtasks are nested under their parent row, so they
|
|
529
|
+
// never move between tabs on their own.
|
|
530
|
+
builder.addCase(taskReducer_1.updateTasks, (draft, action) => {
|
|
531
|
+
action.payload.forEach((taskPayload) => {
|
|
532
|
+
// Only re-bucket parents; subtasks (parent_task_id is a non-empty
|
|
533
|
+
// string) are nested under their parent row and don't move tabs.
|
|
534
|
+
if (taskPayload.parent_task_id != null &&
|
|
535
|
+
taskPayload.parent_task_id !== '') {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
const taskId = taskPayload.task_id;
|
|
539
|
+
// `TaskPayload.status` is required per the type — every producer
|
|
540
|
+
// in this repo sends it, and `mapTaskPayloadToTask` dereferences
|
|
541
|
+
// it unguarded. The optional chain + null guard are defensive
|
|
542
|
+
// only, in case a downstream consumer (web-app-ui / cockpit-ui)
|
|
543
|
+
// ever dispatches `updateTasks` with a partial payload; in that
|
|
544
|
+
// case we treat missing status as "no status change" and skip
|
|
545
|
+
// re-bucketing so we don't migrate a Completed task back into
|
|
546
|
+
// the Live tab.
|
|
547
|
+
const statusCode = taskPayload.status?.code;
|
|
548
|
+
if (statusCode == null) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
const isCompleted = statusCode === 'resolved';
|
|
552
|
+
const targetTab = isCompleted ? 'completed' : 'live';
|
|
553
|
+
const otherTab = isCompleted ? 'live' : 'completed';
|
|
554
|
+
// Skip if the task isn't currently in either of these buckets
|
|
555
|
+
// (archived/snoozed/deleted are managed by their own actions).
|
|
556
|
+
const inLive = draft.byTab.live.taskIds.includes(taskId);
|
|
557
|
+
const inCompleted = draft.byTab.completed.taskIds.includes(taskId);
|
|
558
|
+
if (!inLive && !inCompleted) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (draft.byTab[otherTab].taskIds.includes(taskId)) {
|
|
562
|
+
migrateTaskPayloadBetweenTabs(draft, taskId, taskPayload, otherTab, targetTab);
|
|
563
|
+
}
|
|
564
|
+
else if (!draft.byTab[targetTab].taskIds.includes(taskId)) {
|
|
565
|
+
draft.byTab[targetTab].taskIds.push(taskId);
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
// Re-sync the top-level taskIds / grouping arrays for whichever
|
|
569
|
+
// tab the user is currently looking at.
|
|
570
|
+
copyTabDataToTopLevel(draft, draft.byTab[draft.currentTab]);
|
|
571
|
+
});
|
|
572
|
+
},
|
|
454
573
|
});
|
|
455
|
-
_a = taskList.actions, exports.fetchTaskListPage = _a.fetchTaskListPage, exports.fetchTaskList = _a.fetchTaskList, exports.updateTaskList = _a.updateTaskList, exports.updateTaskListTab = _a.updateTaskListTab, exports.updateTaskListFetchStatus = _a.updateTaskListFetchStatus, exports.updateTaskListSearchText = _a.updateTaskListSearchText, exports.updateTaskListUIState = _a.updateTaskListUIState, exports.updateTaskFilters = _a.updateTaskFilters, exports.updateTaskListOnNewGroupCreationSuccess = _a.updateTaskListOnNewGroupCreationSuccess, exports.bulkUpdateTaskList = _a.bulkUpdateTaskList, exports.updateTasksListOnBulkUpdateTasksSuccess = _a.updateTasksListOnBulkUpdateTasksSuccess, exports.updateTasksListOnBulkUpdateTasksFailure = _a.updateTasksListOnBulkUpdateTasksFailure, exports.initiateTaskListLocalData = _a.initiateTaskListLocalData, exports.updateTaskListLocalData = _a.updateTaskListLocalData, exports.updateTaskListOnTaskGroupDeletion = _a.updateTaskListOnTaskGroupDeletion, exports.dragNDropTasks = _a.dragNDropTasks, exports.updateTaskListOnNewTaskCreationSuccess = _a.updateTaskListOnNewTaskCreationSuccess, exports.updateTaskListOnTaskGroupNameUpdate = _a.updateTaskListOnTaskGroupNameUpdate, exports.updateTaskFromListView = _a.updateTaskFromListView, exports.updateTasksListOnUpdateTaskSuccess = _a.updateTasksListOnUpdateTaskSuccess, exports.updateTasksListOnUpdateTaskFailure = _a.updateTasksListOnUpdateTaskFailure, exports.updateTaskListOnCreateTaskFromTemplateSuccess = _a.updateTaskListOnCreateTaskFromTemplateSuccess, exports.removeTaskFromList = _a.removeTaskFromList, exports.clearTaskList = _a.clearTaskList;
|
|
574
|
+
_a = taskList.actions, exports.fetchTaskListPage = _a.fetchTaskListPage, exports.fetchTaskList = _a.fetchTaskList, exports.updateTaskList = _a.updateTaskList, exports.updateTaskListTab = _a.updateTaskListTab, exports.updateTaskListFetchStatus = _a.updateTaskListFetchStatus, exports.updateTaskListSearchText = _a.updateTaskListSearchText, exports.updateTaskListUIState = _a.updateTaskListUIState, exports.updateTaskFilters = _a.updateTaskFilters, exports.updateTaskListOnNewGroupCreationSuccess = _a.updateTaskListOnNewGroupCreationSuccess, exports.bulkUpdateTaskList = _a.bulkUpdateTaskList, exports.updateTasksListOnBulkUpdateTasksSuccess = _a.updateTasksListOnBulkUpdateTasksSuccess, exports.updateTasksListOnBulkUpdateTasksFailure = _a.updateTasksListOnBulkUpdateTasksFailure, exports.initiateTaskListLocalData = _a.initiateTaskListLocalData, exports.updateTaskListLocalData = _a.updateTaskListLocalData, exports.updateTaskListOnTaskGroupDeletion = _a.updateTaskListOnTaskGroupDeletion, exports.dragNDropTasks = _a.dragNDropTasks, exports.updateTaskListOnNewTaskCreationSuccess = _a.updateTaskListOnNewTaskCreationSuccess, exports.updateTaskListOnTaskGroupNameUpdate = _a.updateTaskListOnTaskGroupNameUpdate, exports.updateTaskFromListView = _a.updateTaskFromListView, exports.updateTasksListOnUpdateTaskSuccess = _a.updateTasksListOnUpdateTaskSuccess, exports.updateTasksListOnUpdateTaskFailure = _a.updateTasksListOnUpdateTaskFailure, exports.updateTaskListOnCreateTaskFromTemplateSuccess = _a.updateTaskListOnCreateTaskFromTemplateSuccess, exports.removeTaskFromList = _a.removeTaskFromList, exports.removeTaskFromGroupBucket = _a.removeTaskFromGroupBucket, exports.clearTaskList = _a.clearTaskList;
|
|
456
575
|
exports.default = taskList.reducer;
|
|
457
576
|
/**
|
|
458
577
|
* helpers
|
|
@@ -559,6 +678,115 @@ const copyTabDataToTopLevel = (draft, tabData) => {
|
|
|
559
678
|
draft.taskIdsByDueDate = tabData.taskIdsByDueDate;
|
|
560
679
|
draft.taskIdsByTags = tabData.taskIdsByTags;
|
|
561
680
|
};
|
|
681
|
+
/**
|
|
682
|
+
* Migrate a parent task between two `byTab` buckets (live ↔ completed)
|
|
683
|
+
* when its status flips into / out of `resolved`. The destination tab
|
|
684
|
+
* picks up the task in EVERY grouping dimension (status, priority,
|
|
685
|
+
* group id, assignees, dueDate, tags) using the UPDATED task as the
|
|
686
|
+
* source-of-truth for the new bucket keys. Otherwise the Completed tab
|
|
687
|
+
* shows the task in the right tab-level list but the grouped views
|
|
688
|
+
* (Group by Status, Group by Priority, etc.) miss it until the next
|
|
689
|
+
* full fetch.
|
|
690
|
+
*/
|
|
691
|
+
const migrateTaskBetweenTabs = (draft, taskId, updatedTask, from, to) => {
|
|
692
|
+
const fromTab = draft.byTab[from];
|
|
693
|
+
const toTab = draft.byTab[to];
|
|
694
|
+
// Source tab: drop the task from every grouping dimension.
|
|
695
|
+
removeIdsFromTabData(fromTab, [taskId]);
|
|
696
|
+
// Destination tab: add the task to taskIds (deduped) plus the
|
|
697
|
+
// appropriate bucket inside each grouping dimension based on the
|
|
698
|
+
// updated task.
|
|
699
|
+
if (!toTab.taskIds.includes(taskId)) {
|
|
700
|
+
toTab.taskIds.push(taskId);
|
|
701
|
+
}
|
|
702
|
+
const priorityKey = (0, taskState_1.toPriorityCodeType)(updatedTask.priority.code);
|
|
703
|
+
if (!toTab.taskIdsByPriority[priorityKey].includes(taskId)) {
|
|
704
|
+
toTab.taskIdsByPriority[priorityKey].push(taskId);
|
|
705
|
+
}
|
|
706
|
+
const statusKey = (0, taskState_1.toTaskStatusCodeType)(updatedTask.status.code);
|
|
707
|
+
if (!toTab.taskIdsByStatus[statusKey].includes(taskId)) {
|
|
708
|
+
toTab.taskIdsByStatus[statusKey].push(taskId);
|
|
709
|
+
}
|
|
710
|
+
const dueDateKey = updatedTask.dueDate != null
|
|
711
|
+
? getDueDateGroupKey(updatedTask.dueDate.toString())
|
|
712
|
+
: 'upcoming';
|
|
713
|
+
if (!toTab.taskIdsByDueDate[dueDateKey].includes(taskId)) {
|
|
714
|
+
toTab.taskIdsByDueDate[dueDateKey].push(taskId);
|
|
715
|
+
}
|
|
716
|
+
const assigneeKey = getAssigneesGroupKey(updatedTask.assignees);
|
|
717
|
+
if (toTab.taskIdsByAssignees[assigneeKey] == null) {
|
|
718
|
+
toTab.taskIdsByAssignees[assigneeKey] = [taskId];
|
|
719
|
+
}
|
|
720
|
+
else if (!toTab.taskIdsByAssignees[assigneeKey].includes(taskId)) {
|
|
721
|
+
toTab.taskIdsByAssignees[assigneeKey].push(taskId);
|
|
722
|
+
}
|
|
723
|
+
const tagIds = [...updatedTask.tagIds].sort();
|
|
724
|
+
const tagsKey = tagIds.join(',');
|
|
725
|
+
if (toTab.taskIdsByTags[tagsKey] == null) {
|
|
726
|
+
toTab.taskIdsByTags[tagsKey] = [taskId];
|
|
727
|
+
}
|
|
728
|
+
else if (!toTab.taskIdsByTags[tagsKey].includes(taskId)) {
|
|
729
|
+
toTab.taskIdsByTags[tagsKey].push(taskId);
|
|
730
|
+
}
|
|
731
|
+
(updatedTask.taskGroupIds ?? []).forEach((groupId) => {
|
|
732
|
+
if (toTab.taskIdsByGroupsIds[groupId] == null) {
|
|
733
|
+
toTab.taskIdsByGroupsIds[groupId] = [taskId];
|
|
734
|
+
}
|
|
735
|
+
else if (!toTab.taskIdsByGroupsIds[groupId].includes(taskId)) {
|
|
736
|
+
toTab.taskIdsByGroupsIds[groupId].push(taskId);
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* `updateTasks` extraReducer variant — same migration semantics but
|
|
742
|
+
* keyed off the raw `TaskPayload` instead of the rich `Task` entity.
|
|
743
|
+
*/
|
|
744
|
+
const migrateTaskPayloadBetweenTabs = (draft, taskId, payload, from, to) => {
|
|
745
|
+
const fromTab = draft.byTab[from];
|
|
746
|
+
const toTab = draft.byTab[to];
|
|
747
|
+
removeIdsFromTabData(fromTab, [taskId]);
|
|
748
|
+
if (!toTab.taskIds.includes(taskId)) {
|
|
749
|
+
toTab.taskIds.push(taskId);
|
|
750
|
+
}
|
|
751
|
+
if (payload.priority?.code != null) {
|
|
752
|
+
const priorityKey = (0, taskState_1.toPriorityCodeType)(payload.priority.code);
|
|
753
|
+
if (!toTab.taskIdsByPriority[priorityKey].includes(taskId)) {
|
|
754
|
+
toTab.taskIdsByPriority[priorityKey].push(taskId);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if (payload.status?.code != null) {
|
|
758
|
+
const statusKey = (0, taskState_1.toTaskStatusCodeType)(payload.status.code);
|
|
759
|
+
if (!toTab.taskIdsByStatus[statusKey].includes(taskId)) {
|
|
760
|
+
toTab.taskIdsByStatus[statusKey].push(taskId);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
const dueDateKey = getDueDateGroupKey(payload.due_date);
|
|
764
|
+
if (!toTab.taskIdsByDueDate[dueDateKey].includes(taskId)) {
|
|
765
|
+
toTab.taskIdsByDueDate[dueDateKey].push(taskId);
|
|
766
|
+
}
|
|
767
|
+
const assigneeKey = getAssigneesGroupKey(payload.assignees ?? []);
|
|
768
|
+
if (toTab.taskIdsByAssignees[assigneeKey] == null) {
|
|
769
|
+
toTab.taskIdsByAssignees[assigneeKey] = [taskId];
|
|
770
|
+
}
|
|
771
|
+
else if (!toTab.taskIdsByAssignees[assigneeKey].includes(taskId)) {
|
|
772
|
+
toTab.taskIdsByAssignees[assigneeKey].push(taskId);
|
|
773
|
+
}
|
|
774
|
+
const tagsKey = getTagsGroupKey(payload.tags ?? []);
|
|
775
|
+
if (toTab.taskIdsByTags[tagsKey] == null) {
|
|
776
|
+
toTab.taskIdsByTags[tagsKey] = [taskId];
|
|
777
|
+
}
|
|
778
|
+
else if (!toTab.taskIdsByTags[tagsKey].includes(taskId)) {
|
|
779
|
+
toTab.taskIdsByTags[tagsKey].push(taskId);
|
|
780
|
+
}
|
|
781
|
+
(payload.task_group_ids ?? []).forEach((groupId) => {
|
|
782
|
+
if (toTab.taskIdsByGroupsIds[groupId] == null) {
|
|
783
|
+
toTab.taskIdsByGroupsIds[groupId] = [taskId];
|
|
784
|
+
}
|
|
785
|
+
else if (!toTab.taskIdsByGroupsIds[groupId].includes(taskId)) {
|
|
786
|
+
toTab.taskIdsByGroupsIds[groupId].push(taskId);
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
};
|
|
562
790
|
const removeIdsFromTabData = (tabData, taskIds) => {
|
|
563
791
|
const removedSet = new Set(taskIds);
|
|
564
792
|
const isRemoved = (id) => removedSet.has(id);
|
|
@@ -342,6 +342,7 @@ exports.getAllTasks = (0, toolkit_1.createSelector)((state) => state.taskListSta
|
|
|
342
342
|
const taskGroupTemplates = (0, taskGroupTemplateSelector_1.getTaskGroupTemplateByIds)(taskGroupTemplateState, taskGroupTemplateViewState.taskGroupTemplateIds);
|
|
343
343
|
const tabCounts = {
|
|
344
344
|
live: taskListState.byTab.live.taskIds.length,
|
|
345
|
+
completed: taskListState.byTab.completed.taskIds.length,
|
|
345
346
|
archived: taskListState.byTab.archived.taskIds.length,
|
|
346
347
|
deleted: taskListState.byTab.deleted.taskIds.length,
|
|
347
348
|
snoozed: taskListState.byTab.snoozed.taskIds.length,
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
import { Tag } from '../../../entity/tag/tagState';
|
|
1
2
|
import { Task } from '../../../entity/task/taskState';
|
|
3
|
+
import { User } from '../../../entity/user/userState';
|
|
2
4
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
3
5
|
import { TaskGroupKey } from './taskList';
|
|
6
|
+
export type SubtaskSortKey = 'name' | 'status' | 'assignee' | 'tag';
|
|
7
|
+
export type SubtaskSortOrder = 'asc' | 'desc';
|
|
4
8
|
export declare const getDueDateValueFromDueDateGroupId: (groupId: string) => ZeniDate;
|
|
5
9
|
export declare const getTaskUpdates: (groupByKey: TaskGroupKey, groupId: string) => Partial<Task>;
|
|
10
|
+
/**
|
|
11
|
+
* Sort a subtask list by one of the sortable columns. Pure — no state
|
|
12
|
+
* dependency. `statusOrder` is derived from `allTaskStatus` so any new
|
|
13
|
+
* status added upstream slots in by its enum position instead of
|
|
14
|
+
* falling into a catch-all bucket.
|
|
15
|
+
*/
|
|
16
|
+
export declare const sortSubtasks: (subtasks: Task[], sortKey: SubtaskSortKey | null, sortOrder: SubtaskSortOrder, userList: User[], tagList: Tag[]) => Task[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTaskUpdates = exports.getDueDateValueFromDueDateGroupId = void 0;
|
|
3
|
+
exports.sortSubtasks = exports.getTaskUpdates = exports.getDueDateValueFromDueDateGroupId = void 0;
|
|
4
4
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
5
5
|
const taskDetailSelector_1 = require("../taskDetailView/taskDetailSelector");
|
|
6
6
|
const taskList_1 = require("./taskList");
|
|
@@ -53,3 +53,62 @@ const getTaskUpdates = (groupByKey, groupId) => {
|
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
55
|
exports.getTaskUpdates = getTaskUpdates;
|
|
56
|
+
/**
|
|
57
|
+
* Sort a subtask list by one of the sortable columns. Pure — no state
|
|
58
|
+
* dependency. `statusOrder` is derived from `allTaskStatus` so any new
|
|
59
|
+
* status added upstream slots in by its enum position instead of
|
|
60
|
+
* falling into a catch-all bucket.
|
|
61
|
+
*/
|
|
62
|
+
const sortSubtasks = (subtasks, sortKey, sortOrder, userList, tagList) => {
|
|
63
|
+
if (sortKey == null) {
|
|
64
|
+
return subtasks;
|
|
65
|
+
}
|
|
66
|
+
const statusOrder = taskDetailSelector_1.allTaskStatus.reduce((acc, status, index) => {
|
|
67
|
+
acc[status.code] = index;
|
|
68
|
+
return acc;
|
|
69
|
+
}, {});
|
|
70
|
+
const unknownStatusRank = taskDetailSelector_1.allTaskStatus.length;
|
|
71
|
+
const cmpStr = (a, b) => a.localeCompare(b, undefined, { sensitivity: 'base' });
|
|
72
|
+
const keyFn = (task) => {
|
|
73
|
+
if (sortKey === 'name') {
|
|
74
|
+
return task.name ?? '';
|
|
75
|
+
}
|
|
76
|
+
if (sortKey === 'status') {
|
|
77
|
+
return statusOrder[task.status.code] ?? unknownStatusRank;
|
|
78
|
+
}
|
|
79
|
+
if (sortKey === 'assignee') {
|
|
80
|
+
const firstId = task.assignees?.[0];
|
|
81
|
+
if (firstId == null) {
|
|
82
|
+
return '';
|
|
83
|
+
}
|
|
84
|
+
const user = userList.find((candidate) => candidate.userId === firstId);
|
|
85
|
+
return user
|
|
86
|
+
? `${user.firstName ?? ''} ${user.lastName ?? ''}`.trim()
|
|
87
|
+
: '';
|
|
88
|
+
}
|
|
89
|
+
if (sortKey === 'tag') {
|
|
90
|
+
const firstTagId = task.tagIds?.[0];
|
|
91
|
+
if (firstTagId == null) {
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
const tag = tagList.find((candidate) => candidate.tagId === firstTagId);
|
|
95
|
+
return tag?.name ?? '';
|
|
96
|
+
}
|
|
97
|
+
return '';
|
|
98
|
+
};
|
|
99
|
+
const copy = [...subtasks];
|
|
100
|
+
copy.sort((a, b) => {
|
|
101
|
+
const av = keyFn(a);
|
|
102
|
+
const bv = keyFn(b);
|
|
103
|
+
let cmp;
|
|
104
|
+
if (typeof av === 'number' && typeof bv === 'number') {
|
|
105
|
+
cmp = av - bv;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
cmp = cmpStr(String(av), String(bv));
|
|
109
|
+
}
|
|
110
|
+
return sortOrder === 'asc' ? cmp : -cmp;
|
|
111
|
+
});
|
|
112
|
+
return copy;
|
|
113
|
+
};
|
|
114
|
+
exports.sortSubtasks = sortSubtasks;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.41-
|
|
3
|
+
"version": "5.1.41-betaDI3",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|