@zeniai/client-epic-state 5.1.35-betaDI1 → 5.1.35-betaRD11

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 +0 -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/epic.d.ts +1 -3
  9. package/lib/epic.js +1 -3
  10. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  11. package/lib/esm/entity/task/taskPayload.js +1 -8
  12. package/lib/esm/entity/task/taskReducer.js +3 -28
  13. package/lib/esm/epic.js +1 -3
  14. package/lib/esm/index.js +2 -2
  15. package/lib/esm/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +0 -4
  16. package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -7
  17. package/lib/esm/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +0 -1
  18. package/lib/esm/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +9 -65
  19. package/lib/esm/view/taskManager/taskDetailView/taskDetailReducer.js +2 -56
  20. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +9 -32
  21. package/lib/esm/view/taskManager/taskListView/epics/fetchTaskListEpic.js +1 -3
  22. package/lib/esm/view/taskManager/taskListView/taskList.js +0 -1
  23. package/lib/esm/view/taskManager/taskListView/taskListReducer.js +12 -234
  24. package/lib/esm/view/taskManager/taskListView/taskListSelector.js +0 -1
  25. package/lib/esm/view/transactionDetail/epics/saveTransactionDetailEpic.js +3 -2
  26. package/lib/esm/view/transactionDetail/epics/saveTransactionHelper.js +6 -5
  27. package/lib/index.d.ts +5 -5
  28. package/lib/index.js +9 -12
  29. package/lib/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +0 -4
  30. package/lib/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -7
  31. package/lib/view/companyView/types/cockpitTypes.d.ts +0 -3
  32. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  33. package/lib/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +0 -1
  34. package/lib/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.d.ts +2 -2
  35. package/lib/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +8 -64
  36. package/lib/view/taskManager/taskDetailView/taskDetail.d.ts +0 -15
  37. package/lib/view/taskManager/taskDetailView/taskDetailReducer.d.ts +2 -14
  38. package/lib/view/taskManager/taskDetailView/taskDetailReducer.js +3 -57
  39. package/lib/view/taskManager/taskDetailView/taskDetailSelector.d.ts +1 -2
  40. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +7 -30
  41. package/lib/view/taskManager/taskListView/epics/fetchTaskListEpic.js +1 -3
  42. package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
  43. package/lib/view/taskManager/taskListView/taskList.js +0 -1
  44. package/lib/view/taskManager/taskListView/taskListPayload.d.ts +0 -4
  45. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +2 -6
  46. package/lib/view/taskManager/taskListView/taskListReducer.js +13 -235
  47. package/lib/view/taskManager/taskListView/taskListSelector.js +0 -1
  48. package/lib/view/transactionDetail/epics/saveTransactionDetailEpic.js +3 -2
  49. package/lib/view/transactionDetail/epics/saveTransactionHelper.d.ts +2 -2
  50. package/lib/view/transactionDetail/epics/saveTransactionHelper.js +6 -5
  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 isParent = task.parentTaskId == null;
429
- const wasCompleted = prevStatusCode === 'resolved';
430
- const isCompleted = newStatusCode === 'resolved';
431
- if (isParent && 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,74 +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] = activeTab.taskIdsByGroupsIds[taskGroupId].filter((id) => id !== taskId);
516
- }
517
- },
518
450
  clearTaskList(draft) {
519
451
  Object.assign(draft, exports.initialState);
520
452
  },
521
453
  },
