rez_core 2.1.104 → 2.1.106

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.1.104",
3
+ "version": "2.1.106",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -20,27 +20,32 @@ export class ListMasterItemsRepository {
20
20
  return this.repo.findOne({ where: { id } });
21
21
  }
22
22
 
23
- async findItemsByType(type: string, sort_by, organizationId?: number) {
24
- const listMasterItem = await this.repo.find({
25
- where: {
26
- id: sort_by,
27
- },
28
- });
29
-
30
- let orderBy = {};
31
-
32
- const listMasterSortBy = listMasterItem[0].value;
33
-
34
- switch (listMasterSortBy) {
35
- case 'az':
36
- orderBy = { name: 'ASC' };
37
- break;
38
- case 'za':
39
- orderBy = { name: 'DESC' };
40
- break;
41
- case 'custom':
42
- orderBy = { sortindex: 'ASC' };
43
- break;
23
+ async findItemsByType(type: string, sort_by?, organizationId?: number) {
24
+ let orderBy: Record<string, 'ASC' | 'DESC'> = {}; // no default sort unless specified
25
+
26
+ // Only sort if sort_by is provided
27
+ if (sort_by) {
28
+ const listMasterItem = await this.repo.find({
29
+ where: { id: sort_by },
30
+ });
31
+
32
+ const sortValue = listMasterItem?.[0]?.value;
33
+
34
+ if (sortValue) {
35
+ const listMasterSortBy = String(sortValue).toLowerCase();
36
+
37
+ switch (listMasterSortBy) {
38
+ case 'az':
39
+ orderBy = { name: 'ASC' };
40
+ break;
41
+ case 'za':
42
+ orderBy = { name: 'DESC' };
43
+ break;
44
+ case 'custom':
45
+ orderBy = { sortindex: 'ASC' };
46
+ break;
47
+ }
48
+ }
44
49
  }
45
50
 
46
51
  const items = await this.repo.find({
@@ -49,9 +54,7 @@ export class ListMasterItemsRepository {
49
54
  organization_id: organizationId,
50
55
  status: 'ACTIVE',
51
56
  },
52
- order: {
53
- ...orderBy,
54
- },
57
+ order: orderBy,
55
58
  });
56
59
 
57
60
  return items.map((i) => ({ label: i.name, value: i.id }));
@@ -13,6 +13,7 @@ export class EntityTableColumnRepository {
13
13
  async findByParentIdAndParentType(
14
14
  parentId: number,
15
15
  parentType: string,
16
+ organization_id,
16
17
  isVisible?: boolean,
17
18
  ) {
18
19
  if (isVisible) {
@@ -20,6 +21,7 @@ export class EntityTableColumnRepository {
20
21
  where: {
21
22
  parent_id: parentId,
22
23
  parent_type: parentType,
24
+ organization_id: organization_id,
23
25
  },
24
26
  order: { col_position: 'ASC' },
25
27
  });
@@ -29,6 +31,7 @@ export class EntityTableColumnRepository {
29
31
  parent_id: parentId,
30
32
  parent_type: parentType,
31
33
  visible: '1',
34
+ organization_id: organization_id,
32
35
  },
33
36
  order: { col_position: 'ASC' },
34
37
  });
@@ -356,6 +356,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
356
356
  await this.entityTableColumnService.findByParentIdAndParentType(
357
357
  entityTable.id,
358
358
  entityTable.entity_type,
359
+ loggedInUser.organization_id,
359
360
  );
360
361
 
361
362
  sheet.headers = entityTableColumnList.map((col) => col.name);
@@ -24,6 +24,7 @@ export class EntityTableColumnService {
24
24
  async findByParentIdAndParentType(
25
25
  parentId: number,
26
26
  parentType: string,
27
+ organization_id,
27
28
  isVisible?: boolean,
28
29
  ) {
29
30
  let entityTableColumns =
@@ -31,6 +32,7 @@ export class EntityTableColumnService {
31
32
  parentId,
32
33
  parentType,
33
34
  isVisible,
35
+ organization_id,
34
36
  );
35
37
  return entityTableColumns;
36
38
  }
@@ -95,6 +95,7 @@ export class EntityTableService {
95
95
  await this.entityTableColumnRepository.findByParentIdAndParentType(
96
96
  entityTable.id,
97
97
  entityTable.entity_type,
98
+ loggedInUser.organization_id,
98
99
  );
99
100
  entityTableDto.operation_list = {
100
101
  text: await this.listMasterService.getDropdownOptions(