rez_core 2.1.127 → 2.1.129
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/listmaster/entity/list-master-items.entity.d.ts +1 -0
- package/dist/module/listmaster/entity/list-master-items.entity.js +4 -0
- package/dist/module/listmaster/entity/list-master-items.entity.js.map +1 -1
- package/dist/module/listmaster/repository/list-master-items.repository.d.ts +1 -1
- package/dist/module/listmaster/repository/list-master-items.repository.js +18 -10
- package/dist/module/listmaster/repository/list-master-items.repository.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +1 -1
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/workflow/controller/action-template-mapping.controller.d.ts +12 -0
- package/dist/module/workflow/controller/action-template-mapping.controller.js +44 -0
- package/dist/module/workflow/controller/action-template-mapping.controller.js.map +1 -0
- package/dist/module/workflow/controller/workflow-list-master.controller.d.ts +3 -1
- package/dist/module/workflow/controller/workflow-list-master.controller.js +7 -3
- package/dist/module/workflow/controller/workflow-list-master.controller.js.map +1 -1
- package/dist/module/workflow/entity/comm-template.entity.d.ts +1 -0
- package/dist/module/workflow/entity/comm-template.entity.js +4 -0
- package/dist/module/workflow/entity/comm-template.entity.js.map +1 -1
- package/dist/module/workflow/service/action-template-mapping.service.d.ts +4 -0
- package/dist/module/workflow/service/action-template-mapping.service.js +33 -1
- package/dist/module/workflow/service/action-template-mapping.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-list-master.service.d.ts +1 -1
- package/dist/module/workflow/service/workflow-list-master.service.js +5 -7
- package/dist/module/workflow/service/workflow-list-master.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +3 -6
- 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/listmaster/entity/list-master-items.entity.ts +3 -0
- package/src/module/listmaster/repository/list-master-items.repository.ts +27 -14
- package/src/module/listmaster/service/list-master.service.ts +1 -0
- package/src/module/workflow/controller/action-template-mapping.controller.ts +35 -0
- package/src/module/workflow/controller/workflow-list-master.controller.ts +7 -2
- package/src/module/workflow/entity/comm-template.entity.ts +4 -1
- package/src/module/workflow/service/action-template-mapping.service.ts +48 -1
- package/src/module/workflow/service/workflow-list-master.service.ts +5 -12
- package/src/module/workflow/workflow.module.ts +3 -6
package/package.json
CHANGED
|
@@ -25,21 +25,26 @@ export class ListMasterItemsRepository {
|
|
|
25
25
|
sort_by?,
|
|
26
26
|
inactiveIdsArray?: number[],
|
|
27
27
|
organizationId?: number,
|
|
28
|
+
params?: Record<string, string>,
|
|
28
29
|
) {
|
|
29
|
-
let orderBy: Record<string, 'ASC' | 'DESC'> = {};
|
|
30
|
+
let orderBy: Record<string, 'ASC' | 'DESC'> = {};
|
|
30
31
|
|
|
31
|
-
//
|
|
32
|
+
// Initial where clause
|
|
33
|
+
const whereClause: any = {
|
|
34
|
+
listtype: type,
|
|
35
|
+
organization_id: organizationId,
|
|
36
|
+
status: 'ACTIVE',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Sorting logic
|
|
32
40
|
if (sort_by) {
|
|
33
|
-
const listMasterItem = await this.repo.
|
|
41
|
+
const listMasterItem = await this.repo.findOne({
|
|
34
42
|
where: { id: sort_by },
|
|
35
43
|
});
|
|
36
|
-
|
|
37
|
-
const sortValue = listMasterItem?.[0]?.value;
|
|
44
|
+
const sortValue = listMasterItem?.value?.toLowerCase();
|
|
38
45
|
|
|
39
46
|
if (sortValue) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
switch (listMasterSortBy) {
|
|
47
|
+
switch (sortValue) {
|
|
43
48
|
case 'az':
|
|
44
49
|
orderBy = { name: 'ASC' };
|
|
45
50
|
break;
|
|
@@ -53,18 +58,26 @@ export class ListMasterItemsRepository {
|
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
|
|
61
|
+
// Handle parent_code logic
|
|
62
|
+
if (params?.parent) {
|
|
63
|
+
const parentItem = await this.repo.findOne({
|
|
64
|
+
where: { id: parseInt(params.parent) },
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (parentItem?.parent_code) {
|
|
68
|
+
whereClause.parent_code = parentItem.parent_code;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Fetch active items
|
|
56
73
|
const items = await this.repo.find({
|
|
57
|
-
where:
|
|
58
|
-
listtype: type,
|
|
59
|
-
organization_id: organizationId,
|
|
60
|
-
status: 'ACTIVE',
|
|
61
|
-
},
|
|
74
|
+
where: whereClause,
|
|
62
75
|
order: orderBy,
|
|
63
76
|
});
|
|
64
77
|
|
|
65
78
|
let result = items.map((i) => ({ label: i.name, value: i.id }));
|
|
66
79
|
|
|
67
|
-
//
|
|
80
|
+
// Handle inactive items if specified
|
|
68
81
|
if (inactiveIdsArray?.length) {
|
|
69
82
|
const inactiveItems = await this.repo.find({
|
|
70
83
|
where: {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
HttpCode,
|
|
5
|
+
HttpStatus,
|
|
6
|
+
Post,
|
|
7
|
+
Req,
|
|
8
|
+
UseGuards,
|
|
9
|
+
} from '@nestjs/common';
|
|
10
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
11
|
+
import { ActionTemplateMappingService } from '../service/action-template-mapping.service';
|
|
12
|
+
|
|
13
|
+
@Controller('/action-template-mapping')
|
|
14
|
+
@UseGuards(JwtAuthGuard)
|
|
15
|
+
export class ActionTemplateMappingController {
|
|
16
|
+
constructor(
|
|
17
|
+
private readonly actionTemplateMappingService: ActionTemplateMappingService,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
@Post('/get-template')
|
|
21
|
+
@HttpCode(HttpStatus.OK)
|
|
22
|
+
async getTemplate(
|
|
23
|
+
@Body() body: { stage_id: number; action_id: number; mode: number },
|
|
24
|
+
@Req() req: Request & { user: any },
|
|
25
|
+
) {
|
|
26
|
+
const loggedInUser = req.user.userData;
|
|
27
|
+
const result = this.actionTemplateMappingService.getTemplateByMode(
|
|
28
|
+
body.stage_id,
|
|
29
|
+
body.action_id,
|
|
30
|
+
body.mode,
|
|
31
|
+
loggedInUser,
|
|
32
|
+
);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -5,10 +5,14 @@ import {
|
|
|
5
5
|
HttpCode,
|
|
6
6
|
HttpStatus,
|
|
7
7
|
Get,
|
|
8
|
+
Req,
|
|
9
|
+
UseGuards,
|
|
8
10
|
} from '@nestjs/common';
|
|
9
11
|
import { WorkflowListMasterService } from '../service/workflow-list-master.service';
|
|
12
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
10
13
|
|
|
11
14
|
@Controller('/workflow-list')
|
|
15
|
+
@UseGuards(JwtAuthGuard)
|
|
12
16
|
export class WorkflowListMasterController {
|
|
13
17
|
constructor(private readonly workflowService: WorkflowListMasterService) {}
|
|
14
18
|
|
|
@@ -32,8 +36,9 @@ export class WorkflowListMasterController {
|
|
|
32
36
|
|
|
33
37
|
@Get('/getModes')
|
|
34
38
|
@HttpCode(HttpStatus.OK)
|
|
35
|
-
async getModes() {
|
|
36
|
-
const
|
|
39
|
+
async getModes(@Req() req: Request & { user: any }) {
|
|
40
|
+
const loggedInUser = req.user.userData;
|
|
41
|
+
const result = await this.workflowService.getModes(loggedInUser);
|
|
37
42
|
return result;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COMM_TEMPLATE } from 'src/constant/global.constant';
|
|
2
2
|
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
3
|
-
import { Entity } from 'typeorm';
|
|
3
|
+
import { Column, Entity } from 'typeorm';
|
|
4
4
|
|
|
5
5
|
@Entity({ name: 'cr_wf_comm_template' })
|
|
6
6
|
export class CommTemplate extends BaseEntity {
|
|
@@ -8,4 +8,7 @@ export class CommTemplate extends BaseEntity {
|
|
|
8
8
|
super();
|
|
9
9
|
this.entity_type = COMM_TEMPLATE;
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
@Column({ type: 'varchar', nullable: true })
|
|
13
|
+
mode: string;
|
|
11
14
|
}
|
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
+
import { DataSource } from 'typeorm';
|
|
3
4
|
|
|
4
5
|
@Injectable()
|
|
5
|
-
export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
6
|
+
export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
7
|
+
constructor(private readonly dataSource: DataSource) {
|
|
8
|
+
super();
|
|
9
|
+
}
|
|
10
|
+
async getTemplateByMode(
|
|
11
|
+
stage_id: number,
|
|
12
|
+
action_id: number,
|
|
13
|
+
mode: number,
|
|
14
|
+
loggedInUser,
|
|
15
|
+
) {
|
|
16
|
+
const stageAction = await this.dataSource.query(
|
|
17
|
+
`
|
|
18
|
+
SELECT id FROM cr_wf_stage_action_mapping
|
|
19
|
+
WHERE stage_id = ? AND action_id = ?
|
|
20
|
+
`,
|
|
21
|
+
[stage_id, action_id],
|
|
22
|
+
);
|
|
23
|
+
if (!stageAction?.length) return [];
|
|
24
|
+
|
|
25
|
+
const stgActMappingId = stageAction[0].id;
|
|
26
|
+
|
|
27
|
+
const templates = await this.dataSource.query(
|
|
28
|
+
`
|
|
29
|
+
SELECT template_code FROM cr_wf_action_template_mapping
|
|
30
|
+
WHERE stg_act_mapping_id = ?
|
|
31
|
+
`,
|
|
32
|
+
[stgActMappingId],
|
|
33
|
+
);
|
|
34
|
+
const listMasterItemData = await this.dataSource.query(
|
|
35
|
+
`SELECT code FROM cr_list_master_items WHERE id = ?`,
|
|
36
|
+
[mode],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const templateCodes = templates.map((t) => t.template_code);
|
|
40
|
+
if (!templateCodes.length) return [];
|
|
41
|
+
|
|
42
|
+
const commTemplates = await this.dataSource.query(
|
|
43
|
+
`
|
|
44
|
+
SELECT id, name
|
|
45
|
+
FROM cr_wf_comm_template
|
|
46
|
+
WHERE code IN (?) AND mode = ? AND organization_id = ?
|
|
47
|
+
`,
|
|
48
|
+
[templateCodes, listMasterItemData[0].code, loggedInUser.organization_id],
|
|
49
|
+
);
|
|
50
|
+
return commTemplates.map((t) => ({ id: t.id, name: t.name }));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -42,24 +42,17 @@ export class WorkflowListMasterService extends EntityServiceImpl {
|
|
|
42
42
|
return results;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
async getModes(): Promise<any[]> {
|
|
46
|
-
|
|
47
|
-
const modeLists = await this.dataSource.query(
|
|
48
|
-
`SELECT id FROM cr_list_master WHERE type = 'MOD'`,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
if (modeLists.length === 0) return [];
|
|
52
|
-
|
|
53
|
-
const listIds = modeLists.map((item) => item.id);
|
|
45
|
+
async getModes(loggedInUser): Promise<any[]> {
|
|
46
|
+
const { organization_id } = loggedInUser;
|
|
54
47
|
|
|
55
|
-
// Step 2: Get all list items where list_id is in the MOD list IDs
|
|
56
48
|
const modes = await this.dataSource.query(
|
|
57
49
|
`
|
|
58
50
|
SELECT id, name
|
|
59
51
|
FROM cr_list_master_items
|
|
60
|
-
WHERE
|
|
52
|
+
WHERE listtype = 'MOD'
|
|
53
|
+
AND organization_id = ?
|
|
61
54
|
`,
|
|
62
|
-
|
|
55
|
+
[organization_id],
|
|
63
56
|
);
|
|
64
57
|
|
|
65
58
|
return modes;
|
|
@@ -19,6 +19,7 @@ import { EntityModule } from '../meta/entity.module';
|
|
|
19
19
|
import { Action } from './entity/action.entity';
|
|
20
20
|
import { WorkflowListMasterService } from './service/workflow-list-master.service';
|
|
21
21
|
import { WorkflowListMasterController } from './controller/workflow-list-master.controller';
|
|
22
|
+
import { ActionTemplateMappingController } from './controller/action-template-mapping.controller';
|
|
22
23
|
|
|
23
24
|
@Module({
|
|
24
25
|
imports: [
|
|
@@ -38,10 +39,6 @@ import { WorkflowListMasterController } from './controller/workflow-list-master.
|
|
|
38
39
|
{ provide: 'WorkflowService', useClass: WorkflowService },
|
|
39
40
|
{ provide: 'ActionCategoryService', useClass: ActionCategoryService },
|
|
40
41
|
{ provide: 'CommTemplateService', useClass: CommTemplateService },
|
|
41
|
-
{
|
|
42
|
-
provide: 'ActionTemplateMappingService',
|
|
43
|
-
useClass: ActionTemplateMappingService,
|
|
44
|
-
},
|
|
45
42
|
{
|
|
46
43
|
provide: 'StageActionMappingService',
|
|
47
44
|
useClass: StageActionMappingService,
|
|
@@ -50,17 +47,17 @@ import { WorkflowListMasterController } from './controller/workflow-list-master.
|
|
|
50
47
|
{ provide: 'StageService', useClass: StageService },
|
|
51
48
|
{ provide: 'StageGroupService', useClass: StageGroupService },
|
|
52
49
|
WorkflowListMasterService,
|
|
50
|
+
ActionTemplateMappingService,
|
|
53
51
|
],
|
|
54
52
|
exports: [
|
|
55
53
|
'WorkflowService',
|
|
56
54
|
'ActionCategoryService',
|
|
57
55
|
'CommTemplateService',
|
|
58
|
-
'ActionTemplateMappingService',
|
|
59
56
|
'StageActionMappingService',
|
|
60
57
|
'ActionService',
|
|
61
58
|
'StageService',
|
|
62
59
|
'StageGroupService',
|
|
63
60
|
],
|
|
64
|
-
controllers: [WorkflowListMasterController],
|
|
61
|
+
controllers: [WorkflowListMasterController, ActionTemplateMappingController],
|
|
65
62
|
})
|
|
66
63
|
export class WorkflowModule {}
|