rez_core 2.2.70 → 2.2.72
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/activity-log.controller.d.ts +1 -0
- package/dist/module/workflow/controller/form-master.controller.d.ts +1 -1
- package/dist/module/workflow/controller/form-master.controller.js +1 -1
- package/dist/module/workflow/controller/form-master.controller.js.map +1 -1
- package/dist/module/workflow/entity/form-master.entity.d.ts +3 -1
- package/dist/module/workflow/entity/form-master.entity.js +9 -1
- package/dist/module/workflow/entity/form-master.entity.js.map +1 -1
- package/dist/module/workflow/repository/activity-log.repository.d.ts +4 -1
- package/dist/module/workflow/repository/activity-log.repository.js +23 -9
- package/dist/module/workflow/repository/activity-log.repository.js.map +1 -1
- package/dist/module/workflow/repository/form-master.repository.d.ts +4 -3
- package/dist/module/workflow/repository/form-master.repository.js +9 -9
- package/dist/module/workflow/repository/form-master.repository.js.map +1 -1
- package/dist/module/workflow/repository/stage-group.repository.d.ts +4 -2
- package/dist/module/workflow/repository/stage-group.repository.js +29 -13
- package/dist/module/workflow/repository/stage-group.repository.js.map +1 -1
- package/dist/module/workflow/service/activity-log.service.d.ts +1 -0
- package/dist/module/workflow/service/form-master.service.d.ts +8 -2
- package/dist/module/workflow/service/form-master.service.js +9 -8
- package/dist/module/workflow/service/form-master.service.js.map +1 -1
- package/dist/module/workflow/service/stage-group.service.js +1 -1
- package/dist/module/workflow/service/stage-group.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.d.ts +1 -1
- package/dist/module/workflow/service/task.service.js +17 -14
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/workflow/controller/form-master.controller.ts +1 -1
- package/src/module/workflow/entity/form-master.entity.ts +6 -1
- package/src/module/workflow/repository/activity-log.repository.ts +34 -8
- package/src/module/workflow/repository/form-master.repository.ts +16 -8
- package/src/module/workflow/repository/stage-group.repository.ts +34 -15
- package/src/module/workflow/service/form-master.service.ts +18 -9
- package/src/module/workflow/service/stage-group.service.ts +1 -0
- package/src/module/workflow/service/task.service.ts +24 -19
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@ export class FormMasterController {
|
|
|
37
37
|
@HttpCode(HttpStatus.OK)
|
|
38
38
|
async submitForm(@Req() req: Request & { user: any }, @Body() body: any) {
|
|
39
39
|
const loggedInUser = req.user.userData;
|
|
40
|
-
const result = this.formMasterService.submitForm(body);
|
|
40
|
+
const result = this.formMasterService.submitForm(body, loggedInUser);
|
|
41
41
|
return result;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -7,6 +7,8 @@ export class FormMasterDataEntity extends BaseEntity {
|
|
|
7
7
|
super();
|
|
8
8
|
this.entity_type = 'FORM';
|
|
9
9
|
}
|
|
10
|
+
@Column({ nullable: true })
|
|
11
|
+
mapped_entity_id: number;
|
|
10
12
|
|
|
11
13
|
@Column({ nullable: true })
|
|
12
14
|
mapped_entity_type: string;
|
|
@@ -15,8 +17,11 @@ export class FormMasterDataEntity extends BaseEntity {
|
|
|
15
17
|
source_entity_type: string;
|
|
16
18
|
|
|
17
19
|
@Column({ nullable: true })
|
|
18
|
-
view_id:
|
|
20
|
+
view_id: number;
|
|
19
21
|
|
|
20
22
|
@Column({ nullable: true })
|
|
21
23
|
form_name: string;
|
|
24
|
+
|
|
25
|
+
@Column({ type: 'varchar', nullable: true })
|
|
26
|
+
form_url: string;
|
|
22
27
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
2
|
+
import { MediaDataService } from 'src/module/meta/service/media-data.service';
|
|
2
3
|
import { ActivityLog } from '../entity/activity-log.entity';
|
|
3
4
|
import { Repository } from 'typeorm';
|
|
4
5
|
import * as moment from 'moment';
|
|
@@ -23,6 +24,7 @@ export class ActivityLogRepository {
|
|
|
23
24
|
constructor(
|
|
24
25
|
@InjectRepository(ActivityLog)
|
|
25
26
|
private readonly activityLogRepository: Repository<ActivityLog>,
|
|
27
|
+
private readonly mediaDataService: MediaDataService,
|
|
26
28
|
) {}
|
|
27
29
|
|
|
28
30
|
async getAllActivityLog(
|
|
@@ -31,12 +33,19 @@ export class ActivityLogRepository {
|
|
|
31
33
|
category: string | undefined,
|
|
32
34
|
loggedInUser,
|
|
33
35
|
) {
|
|
34
|
-
const { organization_id } = loggedInUser;
|
|
36
|
+
const { organization_id, id: loggedInUserId } = loggedInUser;
|
|
35
37
|
|
|
36
38
|
const query = this.activityLogRepository
|
|
37
39
|
.createQueryBuilder('log')
|
|
38
40
|
.leftJoin('cr_user', 'user', 'log.created_by = user.id')
|
|
41
|
+
.leftJoin(
|
|
42
|
+
'eth_user_profile',
|
|
43
|
+
'profile',
|
|
44
|
+
'profile.parent_id = user.id AND profile.parent_id = :loggedInUserId',
|
|
45
|
+
{ loggedInUserId },
|
|
46
|
+
)
|
|
39
47
|
.addSelect('user.name', 'user_name')
|
|
48
|
+
.addSelect('profile.profile_image', 'profile_image') // media ID
|
|
40
49
|
.where('log.mapped_entity_type = :mapped_entity_type', {
|
|
41
50
|
mapped_entity_type,
|
|
42
51
|
})
|
|
@@ -52,13 +61,30 @@ export class ActivityLogRepository {
|
|
|
52
61
|
query.orderBy('log.created_date', 'DESC');
|
|
53
62
|
const rows = await query.getRawAndEntities();
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
const result = await Promise.all(
|
|
65
|
+
rows.entities.map(async (entity, i) => {
|
|
66
|
+
const profileImageId = rows.raw[i].profile_image;
|
|
67
|
+
|
|
68
|
+
let profile: any = null;
|
|
69
|
+
if (profileImageId) {
|
|
70
|
+
profile = await this.mediaDataService.getMediaDownloadUrl(
|
|
71
|
+
profileImageId,
|
|
72
|
+
loggedInUser,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
...entity,
|
|
78
|
+
user_name: rows.raw[i].user_name,
|
|
79
|
+
profile, // whole JSON from media service
|
|
80
|
+
created_date: entity.created_date
|
|
81
|
+
? moment(entity.created_date).format('DD-MMM, hh:mm A')
|
|
82
|
+
: null,
|
|
83
|
+
};
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return result;
|
|
62
88
|
}
|
|
63
89
|
|
|
64
90
|
async getAllActivityCategory(
|
|
@@ -8,12 +8,13 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|
|
8
8
|
import { DataSource, Repository } from 'typeorm';
|
|
9
9
|
import { FormMasterDataEntity } from '../entity/form-master.entity';
|
|
10
10
|
import { FormDataEntity } from '../entity/form.entity';
|
|
11
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
11
12
|
|
|
12
13
|
@Injectable()
|
|
13
14
|
export class FormMasterRepository {
|
|
14
15
|
constructor(
|
|
15
16
|
@InjectRepository(FormMasterDataEntity)
|
|
16
|
-
private readonly
|
|
17
|
+
private readonly formMasterEntity: Repository<FormMasterDataEntity>,
|
|
17
18
|
private readonly dataSource: DataSource,
|
|
18
19
|
@InjectRepository(FormDataEntity)
|
|
19
20
|
private readonly formRepo: Repository<FormDataEntity>,
|
|
@@ -38,19 +39,26 @@ export class FormMasterRepository {
|
|
|
38
39
|
return formatted;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
// to_be_sent
|
|
43
|
+
// saved
|
|
44
|
+
// sent
|
|
45
|
+
// submitted
|
|
46
|
+
// resubmit_requested
|
|
47
|
+
// accepted
|
|
48
|
+
|
|
49
|
+
async submitForm(redirect_data: any, loggedInUser: UserData) {
|
|
50
|
+
const currentForm = await this.formMasterEntity.findOneBy({
|
|
51
|
+
mapped_entity_id: redirect_data.entity_id,
|
|
52
|
+
mapped_entity_type: redirect_data.entity_type,
|
|
53
|
+
view_id: redirect_data.view_id,
|
|
46
54
|
});
|
|
47
55
|
|
|
48
56
|
if (!currentForm) {
|
|
49
57
|
throw new NotFoundException('Form not found');
|
|
50
58
|
}
|
|
51
59
|
|
|
52
|
-
currentForm.status = '
|
|
60
|
+
currentForm.status = 'submitted';
|
|
53
61
|
|
|
54
|
-
return this.
|
|
62
|
+
return this.formMasterEntity.update(currentForm.id, currentForm);
|
|
55
63
|
}
|
|
56
64
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { StageGroup } from '../entity/stage-group.entity';
|
|
8
8
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
9
9
|
import { DataSource, Repository } from 'typeorm';
|
|
10
|
+
import { MediaDataService } from 'src/module/meta/service/media-data.service';
|
|
10
11
|
|
|
11
12
|
@Injectable()
|
|
12
13
|
export class StageGroupRepository {
|
|
@@ -14,6 +15,7 @@ export class StageGroupRepository {
|
|
|
14
15
|
@InjectRepository(StageGroup)
|
|
15
16
|
private readonly stageGroupRepository: Repository<StageGroup>,
|
|
16
17
|
private readonly dataSource: DataSource,
|
|
18
|
+
private readonly mediaDataService: MediaDataService,
|
|
17
19
|
) {}
|
|
18
20
|
|
|
19
21
|
async getAllStageGroup(workflow_id: number, organization_id: number) {
|
|
@@ -43,6 +45,7 @@ export class StageGroupRepository {
|
|
|
43
45
|
async getAllStageGroupAndStageHierarchy(
|
|
44
46
|
workflow_id: number,
|
|
45
47
|
organization_id: number,
|
|
48
|
+
loggedInUser: any, // required for media service
|
|
46
49
|
lead_id: number,
|
|
47
50
|
) {
|
|
48
51
|
if (!workflow_id) {
|
|
@@ -54,28 +57,27 @@ export class StageGroupRepository {
|
|
|
54
57
|
workflow_id,
|
|
55
58
|
organization_id,
|
|
56
59
|
);
|
|
57
|
-
|
|
58
60
|
if (!stageGroups.length) return [];
|
|
59
61
|
|
|
60
62
|
// Step 2: Get all stages for these stage groups
|
|
61
63
|
const stageGroupIds = stageGroups.map((sg) => sg.id);
|
|
62
|
-
|
|
63
|
-
const stages = await this.dataSource.query(
|
|
64
|
+
const stagesRaw = await this.dataSource.query(
|
|
64
65
|
`
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
SELECT
|
|
67
|
+
cr_wf_stage.*,
|
|
68
|
+
eth_user_profile.name AS created_by_name,
|
|
69
|
+
eth_user_profile.profile_image AS profile_image
|
|
70
|
+
FROM cr_wf_stage
|
|
71
|
+
LEFT JOIN eth_user_profile
|
|
72
|
+
ON cr_wf_stage.created_by = eth_user_profile.parent_id
|
|
73
|
+
WHERE cr_wf_stage.stage_group_id IN (${stageGroupIds.map(() => '?').join(',')})
|
|
74
|
+
AND cr_wf_stage.organization_id = ?
|
|
75
|
+
ORDER BY cr_wf_stage.sequence ASC
|
|
73
76
|
`,
|
|
74
77
|
[...stageGroupIds, organization_id],
|
|
75
78
|
);
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
const stageIds = stages.map((s) => s.id);
|
|
80
|
+
const stageIds = stagesRaw.map((s) => s.id);
|
|
79
81
|
|
|
80
82
|
// Task counts
|
|
81
83
|
const taskCounts = await this.dataSource.query(
|
|
@@ -111,7 +113,6 @@ export class StageGroupRepository {
|
|
|
111
113
|
[...stageIds, lead_id],
|
|
112
114
|
);
|
|
113
115
|
|
|
114
|
-
// Convert to maps for quick lookup
|
|
115
116
|
// Convert to maps for quick lookup
|
|
116
117
|
const taskCountMap = new Map(
|
|
117
118
|
taskCounts.map((row) => [Number(row.stage_id), Number(row.task_count)]),
|
|
@@ -129,7 +130,25 @@ export class StageGroupRepository {
|
|
|
129
130
|
]),
|
|
130
131
|
);
|
|
131
132
|
|
|
132
|
-
// Step 4: Add counts to each stage
|
|
133
|
+
// Step 4: Add counts & profile to each stage
|
|
134
|
+
const stages = await Promise.all(
|
|
135
|
+
stagesRaw.map(async (stage) => {
|
|
136
|
+
const profileImageId = stage.profile_image;
|
|
137
|
+
let profile: any = null;
|
|
138
|
+
if (profileImageId) {
|
|
139
|
+
profile = await this.mediaDataService.getMediaDownloadUrl(
|
|
140
|
+
profileImageId,
|
|
141
|
+
loggedInUser,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
...stage,
|
|
146
|
+
profile, // enriched profile object
|
|
147
|
+
};
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
// Step 5: Group stages by stage_group_id
|
|
133
152
|
const stageMap = new Map<number, any[]>();
|
|
134
153
|
for (const stage of stages) {
|
|
135
154
|
const stageId = Number(stage.id); // ensure number
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { FormMasterRepository } from '../repository/form-master.repository';
|
|
3
3
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
4
|
+
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
4
5
|
|
|
5
6
|
@Injectable()
|
|
6
|
-
export class FormMasterService {
|
|
7
|
-
constructor(private readonly formMasterRepository: FormMasterRepository) {
|
|
7
|
+
export class FormMasterService extends EntityServiceImpl {
|
|
8
|
+
constructor(private readonly formMasterRepository: FormMasterRepository) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
8
11
|
|
|
9
12
|
async getForms(loggedInUser: UserData, source_entity_type: string) {
|
|
10
13
|
const { organization_id } = loggedInUser;
|
|
@@ -14,13 +17,19 @@ export class FormMasterService {
|
|
|
14
17
|
);
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
async
|
|
18
|
-
|
|
20
|
+
async saveForm(
|
|
21
|
+
data: { entity_id: number; entity_type: string; view_id: number },
|
|
22
|
+
loggedInUser: UserData,
|
|
23
|
+
) {
|
|
24
|
+
// return this.formMasterRepository.saveForm(data, loggedInUser);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async submitForm(data: any, loggedInUser: UserData) {
|
|
28
|
+
const { form_data, redirect_data } = data;
|
|
29
|
+
|
|
30
|
+
// update from
|
|
31
|
+
super.updateEntity(form_data, loggedInUser);
|
|
19
32
|
|
|
20
|
-
return this.formMasterRepository.submitForm(
|
|
21
|
-
entity_id,
|
|
22
|
-
entity_type,
|
|
23
|
-
view_id,
|
|
24
|
-
});
|
|
33
|
+
return this.formMasterRepository.submitForm(redirect_data, loggedInUser);
|
|
25
34
|
}
|
|
26
35
|
}
|
|
@@ -75,6 +75,7 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
75
75
|
(await this.stageGroupRepository.getAllStageGroupAndStageHierarchy(
|
|
76
76
|
workflowLevelMapping.workflow_id,
|
|
77
77
|
loggedInUser.organization_id,
|
|
78
|
+
loggedInUser,
|
|
78
79
|
lead_id,
|
|
79
80
|
)) as Array<{
|
|
80
81
|
stages: any[];
|
|
@@ -59,10 +59,32 @@ export class TaskService extends EntityServiceImpl {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
async updateEntity(
|
|
62
|
-
entityData
|
|
62
|
+
entityData,
|
|
63
63
|
loggedInUser: UserData,
|
|
64
64
|
appcode?: string,
|
|
65
65
|
): Promise<any> {
|
|
66
|
+
const taskStatusQuery = `
|
|
67
|
+
SELECT name
|
|
68
|
+
FROM cr_list_master_items
|
|
69
|
+
WHERE id = ?
|
|
70
|
+
AND organization_id = ?
|
|
71
|
+
AND listtype = 'TKST'
|
|
72
|
+
LIMIT 1;
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
const statusRows = await this.dataSource.query(taskStatusQuery, [
|
|
76
|
+
entityData.status,
|
|
77
|
+
loggedInUser.organization_id,
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
const isCompletedStatus =
|
|
81
|
+
statusRows.length > 0 &&
|
|
82
|
+
statusRows[0].name?.toLowerCase() === 'completed';
|
|
83
|
+
|
|
84
|
+
// Sync flags based on status
|
|
85
|
+
entityData.is_completed = isCompletedStatus;
|
|
86
|
+
entityData.is_done = isCompletedStatus;
|
|
87
|
+
|
|
66
88
|
const updatedEntity = await super.updateEntity(
|
|
67
89
|
entityData,
|
|
68
90
|
loggedInUser,
|
|
@@ -88,24 +110,7 @@ export class TaskService extends EntityServiceImpl {
|
|
|
88
110
|
|
|
89
111
|
await this.activityLogService.logActivity(editLogData, loggedInUser);
|
|
90
112
|
|
|
91
|
-
|
|
92
|
-
SELECT name
|
|
93
|
-
FROM cr_list_master_items
|
|
94
|
-
WHERE id = ?
|
|
95
|
-
AND organization_id = ?
|
|
96
|
-
AND listtype = 'TKST'
|
|
97
|
-
LIMIT 1;
|
|
98
|
-
`;
|
|
99
|
-
|
|
100
|
-
const statusRows = await this.dataSource.query(taskStatusQuery, [
|
|
101
|
-
entityData.status,
|
|
102
|
-
loggedInUser.organization_id,
|
|
103
|
-
]);
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
statusRows.length > 0 &&
|
|
107
|
-
statusRows[0].name?.toLowerCase() === 'completed'
|
|
108
|
-
) {
|
|
113
|
+
if (isCompletedStatus) {
|
|
109
114
|
const completedLogData = {
|
|
110
115
|
mapped_entity_id: updatedEntity.mapped_entity_id,
|
|
111
116
|
mapped_entity_type: updatedEntity.mapped_entity_type,
|