522
- extraReducers: (builder) => {
523
- // When the entity store receives updated tasks (e.g. from task detail
524
- // save, snooze/archive/unarchive, etc.), re-bucket parent tasks between
525
- // the live and completed tabs based on the new status. Mirrors the
526
- // backend split in task_handler.py: only `resolved` parents count as
527
- // completed. Subtasks are nested under their parent row, so they
528
- // never move between tabs on their own.
529
- builder.addCase(taskReducer_1.updateTasks, (draft, action) => {
530
- action.payload.forEach((taskPayload) => {
531
- // Only re-bucket parents; subtasks (parent_task_id is a non-empty
532
- // string) are nested under their parent row and don't move tabs.
533
- if (taskPayload.parent_task_id !== null && taskPayload.parent_task_id !== undefined && taskPayload.parent_task_id !== '') {
534
- return;
535
- }
536
- const taskId = taskPayload.task_id;
537
- const statusCode = taskPayload.status?.code;
538
- // Partial payloads may omit `status` entirely (e.g. comment-only
539
- // updates). Treat a missing status as "no status change" and skip
540
- // re-bucketing so we don't accidentally migrate a Completed task
541
- // back into the Live tab.
542
- if (statusCode == null) {
543
- return;
544
- }
545
- const isCompleted = statusCode === 'resolved';
546
- const targetTab = isCompleted ? 'completed' : 'live';
547
- const otherTab = isCompleted ? 'live' : 'completed';
548
- // Skip if the task isn't currently in either of these buckets
549
- // (archived/snoozed/deleted are managed by their own actions).
550
- const inLive = draft.byTab.live.taskIds.includes(taskId);
551
- const inCompleted = draft.byTab.completed.taskIds.includes(taskId);
552
- if (!inLive && !inCompleted) {
553
- return;
554
- }
555
- if (draft.byTab[otherTab].taskIds.includes(taskId)) {
556
- migrateTaskPayloadBetweenTabs(draft, taskId, taskPayload, otherTab, targetTab);
557
- }
558
- else if (!draft.byTab[targetTab].taskIds.includes(taskId)) {
559
- draft.byTab[targetTab].taskIds.push(taskId);
560
- }
561
- });
562
- // Re-sync the top-level taskIds / grouping arrays for whichever
563
- // tab the user is currently looking at.
564
- copyTabDataToTopLevel(draft, draft.byTab[draft.currentTab]);
565
- });
566
- },
567
454
  });
568
- _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;
569
456
  exports.default = taskList.reducer;
