rez_core 2.1.43 → 2.1.45
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/filter/service/filter.service.js +12 -0
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +7 -1
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.js +7 -1
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +2 -1
- package/dist/module/module/service/module-access.service.js +10 -3
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/service/filter.service.ts +16 -0
- package/src/module/listmaster/service/list-master.service.ts +7 -1
- package/src/module/module/controller/module-access.controller.ts +21 -14
- package/src/module/module/service/module-access.service.ts +33 -31
package/package.json
CHANGED
|
@@ -210,6 +210,22 @@ export class FilterService {
|
|
|
210
210
|
filteredTabs.sort((a, b) => a.tab_value_count - b.tab_value_count);
|
|
211
211
|
} else if (layout.sorting === 'count_dsc') {
|
|
212
212
|
filteredTabs.sort((a, b) => b.tab_value_count - a.tab_value_count);
|
|
213
|
+
} else if (layout.sorting === 'custom') {
|
|
214
|
+
const orderMap = new Map<string, number>(
|
|
215
|
+
showList.map((val, index) => [val.toLowerCase(), index]),
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
filteredTabs.sort((a, b) => {
|
|
219
|
+
const aIndex = orderMap.has(a.tab_value.toLowerCase())
|
|
220
|
+
? orderMap.get(a.tab_value.toLowerCase())!
|
|
221
|
+
: Infinity;
|
|
222
|
+
|
|
223
|
+
const bIndex = orderMap.has(b.tab_value.toLowerCase())
|
|
224
|
+
? orderMap.get(b.tab_value.toLowerCase())!
|
|
225
|
+
: Infinity;
|
|
226
|
+
|
|
227
|
+
return aIndex - bIndex;
|
|
228
|
+
});
|
|
213
229
|
}
|
|
214
230
|
|
|
215
231
|
// Re-insert 'all' at the beginning
|
|
@@ -82,12 +82,18 @@ export class ListMasterService {
|
|
|
82
82
|
// Skip level filter for certain entities
|
|
83
83
|
if (!this.skipLevelFilterEntities.includes(sourceList)) {
|
|
84
84
|
qb.andWhere(
|
|
85
|
-
`${tableName}.level_type = :levelType AND ${tableName}.level_id = :levelId`,
|
|
85
|
+
`${tableName}.level_type = :levelType AND ${tableName}.level_id = :levelId AND ${tableName}.organization_id = :organization_id`,
|
|
86
86
|
{
|
|
87
87
|
levelType: loggedInUser.level_type,
|
|
88
88
|
levelId: loggedInUser.level_id,
|
|
89
|
+
organization_id: loggedInUser.organization_id,
|
|
89
90
|
},
|
|
90
91
|
);
|
|
92
|
+
} else {
|
|
93
|
+
// IN the case of BRN, we don't filter by level
|
|
94
|
+
qb.andWhere(`${tableName}.organization_id = :organization_id`, {
|
|
95
|
+
organization_id: loggedInUser.organization_id,
|
|
96
|
+
});
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
99
|
|
|
@@ -25,9 +25,15 @@ export class ModuleAccessController {
|
|
|
25
25
|
|
|
26
26
|
@Get('roles')
|
|
27
27
|
async getRoles(@Query('appcode') appcode: string, @Request() req) {
|
|
28
|
-
let level_type= req.user.userData.level_type
|
|
29
|
-
let level_id= req.user.userData.level_id
|
|
30
|
-
|
|
28
|
+
let level_type = req.user.userData.level_type;
|
|
29
|
+
let level_id = req.user.userData.level_id;
|
|
30
|
+
let organization_id = req.user.userData.organization_id;
|
|
31
|
+
return this.moduleAccessService.getRoles({
|
|
32
|
+
appcode,
|
|
33
|
+
level_type,
|
|
34
|
+
level_id,
|
|
35
|
+
organization_id,
|
|
36
|
+
});
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
@Get('modules')
|
|
@@ -45,9 +51,14 @@ export class ModuleAccessController {
|
|
|
45
51
|
) {
|
|
46
52
|
const roleIdArray = roleIds.split(',').map(Number);
|
|
47
53
|
const appcode = queryAppcode || req.user.userData.appcode;
|
|
48
|
-
const level_type =
|
|
49
|
-
const level_id =
|
|
50
|
-
return this.moduleAccessService.getAccessListing(
|
|
54
|
+
const level_type = req.user.userData.level_type;
|
|
55
|
+
const level_id = req.user.userData.level_id;
|
|
56
|
+
return this.moduleAccessService.getAccessListing(
|
|
57
|
+
roleIdArray,
|
|
58
|
+
appcode,
|
|
59
|
+
level_type,
|
|
60
|
+
level_id,
|
|
61
|
+
);
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
@Get('menu-listing')
|
|
@@ -68,9 +79,7 @@ export class ModuleAccessController {
|
|
|
68
79
|
|
|
69
80
|
@Post('update')
|
|
70
81
|
async updateModuleAccess(@Body() moduleAccessData: any[], @Request() req) {
|
|
71
|
-
return this.moduleAccessService.updateModuleAccess(
|
|
72
|
-
moduleAccessData
|
|
73
|
-
);
|
|
82
|
+
return this.moduleAccessService.updateModuleAccess(moduleAccessData);
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
// src/module/module-access/controller/module-access.controller.ts
|
|
@@ -97,16 +106,16 @@ export class ModuleAccessController {
|
|
|
97
106
|
@Get('user-permissions')
|
|
98
107
|
async getUserPermissions(@Request() req) {
|
|
99
108
|
const userData = req.user.userData;
|
|
100
|
-
|
|
109
|
+
|
|
101
110
|
const userId = userData?.id;
|
|
102
111
|
const appcode = userData?.appcode;
|
|
103
112
|
const level_type = userData?.level_type;
|
|
104
113
|
const level_id = userData?.level_id;
|
|
105
|
-
|
|
114
|
+
|
|
106
115
|
if (!userId || !appcode || !level_type || !level_id) {
|
|
107
116
|
throw new BadRequestException('Invalid token data');
|
|
108
117
|
}
|
|
109
|
-
|
|
118
|
+
|
|
110
119
|
return this.moduleAccessService.getUserPermissions({
|
|
111
120
|
userId,
|
|
112
121
|
appcode,
|
|
@@ -114,6 +123,4 @@ export class ModuleAccessController {
|
|
|
114
123
|
level_id,
|
|
115
124
|
});
|
|
116
125
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
126
|
}
|
|
@@ -15,7 +15,6 @@ export class ModuleAccessService {
|
|
|
15
15
|
private readonly menuRepository: MenuRepository,
|
|
16
16
|
private readonly dataSource: DataSource,
|
|
17
17
|
) {}
|
|
18
|
-
|
|
19
18
|
|
|
20
19
|
async getModules({ appcode }: { appcode: string }) {
|
|
21
20
|
return this.moduleAccessRepository.getModules({
|
|
@@ -23,15 +22,16 @@ export class ModuleAccessService {
|
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
27
25
|
async getRoles({
|
|
28
26
|
appcode,
|
|
29
27
|
level_type,
|
|
30
28
|
level_id,
|
|
29
|
+
organization_id,
|
|
31
30
|
}: {
|
|
32
31
|
appcode: string;
|
|
33
32
|
level_type?: string;
|
|
34
33
|
level_id?: number;
|
|
34
|
+
organization_id?: number;
|
|
35
35
|
}) {
|
|
36
36
|
const query = this.dataSource
|
|
37
37
|
.createQueryBuilder()
|
|
@@ -39,24 +39,31 @@ export class ModuleAccessService {
|
|
|
39
39
|
.from('cr_role', 'role')
|
|
40
40
|
.where('role.appcode = :appcode', { appcode })
|
|
41
41
|
.andWhere('(role.is_factory IS NULL OR role.is_factory != 1)');
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
|
|
44
43
|
if (level_type) {
|
|
45
44
|
query.andWhere('role.level_type = :level_type', { level_type });
|
|
46
45
|
}
|
|
47
|
-
|
|
46
|
+
|
|
47
|
+
if (organization_id) {
|
|
48
|
+
query.andWhere('role.organization_id = :organization_id', {
|
|
49
|
+
organization_id,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
48
53
|
if (level_id !== undefined) {
|
|
49
|
-
query.andWhere('role.level_id = :level_id', {
|
|
54
|
+
query.andWhere('role.level_id = :level_id', {
|
|
55
|
+
level_id: String(level_id),
|
|
56
|
+
});
|
|
50
57
|
}
|
|
51
|
-
|
|
58
|
+
|
|
52
59
|
const roles = await query.getRawMany(); // use getRawMany since you're selecting from a raw table
|
|
53
|
-
|
|
60
|
+
|
|
54
61
|
return roles.map((role) => ({
|
|
55
62
|
label: role.name,
|
|
56
63
|
value: role.id,
|
|
57
64
|
}));
|
|
58
65
|
}
|
|
59
|
-
|
|
66
|
+
|
|
60
67
|
async getAccessListing(
|
|
61
68
|
roleIds: number[],
|
|
62
69
|
appcode: string,
|
|
@@ -67,7 +74,7 @@ export class ModuleAccessService {
|
|
|
67
74
|
roleIds,
|
|
68
75
|
appcode,
|
|
69
76
|
levelType,
|
|
70
|
-
level_id
|
|
77
|
+
level_id,
|
|
71
78
|
);
|
|
72
79
|
}
|
|
73
80
|
|
|
@@ -101,9 +108,8 @@ export class ModuleAccessService {
|
|
|
101
108
|
return { success: false, msg: 'No data provided' };
|
|
102
109
|
}
|
|
103
110
|
|
|
104
|
-
const result =
|
|
105
|
-
moduleAccessData
|
|
106
|
-
);
|
|
111
|
+
const result =
|
|
112
|
+
await this.moduleAccessRepository.updateModuleAccess(moduleAccessData);
|
|
107
113
|
|
|
108
114
|
if (result) {
|
|
109
115
|
return { success: true, msg: 'Module access updated successfully' };
|
|
@@ -136,40 +142,36 @@ export class ModuleAccessService {
|
|
|
136
142
|
level_type,
|
|
137
143
|
level_id,
|
|
138
144
|
);
|
|
139
|
-
|
|
145
|
+
|
|
140
146
|
if (!roleCodes || roleCodes.length === 0) {
|
|
141
147
|
return [];
|
|
142
148
|
}
|
|
143
|
-
|
|
149
|
+
|
|
144
150
|
const roleIds = roleCodes.map(Number);
|
|
145
|
-
|
|
151
|
+
|
|
146
152
|
// Step 2: Get full permissions
|
|
147
|
-
const allPermissions =
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
const allPermissions =
|
|
154
|
+
await this.moduleAccessRepository.getModuleAccessByRoles(
|
|
155
|
+
roleIds,
|
|
156
|
+
appcode,
|
|
157
|
+
);
|
|
158
|
+
|
|
152
159
|
// Step 3: If level_type is SCH, check school status using raw query
|
|
153
160
|
if (level_type === 'SCH') {
|
|
154
161
|
const result = await this.dataSource.query(
|
|
155
162
|
`SELECT * FROM cr_school WHERE id = ${level_id}`,
|
|
156
163
|
[level_id],
|
|
157
164
|
);
|
|
158
|
-
|
|
165
|
+
|
|
159
166
|
const school = result?.[0];
|
|
160
|
-
|
|
161
|
-
if (!school || school.status ===
|
|
167
|
+
|
|
168
|
+
if (!school || school.status === 'INACTIVE') {
|
|
162
169
|
// Return only VIEW permissions
|
|
163
|
-
return allPermissions.filter(
|
|
164
|
-
(perm) => perm.action === 'VIEW'
|
|
165
|
-
);
|
|
170
|
+
return allPermissions.filter((perm) => perm.action === 'VIEW');
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
|
-
|
|
173
|
+
|
|
169
174
|
// Step 4: Return all permissions normally
|
|
170
175
|
return allPermissions;
|
|
171
176
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
177
|
}
|