@zeniai/client-epic-state 5.0.16-betaSS1 → 5.0.17-betaND1

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 (37) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/commonStateTypes/animations.js +3 -0
  3. package/lib/entity/task/taskPayload.d.ts +1 -0
  4. package/lib/entity/task/taskPayload.js +3 -0
  5. package/lib/entity/task/taskState.d.ts +1 -0
  6. package/lib/epic.d.ts +2 -1
  7. package/lib/epic.js +2 -1
  8. package/lib/esm/commonStateTypes/animations.js +3 -0
  9. package/lib/esm/entity/task/taskPayload.js +3 -0
  10. package/lib/esm/epic.js +2 -1
  11. package/lib/esm/index.js +2 -2
  12. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +6 -26
  13. package/lib/esm/view/monthEndCloseChecksView/monthEndCloseChecksViewSelector.js +3 -11
  14. package/lib/esm/view/scheduleView/scheduleListView/scheduleListSelector.js +2 -7
  15. package/lib/esm/view/taskManager/taskListView/epics/createSubtaskFromListViewEpic.js +31 -0
  16. package/lib/esm/view/taskManager/taskListView/epics/fetchTaskListEpic.js +6 -3
  17. package/lib/esm/view/taskManager/taskListView/taskListPayload.js +5 -1
  18. package/lib/esm/view/taskManager/taskListView/taskListReducer.js +30 -1
  19. package/lib/esm/view/taskManager/taskListView/taskListSelector.js +27 -4
  20. package/lib/index.d.ts +2 -2
  21. package/lib/index.js +6 -4
  22. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  23. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -1
  24. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +5 -25
  25. package/lib/view/monthEndCloseChecksView/monthEndCloseChecksViewSelector.js +1 -12
  26. package/lib/view/scheduleView/scheduleListView/scheduleListSelector.js +2 -7
  27. package/lib/view/taskManager/taskListView/epics/createSubtaskFromListViewEpic.d.ts +8 -0
  28. package/lib/view/taskManager/taskListView/epics/createSubtaskFromListViewEpic.js +35 -0
  29. package/lib/view/taskManager/taskListView/epics/fetchTaskListEpic.js +6 -3
  30. package/lib/view/taskManager/taskListView/taskList.d.ts +2 -0
  31. package/lib/view/taskManager/taskListView/taskListPayload.d.ts +31 -1
  32. package/lib/view/taskManager/taskListView/taskListPayload.js +7 -0
  33. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +7 -3
  34. package/lib/view/taskManager/taskListView/taskListReducer.js +31 -2
  35. package/lib/view/taskManager/taskListView/taskListSelector.d.ts +4 -1
  36. package/lib/view/taskManager/taskListView/taskListSelector.js +27 -4
  37. package/package.json +2 -2
@@ -24,7 +24,6 @@ export interface ExpenseAutomationJESchedulesViewSelector extends SelectorView {
24
24
  ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
25
25
  jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
26
26
  ongoingSchedules: JEScheduledTransaction[];
27
- pendingReviewSchedules: (JEScheduledTransaction | JEScheduledTransactionWithFailedEntries)[];
28
27
  postStatusById: Record<ID, FetchStateAndError>;
29
28
  refreshStatus: FetchStateAndError;
30
29
  resolveSchedules: JEScheduledTransactionWithFailedEntries[];
@@ -29,33 +29,19 @@ function getJEScheduleSortAccessor(sortKey) {
29
29
  case 'depCategory':
30
30
  return (s) => s.jeCredit.account?.accountName?.toLowerCase();
31
31
  case 'scheduleCategory':
32
- return (s) => s.baseTransaction.account?.accountName?.toLowerCase();
32
+ return (s) => s.jeScheduleType;
33
33
  case 'startMonth':
34
34
  return (s) => s.startDate?.valueOf();
35
35
  case 'type':
36
- return (s) => s.jeScheduleType;
36
+ return (s) => s.baseTransaction.typeOfTransaction;
37
37
  case 'amortizationPeriod':
38
38
  return (s) => s.period;
39
39
  case 'jePostingDate':
40
- return (s) => s.lastDayOfMonth === true
41
- ? timePeriod_1.LAST_SCHEDULE_DAY_OF_MONTH
42
- : (s.dayOfPostingDate ?? null);
40
+ return (s) => s.dayOfPostingDate;
43
41
  case 'remainingMonths':
44
- return (s) => {
45
- const total = s.period ?? 0;
46
- const posted = Array.isArray(s.scheduledJournalEntry)
47
- ? s.scheduledJournalEntry.length
48
- : 0;
49
- return total - posted;
50
- };
42
+ return (s) => s.period;
51
43
  case 'runningBalance':
52
- return (s) => {
53
- const sje = s.scheduledJournalEntry;
54
- if (sje != null && !Array.isArray(sje)) {
55
- return sje.runningBalance?.amount ?? null;
56
- }
57
- return s.balanceAsOfToday?.amount ?? null;
58
- };
44
+ return (s) => s.balanceAsOfToday?.amount;
59
45
  case 'totalAmount':
60
46
  return (s) => s.baseTransaction.amount.amount;
61
47
  case 'transactionDate':
@@ -134,11 +120,6 @@ function getExpenseAutomationJESchedulesView(state) {
134
120
  });
135
121
  });
