@zeniai/client-epic-state 5.1.41-betaDI3 → 5.1.41

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.
Files changed (57) hide show
  1. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  2. package/lib/entity/snackbar/snackbarTypes.js +1 -1
  3. package/lib/entity/task/taskPayload.d.ts +1 -2
  4. package/lib/entity/task/taskPayload.js +1 -8
  5. package/lib/entity/task/taskReducer.d.ts +1 -8
  6. package/lib/entity/task/taskReducer.js +4 -29
  7. package/lib/entity/task/taskState.d.ts +0 -1
  8. package/lib/entity/tenant/epic/saveExternalConnectionEpic.js +15 -11
  9. package/lib/epic.d.ts +3 -5
  10. package/lib/epic.js +3 -5
  11. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -1
  12. package/lib/esm/entity/task/taskPayload.js +1 -8
  13. package/lib/esm/entity/task/taskReducer.js +3 -28
  14. package/lib/esm/entity/tenant/epic/saveExternalConnectionEpic.js +15 -11
  15. package/lib/esm/epic.js +3 -5
  16. package/lib/esm/index.js +3 -3
  17. package/lib/esm/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +0 -3
  18. package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -7
  19. package/lib/esm/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +0 -1
  20. package/lib/esm/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +9 -70
  21. package/lib/esm/view/taskManager/taskDetailView/taskDetailReducer.js +2 -56
  22. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +9 -32
  23. package/lib/esm/view/taskManager/taskListView/epics/fetchTaskListEpic.js +1 -3
  24. package/lib/esm/view/taskManager/taskListView/taskList.js +0 -1
  25. package/lib/esm/view/taskManager/taskListView/taskListReducer.js +12 -240
  26. package/lib/esm/view/taskManager/taskListView/taskListSelector.js +0 -1
  27. package/lib/esm/view/taskManager/taskListView/taskListViewHelpers.js +0 -58
  28. package/lib/index.d.ts +6 -6
  29. package/lib/index.js +9 -13
  30. package/lib/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +0 -3
  31. package/lib/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -7
  32. package/lib/view/companyView/types/cockpitTypes.d.ts +0 -3
  33. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  34. package/lib/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +0 -1
  35. package/lib/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.d.ts +2 -2
  36. package/lib/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +8 -69
  37. package/lib/view/taskManager/taskDetailView/taskDetail.d.ts +0 -15
  38. package/lib/view/taskManager/taskDetailView/taskDetailReducer.d.ts +2 -14
  39. package/lib/view/taskManager/taskDetailView/taskDetailReducer.js +3 -57
  40. package/lib/view/taskManager/taskDetailView/taskDetailSelector.d.ts +1 -2
  41. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +7 -30
  42. package/lib/view/taskManager/taskListView/epics/fetchTaskListEpic.js +1 -3
  43. package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
  44. package/lib/view/taskManager/taskListView/taskList.js +0 -1
  45. package/lib/view/taskManager/taskListView/taskListPayload.d.ts +0 -4
  46. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +2 -6
  47. package/lib/view/taskManager/taskListView/taskListReducer.js +13 -241
  48. package/lib/view/taskManager/taskListView/taskListSelector.js +0 -1
  49. package/lib/view/taskManager/taskListView/taskListViewHelpers.d.ts +0 -11
  50. package/lib/view/taskManager/taskListView/taskListViewHelpers.js +1 -60
  51. package/package.json +1 -1
  52. package/lib/esm/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +0 -96
  53. package/lib/esm/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +0 -53
  54. package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.d.ts +0 -9
  55. package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +0 -100
  56. package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.d.ts +0 -8
  57. package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +0 -57
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
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;
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;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
- const taskReducer_1 = require("../../../entity/task/taskReducer");
7
6
  const taskState_1 = require("../../../entity/task/taskState");
8
7
  const zeniDayJS_1 = require("../../../zeniDayJS");
9
8
  const taskList_1 = require("./taskList");
