rez_core 2.2.255 → 2.2.256
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/service/list-master.service.js +1 -0
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/meta/controller/meta.controller.d.ts +6 -1
- package/dist/module/meta/controller/meta.controller.js +23 -2
- package/dist/module/meta/controller/meta.controller.js.map +1 -1
- package/dist/module/meta/repository/entity-master.repository.d.ts +1 -0
- package/dist/module/meta/repository/entity-master.repository.js +8 -0
- package/dist/module/meta/repository/entity-master.repository.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.d.ts +8 -2
- package/dist/module/meta/service/entity-master.service.js +43 -2
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/listmaster/service/list-master.service.ts +1 -0
- package/src/module/meta/controller/meta.controller.ts +20 -0
- package/src/module/meta/repository/entity-master.repository.ts +12 -0
- package/src/module/meta/service/entity-master.service.ts +98 -2
- package/src/module/meta/service/entity-table.service.ts +0 -2
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ export class ListMasterService {
|
|
|
22
22
|
private readonly entityManager: EntityManager,
|
|
23
23
|
@Inject(forwardRef(() => EntityServiceImpl))
|
|
24
24
|
private readonly entityServiceImpl: EntityServiceImpl,
|
|
25
|
+
@Inject(forwardRef(() => EntityMasterService))
|
|
25
26
|
private readonly entityMasterService: EntityMasterService,
|
|
26
27
|
private readonly listMasterRepo: ListMasterRepository,
|
|
27
28
|
private readonly listItemsRepo: ListMasterItemsRepository,
|
|
@@ -11,6 +11,7 @@ import { EntityTableService } from '../service/entity-table.service';
|
|
|
11
11
|
import { Response } from 'express';
|
|
12
12
|
import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
13
13
|
import { PopulateMetaService } from '../service/populate-meta.service';
|
|
14
|
+
import { EntityMasterService } from '../service/entity-master.service';
|
|
14
15
|
|
|
15
16
|
@Controller('meta')
|
|
16
17
|
@UseGuards(JwtAuthGuard)
|
|
@@ -18,6 +19,7 @@ export class MetaController {
|
|
|
18
19
|
constructor(
|
|
19
20
|
private readonly entityTableService: EntityTableService,
|
|
20
21
|
private readonly populateMetaService: PopulateMetaService,
|
|
22
|
+
private readonly entityMaster: EntityMasterService,
|
|
21
23
|
) {}
|
|
22
24
|
|
|
23
25
|
@Post('get-table-data')
|
|
@@ -41,6 +43,24 @@ export class MetaController {
|
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
@Post('get-filter-data')
|
|
47
|
+
async getFilterData(
|
|
48
|
+
@Query('entity_type') entityType: string,
|
|
49
|
+
@Res() response: Response,
|
|
50
|
+
@Req() req: Request & { user: any },
|
|
51
|
+
) {
|
|
52
|
+
const loggedInUser = req.user.userData;
|
|
53
|
+
const entitydata = await this.entityMaster.getFilterMetaData(
|
|
54
|
+
entityType,
|
|
55
|
+
loggedInUser,
|
|
56
|
+
);
|
|
57
|
+
return response.status(HttpStatus.OK).json({
|
|
58
|
+
success: true,
|
|
59
|
+
data: entitydata,
|
|
60
|
+
message: 'Data fetch successfully!',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
44
64
|
@Post('populate')
|
|
45
65
|
async populateMetaData(
|
|
46
66
|
@Query('organization_id') organizationId: number,
|
|
@@ -14,4 +14,16 @@ export class EntityMasterRepository {
|
|
|
14
14
|
async getEntityById(id: number): Promise<EntityMaster | null> {
|
|
15
15
|
return await this.entityMasterRepository.findOne({ where: { id } });
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
async getEntityByMappedEntityType(
|
|
19
|
+
mappedEntityType: string,
|
|
20
|
+
organizationId: number,
|
|
21
|
+
): Promise<EntityMaster | null> {
|
|
22
|
+
return await this.entityMasterRepository.findOne({
|
|
23
|
+
where: {
|
|
24
|
+
mapped_entity_type: mappedEntityType,
|
|
25
|
+
organization_id: organizationId,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
17
29
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { Repository } from 'typeorm';
|
|
1
|
+
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
|
2
|
+
import { DataSource, Repository } from 'typeorm';
|
|
3
3
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
4
4
|
import { EntityMaster } from '../entity/entity-master.entity';
|
|
5
5
|
import { EntityMasterRepository } from '../repository/entity-master.repository';
|
|
6
|
+
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
7
|
+
import { SavedFilterRepositoryService } from 'src/module/filter/repository/saved-filter.repository';
|
|
6
8
|
|
|
7
9
|
@Injectable()
|
|
8
10
|
export class EntityMasterService {
|
|
@@ -11,6 +13,10 @@ export class EntityMasterService {
|
|
|
11
13
|
private entityMasterRepository: Repository<EntityMaster>,
|
|
12
14
|
|
|
13
15
|
private entityMasterRepo: EntityMasterRepository,
|
|
16
|
+
private readonly dataSource: DataSource,
|
|
17
|
+
@Inject('ListMasterService')
|
|
18
|
+
private readonly listMasterService: ListMasterService,
|
|
19
|
+
private readonly savedFilterRepoService: SavedFilterRepositoryService,
|
|
14
20
|
) {}
|
|
15
21
|
|
|
16
22
|
async getEntityById(id: number): Promise<EntityMaster | null> {
|
|
@@ -61,4 +67,94 @@ export class EntityMasterService {
|
|
|
61
67
|
where: { mapped_entity_type: mappedEntityType },
|
|
62
68
|
});
|
|
63
69
|
}
|
|
70
|
+
|
|
71
|
+
async getFilterMetaData(entityType: string, loggedInUser: any) {
|
|
72
|
+
console.log(entityType, loggedInUser);
|
|
73
|
+
|
|
74
|
+
// Step 1: Get entity_master record by mapped_entity_type
|
|
75
|
+
const entityMaster = await this.dataSource.query(
|
|
76
|
+
`SELECT *
|
|
77
|
+
FROM cr_entity_master
|
|
78
|
+
WHERE mapped_entity_type = ?
|
|
79
|
+
AND organization_id = ?
|
|
80
|
+
LIMIT 1`,
|
|
81
|
+
[entityType, loggedInUser.organization_id],
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
if (!entityMaster || entityMaster.length === 0) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Entity master with mapped_entity_type "${entityType}" not found.`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const entityMasterData = entityMaster[0] as any; // cast as DTO if you have one
|
|
91
|
+
|
|
92
|
+
// Step 2: Get attribute_master (instead of entity_table_column)
|
|
93
|
+
const attributes = await this.dataSource.query(
|
|
94
|
+
`SELECT *
|
|
95
|
+
FROM cr_attribute_master
|
|
96
|
+
WHERE mapped_entity_type = ?
|
|
97
|
+
AND organization_id = ? `,
|
|
98
|
+
[entityMasterData.mapped_entity_type, loggedInUser.organization_id],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// Step 3: Attach column_list from attribute_master
|
|
102
|
+
entityMasterData.column_list = attributes;
|
|
103
|
+
|
|
104
|
+
// Step 4: Keep existing operation_list logic
|
|
105
|
+
entityMasterData.operation_list = {
|
|
106
|
+
text: await this.listMasterService.getDropdownOptions(
|
|
107
|
+
'OPT',
|
|
108
|
+
{},
|
|
109
|
+
[],
|
|
110
|
+
loggedInUser,
|
|
111
|
+
),
|
|
112
|
+
number: await this.listMasterService.getDropdownOptions(
|
|
113
|
+
'OPN',
|
|
114
|
+
{},
|
|
115
|
+
[],
|
|
116
|
+
loggedInUser,
|
|
117
|
+
),
|
|
118
|
+
date: await this.listMasterService.getDropdownOptions(
|
|
119
|
+
'OPD',
|
|
120
|
+
{},
|
|
121
|
+
[],
|
|
122
|
+
loggedInUser,
|
|
123
|
+
),
|
|
124
|
+
select: await this.listMasterService.getDropdownOptions(
|
|
125
|
+
'OPS',
|
|
126
|
+
{},
|
|
127
|
+
[],
|
|
128
|
+
loggedInUser,
|
|
129
|
+
),
|
|
130
|
+
multiselect: await this.listMasterService.getDropdownOptions(
|
|
131
|
+
'OPM',
|
|
132
|
+
{},
|
|
133
|
+
[],
|
|
134
|
+
loggedInUser,
|
|
135
|
+
),
|
|
136
|
+
year: await this.listMasterService.getDropdownOptions(
|
|
137
|
+
'OPY',
|
|
138
|
+
{},
|
|
139
|
+
[],
|
|
140
|
+
loggedInUser,
|
|
141
|
+
),
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// Step 5: Keep filters as is
|
|
145
|
+
entityMasterData.default_filter =
|
|
146
|
+
await this.savedFilterRepoService.getDefaultFilterByEntityType(
|
|
147
|
+
entityType,
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
if (loggedInUser.id) {
|
|
151
|
+
entityMasterData.saved_filter =
|
|
152
|
+
await this.savedFilterRepoService.getSavedFiltersByUserIdAndEntityType(
|
|
153
|
+
loggedInUser.id,
|
|
154
|
+
entityType,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return entityMasterData;
|
|
159
|
+
}
|
|
64
160
|
}
|
|
@@ -4,9 +4,7 @@ import { EntityTableColumnRepository } from '../repository/entity-table-column.r
|
|
|
4
4
|
import { EntityTableDto } from '../dto/entity-table.dto';
|
|
5
5
|
import { DISPLAY_LIST } from '../../../constant/global.constant';
|
|
6
6
|
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
7
|
-
import { SavedFilterService } from 'src/module/filter/service/saved-filter.service';
|
|
8
7
|
import { SavedFilterRepositoryService } from 'src/module/filter/repository/saved-filter.repository';
|
|
9
|
-
import { UserData } from 'src/module/user/entity/user.entity';
|
|
10
8
|
|
|
11
9
|
@Injectable()
|
|
12
10
|
export class EntityTableService {
|