136
122
  const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
137
- const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
138
- const pendingReviewSchedules = sortJEScheduledTransactions([
139
- ...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'),
140
- ...validResolveForPending,
141
- ], sortKey, sortOrder);
142
123
  const allSteps = monthYearPeriodId != null
143
124
  ? (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
144
125
  : [];
@@ -162,7 +143,6 @@ function getExpenseAutomationJESchedulesView(state) {
162
143
  completedSchedules,
163
144
  draftSchedules,
164
145
  ongoingSchedules,
165
- pendingReviewSchedules,
166
146
  resolveSchedules: resolveSchedules,
167
147
  accountSettingsView,
168
148
  postStatusById: postStatusById,
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getMonthEndCloseChecksViewByTenantId = exports.isMonthEndInsightDisabled = void 0;
7
4
  const toolkit_1 = require("@reduxjs/toolkit");
8
- const isEqual_1 = __importDefault(require("lodash/isEqual"));
9
5
  const formatZeniDateFY_1 = require("../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
10
6
  const timePeriod_1 = require("../../commonStateTypes/timePeriod");
11
7
  const monthEndCloseChecksSelector_1 = require("../../entity/monthEndCloseChecks/monthEndCloseChecksSelector");
@@ -18,13 +14,6 @@ const isMonthEndInsightDisabled = (currentTenant, selectedPeriod, userAllowedToA
18
14
  userAllowedToAccessMonthEndInsights === false) {
19
15
  return true;
20
16
  }
21
- const previousMonthPeriod = {
22
- month: (0, timePeriod_1.toMonth)((0, zeniDayJS_1.dateNow)().subtract(1, 'month').month() + 1),
23
- year: (0, zeniDayJS_1.dateNow)().subtract(1, 'month').year(),
24
- };
25
- if (!(0, isEqual_1.default)(previousMonthPeriod, selectedPeriod)) {
26
- return true;
27
- }
28
17
  // if the selected period is November 2024, then book close date should not be null and book close date should be 30th November 2024
29
18
  const { bookCloseDate } = currentTenant;
30
19
  const selectedPeriodFirstDay = (0, zeniDayJS_1.date)(`${selectedPeriod.year}-${selectedPeriod.month}-01`);
@@ -63,7 +52,7 @@ exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((st
63
52
  if (check.id === 'month_end_insights') {
64
53
  const isDisabled = monthEndCloseChecks.reportEmailSentDate == null
65
54
  ? (0, exports.isMonthEndInsightDisabled)(currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, monthEndCloseChecks.auditSummary)
66
- : false;
55
+ : true;
67
56
  return {
68
57
  ...check,
69
58
  isDisabled,
@@ -53,13 +53,8 @@ const sortedJETransactionsView = (jeTransactions, sortKey, sortOrder) => {
53
53
  return jeTransaction.endDate != null
54
54
  ? jeTransaction.endDate.valueOf()
55
55
  : null;
56
- case 'months': {
57
- const total = jeTransaction.period ?? 0;
58
- const posted = Array.isArray(jeTransaction.scheduledJournalEntry)
59
- ? jeTransaction.scheduledJournalEntry.length
60
- : 0;
61
- return total - posted;
62
- }
56
+ case 'months':
57
+ return jeTransaction.period ?? null;
63
58
  case 'transactionType':
64
59
  return jeTransaction.baseTransaction.type.toLowerCase();
65
60
  case 'status':
@@ -0,0 +1,8 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateTasks } from '../../../../entity/task/taskReducer';
4
+ import { RootState } from '../../../../reducer';
5
+ import { ZeniAPI } from '../../../../zeniAPI';
6
+ import { createSubtaskFromListView, updateTasksListOnCreateSubtaskFromListViewSuccess, updateTasksListOnUpdateTaskFailure } from '../taskListReducer';
7
+ export type ActionType = ReturnType<typeof createSubtaskFromListView> | ReturnType<typeof updateTasks> | ReturnType<typeof updateTasksListOnCreateSubtaskFromListViewSuccess> | ReturnType<typeof updateTasksListOnUpdateTaskFailure>;
8
+ export declare const createSubtaskFromListViewEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSubtaskFromListViewEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const taskReducer_1 = require("../../../../entity/task/taskReducer");
7
+ const responsePayload_1 = require("../../../../responsePayload");
8
+ const taskListReducer_1 = require("../taskListReducer");
9
+ const createSubtaskFromListViewEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(taskListReducer_1.createSubtaskFromListView.match), (0, operators_1.switchMap)((action) => {
10
+ const payload = action.payload;
11
+ const parentTaskId = payload.parent_task_id;
12
+ return zeniAPI
13
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`, { ...payload })
14
+ .pipe((0, operators_1.mergeMap)((response) => {
15
+ if ((0, responsePayload_1.isSuccessResponse)(response) &&
16
+ response.data != null &&
17
+ response.data.tasks.length > 0) {
18
+ const subtaskId = response.data.tasks[0].task_id;
19
+ return (0, rxjs_1.from)([
20
+ (0, taskReducer_1.updateTasks)(response.data.tasks),
21
+ (0, taskListReducer_1.updateTasksListOnCreateSubtaskFromListViewSuccess)({
22
+ parentTaskId,
23
+ subtaskId,
24
+ }),
25
+ ]);
26
+ }
27
+ return (0, rxjs_1.of)((0, taskListReducer_1.updateTasksListOnUpdateTaskFailure)({
28
+ error: response.status,
29
+ }));
30
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, taskListReducer_1.updateTasksListOnUpdateTaskFailure)({
31
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'create subtask from list view REST API call errored out' +
32
+ JSON.stringify(error)),
33
+ }))));
34
+ }));
35
+ exports.createSubtaskFromListViewEpic = createSubtaskFromListViewEpic;
@@ -6,16 +6,19 @@ const operators_1 = require("rxjs/operators");
6
6
  const tagReducer_1 = require("../../../../entity/tag/tagReducer");
7
7
  const taskReducer_1 = require("../../../../entity/task/taskReducer");
8
8
  const responsePayload_1 = require("../../../../responsePayload");
9
+ const taskListPayload_1 = require("../taskListPayload");
9
10
  const taskListReducer_1 = require("../taskListReducer");
10
11
  const fetchTaskListEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(taskListReducer_1.fetchTaskList.match), (0, operators_1.switchMap)(() => {
11
12
  return zeniAPI
12
13
  .getJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent(`{"task_type": "all"}`)}`)
13
14
  .pipe((0, operators_1.mergeMap)((response) => {
14
15
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
15
- return (0, rxjs_1.of)((0, taskReducer_1.updateTasks)(response.data.tasks), (0, taskListReducer_1.updateTaskList)({
16
- data: response.data.tasks,
16
+ const { tasks } = response.data;
17
+ const tasksForEntity = (0, taskListPayload_1.flattenTasksAndSubtasksForEntity)(tasks);
18
+ return (0, rxjs_1.of)((0, taskReducer_1.updateTasks)(tasksForEntity), (0, taskListReducer_1.updateTaskList)({
19
+ data: tasks,
17
20
  updateType: 'replace',
18
- }), (0, tagReducer_1.updateTags)(response.data.tasks.map((task) => task.tags).flat()));
21
+ }), (0, tagReducer_1.updateTags)(tasksForEntity.map((task) => task.tags).flat()));
19
22
  }
20
23
  else {
21
24
  return (0, rxjs_1.of)((0, taskListReducer_1.updateTaskListFetchStatus)({
@@ -15,6 +15,8 @@ export declare type DueDateGroupKey = ReturnType<typeof toDueDateGroupKeyType>;
15
15
  export interface TaskListState extends FetchedState {
16
16
  filters: TaskListFilters;
17
17
  localData: TaskListLocalData;
18
+ /** Maps each list (parent) task id to ordered subtask ids from the last list fetch. */
19
+ subtaskIdsByParentTaskId: Record<ID, ID[]>;
18
20
  taskIds: ID[];
19
21
  taskIdsByAssignees: Record<ID, ID[]>;
20
22
  taskIdsByDueDate: Record<DueDateGroupKey, ID[]>;
@@ -1,7 +1,37 @@
1
+ import { ID } from '../../../commonStateTypes/common';
1
2
  import { TaskPayload } from '../../../entity/task/taskPayload';
2
3
  import { ZeniAPIResponse } from '../../../responsePayload';
4
+ /**
5
+ * Task row returned by the task list API. Subtasks share the same wire shape
6
+ * as tasks but are nested under their parent and indexed separately in list state.
7
+ */
8
+ export interface TaskListTaskPayload extends TaskPayload {
9
+ subtasks?: TaskPayload[];
10
+ }
3
11
  interface FetchTaskListPayload {
4
- tasks: TaskPayload[];
12
+ tasks: TaskListTaskPayload[];
5
13
  }
6
14
  export type FetchTaskListResponse = ZeniAPIResponse<FetchTaskListPayload>;
15
+ /** Request body for POST `/task-manager/tasks` when creating a subtask from the list view. */
16
+ export interface CreateSubtaskFromListViewPayload {
17
+ assignees: string[];
18
+ description: string;
19
+ due_date: string | null;
20
+ file_ids: string[];
21
+ group_assignees: string[];
22
+ name: string;
23
+ parent_task_id: ID;
24
+ priority: string;
25
+ recurring_end_date: string | null;
26
+ recurring_frequency: string | null;
27
+ recurring_start_date: string | null;
28
+ status: string;
29
+ sync_token: string;
30
+ tags: string[];
31
+ task_group_ids: string[];
32
+ time_spent: number;
33
+ type: string;
34
+ }
35
+ /** Parent tasks and nested subtasks as flat `TaskPayload`s for `updateTasks`. */
36
+ export declare const flattenTasksAndSubtasksForEntity: (tasks: TaskListTaskPayload[]) => TaskPayload[];
7
37
  export {};
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flattenTasksAndSubtasksForEntity = void 0;
4
+ /** Parent tasks and nested subtasks as flat `TaskPayload`s for `updateTasks`. */
5
+ const flattenTasksAndSubtasksForEntity = (tasks) => tasks.flatMap((task) => {
6
+ const { subtasks, ...parent } = task;
7
+ return [parent, ...(subtasks ?? [])];
8
+ });
9
+ exports.flattenTasksAndSubtasksForEntity = flattenTasksAndSubtasksForEntity;
@@ -5,12 +5,13 @@ import { TaskGroupPayload } from '../../../entity/taskGroup/taskGroupPayload';
5
5
  import { TaskGroup } from '../../../entity/taskGroup/taskGroupState';
6
6
  import { ZeniAPIStatus } from '../../../responsePayload';
7
7
  import { TaskListFilters, TaskListLocalData, TaskListState, TaskListUIState } from './taskList';
8
+ import { CreateSubtaskFromListViewPayload, TaskListTaskPayload } from './taskListPayload';
8
9
  export declare const initialState: TaskListState;
9
10
  export declare const fetchTaskListPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride: boolean, isTaskTemplatesEnabled: boolean], {
10
11
  cacheOverride: boolean;
11
12
  isTaskTemplatesEnabled: boolean;
12
13
  }, "taskList/fetchTaskListPage", never, never>, fetchTaskList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"taskList/fetchTaskList">, updateTaskList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
13
- data: TaskPayload[];
14
+ data: TaskListTaskPayload[];
14
15
  updateType: UpdateType;
15
16
  }, "taskList/updateTaskList">, updateTaskListFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
16
17
  fetchState: FetchState;
@@ -48,10 +49,13 @@ export declare const fetchTaskListPage: import("@reduxjs/toolkit").ActionCreator
48
49
  }, "taskList/updateTaskListOnNewTaskCreationSuccess">, updateTaskListOnTaskGroupNameUpdate: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
49
50
  taskGroupId: ID;
50
51
  taskGroupName: ID;
51
- }, "taskList/updateTaskListOnTaskGroupNameUpdate">, updateTaskFromListView: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
52
+ }, "taskList/updateTaskListOnTaskGroupNameUpdate">, createSubtaskFromListView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: CreateSubtaskFromListViewPayload], CreateSubtaskFromListViewPayload, "taskList/createSubtaskFromListView", never, never>, updateTaskFromListView: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
52
53
  task: Task;
53
54
  updates: Partial<Task>;
54
- }, "taskList/updateTaskFromListView">, updateTasksListOnUpdateTaskSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"taskList/updateTasksListOnUpdateTaskSuccess">, updateTasksListOnUpdateTaskFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
55
+ }, "taskList/updateTaskFromListView">, updateTasksListOnCreateSubtaskFromListViewSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
56
+ parentTaskId: ID;
57
+ subtaskId: ID;
58
+ }, "taskList/updateTasksListOnCreateSubtaskFromListViewSuccess">, updateTasksListOnUpdateTaskSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"taskList/updateTasksListOnUpdateTaskSuccess">, updateTasksListOnUpdateTaskFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
55
59
  error: ZeniAPIStatus;
56
60
  }, "taskList/updateTasksListOnUpdateTaskFailure">, updateTaskListOnCreateTaskFromTemplateSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
57
61
  tasks: TaskPayload[];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearTaskList = 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.updateTaskList = exports.fetchTaskList = exports.fetchTaskListPage = exports.initialState = void 0;
4
+ exports.clearTaskList = exports.updateTaskListOnCreateTaskFromTemplateSuccess = exports.updateTasksListOnUpdateTaskFailure = exports.updateTasksListOnUpdateTaskSuccess = exports.updateTasksListOnCreateSubtaskFromListViewSuccess = exports.updateTaskFromListView = exports.createSubtaskFromListView = 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.updateTaskList = exports.fetchTaskList = exports.fetchTaskListPage = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const taskState_1 = require("../../../entity/task/taskState");
7
7
  const zeniDayJS_1 = require("../../../zeniDayJS");
@@ -34,6 +34,7 @@ const initialTaskIdsByDueDate = {
34
34
  upcoming: [],
35
35
  };
36
36
  exports.initialState = {
37
+ subtaskIdsByParentTaskId: {},
37
38
  taskIds: [],
38
39
  taskIdsByGroupsIds: {},
39
40
  taskIdsByPriority: initialTaskIdsByPriority,
@@ -93,6 +94,7 @@ const taskList = (0, toolkit_1.createSlice)({
93
94
  const { data } = action.payload;
94
95
  draft.fetchState = 'Completed';
95
96
  draft.error = undefined;
97
+ draft.subtaskIdsByParentTaskId = buildSubtaskIdsByParentTaskId(data);
96
98
  const { taskIds, taskIdsGroupedByPriority, taskIdsByGroupIds, taskIdsGroupedByStatus, taskIdsByAssignees, taskIdsByDueDate, taskIdsByTags, } = getGroupedTaskIds(data);
97
99
  draft.taskIds = taskIds;
98
100
  draft.taskIdsByGroupsIds = taskIdsByGroupIds;
@@ -344,6 +346,17 @@ const taskList = (0, toolkit_1.createSlice)({
344
346
  [taskGroupId]: taskGroupName,
345
347
  };
346
348
  },
349
+ createSubtaskFromListView: {
350
+ reducer(draft) {
351
+ draft.updateTasksFetchState = {
352
+ fetchState: 'In-Progress',
353
+ error: undefined,
354
+ };
355
+ },
356
+ prepare(payload) {
357
+ return { payload };
358
+ },
359
+ },
347
360
  updateTaskFromListView(draft, action) {
348
361
  const { updates, task } = action.payload;
349
362
  const taskId = task.id;
@@ -400,6 +413,13 @@ const taskList = (0, toolkit_1.createSlice)({
400
413
  }
401
414
  }
402
415
  },
416
+ updateTasksListOnCreateSubtaskFromListViewSuccess(draft, action) {
417
+ const { parentTaskId, subtaskId } = action.payload;
418
+ draft.updateTasksFetchState.fetchState = 'Completed';
419
+ draft.updateTasksFetchState.error = undefined;
420
+ const existing = draft.subtaskIdsByParentTaskId[parentTaskId] ?? [];
421
+ draft.subtaskIdsByParentTaskId[parentTaskId] = [...existing, subtaskId];
422
+ },
403
423
  updateTasksListOnUpdateTaskSuccess(draft) {
404
424
  draft.updateTasksFetchState.fetchState = 'Completed';
405
425
  draft.updateTasksFetchState.error = undefined;
@@ -413,7 +433,7 @@ const taskList = (0, toolkit_1.createSlice)({
413
433
  },
414
434
  },
415
435
  });
416
- _a = taskList.actions, exports.fetchTaskListPage = _a.fetchTaskListPage, exports.fetchTaskList = _a.fetchTaskList, exports.updateTaskList = _a.updateTaskList, 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.clearTaskList = _a.clearTaskList;
436
+ _a = taskList.actions, exports.fetchTaskListPage = _a.fetchTaskListPage, exports.fetchTaskList = _a.fetchTaskList, exports.updateTaskList = _a.updateTaskList, 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.createSubtaskFromListView = _a.createSubtaskFromListView, exports.updateTaskFromListView = _a.updateTaskFromListView, exports.updateTasksListOnCreateSubtaskFromListViewSuccess = _a.updateTasksListOnCreateSubtaskFromListViewSuccess, exports.updateTasksListOnUpdateTaskSuccess = _a.updateTasksListOnUpdateTaskSuccess, exports.updateTasksListOnUpdateTaskFailure = _a.updateTasksListOnUpdateTaskFailure, exports.updateTaskListOnCreateTaskFromTemplateSuccess = _a.updateTaskListOnCreateTaskFromTemplateSuccess, exports.clearTaskList = _a.clearTaskList;
417
437
  exports.default = taskList.reducer;
418
438
  /**
419
439
  * helpers
@@ -492,6 +512,15 @@ const getTagsGroupKey = (tags) => {
492
512
  tagIds.sort();
493
513
  return tagIds.join(',');
494
514
  };
515
+ const buildSubtaskIdsByParentTaskId = (tasks) => {
516
+ const subtaskIdsByParentTaskId = {};
517
+ tasks.forEach((task) => {
518
+ if (task.subtasks != null && task.subtasks.length > 0) {
519
+ subtaskIdsByParentTaskId[task.task_id] = task.subtasks.map((s) => s.task_id);
520
+ }
521
+ });
522
+ return subtaskIdsByParentTaskId;
523
+ };
495
524
  const getGroupedTaskIds = (tasks) => {
496
525
  const taskIds = [];
497
526
  const taskIdsByGroupIds = {};
@@ -1,4 +1,4 @@
1
- import { FetchStateAndError } from '../../../commonStateTypes/common';
1
+ import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
3
  import { AddressState } from '../../../entity/address/addressState';
4
4
  import { TagState } from '../../../entity/tag/tagState';
@@ -13,6 +13,7 @@ import { UserListSelectorView } from '../../userListView/userListViewSelector';
13
13
  import { TaskListFilters, TaskListLocalData, TaskListState, TaskListUIState } from './taskList';
14
14
  export interface TaskWithUserDetails extends Task {
15
15
  assigneeUsers: UserAndRole[];
16
+ subtasks: TaskWithUserDetails[];
16
17
  }
17
18
  export interface TaskGroupWithTasksList {
18
19
  groupName: string;
@@ -23,6 +24,8 @@ export interface TaskGroupWithTasksList {
23
24
  export interface TaskListSelectorView extends SelectorView {
24
25
  filters: TaskListFilters;
25
26
  localData: TaskListLocalData;
27
+ /** Subtask ids grouped by parent list task id (from the task list API). */
28
+ subtaskIdsByParentTaskId: Record<ID, ID[]>;
26
29
  taskCreationFromTemplateStatus: FetchStateAndError;
27
30
  taskGroupCreationStatus: FetchStateAndError;
28
31
  taskGroupDeleteStatus: FetchStateAndError;
@@ -49,6 +49,30 @@ const sortTasksList = (tagState, tasksList, sortKey, sortOrder) => {
49
49
  }, sortOrder);
50
50
  return tasksInOrder;
51
51
  };
52
+ const taskToTaskWithUserDetails = (task, userState, userRoleState, addressState) => ({
53
+ ...task,
54
+ assigneeUsers: task.assignees
55
+ .map((userId) => (0, userAndRole_1.getUserAndUserRole)(userState, userRoleState, addressState, userId))
56
+ .filter((value) => value != null),
57
+ subtasks: [],
58
+ });
59
+ const attachSubtasksForTask = (taskWithAssignees, taskListState, taskState, userState, userRoleState, addressState) => {
60
+ const subtaskIds = taskListState.subtaskIdsByParentTaskId[taskWithAssignees.id] ?? [];
61
+ if (subtaskIds.length === 0) {
62
+ return { ...taskWithAssignees, subtasks: [] };
63
+ }
64
+ const subtasks = subtaskIds
65
+ .map((subtaskId) => {
66
+ const subtask = (0, taskSelector_1.getTaskById)(taskState, subtaskId);
67
+ if (subtask == null) {
68
+ return undefined;
69
+ }
70
+ const withAssignees = taskToTaskWithUserDetails(subtask, userState, userRoleState, addressState);
71
+ return attachSubtasksForTask(withAssignees, taskListState, taskState, userState, userRoleState, addressState);
72
+ })
73
+ .filter((value) => value != null);
74
+ return { ...taskWithAssignees, subtasks };
75
+ };
52
76
  const getTasksWithUserDetails = ({ taskListState, taskState, userState, userRoleState, addressState, taskIds, tagState, }) => {
53
77
  const { sortKey, searchText } = taskListState.uiState;
54
78
  const sortOrder = (0, sortOrderPayload_1.getSortOrder)(taskListState.uiState.sortOrder);
@@ -56,10 +80,8 @@ const getTasksWithUserDetails = ({ taskListState, taskState, userState, userRole
56
80
  .map((taskId) => {
57
81
  const task = (0, taskSelector_1.getTaskById)(taskState, taskId);
58
82
  if (task != null) {
59
- const assigneeUsers = task.assignees
60
- .map((userId) => (0, userAndRole_1.getUserAndUserRole)(userState, userRoleState, addressState, userId))
61
- .filter((value) => value != null);
62
- return { ...task, assigneeUsers };
83
+ const taskWithAssignees = taskToTaskWithUserDetails(task, userState, userRoleState, addressState);
84
+ return attachSubtasksForTask(taskWithAssignees, taskListState, taskState, userState, userRoleState, addressState);
63
85
  }
64
86
  return undefined;
65
87
  })
@@ -342,6 +364,7 @@ exports.getAllTasks = (0, toolkit_1.createSelector)((state) => state.taskListSta
342
364
  return {
343
365
  uiState: taskListState.uiState,
344
366
  filters: taskListState.filters,
367
+ subtaskIdsByParentTaskId: taskListState.subtaskIdsByParentTaskId,
345
368
  taskGroupTemplates,
346
369
  fetchState: fetchState,
347
370
  userList: (0, userListViewSelector_1.getUserList)(userState, userRoleState, userListViewState, 'taskManagerCandidate'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.16-betaSS1",
3
+ "version": "5.0.17-betaND1",
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",
@@ -106,7 +106,7 @@
106
106
  "scripts": {
107
107
  "clean": "rimraf lib",
108
108
  "test:typecheck": "echo 'Typechecking test files...' && NODE_OPTIONS=--max-old-space-size=4096 time tsc -p tsconfig.typecheck.json",
109
- "test": "pnpm test:typecheck && vitest run --typecheck",
109
+ "test": "pnpm test:typecheck",
110
110
  "lint": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
111
111
  "find-dead-code": "ts-prune | grep -v '(used in module)'",
112
112
  "find-unused-exports": "ts-unused-exports ./tsconfig.json",