570
457
  /**
571
458
  * helpers
@@ -672,115 +559,6 @@ const copyTabDataToTopLevel = (draft, tabData) => {
672
559
  draft.taskIdsByDueDate = tabData.taskIdsByDueDate;
673
560
  draft.taskIdsByTags = tabData.taskIdsByTags;
674
561
  };
675
- /**
676
- * Migrate a parent task between two `byTab` buckets (live ↔ completed)
677
- * when its status flips into / out of `resolved`. The destination tab
678
- * picks up the task in EVERY grouping dimension (status, priority,
679
- * group id, assignees, dueDate, tags) using the UPDATED task as the
680
- * source-of-truth for the new bucket keys. Otherwise the Completed tab
681
- * shows the task in the right tab-level list but the grouped views
682
- * (Group by Status, Group by Priority, etc.) miss it until the next
683
- * full fetch.
684
- */
685
- const migrateTaskBetweenTabs = (draft, taskId, updatedTask, from, to) => {
686
- const fromTab = draft.byTab[from];
687
- const toTab = draft.byTab[to];
688
- // Source tab: drop the task from every grouping dimension.
689
- removeIdsFromTabData(fromTab, [taskId]);
690
- // Destination tab: add the task to taskIds (deduped) plus the
691
- // appropriate bucket inside each grouping dimension based on the
692
- // updated task.
693
- if (!toTab.taskIds.includes(taskId)) {
694
- toTab.taskIds.push(taskId);
695
- }
696
- const priorityKey = (0, taskState_1.toPriorityCodeType)(updatedTask.priority.code);
697
- if (!toTab.taskIdsByPriority[priorityKey].includes(taskId)) {
698
- toTab.taskIdsByPriority[priorityKey].push(taskId);
699
- }
700
- const statusKey = (0, taskState_1.toTaskStatusCodeType)(updatedTask.status.code);
701
- if (!toTab.taskIdsByStatus[statusKey].includes(taskId)) {
702
- toTab.taskIdsByStatus[statusKey].push(taskId);
703
- }
704
- const dueDateKey = updatedTask.dueDate != null
705
- ? getDueDateGroupKey(updatedTask.dueDate.toString())
706
- : 'upcoming';
707
- if (!toTab.taskIdsByDueDate[dueDateKey].includes(taskId)) {
708
- toTab.taskIdsByDueDate[dueDateKey].push(taskId);
709
- }
710
- const assigneeKey = getAssigneesGroupKey(updatedTask.assignees);
711
- if (toTab.taskIdsByAssignees[assigneeKey] == null) {
712
- toTab.taskIdsByAssignees[assigneeKey] = [taskId];
713
- }
714
- else if (!toTab.taskIdsByAssignees[assigneeKey].includes(taskId)) {
715
- toTab.taskIdsByAssignees[assigneeKey].push(taskId);
716
- }
717
- const tagIds = [...updatedTask.tagIds].sort();
718
- const tagsKey = tagIds.join(',');
719
- if (toTab.taskIdsByTags[tagsKey] == null) {
720
- toTab.taskIdsByTags[tagsKey] = [taskId];
721
- }
722
- else if (!toTab.taskIdsByTags[tagsKey].includes(taskId)) {
723
- toTab.taskIdsByTags[tagsKey].push(taskId);
724
- }
725
- (updatedTask.taskGroupIds ?? []).forEach((groupId) => {
726
- if (toTab.taskIdsByGroupsIds[groupId] == null) {
727
- toTab.taskIdsByGroupsIds[groupId] = [taskId];
728
- }
729
- else if (!toTab.taskIdsByGroupsIds[groupId].includes(taskId)) {
730
- toTab.taskIdsByGroupsIds[groupId].push(taskId);
731
- }
732
- });
733
- };
734
- /**
735
- * `updateTasks` extraReducer variant — same migration semantics but
736
- * keyed off the raw `TaskPayload` instead of the rich `Task` entity.
737
- */
738
- const migrateTaskPayloadBetweenTabs = (draft, taskId, payload, from, to) => {
739
- const fromTab = draft.byTab[from];
740
- const toTab = draft.byTab[to];
741
- removeIdsFromTabData(fromTab, [taskId]);
742
- if (!toTab.taskIds.includes(taskId)) {
743
- toTab.taskIds.push(taskId);
744
- }
745
- if (payload.priority?.code != null) {
746
- const priorityKey = (0, taskState_1.toPriorityCodeType)(payload.priority.code);
747
- if (!toTab.taskIdsByPriority[priorityKey].includes(taskId)) {
748
- toTab.taskIdsByPriority[priorityKey].push(taskId);
749
- }
750
- }
751
- if (payload.status?.code != null) {
752
- const statusKey = (0, taskState_1.toTaskStatusCodeType)(payload.status.code);
753
- if (!toTab.taskIdsByStatus[statusKey].includes(taskId)) {
754
- toTab.taskIdsByStatus[statusKey].push(taskId);
755
- }
756
- }
757
- const dueDateKey = getDueDateGroupKey(payload.due_date);
758
- if (!toTab.taskIdsByDueDate[dueDateKey].includes(taskId)) {
759
- toTab.taskIdsByDueDate[dueDateKey].push(taskId);
760
- }
761
- const assigneeKey = getAssigneesGroupKey(payload.assignees ?? []);
762
- if (toTab.taskIdsByAssignees[assigneeKey] == null) {
763
- toTab.taskIdsByAssignees[assigneeKey] = [taskId];
764
- }
765
- else if (!toTab.taskIdsByAssignees[assigneeKey].includes(taskId)) {
766
- toTab.taskIdsByAssignees[assigneeKey].push(taskId);
767
- }
768
- const tagsKey = getTagsGroupKey(payload.tags ?? []);
769
- if (toTab.taskIdsByTags[tagsKey] == null) {
770
- toTab.taskIdsByTags[tagsKey] = [taskId];
771
- }
772
- else if (!toTab.taskIdsByTags[tagsKey].includes(taskId)) {
773
- toTab.taskIdsByTags[tagsKey].push(taskId);
774
- }
775
- (payload.task_group_ids ?? []).forEach((groupId) => {
776
- if (toTab.taskIdsByGroupsIds[groupId] == null) {
777
- toTab.taskIdsByGroupsIds[groupId] = [taskId];
778
- }
779
- else if (!toTab.taskIdsByGroupsIds[groupId].includes(taskId)) {
780
- toTab.taskIdsByGroupsIds[groupId].push(taskId);
781
- }
782
- });
783
- };
784
562
  const removeIdsFromTabData = (tabData, taskIds) => {
785
563
  const removedSet = new Set(taskIds);
786
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,
@@ -7,8 +7,8 @@ exports.saveTransactionDetailEpic = void 0;
7
7
  const get_1 = __importDefault(require("lodash/get"));
8
8
  const rxjs_1 = require("rxjs");
9
9
  const operators_1 = require("rxjs/operators");
10
- const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
11
10
  const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
11
+ const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
12
12
  const transactionDetailReducer_1 = require("../transactionDetailReducer");
13
13
  const transactionDetailState_1 = require("../transactionDetailState");
14
14
  const saveTransactionHelper_1 = require("./saveTransactionHelper");
@@ -18,12 +18,13 @@ const saveTransactionDetailEpic = (actions$, state$) => actions$.pipe((0, operat
18
18
  const transactionDetailState = state$.value.transactionDetailState;
19
19
  const transactionState = state$.value.transactionState;
20
20
  const isAccountingProjectsEnabled = (0, tenantSelector_1.getIsAccountingProjectsEnabled)(state$.value);
21
+ const isAccountingClassesEnabled = (0, tenantSelector_1.getIsAccountingClassesEnabled)(state$.value);
21
22
  const key = (0, transactionDetailState_1.getTransactionDetailKey)(transactionId);
22
23
  const detail = (0, get_1.default)(transactionDetailState.transactionDetailById, key, undefined);
23
24
  const transaction = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, key);
24
25
  if (detail != null && transaction != null) {
25
26
  const localData = detail.transactionDetailLocalData;
26
- const transactionSaveUpdates = (0, saveTransactionHelper_1.toTransactionUpdatesFromTransactionDetailLocalData)(localData, transaction, isExpenseAutomationEnabled, isAccountingProjectsEnabled);
27
+ const transactionSaveUpdates = (0, saveTransactionHelper_1.toTransactionUpdatesFromTransactionDetailLocalData)(localData, transaction, isExpenseAutomationEnabled, isAccountingProjectsEnabled, isAccountingClassesEnabled);
27
28
  fetchActions.push((0, transactionDetailReducer_1.updateTransactionDetail)(transactionId, transactionSaveUpdates, isExpenseAutomationEnabled, cotTransactionTracking, isUncategorizedExpenseCategoryEnabled));
28
29
  return (0, rxjs_1.from)(fetchActions);
29
30
  }
@@ -21,8 +21,8 @@ import { TransactionDetailLocalData } from '../transactionDetailTypes';
21
21
  * 4. Only difference between this and Miscategorized will be that we will
22
22
  * additionally fire “Mark as not miscat” for every point above.
23
23
  */
24
- export declare const toTransactionUpdatesFromTransactionDetailLocalData: (transactionDetailLocalData: TransactionDetailLocalData, transaction: SupportedTransaction, isExpenseAutomationEnabled: boolean, isAccountingProjectsEnabled?: boolean) => TransactionSaveUpdates;
24
+ export declare const toTransactionUpdatesFromTransactionDetailLocalData: (transactionDetailLocalData: TransactionDetailLocalData, transaction: SupportedTransaction, isExpenseAutomationEnabled: boolean, isAccountingProjectsEnabled?: boolean, isAccountingClassesEnabled?: boolean) => TransactionSaveUpdates;
25
25
  export declare const toRecommendedAccountBase: (amountValue: number, accountBase?: AccountBase, recommendationBase?: RecommendationBase) => RecommendedAccountBase | undefined;
26
26
  export declare const toRecommendedClassBase: (amountValue: number, classBase?: ClassBase, recommendationBase?: RecommendationBase) => RecommendedClassBase | undefined;
27
- export declare const isTransactionMiscategorized: (transaction: SupportedTransaction, isExpenseAutomationEnabled: boolean) => boolean;
27
+ export declare const isTransactionMiscategorized: (transaction: SupportedTransaction, isExpenseAutomationEnabled: boolean, isAccountingClassesEnabled?: boolean) => boolean;
28
28
  export declare const isTransactionUncategorized: (transaction: SupportedTransaction, uncategorizedIncomeExpense: UncategorizedAccounts) => boolean;
@@ -24,13 +24,13 @@ const transactionDetailLocalDataHelper_1 = require("../transactionDetailLocalDat
24
24
  * 4. Only difference between this and Miscategorized will be that we will
25
25
  * additionally fire “Mark as not miscat” for every point above.
26
26
  */
27
- const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLocalData, transaction, isExpenseAutomationEnabled, isAccountingProjectsEnabled = false) => {
27
+ const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLocalData, transaction, isExpenseAutomationEnabled, isAccountingProjectsEnabled = false, isAccountingClassesEnabled = false) => {
28
28
  const updates = {
29
29
  updatesByLineId: {},
30
30
  };
31
31
  const updatesByLineId = {};
32
32
  const entityUpdates = {};
33
- const isTransactionMisCategorized = (0, exports.isTransactionMiscategorized)(transaction, isExpenseAutomationEnabled);
33
+ const isTransactionMisCategorized = (0, exports.isTransactionMiscategorized)(transaction, isExpenseAutomationEnabled, isAccountingClassesEnabled);
34
34
  updates.memo = transactionDetailLocalData.memo;
35
35
  updates.documentId = transactionDetailLocalData.documentId;
36
36
  // Project is at the transaction level only for invoice and credit_memo,
@@ -277,9 +277,10 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpda
277
277
  }
278
278
  return undefined;
279
279
  };
280
- const isTransactionMiscategorized = (transaction, isExpenseAutomationEnabled) => {
280
+ const isTransactionMiscategorized = (transaction, isExpenseAutomationEnabled, isAccountingClassesEnabled = false) => {
281
281
  const lines = transaction.lines;
282
- if (isExpenseAutomationEnabled === true &&
282
+ if ((isExpenseAutomationEnabled === true ||
283
+ isAccountingClassesEnabled === true) &&
283
284
  ((0, vendorTransaction_1.isVendorTransaction)(transaction) || transaction.type === 'journal_entry')) {
284
285
  return true;
285
286
  }
@@ -290,7 +291,7 @@ const isTransactionMiscategorized = (transaction, isExpenseAutomationEnabled) =>
290
291
  line.type === 'journal_entry_transaction_line') {
291
292
  const lineItem = line;
292
293
  if (lineItem.isCategoryMiscategorized ||
293
- lineItem.isClassMiscategorized ||
294
+ (isAccountingClassesEnabled && lineItem.isClassMiscategorized) ||
294
295
  // This ensures that neither vendor or customer is present at line level, safe to say miscat line due to vendor/customer
295
296
  ((0, transactionType_1.toVendorTransactionTypeStrict)(transaction.type) &&
296
297
  transaction.vendor == null) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.35-betaDI1",
3
+ "version": "5.1.35-betaRD11",
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>;