rez_core 2.1.1 → 2.1.3

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.
Files changed (22) hide show
  1. package/dist/module/filter/service/filter.service.js +2 -1
  2. package/dist/module/filter/service/filter.service.js.map +1 -1
  3. package/dist/module/layout_preference/service/layout_preference.service.js +1 -0
  4. package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
  5. package/dist/module/master/service/master.service.js.map +1 -1
  6. package/dist/module/module/controller/module-access.controller.d.ts +1 -10
  7. package/dist/module/module/controller/module-access.controller.js +3 -1
  8. package/dist/module/module/controller/module-access.controller.js.map +1 -1
  9. package/dist/module/module/repository/module-access.repository.d.ts +1 -10
  10. package/dist/module/module/repository/module-access.repository.js +30 -5
  11. package/dist/module/module/repository/module-access.repository.js.map +1 -1
  12. package/dist/module/module/service/module-access.service.d.ts +1 -10
  13. package/dist/module/module/service/module-access.service.js +2 -2
  14. package/dist/module/module/service/module-access.service.js.map +1 -1
  15. package/dist/tsconfig.build.tsbuildinfo +1 -1
  16. package/package.json +1 -1
  17. package/src/module/filter/service/filter.service.ts +1 -1
  18. package/src/module/layout_preference/service/layout_preference.service.ts +1 -0
  19. package/src/module/master/service/master.service.ts +0 -1
  20. package/src/module/module/controller/module-access.controller.ts +3 -1
  21. package/src/module/module/repository/module-access.repository.ts +44 -11
  22. package/src/module/module/service/module-access.service.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -206,7 +206,7 @@ export class FilterService {
206
206
  tabAttrMeta,
207
207
  );
208
208
  if (tabCondition) {
209
- dataWhere.push(tabCondition);
209
+ if (tabs.value.toLowerCase() !== 'all') dataWhere.push(tabCondition);
210
210
  }
211
211
  }
212
212
 
@@ -74,6 +74,7 @@ export class LayoutPreferenceService extends EntityServiceImpl {
74
74
  .select(`${column} AS column_value`)
75
75
  .addSelect(`COUNT(*) AS count`)
76
76
  .from(tableName, tableName)
77
+ .where(`${column} IS NOT NULL`)
77
78
  .groupBy(column)
78
79
  .getRawMany();
79
80
 
@@ -472,7 +472,6 @@ export class MasterService {
472
472
  row.entity_type = entityType;
473
473
  row.organization_id = loggedInUser.organization_id;
474
474
  row.status = 'ACTIVE';
475
-
476
475
  let errors = [];
477
476
  if (existing) {
478
477
  if (duplicateHandling === 'skip_duplicates') continue;
@@ -45,7 +45,9 @@ export class ModuleAccessController {
45
45
  ) {
46
46
  const roleIdArray = roleIds.split(',').map(Number);
47
47
  const appcode = queryAppcode || req.user.userData.appcode;
48
- return this.moduleAccessService.getAccessListing(roleIdArray, appcode, '');
48
+ const level_type = req.user.userData.appcode;
49
+ const level_id = req.user.userData.appcode;
50
+ return this.moduleAccessService.getAccessListing(roleIdArray, appcode, level_type, level_id);
49
51
  }
50
52
 
51
53
  @Get('menu-listing')
@@ -1,6 +1,6 @@
1
1
  import { BadRequestException, Injectable } from '@nestjs/common';
2
2
  import { InjectRepository } from '@nestjs/typeorm';
3
- import { In, Repository } from 'typeorm';
3
+ import { In, Not, Repository , IsNull} from 'typeorm';
4
4
  import { Role } from 'src/module/user/entity/role.entity';
5
5
  import { ModuleAccess } from '../entity/module-access.entity';
6
6
  import { ModuleAction } from '../entity/module-action.entity';
@@ -23,6 +23,8 @@ export class ModuleAccessRepository {
23
23
  private readonly moduleActionRepo: Repository<ModuleAction>,
24
24
  ) {}
25
25
 
26
+
27
+
26
28
  async getRoles({
27
29
  appcode,
28
30
  level_type,
@@ -32,17 +34,22 @@ export class ModuleAccessRepository {
32
34
  level_type?: string;
33
35
  level_id?: number;
34
36
  }) {
35
- const where: any = { appcode };
37
+ const where: any = {
38
+ appcode,
39
+ is_factory: [Not(1), IsNull()], // Include NULL or anything not 1
40
+ };
41
+
36
42
  if (level_type) where.level_type = level_type;
37
43
  if (level_id !== undefined) where.level_id = String(level_id);
38
-
44
+
39
45
  const roles = await this.roleRepo.find({ where });
40
-
46
+
41
47
  return roles.map((role) => ({
42
48
  label: role.name,
43
49
  value: role.id,
44
50
  }));
45
51
  }
52
+
46
53
 
47
54
  async getModules({ appcode }: { appcode: string }) {
48
55
  const modules = await this.moduleRepo.find({
@@ -59,23 +66,48 @@ export class ModuleAccessRepository {
59
66
  }
60
67
 
61
68
  async getAccessListing(
62
- roleIds: number[],
69
+ roleIds: (number | string)[],
63
70
  appcode: string,
64
71
  levelType: string,
72
+ levelId?: number, // add levelId as input so we can fetch roles based on it
65
73
  ) {
66
- const roles = await this.roleRepo.find({
67
- where: { id: In(roleIds), appcode },
68
- });
69
-
74
+ let roles;
75
+
76
+ if (roleIds.length === 1 && roleIds[0] === '-1') {
77
+ // Internally call getRoles
78
+ const fetchedRoles = await this.getRoles({
79
+ appcode,
80
+ level_type: levelType,
81
+ level_id: levelId,
82
+ });
83
+
84
+ const fetchedRoleIds = fetchedRoles.map((r) => r.value);
85
+ roles = await this.roleRepo.find({
86
+ where: {
87
+ id: In(fetchedRoleIds),
88
+ appcode,
89
+ },
90
+ });
91
+ } else {
92
+ roles = await this.roleRepo.find({
93
+ where: {
94
+ id: In(roleIds.map((id) => Number(id))),
95
+ appcode,
96
+ },
97
+ });
98
+ }
99
+
100
+ if (!roles.length) return [];
101
+
70
102
  const roleCodes = roles.map((role) => role.code);
71
-
103
+
72
104
  const moduleAccesses = await this.moduleAccessRepo.find({
73
105
  where: {
74
106
  role_code: In(roleCodes),
75
107
  appcode,
76
108
  },
77
109
  });
78
-
110
+
79
111
  return roles.map((role) => ({
80
112
  role_code: role.code,
81
113
  name: role.name,
@@ -89,6 +121,7 @@ export class ModuleAccessRepository {
89
121
  })),
90
122
  }));
91
123
  }
124
+
92
125
 
93
126
  async getAllModulesByLevel(mainModIds: string[], appcode: string, levelType) {
94
127
  const mainModules =
@@ -40,11 +40,13 @@ export class ModuleAccessService {
40
40
  roleIds: number[],
41
41
  appcode: string,
42
42
  levelType: string,
43
+ level_id?: number,
43
44
  ) {
44
45
  return this.moduleAccessRepository.getAccessListing(
45
46
  roleIds,
46
47
  appcode,
47
48
  levelType,
49
+ level_id
48
50
  );
49
51
  }
50
52