@zeniai/client-epic-state 5.0.84-betaJK3 → 5.0.84-betaJK5

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.
@@ -2,7 +2,7 @@ import { from, of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { convertHHMMStrToMinutes } from '../../../../commonStateTypes/fiscalYearHelpers/formatMinutesToFromHHMM';
4
4
  import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
5
- import { appendSubTaskId, updateTasks } from '../../../../entity/task/taskReducer';
5
+ import { appendSubTaskId, updateTasks, } from '../../../../entity/task/taskReducer';
6
6
  import { getTaskById } from '../../../../entity/task/taskSelector';
7
7
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
8
8
  import { updateTaskListOnNewTaskCreationSuccess } from '../../taskListView/taskListReducer';
@@ -12,7 +12,7 @@ export const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe(fi
12
12
  const parentTask = getTaskById(state.taskState, action.payload.parentTaskId);
13
13
  const parentTaskGroupId = parentTask?.taskGroupIds[0];
14
14
  const isTaskListFetched = state.taskListState.fetchState === 'Completed';
15
- const payload = prepareSubTaskPayload(action.payload);
15
+ const payload = prepareSubTaskPayload(action.payload, parentTaskGroupId);
16
16
  return zeniAPI
17
17
  .postAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`, payload)
18
18
  .pipe(mergeMap((response) => {
@@ -36,8 +36,7 @@ export const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe(fi
36
36
  type: 'success',
37
37
  }),
38
38
  ];
39
- if (isTaskListFetched === true &&
40
- parentTaskGroupId != null) {
39
+ if (isTaskListFetched === true && parentTaskGroupId != null) {
41
40
  actions.push(updateTaskListOnNewTaskCreationSuccess({
42
41
  taskGroupId: parentTaskGroupId,
43
42
  task: response.data.tasks[0],
@@ -67,7 +66,7 @@ export const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe(fi
67
66
  JSON.stringify(error)),
68
67
  }))));
69
68
  }));
70
- const prepareSubTaskPayload = (subTask) => ({
69
+ const prepareSubTaskPayload = (subTask, parentTaskGroupId) => ({
71
70
  name: subTask.name,
72
71
  assignees: subTask.assignee,
73
72
  description: subTask.description,
@@ -77,4 +76,5 @@ const prepareSubTaskPayload = (subTask) => ({
77
76
  time_spent: convertHHMMStrToMinutes(subTask.timeSpent),
78
77
  group_assignees: subTask.groupAssignees,
79
78
  parent_task_id: subTask.parentTaskId,
79
+ task_group_ids: parentTaskGroupId == null ? [] : [parentTaskGroupId],
80
80
  });
@@ -4,13 +4,16 @@ import { catchError, filter, mergeMap } from 'rxjs/operators';
4
4
  import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
5
5
  import { updateTags } from '../../../../entity/tag/tagReducer';
6
6
  import { updateTasks } from '../../../../entity/task/taskReducer';
7
+ import { getTaskById } from '../../../../entity/task/taskSelector';
7
8
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
8
9
  import { fetchFileList } from '../../../fileView/fileViewReducer';
10
+ import { updateTaskListOnNewTaskCreationSuccess } from '../../taskListView/taskListReducer';
9
11
  import { fetchTaskDetail, initializeTaskToLocalStore, removeTaskDetail, updateEditTaskFetchStatus, } from '../taskDetailReducer';
10
12
  export const fetchTaskDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchTaskDetail.match), mergeMap((action) => {
11
13
  const { taskId, cacheOverride } = action.payload;
12
14
  const taskActions = [];
13
15
  const state = state$.value;
16
+ const isTaskListFetched = state.taskListState.fetchState === 'Completed';
14
17
  const taskDetail = recordGet(state.taskDetailState.editTaskStateById, taskId, undefined);
15
18
  if (cacheOverride === true) {
16
19
  taskActions.push(removeTaskDetail(taskId));
@@ -32,6 +35,16 @@ export const fetchTaskDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe(
32
35
  updateTags(response.data.tasks.map((task) => task.tags).flat()),
33
36
  initializeTaskToLocalStore(taskId),
34
37
  ];
38
+ if (isTaskListFetched === true) {
39
+ const taskGroupId = response.data.tasks[0].task_group_ids?.[0];
40
+ if (taskGroupId != null) {
41
+ fetchActions.push(updateTaskListOnNewTaskCreationSuccess({
42
+ taskGroupId,
43
+ task: response.data.tasks[0],
44
+ currentTaskState: getTaskById(state.taskState, taskId),
45
+ }));
46
+ }
47
+ }
35
48
  const fileIds = response.data.tasks[0].file_ids;
36
49
  if (fileIds.length > 0) {
37
50
  fetchActions.push(fetchFileList(fileIds));
@@ -15,7 +15,7 @@ const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, opera
15
15
  const parentTask = (0, taskSelector_1.getTaskById)(state.taskState, action.payload.parentTaskId);
16
16
  const parentTaskGroupId = parentTask?.taskGroupIds[0];
17
17
  const isTaskListFetched = state.taskListState.fetchState === 'Completed';
18
- const payload = prepareSubTaskPayload(action.payload);
18
+ const payload = prepareSubTaskPayload(action.payload, parentTaskGroupId);
19
19
  return zeniAPI
20
20
  .postAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`, payload)
21
21
  .pipe((0, operators_1.mergeMap)((response) => {
@@ -39,8 +39,7 @@ const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, opera
39
39
  type: 'success',
40
40
  }),
41
41
  ];
42
- if (isTaskListFetched === true &&
43
- parentTaskGroupId != null) {
42
+ if (isTaskListFetched === true && parentTaskGroupId != null) {
44
43
  actions.push((0, taskListReducer_1.updateTaskListOnNewTaskCreationSuccess)({
45
44
  taskGroupId: parentTaskGroupId,
46
45
  task: response.data.tasks[0],
@@ -71,7 +70,7 @@ const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, opera
71
70
  }))));
72
71
  }));
