rez_core 2.1.46 → 2.1.47
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 +13 -1
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.js +6 -1
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/service/module-access.service.js +1 -1
- 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 +17 -1
- package/src/module/module/controller/module-access.controller.ts +21 -15
- package/src/module/module/service/module-access.service.ts +18 -24
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
|
|
@@ -460,7 +476,7 @@ export class FilterService {
|
|
|
460
476
|
case 'date':
|
|
461
477
|
return this.buildDateCondition(attr, op, val, key);
|
|
462
478
|
case 'select':
|
|
463
|
-
return this.
|
|
479
|
+
return this.buildMultiSelectCondition(attr, op, val, key);
|
|
464
480
|
case 'multiselect':
|
|
465
481
|
return this.buildMultiSelectCondition(attr, op, val, key);
|
|
466
482
|
case 'year':
|
|
@@ -25,14 +25,19 @@ 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
|
|
28
|
+
let level_type = req.user.userData.level_type;
|
|
29
|
+
let level_id = req.user.userData.level_id;
|
|
30
30
|
let organization_id = req.user.userData.organization_id;
|
|
31
|
-
return this.moduleAccessService.getRoles({
|
|
31
|
+
return this.moduleAccessService.getRoles({
|
|
32
|
+
appcode,
|
|
33
|
+
level_type,
|
|
34
|
+
level_id,
|
|
35
|
+
organization_id,
|
|
36
|
+
});
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
@Get('modules')
|
|
35
|
-
async getModules(
|
|
40
|
+
async getModules(@Query('appcode') appcode: string, @Request() req) {
|
|
36
41
|
return this.moduleAccessService.getModules({
|
|
37
42
|
appcode,
|
|
38
43
|
});
|
|
@@ -46,9 +51,14 @@ export class ModuleAccessController {
|
|
|
46
51
|
) {
|
|
47
52
|
const roleIdArray = roleIds.split(',').map(Number);
|
|
48
53
|
const appcode = queryAppcode || req.user.userData.appcode;
|
|
49
|
-
const level_type =
|
|
50
|
-
const level_id =
|
|
51
|
-
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
|
+
);
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
@Get('menu-listing')
|
|
@@ -69,9 +79,7 @@ export class ModuleAccessController {
|
|
|
69
79
|
|
|
70
80
|
@Post('update')
|
|
71
81
|
async updateModuleAccess(@Body() moduleAccessData: any[], @Request() req) {
|
|
72
|
-
return this.moduleAccessService.updateModuleAccess(
|
|
73
|
-
moduleAccessData
|
|
74
|
-
);
|
|
82
|
+
return this.moduleAccessService.updateModuleAccess(moduleAccessData);
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
// src/module/module-access/controller/module-access.controller.ts
|
|
@@ -98,16 +106,16 @@ export class ModuleAccessController {
|
|
|
98
106
|
@Get('user-permissions')
|
|
99
107
|
async getUserPermissions(@Request() req) {
|
|
100
108
|
const userData = req.user.userData;
|
|
101
|
-
|
|
109
|
+
|
|
102
110
|
const userId = userData?.id;
|
|
103
111
|
const appcode = userData?.appcode;
|
|
104
112
|
const level_type = userData?.level_type;
|
|
105
113
|
const level_id = userData?.level_id;
|
|
106
|
-
|
|
114
|
+
|
|
107
115
|
if (!userId || !appcode || !level_type || !level_id) {
|
|
108
116
|
throw new BadRequestException('Invalid token data');
|
|
109
117
|
}
|
|
110
|
-
|
|
118
|
+
|
|
111
119
|
return this.moduleAccessService.getUserPermissions({
|
|
112
120
|
userId,
|
|
113
121
|
appcode,
|
|
@@ -115,6 +123,4 @@ export class ModuleAccessController {
|
|
|
115
123
|
level_id,
|
|
116
124
|
});
|
|
117
125
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
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({
|
|
@@ -64,7 +63,7 @@ export class ModuleAccessService {
|
|
|
64
63
|
value: role.id,
|
|
65
64
|
}));
|
|
66
65
|
}
|
|
67
|
-
|
|
66
|
+
|
|
68
67
|
async getAccessListing(
|
|
69
68
|
roleIds: number[],
|
|
70
69
|
appcode: string,
|
|
@@ -75,7 +74,7 @@ export class ModuleAccessService {
|
|
|
75
74
|
roleIds,
|
|
76
75
|
appcode,
|
|
77
76
|
levelType,
|
|
78
|
-
level_id
|
|
77
|
+
level_id,
|
|
79
78
|
);
|
|
80
79
|
}
|
|
81
80
|
|
|
@@ -109,9 +108,8 @@ export class ModuleAccessService {
|
|
|
109
108
|
return { success: false, msg: 'No data provided' };
|
|
110
109
|
}
|
|
111
110
|
|
|
112
|
-
const result =
|
|
113
|
-
moduleAccessData
|
|
114
|
-
);
|
|
111
|
+
const result =
|
|
112
|
+
await this.moduleAccessRepository.updateModuleAccess(moduleAccessData);
|
|
115
113
|
|
|
116
114
|
if (result) {
|
|
117
115
|
return { success: true, msg: 'Module access updated successfully' };
|
|
@@ -144,40 +142,36 @@ export class ModuleAccessService {
|
|
|
144
142
|
level_type,
|
|
145
143
|
level_id,
|
|
146
144
|
);
|
|
147
|
-
|
|
145
|
+
|
|
148
146
|
if (!roleCodes || roleCodes.length === 0) {
|
|
149
147
|
return [];
|
|
150
148
|
}
|
|
151
|
-
|
|
149
|
+
|
|
152
150
|
const roleIds = roleCodes.map(Number);
|
|
153
|
-
|
|
151
|
+
|
|
154
152
|
// Step 2: Get full permissions
|
|
155
|
-
const allPermissions =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
const allPermissions =
|
|
154
|
+
await this.moduleAccessRepository.getModuleAccessByRoles(
|
|
155
|
+
roleIds,
|
|
156
|
+
appcode,
|
|
157
|
+
);
|
|
158
|
+
|
|
160
159
|
// Step 3: If level_type is SCH, check school status using raw query
|
|
161
160
|
if (level_type === 'SCH') {
|
|
162
161
|
const result = await this.dataSource.query(
|
|
163
162
|
`SELECT * FROM cr_school WHERE id = ${level_id}`,
|
|
164
163
|
[level_id],
|
|
165
164
|
);
|
|
166
|
-
|
|
165
|
+
|
|
167
166
|
const school = result?.[0];
|
|
168
|
-
|
|
169
|
-
if (!school || school.status ===
|
|
167
|
+
|
|
168
|
+
if (!school || school.status === 'INACTIVE') {
|
|
170
169
|
// Return only VIEW permissions
|
|
171
|
-
return allPermissions.filter(
|
|
172
|
-
(perm) => perm.action === 'VIEW'
|
|
173
|
-
);
|
|
170
|
+
return allPermissions.filter((perm) => perm.action === 'VIEW');
|
|
174
171
|
}
|
|
175
172
|
}
|
|
176
|
-
|
|
173
|
+
|
|
177
174
|
// Step 4: Return all permissions normally
|
|
178
175
|
return allPermissions;
|
|
179
176
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
177
|
}
|