@@ -47,7 +46,6 @@ exports.initialState = {
47
46
  currentTab: 'live',
48
47
  byTab: {
49
48
  live: { ...initialTabData },
50
- completed: { ...initialTabData },
51
49
  archived: { ...initialTabData },
52
50
  deleted: { ...initialTabData },
53
51
  snoozed: { ...initialTabData },
@@ -69,12 +67,14 @@ exports.initialState = {
69
67
  },
70
68
  filters: {
71
69
  categoryCombinationOperator: 'AND',
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: [],
70
+ categories: [
71
+ {
72
+ field: 'status',
73
+ matchingOperator: 'not_equal',
74
+ values: ['resolved'],
75
+ valuesCombinationOperator: 'ANY',
76
+ },
77
+ ],
78
78
  },
79
79
  hasValidState() {
80
80
  return this.fetchState == 'Completed';
@@ -106,16 +106,13 @@ const taskList = (0, toolkit_1.createSlice)({
106
106
  draft.error = undefined;
107
107
  },
108
108
  updateTaskList(draft, action) {
109
- const { data, archived, completed, deleted, snoozed } = action.payload;
109
+ const { data, archived, 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
- }
119
116
  if (archived != null) {
120
117
  draft.byTab.archived = toTabData(getGroupedTaskIds(archived));
121
118
  }
@@ -361,26 +358,9 @@ const taskList = (0, toolkit_1.createSlice)({
361
358
  draft.taskIdsByAssignees[assigneeKey] = draft.taskIdsByAssignees[assigneeKey].filter((taskId) => taskId !== currentTaskState.id);
362
359
  draft.taskIdsByTags[tagsKey] = draft.taskIdsByTags[tagsKey].filter((taskId) => taskId !== currentTaskState.id);
363
360
  draft.taskIdsByDueDate[dueDateKey] = draft.taskIdsByDueDate[dueDateKey].filter((taskId) => taskId !== currentTaskState.id);
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
- });
361
+ draft.taskIdsByGroupsIds[taskGroupId] = draft.taskIdsByGroupsIds[taskGroupId].filter((taskId) => taskId !== currentTaskState.id);
378
362
  }
379
363
  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);
384
364
  },
385
365
  updateTaskListOnCreateTaskFromTemplateSuccess(draft, action) {
386
366
  const { tasks } = action.payload;
@@ -404,7 +384,6 @@ const taskList = (0, toolkit_1.createSlice)({
404
384
  const taskId = task.id;
405
385
  draft.updateTasksFetchState.fetchState = 'In-Progress';
406
386
  draft.updateTasksFetchState.error = undefined;
407
- let didMigrateTab = false;
408
387
  if (updates.priority != null) {
409
388
  const prevPriorityCode = (0, taskState_1.toPriorityCodeType)(task.priority.code);
410
389
  draft.taskIdsByPriority[prevPriorityCode] = draft.taskIdsByPriority[prevPriorityCode].filter((id) => id != taskId);
@@ -416,25 +395,6 @@ const taskList = (0, toolkit_1.createSlice)({
416
395
  draft.taskIdsByStatus[prevStatusCode] = draft.taskIdsByStatus[prevStatusCode].filter((id) => id != taskId);
417
396
  const newStatusCode = (0, taskState_1.toTaskStatusCodeType)(updates.status.code);
418
397
  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
- }
438
398
  }
439
399
  if (updates.assignees != null) {
440
400
  const prevGroupId = getAssigneesGroupKey(task.assignees);
@@ -474,18 +434,7 @@ const taskList = (0, toolkit_1.createSlice)({
474
434
  };
475
435
  }
476
436
  }
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
- }
437
+ syncTopLevelToActiveTab(draft);
489
438
  },
490
439
  updateTasksListOnUpdateTaskSuccess(draft) {
491
440
  draft.updateTasksFetchState.fetchState = 'Completed';
@@ -498,80 +447,12 @@ const taskList = (0, toolkit_1.createSlice)({
498
447
  removeTaskFromList(draft, action) {
499
448
  removeTaskIds(draft, [action.payload]);
500
449
  },
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
- },
519
450
  clearTaskList(draft) {
520
451
  Object.assign(draft, exports.initialState);
521
452
  },
522
453
  },
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
- },
573
454
  });
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;
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;
575
456
  exports.default = taskList.reducer;
576
457
  /**
577
458
  * helpers
@@ -678,115 +559,6 @@ const copyTabDataToTopLevel = (draft, tabData) => {
678
559
  draft.taskIdsByDueDate = tabData.taskIdsByDueDate;
679
560
  draft.taskIdsByTags = tabData.taskIdsByTags;
680
561
  };
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
- };
790
562
  const removeIdsFromTabData = (tabData, taskIds) => {
791
563
  const removedSet = new Set(taskIds);
792
564
  const isRemoved = (id) => removedSet.has(id);
@@ -342,7 +342,6 @@ 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,
346
345
  archived: taskListState.byTab.archived.taskIds.length,
347
346
  deleted: taskListState.byTab.deleted.taskIds.length,
348
347
  snoozed: taskListState.byTab.snoozed.taskIds.length,
@@ -1,16 +1,5 @@
1
- import { Tag } from '../../../entity/tag/tagState';
2
1
  import { Task } from '../../../entity/task/taskState';
3
- import { User } from '../../../entity/user/userState';
4
2
  import { ZeniDate } from '../../../zeniDayJS';
5
3
  import { TaskGroupKey } from './taskList';
6
- export type SubtaskSortKey = 'name' | 'status' | 'assignee' | 'tag';
7
- export type SubtaskSortOrder = 'asc' | 'desc';
8
4
  export declare const getDueDateValueFromDueDateGroupId: (groupId: string) => ZeniDate;
9
5
  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.sortSubtasks = exports.getTaskUpdates = exports.getDueDateValueFromDueDateGroupId = void 0;
3
+ 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,62 +53,3 @@ 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-betaDI3",
3
+ "version": "5.1.41",
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",
@@ -1,96 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { convertHHMMStrToMinutes } from '../../../../commonStateTypes/fiscalYearHelpers/formatMinutesToFromHHMM';
4
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
5
- import { appendSubTaskId, updateTasks, } from '../../../../entity/task/taskReducer';
6
- import { getTaskById } from '../../../../entity/task/taskSelector';
7
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
8
- import { updateTaskListOnNewTaskCreationSuccess } from '../../taskListView/taskListReducer';
9
- import { createSubTask, createSubTaskSuccessOrFailure, } from '../taskDetailReducer';
10
- export const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(createSubTask.match), mergeMap((action) => {
11
- const state = state$.value;
12
- const parentTask = getTaskById(state.taskState, action.payload.parentTaskId);
13
- // Subtasks inherit every parent group membership, not just the first,
14
- // so the subtask surfaces in all the same buckets as its parent.
15
- const parentTaskGroupIds = parentTask?.taskGroupIds ?? [];
16
- const parentTaskGroupId = parentTaskGroupIds[0];
17
- const isTaskListFetched = state.taskListState.fetchState === 'Completed';
18
- const payload = prepareSubTaskPayload(action.payload, parentTaskGroupIds);
19
- return zeniAPI
20
- .postAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`, payload)
21
- .pipe(mergeMap((response) => {
22
- if (isSuccessResponse(response) &&
23
- response.data != null &&
24
- response.data.tasks.length > 0) {
25
- const newTaskId = response.data.tasks[0].task_id;
26
- const actions = [
27
- updateTasks(response.data.tasks),
28
- appendSubTaskId({
29
- parentTaskId: action.payload.parentTaskId,
30
- subTaskId: newTaskId,
31
- }),
32
- createSubTaskSuccessOrFailure({
33
- fetchState: 'Completed',
34
- newTaskId,
35
- }),
36
- openSnackbar({
37
- messageSection: 'create_sub_task',
38
- messageText: 'success',
39
- type: 'success',
40
- }),
41
- ];
42
- // The task list is keyed on parent tasks (no parent_task_id)
43
- // — subtasks belong to their parent's children list, not the
44
- // top-level list. Pushing a subtask into the list would
45
- // surface it as an orphan row at the top of the group.
46
- // Only fire the list-update for actual parent tasks.
47
- const createdTask = response.data.tasks[0];
48
- const isSubtask = createdTask.parent_task_id != null &&
49
- createdTask.parent_task_id !== '';
50
- if (!isSubtask &&
51
- isTaskListFetched === true &&
52
- parentTaskGroupId != null) {
53
- actions.push(updateTaskListOnNewTaskCreationSuccess({
54
- taskGroupId: parentTaskGroupId,
55
- task: createdTask,
56
- }));
57
- }
58
- return from(actions);
59
- }
60
- else {
61
- return of(createSubTaskSuccessOrFailure({
62
- fetchState: 'Error',
63
- error: response.status,
64
- }), openSnackbar({
65
- messageSection: 'create_sub_task',
66
- messageText: 'failed',
67
- type: 'error',
68
- variables: [
69
- {
70
- variableName: '_api-error_',
71
- variableValue: response.status.message,
72
- },
73
- ],
74
- }));
75
- }
76
- }), catchError((error) => of(createSubTaskSuccessOrFailure({
77
- fetchState: 'Error',
78
- error: createZeniAPIStatus('Unexpected Error', 'Create Sub Task REST API call errored out' +
79
- JSON.stringify(error)),
80
- }))));
81
- }));
82
- const prepareSubTaskPayload = (subTask, parentTaskGroupIds) => ({
83
- name: subTask.name,
84
- assignees: subTask.assignee,
85
- description: subTask.description,
86
- priority: subTask.priority,
87
- status: subTask.status,
88
- tags: subTask.tagIds,
89
- time_spent: convertHHMMStrToMinutes(subTask.timeSpent),
90
- group_assignees: subTask.groupAssignees,
91
- parent_task_id: subTask.parentTaskId,
92
- // Inherit every parent group, not just the first — see callsite for
93
- // the two-scope rationale.
94
- task_group_ids: parentTaskGroupIds,
95
- due_date: subTask.dueDate?.format('YYYY-MM-DD') ?? null,
96
- });
@@ -1,53 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { setSubTaskIds, updateTasks } from '../../../../entity/task/taskReducer';
4
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
5
- import { fetchSubTasks, updateSubTasks, updateSubTasksFetchStatus, } from '../taskDetailReducer';
6
- export const fetchSubTasksEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchSubTasks.match),
7
- // Use mergeMap, not switchMap: switchMap cancels in-flight requests for
8
- // the previous parent without dispatching success or failure, leaving
9
- // subTaskListFetchStatusByParentId stuck at In-Progress and blocking the
10
- // detail page's combined fetchStatus via reduceAnyFetchState. Per-parent
11
- // races on the same parentTaskId are handled last-write-wins downstream.
12
- mergeMap((action) => {
13
- const { parentTaskId } = action.payload;
14
- const query = JSON.stringify({
15
- task_type: 'subtasks',
16
- parent_task_id: parentTaskId,
17
- });
18
- return zeniAPI
19
- .getJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent(query)}`)
20
- .pipe(mergeMap((response) => {
21
- if (isSuccessResponse(response) && response.data != null) {
22
- const { tasks } = response.data;
23
- // Keep the parent's `subTasksIds` in sync with the fetched
24
- // bucket. Without this, the parent entity record can drift
25
- // out of sync with what the children fetch returned —
26
- // e.g. a server-side delete won't drop from the parent
27
- // record until the next list re-fetch.
28
- const fetchedChildIds = tasks
29
- .filter((t) => t.parent_task_id === parentTaskId)
30
- .map((t) => t.task_id);
31
- return of(updateTasks(tasks), setSubTaskIds({
32
- parentTaskId,
33
- subTaskIds: fetchedChildIds,
34
- }), updateSubTasks({
35
- parentTaskId,
36
- }));
37
- }
38
- else {
39
- return of(updateSubTasksFetchStatus({
40
- parentTaskId,
41
- fetchState: 'Error',
42
- error: response.status,
43
- }));
44
- }
45
- }), catchError((error) => {
46
- return of(updateSubTasksFetchStatus({
47
- parentTaskId,
48
- fetchState: 'Error',
49
- error: createZeniAPIStatus('Unexpected Error', 'Fetch Sub Tasks REST API call errored out' +
50
- JSON.stringify(error)),
51
- }));
52
- }));
53
- }));
@@ -1,9 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
3
- import { appendSubTaskId, updateTasks } from '../../../../entity/task/taskReducer';
4
- import { RootState } from '../../../../reducer';
5
- import { ZeniAPI } from '../../../../zeniAPI';
6
- import { updateTaskListOnNewTaskCreationSuccess } from '../../taskListView/taskListReducer';
7
- import { createSubTask, createSubTaskSuccessOrFailure } from '../taskDetailReducer';
8
- export type ActionType = ReturnType<typeof createSubTask> | ReturnType<typeof updateTasks> | ReturnType<typeof appendSubTaskId> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateTaskListOnNewTaskCreationSuccess> | ReturnType<typeof createSubTaskSuccessOrFailure>;
9
- export declare const createSubTaskEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;