rez_core 2.1.154 → 2.1.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/workflow/controller/action.controller.d.ts +12 -0
- package/dist/module/workflow/controller/action.controller.js +16 -0
- package/dist/module/workflow/controller/action.controller.js.map +1 -1
- package/dist/module/workflow/controller/task.controller.d.ts +8 -0
- package/dist/module/workflow/controller/task.controller.js +14 -1
- package/dist/module/workflow/controller/task.controller.js.map +1 -1
- package/dist/module/workflow/repository/action-data.repository.d.ts +10 -0
- package/dist/module/workflow/repository/action-data.repository.js +85 -0
- package/dist/module/workflow/repository/action-data.repository.js.map +1 -0
- package/dist/module/workflow/repository/action.repository.d.ts +17 -0
- package/dist/module/workflow/repository/action.repository.js +93 -0
- package/dist/module/workflow/repository/action.repository.js.map +1 -0
- package/dist/module/workflow/repository/comm-template.repository.d.ts +1 -1
- package/dist/module/workflow/repository/comm-template.repository.js +16 -11
- package/dist/module/workflow/repository/comm-template.repository.js.map +1 -1
- package/dist/module/workflow/repository/stage-movement.repository.d.ts +1 -1
- package/dist/module/workflow/repository/stage-movement.repository.js +5 -1
- package/dist/module/workflow/repository/stage-movement.repository.js.map +1 -1
- package/dist/module/workflow/repository/task.repository.d.ts +5 -2
- package/dist/module/workflow/repository/task.repository.js +40 -2
- package/dist/module/workflow/repository/task.repository.js.map +1 -1
- package/dist/module/workflow/service/action-data.service.d.ts +11 -0
- package/dist/module/workflow/service/action-data.service.js +36 -0
- package/dist/module/workflow/service/action-data.service.js.map +1 -0
- package/dist/module/workflow/service/action.service.d.ts +13 -1
- package/dist/module/workflow/service/action.service.js +9 -2
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.js +1 -1
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.d.ts +11 -1
- package/dist/module/workflow/service/task.service.js +29 -2
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-meta.service.d.ts +6 -2
- package/dist/module/workflow/service/workflow-meta.service.js +14 -6
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +6 -0
- package/dist/module/workflow/workflow.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/workflow/controller/action.controller.ts +18 -0
- package/src/module/workflow/controller/task.controller.ts +17 -1
- package/src/module/workflow/repository/action-data.repository.ts +93 -0
- package/src/module/workflow/repository/action.repository.ts +99 -0
- package/src/module/workflow/repository/comm-template.repository.ts +25 -17
- package/src/module/workflow/repository/stage-movement.repository.ts +7 -3
- package/src/module/workflow/repository/task.repository.ts +64 -1
- package/src/module/workflow/service/action-data.service.ts +45 -0
- package/src/module/workflow/service/action.service.ts +21 -2
- package/src/module/workflow/service/comm-template.service.ts +1 -1
- package/src/module/workflow/service/task.service.ts +71 -1
- package/src/module/workflow/service/workflow-meta.service.ts +40 -34
- package/src/module/workflow/workflow.module.ts +6 -0
package/package.json
CHANGED
|
@@ -52,4 +52,22 @@ export class ActionController {
|
|
|
52
52
|
const result = this.actionService.getActions(loggedInUser, stage_id);
|
|
53
53
|
return result;
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
@Post('/getaction')
|
|
57
|
+
@HttpCode(HttpStatus.OK)
|
|
58
|
+
async getAction(
|
|
59
|
+
@Req() req: Request & { user: any },
|
|
60
|
+
@Body('stage_id') stage_id: number,
|
|
61
|
+
@Body('mapped_entity_id') mapped_entity_id: number,
|
|
62
|
+
@Body('mapped_entity_type') mapped_entity_type: string,
|
|
63
|
+
) {
|
|
64
|
+
const loggedInUser = req.user.userData;
|
|
65
|
+
const result = this.actionService.getAction(
|
|
66
|
+
loggedInUser,
|
|
67
|
+
stage_id,
|
|
68
|
+
mapped_entity_id,
|
|
69
|
+
mapped_entity_type,
|
|
70
|
+
);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
55
73
|
}
|
|
@@ -19,7 +19,7 @@ export class TaskController {
|
|
|
19
19
|
private readonly taskService: TaskService,
|
|
20
20
|
) {}
|
|
21
21
|
|
|
22
|
-
@Post('/
|
|
22
|
+
@Post('/by-user-and-stage')
|
|
23
23
|
@HttpCode(HttpStatus.OK)
|
|
24
24
|
async getTasksbyUserAndStage(
|
|
25
25
|
@Req() req: Request & { user: any },
|
|
@@ -37,4 +37,20 @@ export class TaskController {
|
|
|
37
37
|
);
|
|
38
38
|
return result;
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
@Post('/move-task')
|
|
42
|
+
async moveTask(
|
|
43
|
+
@Req() req: Request & { user: any },
|
|
44
|
+
@Body()
|
|
45
|
+
body: {
|
|
46
|
+
mapped_entity_type: string;
|
|
47
|
+
mapped_entity_id: number;
|
|
48
|
+
stage_id: number;
|
|
49
|
+
action_id: number;
|
|
50
|
+
},
|
|
51
|
+
) {
|
|
52
|
+
const loggedInUser = req.user.userData;
|
|
53
|
+
const result = this.taskService.moveTask(loggedInUser, body);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
40
56
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { ActionDataEntity } from '../entity/action-data.entity';
|
|
4
|
+
import { DataSource, Repository } from 'typeorm';
|
|
5
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ActionDataRepository {
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectRepository(ActionDataEntity)
|
|
11
|
+
private readonly actionDataRepo: Repository<ActionDataEntity>,
|
|
12
|
+
private readonly dataSource: DataSource,
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
async saveActionData(
|
|
16
|
+
action: any,
|
|
17
|
+
loggedInUser: UserData,
|
|
18
|
+
mapped_entity_id,
|
|
19
|
+
mapped_entity_type,
|
|
20
|
+
): Promise<any> {
|
|
21
|
+
if (!action?.length) return;
|
|
22
|
+
|
|
23
|
+
// Find the action with the lowest sequence
|
|
24
|
+
const minSequence = Math.min(...action.map((a) => a.sequence));
|
|
25
|
+
|
|
26
|
+
if (action.length > 0) {
|
|
27
|
+
for (const act of action) {
|
|
28
|
+
const isFirst = act.sequence == minSequence;
|
|
29
|
+
const actionData = this.actionDataRepo.create({
|
|
30
|
+
stage_id: act.stage_id,
|
|
31
|
+
user_id: loggedInUser.id,
|
|
32
|
+
action_id: act.id,
|
|
33
|
+
sequence: act.sequence,
|
|
34
|
+
mapped_entity_id,
|
|
35
|
+
mapped_entity_type,
|
|
36
|
+
is_current: isFirst ? 'Y' : null,
|
|
37
|
+
start_time: isFirst ? new Date() : null,
|
|
38
|
+
} as ActionDataEntity);
|
|
39
|
+
await this.actionDataRepo.save(actionData);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async updateActionStatus(
|
|
45
|
+
loggedInUser: UserData,
|
|
46
|
+
mapped_entity_type: string,
|
|
47
|
+
mapped_entity_id: number,
|
|
48
|
+
stage_id: number,
|
|
49
|
+
action_id: number,
|
|
50
|
+
): Promise<any> {
|
|
51
|
+
const actionData = await this.actionDataRepo.findOne({
|
|
52
|
+
where: {
|
|
53
|
+
mapped_entity_type,
|
|
54
|
+
mapped_entity_id,
|
|
55
|
+
stage_id,
|
|
56
|
+
action_id,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (!actionData) return;
|
|
61
|
+
|
|
62
|
+
actionData.end_time = new Date();
|
|
63
|
+
actionData.modified_by = loggedInUser.id;
|
|
64
|
+
actionData.modified_date = new Date();
|
|
65
|
+
actionData.is_done = true;
|
|
66
|
+
actionData.is_current = 'N'; // Mark as not current
|
|
67
|
+
|
|
68
|
+
// Save the updated action
|
|
69
|
+
await this.actionDataRepo.update(actionData.id, actionData);
|
|
70
|
+
|
|
71
|
+
// NOW, ACTIVATE THE NEXT ACTION (moveNextActionData logic here)
|
|
72
|
+
// Find next sequence action for the same entity/stage
|
|
73
|
+
const allActionData = await this.actionDataRepo.find({
|
|
74
|
+
where: { mapped_entity_type, mapped_entity_id, stage_id },
|
|
75
|
+
order: { sequence: 'ASC' },
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Find the action with the next higher sequence number
|
|
79
|
+
const nextAction = allActionData.find(
|
|
80
|
+
(a) => a.sequence > actionData.sequence,
|
|
81
|
+
);
|
|
82
|
+
if (nextAction && nextAction.is_current !== 'Y') {
|
|
83
|
+
nextAction.is_current = 'Y';
|
|
84
|
+
nextAction.start_time = new Date();
|
|
85
|
+
nextAction.modified_by = loggedInUser.id;
|
|
86
|
+
nextAction.modified_date = new Date();
|
|
87
|
+
await this.actionDataRepo.update(nextAction.id, nextAction);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Optionally return both for audit
|
|
91
|
+
return { finished: actionData, activated: nextAction ?? null };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Inject,
|
|
4
|
+
Injectable,
|
|
5
|
+
NotFoundException,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
8
|
+
import { DataSource, Repository } from 'typeorm';
|
|
9
|
+
import { ActionEntity } from '../entity/action.entity';
|
|
10
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class ActionRepository {
|
|
14
|
+
constructor(
|
|
15
|
+
@InjectRepository(ActionEntity)
|
|
16
|
+
private readonly actionRepository: Repository<ActionEntity>,
|
|
17
|
+
private readonly dataSource: DataSource,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
async getAction(
|
|
21
|
+
organization_id: number,
|
|
22
|
+
stage_id: number,
|
|
23
|
+
mapped_entity_id: number,
|
|
24
|
+
mapped_entity_type: string,
|
|
25
|
+
) {
|
|
26
|
+
// Step 1: Get all action mappings for the stage
|
|
27
|
+
const stageActions = await this.dataSource.query(
|
|
28
|
+
`SELECT id, action_id FROM cr_wf_stage_action_mapping WHERE stage_id = ?`,
|
|
29
|
+
[stage_id],
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (!stageActions?.length) return [];
|
|
33
|
+
|
|
34
|
+
const actionIds = stageActions.map((sa) => sa.action_id);
|
|
35
|
+
|
|
36
|
+
// Step 2: Fetch all actions from cr_wf_action
|
|
37
|
+
const actions = await this.dataSource
|
|
38
|
+
.createQueryBuilder()
|
|
39
|
+
.select([
|
|
40
|
+
'a.id AS action_id',
|
|
41
|
+
'a.name AS action_name',
|
|
42
|
+
'ac.modalName AS modalName',
|
|
43
|
+
'ac.logo AS logo',
|
|
44
|
+
'ac.name AS action_category_name',
|
|
45
|
+
])
|
|
46
|
+
.from('cr_wf_action', 'a')
|
|
47
|
+
.leftJoin('cr_wf_action_category', 'ac', 'ac.id = a.action_category')
|
|
48
|
+
.where('a.organization_id = :orgId', { orgId: organization_id })
|
|
49
|
+
.andWhere('a.id IN (:...actionIds)', { actionIds })
|
|
50
|
+
.getRawMany();
|
|
51
|
+
|
|
52
|
+
// Step 3: Fetch action_data for the matched stage and entity
|
|
53
|
+
const actionData = await this.dataSource
|
|
54
|
+
.createQueryBuilder()
|
|
55
|
+
.select([
|
|
56
|
+
'ad.action_id AS action_id',
|
|
57
|
+
'ad.is_current AS is_current',
|
|
58
|
+
'ad.is_mandatory AS is_mandatory',
|
|
59
|
+
'ad.is_done AS is_done',
|
|
60
|
+
])
|
|
61
|
+
.from('cr_wf_action_data', 'ad')
|
|
62
|
+
.where('ad.stage_id = :stageId', { stageId: stage_id })
|
|
63
|
+
.andWhere('ad.action_id IN (:...actionIds)', { actionIds })
|
|
64
|
+
.andWhere('ad.mapped_entity_id = :mapped_entity_id', {
|
|
65
|
+
mapped_entity_id,
|
|
66
|
+
})
|
|
67
|
+
.andWhere('ad.mapped_entity_type = :mapped_entity_type', {
|
|
68
|
+
mapped_entity_type,
|
|
69
|
+
})
|
|
70
|
+
.getRawMany();
|
|
71
|
+
|
|
72
|
+
// Step 4: Build map of action_id to data
|
|
73
|
+
const actionIdToData = actionData.reduce((acc, row) => {
|
|
74
|
+
acc[row.action_id] = {
|
|
75
|
+
is_current: row.is_current === 'Y',
|
|
76
|
+
is_mandatory: row.is_mandatory === 1,
|
|
77
|
+
is_done: row.is_done === 1,
|
|
78
|
+
};
|
|
79
|
+
return acc;
|
|
80
|
+
}, {});
|
|
81
|
+
|
|
82
|
+
// Step 5: Enrich actions and set default current = false (N)
|
|
83
|
+
const enrichedResult = actions.map((row) => {
|
|
84
|
+
const data = actionIdToData[row.action_id];
|
|
85
|
+
return {
|
|
86
|
+
value: row.action_id,
|
|
87
|
+
label: row.action_name,
|
|
88
|
+
modalName: row.modalName,
|
|
89
|
+
logo: row.logo,
|
|
90
|
+
name: row.action_category_name,
|
|
91
|
+
is_current: data?.is_current ?? false,
|
|
92
|
+
is_done: data?.is_done ?? false,
|
|
93
|
+
is_mandatory: data?.is_mandatory ?? false,
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return enrichedResult;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -46,18 +46,15 @@ export class CommTemplateRepository {
|
|
|
46
46
|
|
|
47
47
|
async getTemplateByCode(
|
|
48
48
|
entity_type: string,
|
|
49
|
-
|
|
49
|
+
id: number,
|
|
50
50
|
loggedInUser,
|
|
51
51
|
): Promise<any | null> {
|
|
52
52
|
const template = await this.commTemplateRepository.findOne({
|
|
53
|
-
where: {
|
|
54
|
-
entity_type,
|
|
55
|
-
code,
|
|
56
|
-
},
|
|
53
|
+
where: { entity_type, id },
|
|
57
54
|
});
|
|
58
55
|
|
|
59
56
|
if (!template) {
|
|
60
|
-
throw new NotFoundException(`Template with
|
|
57
|
+
throw new NotFoundException(`Template with id ${id} not found`);
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
if (template.format_type === 'markup') {
|
|
@@ -65,30 +62,41 @@ export class CommTemplateRepository {
|
|
|
65
62
|
template.markup_id,
|
|
66
63
|
loggedInUser,
|
|
67
64
|
);
|
|
68
|
-
|
|
69
|
-
console.log(media);
|
|
65
|
+
template.markup_id = media as any;
|
|
70
66
|
}
|
|
71
67
|
|
|
72
68
|
if (template.format_type === 'richtext') {
|
|
73
69
|
return template;
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
// Get
|
|
72
|
+
// Get attachments for this template
|
|
77
73
|
const attachments = await this.templateAttachEntity.find({
|
|
78
74
|
select: ['media_id'],
|
|
79
75
|
where: {
|
|
80
|
-
entity_type
|
|
76
|
+
entity_type,
|
|
81
77
|
template_id: template.id,
|
|
82
78
|
},
|
|
83
79
|
});
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
// If there are attachments, return array of media JSONs
|
|
82
|
+
let attachmentsMedia: any[] = [];
|
|
83
|
+
if (attachments.length > 0) {
|
|
84
|
+
attachmentsMedia = await Promise.all(
|
|
85
|
+
attachments.map(async (att) => {
|
|
86
|
+
// Fetch media details for each media_id
|
|
87
|
+
const media = await this.mediaDataService.getMediaDownloadUrl(
|
|
88
|
+
att.media_id,
|
|
89
|
+
loggedInUser,
|
|
90
|
+
);
|
|
91
|
+
return media; // return full media info (e.g., { id, url, ... })
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
// Return template with attachments array
|
|
97
|
+
return {
|
|
98
|
+
...template,
|
|
99
|
+
attachments: attachmentsMedia, // [] or array of media JSONs
|
|
100
|
+
};
|
|
93
101
|
}
|
|
94
102
|
}
|
|
@@ -180,11 +180,15 @@ export class StageMovementRepository {
|
|
|
180
180
|
return nextStageGroupFirstStage || null;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
async getAllActionByStageId(stageId: number): Promise<any
|
|
184
|
-
|
|
185
|
-
`SELECT
|
|
183
|
+
async getAllActionByStageId(stageId: number): Promise<any> {
|
|
184
|
+
const result = await this.dataSource.query(
|
|
185
|
+
`SELECT a.*, m.stage_id
|
|
186
|
+
FROM cr_wf_action a
|
|
187
|
+
INNER JOIN cr_wf_stage_action_mapping m ON a.id = m.action_id
|
|
188
|
+
WHERE m.stage_id = ?`,
|
|
186
189
|
[stageId],
|
|
187
190
|
);
|
|
191
|
+
return result;
|
|
188
192
|
}
|
|
189
193
|
|
|
190
194
|
async saveActionData(action: any, loggedInUser: UserData): Promise<any> {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
3
|
import { TaskDataEntity } from '../entity/task-data.entity';
|
|
4
|
-
import { Repository } from 'typeorm';
|
|
4
|
+
import { DataSource, Repository } from 'typeorm';
|
|
5
5
|
|
|
6
6
|
@Injectable()
|
|
7
7
|
export class TaskRepository {
|
|
8
8
|
constructor(
|
|
9
9
|
@InjectRepository(TaskDataEntity)
|
|
10
10
|
private readonly TaskRepository: Repository<TaskDataEntity>,
|
|
11
|
+
private readonly dataSource: DataSource,
|
|
11
12
|
) {}
|
|
12
13
|
|
|
13
14
|
async getAllTaskByUserIdAndStageId(
|
|
@@ -27,4 +28,66 @@ export class TaskRepository {
|
|
|
27
28
|
|
|
28
29
|
return result;
|
|
29
30
|
}
|
|
31
|
+
|
|
32
|
+
async saveActionDataInTask(
|
|
33
|
+
action: any,
|
|
34
|
+
loggedInUser,
|
|
35
|
+
mapped_entity_id: number,
|
|
36
|
+
mapped_entity_type: string,
|
|
37
|
+
): Promise<any> {
|
|
38
|
+
if (!action?.length) return;
|
|
39
|
+
|
|
40
|
+
const todoListMasterItemId = await this.dataSource.query(
|
|
41
|
+
`SELECT id FROM cr_list_master_items WHERE code = 'todo' and organization_id = ? and listtype = 'TKST' LIMIT 1;`,
|
|
42
|
+
[loggedInUser.organization_id],
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// Find the action with the lowest sequence
|
|
46
|
+
|
|
47
|
+
if (action.length > 0) {
|
|
48
|
+
for (const act of action) {
|
|
49
|
+
const taskData = this.TaskRepository.create({
|
|
50
|
+
stage_id: act.stage_id,
|
|
51
|
+
user_id: loggedInUser.id,
|
|
52
|
+
action_id: act.id,
|
|
53
|
+
sequence: act.sequence,
|
|
54
|
+
mapped_entity_id,
|
|
55
|
+
mapped_entity_type,
|
|
56
|
+
is_system: true,
|
|
57
|
+
task_status: todoListMasterItemId[0]?.id,
|
|
58
|
+
} as TaskDataEntity);
|
|
59
|
+
await this.TaskRepository.save(taskData);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// update task status
|
|
65
|
+
async updateTaskStatus(
|
|
66
|
+
loggedInUser,
|
|
67
|
+
mapped_entity_type,
|
|
68
|
+
mapped_entity_id,
|
|
69
|
+
stage_id,
|
|
70
|
+
action_id,
|
|
71
|
+
): Promise<any> {
|
|
72
|
+
const task = await this.TaskRepository.findOneBy({
|
|
73
|
+
action_id,
|
|
74
|
+
mapped_entity_type,
|
|
75
|
+
mapped_entity_id,
|
|
76
|
+
stage_id,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (!task) return;
|
|
80
|
+
|
|
81
|
+
const completedListMasterItemId = await this.dataSource.query(
|
|
82
|
+
`SELECT id FROM cr_list_master_items WHERE code = 'completed' and organization_id = ? and listtype = 'TKST' LIMIT 1;`,
|
|
83
|
+
[loggedInUser.organization_id],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
task.modified_by = loggedInUser.id;
|
|
87
|
+
task.modified_date = new Date();
|
|
88
|
+
task.is_done = true;
|
|
89
|
+
task.task_status = completedListMasterItemId[0]?.id;
|
|
90
|
+
|
|
91
|
+
await this.TaskRepository.update(task.id, task);
|
|
92
|
+
}
|
|
30
93
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
4
|
+
import { DataSource } from 'typeorm';
|
|
5
|
+
import { ActionDataRepository } from '../repository/action-data.repository';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ActionDataService extends EntityServiceImpl {
|
|
9
|
+
constructor(
|
|
10
|
+
private readonly dataSource: DataSource,
|
|
11
|
+
private readonly actionDataRepo: ActionDataRepository,
|
|
12
|
+
) {
|
|
13
|
+
super();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async saveActionData(
|
|
17
|
+
action: any,
|
|
18
|
+
loggedInUser: UserData,
|
|
19
|
+
mapped_entity_id,
|
|
20
|
+
mapped_entity_type,
|
|
21
|
+
): Promise<any> {
|
|
22
|
+
return this.actionDataRepo.saveActionData(
|
|
23
|
+
action,
|
|
24
|
+
loggedInUser,
|
|
25
|
+
mapped_entity_id,
|
|
26
|
+
mapped_entity_type,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async updateActionStatus(
|
|
31
|
+
loggedInUser: UserData,
|
|
32
|
+
mapped_entity_type: string,
|
|
33
|
+
mapped_entity_id: number,
|
|
34
|
+
stage_id: number,
|
|
35
|
+
action_id: number,
|
|
36
|
+
): Promise<any> {
|
|
37
|
+
return this.actionDataRepo.updateActionStatus(
|
|
38
|
+
loggedInUser,
|
|
39
|
+
mapped_entity_type,
|
|
40
|
+
mapped_entity_id,
|
|
41
|
+
stage_id,
|
|
42
|
+
action_id,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -2,12 +2,16 @@ import { BadRequestException, Injectable } from '@nestjs/common';
|
|
|
2
2
|
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
3
3
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
4
4
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
5
|
-
import { DataSource, EntityManager } from 'typeorm';
|
|
5
|
+
import { DataSource, EntityManager, Repository } from 'typeorm';
|
|
6
|
+
import { ActionRepository } from '../repository/action.repository';
|
|
6
7
|
import { ActionEntity } from '../entity/action.entity';
|
|
7
8
|
|
|
8
9
|
@Injectable()
|
|
9
10
|
export class ActionService extends EntityServiceImpl {
|
|
10
|
-
constructor(
|
|
11
|
+
constructor(
|
|
12
|
+
private readonly dataSource: DataSource,
|
|
13
|
+
private readonly actionRepository: ActionRepository,
|
|
14
|
+
) {
|
|
11
15
|
super();
|
|
12
16
|
}
|
|
13
17
|
|
|
@@ -318,4 +322,19 @@ export class ActionService extends EntityServiceImpl {
|
|
|
318
322
|
|
|
319
323
|
return enrichedResult;
|
|
320
324
|
}
|
|
325
|
+
|
|
326
|
+
async getAction(
|
|
327
|
+
loggedInUser: UserData,
|
|
328
|
+
stage_id: number,
|
|
329
|
+
mapped_entity_id: number,
|
|
330
|
+
mapped_entity_type: string,
|
|
331
|
+
) {
|
|
332
|
+
const { organization_id } = loggedInUser;
|
|
333
|
+
return this.actionRepository.getAction(
|
|
334
|
+
organization_id,
|
|
335
|
+
stage_id,
|
|
336
|
+
mapped_entity_id,
|
|
337
|
+
mapped_entity_type,
|
|
338
|
+
);
|
|
339
|
+
}
|
|
321
340
|
}
|
|
@@ -2,10 +2,14 @@ import { Injectable } from '@nestjs/common';
|
|
|
2
2
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
3
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
4
4
|
import { TaskRepository } from '../repository/task.repository';
|
|
5
|
+
import { ActionDataService } from './action-data.service';
|
|
5
6
|
|
|
6
7
|
@Injectable()
|
|
7
8
|
export class TaskService extends EntityServiceImpl {
|
|
8
|
-
constructor(
|
|
9
|
+
constructor(
|
|
10
|
+
private readonly taskRepository: TaskRepository,
|
|
11
|
+
private readonly actionDataService: ActionDataService,
|
|
12
|
+
) {
|
|
9
13
|
super();
|
|
10
14
|
}
|
|
11
15
|
|
|
@@ -20,6 +24,72 @@ export class TaskService extends EntityServiceImpl {
|
|
|
20
24
|
data.mapped_entity_id,
|
|
21
25
|
);
|
|
22
26
|
|
|
27
|
+
const grouped: { mandatory: any[]; non_mandatory: any[] } = {
|
|
28
|
+
mandatory: [],
|
|
29
|
+
non_mandatory: [],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
for (const task of taskData) {
|
|
33
|
+
if (task && task.is_mandatory) {
|
|
34
|
+
grouped.mandatory.push(task);
|
|
35
|
+
} else {
|
|
36
|
+
grouped.non_mandatory.push(task);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return grouped;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async getEntityData(entityType: string, id: number, loggedInUser: any) {
|
|
44
|
+
const taskData = await super.getEntityData(entityType, id, loggedInUser);
|
|
45
|
+
|
|
23
46
|
return taskData;
|
|
24
47
|
}
|
|
48
|
+
|
|
49
|
+
async saveActionData(
|
|
50
|
+
action: any,
|
|
51
|
+
loggedInUser: UserData,
|
|
52
|
+
mapped_entity_id: number,
|
|
53
|
+
mapped_entity_type: string,
|
|
54
|
+
): Promise<any> {
|
|
55
|
+
await this.taskRepository.saveActionDataInTask(
|
|
56
|
+
action,
|
|
57
|
+
loggedInUser,
|
|
58
|
+
mapped_entity_id,
|
|
59
|
+
mapped_entity_type,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async moveTask(
|
|
64
|
+
loggedInUser: UserData,
|
|
65
|
+
body: {
|
|
66
|
+
mapped_entity_type: string;
|
|
67
|
+
mapped_entity_id: number;
|
|
68
|
+
stage_id: number;
|
|
69
|
+
action_id: number;
|
|
70
|
+
},
|
|
71
|
+
): Promise<any> {
|
|
72
|
+
// Logic to move task based on the provided body parameters
|
|
73
|
+
// This could involve updating the task's stage, action, etc.
|
|
74
|
+
|
|
75
|
+
// update task status
|
|
76
|
+
this.taskRepository.updateTaskStatus(
|
|
77
|
+
loggedInUser,
|
|
78
|
+
body.mapped_entity_type,
|
|
79
|
+
body.mapped_entity_id,
|
|
80
|
+
body.stage_id,
|
|
81
|
+
body.action_id,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// update action status
|
|
85
|
+
await this.actionDataService.updateActionStatus(
|
|
86
|
+
loggedInUser,
|
|
87
|
+
body.mapped_entity_type,
|
|
88
|
+
body.mapped_entity_id,
|
|
89
|
+
body.stage_id,
|
|
90
|
+
body.action_id,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return 'Task moved successfully';
|
|
94
|
+
}
|
|
25
95
|
}
|