73
72
  exports.createSubTaskEpic = createSubTaskEpic;
74
- const prepareSubTaskPayload = (subTask) => ({
73
+ const prepareSubTaskPayload = (subTask, parentTaskGroupId) => ({
75
74
  name: subTask.name,
76
75
  assignees: subTask.assignee,
77
76
  description: subTask.description,
@@ -81,4 +80,5 @@ const prepareSubTaskPayload = (subTask) => ({
81
80
  time_spent: (0, formatMinutesToFromHHMM_1.convertHHMMStrToMinutes)(subTask.timeSpent),
82
81
  group_assignees: subTask.groupAssignees,
83
82
  parent_task_id: subTask.parentTaskId,
83
+ task_group_ids: parentTaskGroupId == null ? [] : [parentTaskGroupId],
84
84
  });
@@ -6,6 +6,7 @@ import { updateTasks } from '../../../../entity/task/taskReducer';
6
6
  import { RootState } from '../../../../reducer';
7
7
  import { ZeniAPI } from '../../../../zeniAPI';
8
8
  import { fetchFileList } from '../../../fileView/fileViewReducer';
9
+ import { updateTaskListOnNewTaskCreationSuccess } from '../../taskListView/taskListReducer';
9
10
  import { fetchTaskDetail, initializeTaskToLocalStore, removeTaskDetail, updateEditTaskFetchStatus } from '../taskDetailReducer';
10
- export type ActionType = ReturnType<typeof fetchTaskDetail> | ReturnType<typeof updateTags> | ReturnType<typeof updateEditTaskFetchStatus> | ReturnType<typeof removeTaskDetail> | ReturnType<typeof updateTasks> | ReturnType<typeof initializeTaskToLocalStore> | ReturnType<typeof fetchFileList> | ReturnType<typeof openSnackbar>;
11
+ export type ActionType = ReturnType<typeof fetchTaskDetail> | ReturnType<typeof updateTags> | ReturnType<typeof updateEditTaskFetchStatus> | ReturnType<typeof removeTaskDetail> | ReturnType<typeof updateTasks> | ReturnType<typeof initializeTaskToLocalStore> | ReturnType<typeof fetchFileList> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateTaskListOnNewTaskCreationSuccess>;
11
12
  export declare const fetchTaskDetailEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -10,13 +10,16 @@ const operators_1 = require("rxjs/operators");
10
10
  const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
11
11
  const tagReducer_1 = require("../../../../entity/tag/tagReducer");
12
12
  const taskReducer_1 = require("../../../../entity/task/taskReducer");
13
+ const taskSelector_1 = require("../../../../entity/task/taskSelector");
13
14
  const responsePayload_1 = require("../../../../responsePayload");
14
15
  const fileViewReducer_1 = require("../../../fileView/fileViewReducer");
16
+ const taskListReducer_1 = require("../../taskListView/taskListReducer");
15
17
  const taskDetailReducer_1 = require("../taskDetailReducer");
16
18
  const fetchTaskDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(taskDetailReducer_1.fetchTaskDetail.match), (0, operators_1.mergeMap)((action) => {
17
19
  const { taskId, cacheOverride } = action.payload;
18
20
  const taskActions = [];
19
21
  const state = state$.value;
22
+ const isTaskListFetched = state.taskListState.fetchState === 'Completed';
20
23
  const taskDetail = (0, get_1.default)(state.taskDetailState.editTaskStateById, taskId, undefined);
21
24
  if (cacheOverride === true) {
22
25
  taskActions.push((0, taskDetailReducer_1.removeTaskDetail)(taskId));
@@ -38,6 +41,16 @@ const fetchTaskDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, ope
38
41
  (0, tagReducer_1.updateTags)(response.data.tasks.map((task) => task.tags).flat()),
39
42
  (0, taskDetailReducer_1.initializeTaskToLocalStore)(taskId),
40
43
  ];
44
+ if (isTaskListFetched === true) {
45
+ const taskGroupId = response.data.tasks[0].task_group_ids?.[0];
46
+ if (taskGroupId != null) {
47
+ fetchActions.push((0, taskListReducer_1.updateTaskListOnNewTaskCreationSuccess)({
48
+ taskGroupId,
49
+ task: response.data.tasks[0],
50
+ currentTaskState: (0, taskSelector_1.getTaskById)(state.taskState, taskId),
51
+ }));
52
+ }
53
+ }
41
54
  const fileIds = response.data.tasks[0].file_ids;
42
55
  if (fileIds.length > 0) {
43
56
  fetchActions.push((0, fileViewReducer_1.fetchFileList)(fileIds));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.84-betaJK3",
3
+ "version": "5.0.84-betaJK5",
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",