rez_core 2.1.90 → 2.1.92

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.90",
3
+ "version": "2.1.92",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -14,6 +14,7 @@ import { EntityManager } from 'typeorm';
14
14
  import { EntityMasterService } from 'src/module/meta/service/entity-master.service';
15
15
  import { UserData } from 'src/module/user/entity/user.entity';
16
16
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
17
+ import { STATUS_ACTIVE, STATUS_INACTIVE } from 'src/constant/global.constant';
17
18
 
18
19
  @Injectable()
19
20
  export class ListMasterService {
@@ -97,10 +98,7 @@ export class ListMasterService {
97
98
  );
98
99
  const tableName = entityMaster.db_table_name;
99
100
 
100
- const applyCommonFilters = (
101
- qb: any,
102
- status: 'active' | null = 'active',
103
- ) => {
101
+ const applyCommonFilters = (qb: any, status?: number) => {
104
102
  if (status) {
105
103
  qb.where(`${tableName}.status = :status`, { status });
106
104
  }
@@ -141,13 +139,18 @@ export class ListMasterService {
141
139
  return qb;
142
140
  };
143
141
 
142
+ const resolveStatus = await this.getResolvedListCode(
143
+ STATUS_ACTIVE,
144
+ loggedInUser?.organization_id || 0,
145
+ );
146
+
144
147
  // Fetch active records
145
148
  const activeQuery = applyCommonFilters(
146
149
  this.entityManager
147
150
  .createQueryBuilder()
148
151
  .select('*')
149
152
  .from(tableName, tableName),
150
- 'active',
153
+ resolveStatus.id || null,
151
154
  );
152
155
 
153
156
  const activeResults = await activeQuery.getRawMany();
@@ -158,6 +161,11 @@ export class ListMasterService {
158
161
  result.push({ label: r.name, value: r.id });
159
162
  });
160
163
 
164
+ const resolveInactiveStatus = await this.getResolvedListCode(
165
+ STATUS_INACTIVE,
166
+ loggedInUser?.organization_id || 0,
167
+ );
168
+
161
169
  // Fetch inactive records (with same filters but without status condition)
162
170
  if (inactiveIdsArray?.length) {
163
171
  const inactiveQuery = applyCommonFilters(
@@ -165,7 +173,7 @@ export class ListMasterService {
165
173
  .createQueryBuilder()
166
174
  .select('*')
167
175
  .from(tableName, tableName),
168
- null, // exclude status filter
176
+ resolveInactiveStatus.id || null,
169
177
  );
170
178
 
171
179
  inactiveQuery.andWhere(`${tableName}.id IN (:...ids)`, {
@@ -178,7 +186,7 @@ export class ListMasterService {
178
186
  inactiveResults.forEach((item) => {
179
187
  if (!activeIds.has(item.id)) {
180
188
  result.push({
181
- label: `${item.name}_INACTIVE`,
189
+ label: `${item.name} [INACTIVE]`,
182
190
  value: item.id,
183
191
  });
184
192
  }
@@ -9,8 +9,6 @@ export class EntityTableColumn extends BaseEntity {
9
9
  this.entity_type = ENTITYTYPE_ENTITYTABLECOLUMN;
10
10
  }
11
11
 
12
-
13
-
14
12
  @Column({ name: 'mapped_entity_type', nullable: true })
15
13
  mapped_entity_type: string;
16
14
 
@@ -51,4 +49,7 @@ export class EntityTableColumn extends BaseEntity {
51
49
 
52
50
  @Column({ name: 'visible', nullable: true })
53
51
  visible: string;
52
+
53
+ @Column({ nullable: true })
54
+ display_type: string;
54
55
  }
@@ -80,62 +80,50 @@ export class PopulateMetaService {
80
80
  .execute();
81
81
  }
82
82
 
83
- // Step 2: Insert cr_entity_table and map mapped_entity_type -> new ID
84
- const factoryEntityData = await this.dataSource.query(
83
+ const entityTables = await this.dataSource.query(
85
84
  `SELECT * FROM cr_entity_table WHERE organization_id = -1 AND level_type = 'ORG' AND level_id = -1`,
86
85
  );
87
86
 
88
- if (factoryEntityData.length) {
89
- const transformedEntityData = factoryEntityData.map(
90
- ({ id, created_date, modified_date, ...rest }) => ({
91
- ...rest,
92
- organization_id,
93
- level_type: 'ORG',
94
- level_id: organization_id,
95
- }),
96
- );
97
-
87
+ for (let entityTable of entityTables) {
88
+ const { id, mapped_entity_type, display_type, ...rest } = entityTable;
89
+ entityTable = {
90
+ ...rest,
91
+ organization_id,
92
+ mapped_entity_type: mapped_entity_type,
93
+ level_type: 'ORG',
94
+ level_id: organization_id,
95
+ display_type: display_type,
96
+ };
98
97
  const insertResult = await this.dataSource
99
98
  .createQueryBuilder()
100
99
  .insert()
101
100
  .into('cr_entity_table')
102
- .values(transformedEntityData)
101
+ .values(entityTable)
103
102
  .execute();
104
103
 
105
- // Build mapped_entity_type -> new id mapping
106
- for (let i = 0; i < factoryEntityData.length; i++) {
107
- const key = factoryEntityData[i].mapped_entity_type;
108
- const newId = insertResult.identifiers[i].id;
109
- entityTypeToNewIdMap.set(key, newId);
110
- }
111
- }
104
+ const newId = insertResult.identifiers[0].id; // or insertResult.raw.insertId if needed
112
105
 
113
- // Step 3: Insert cr_entity_table_column with parent_id from mapped_entity_type
114
- const factoryColumnData = await this.dataSource.query(
115
- `SELECT * FROM cr_entity_table_column WHERE organization_id = -1 AND level_type = 'ORG' AND level_id = -1`,
116
- );
117
-
118
- if (factoryColumnData.length) {
119
- const transformedColumnData = factoryColumnData.map(
120
- ({ id, created_date, modified_date, ...rest }) => {
121
- const mappedEntityType = rest.mapped_entity_type;
122
- const newParentId = entityTypeToNewIdMap.get(mappedEntityType);
123
- return {
124
- ...rest,
125
- parent_id: newParentId ?? null,
126
- organization_id,
127
- level_type: 'ORG',
128
- level_id: organization_id,
129
- };
130
- },
106
+ const entityTableColumns = await this.dataSource.query(
107
+ `SELECT * FROM cr_entity_table_column WHERE organization_id = -1 AND level_type = 'ORG' AND level_id = -1 AND mapped_entity_type = '${mapped_entity_type}' AND display_type = '${display_type}'`,
131
108
  );
132
-
133
- await this.dataSource
134
- .createQueryBuilder()
135
- .insert()
136
- .into('cr_entity_table_column')
137
- .values(transformedColumnData)
138
- .execute();
109
+ for (const column of entityTableColumns) {
110
+ const { id, created_date, modified_date, ...columnRest } = column;
111
+ const newColumn = {
112
+ ...columnRest,
113
+ organization_id,
114
+ parent_id: newId,
115
+ level_type: 'ORG',
116
+ level_id: organization_id,
117
+ mapped_entity_type: mapped_entity_type,
118
+ display_type: display_type,
119
+ };
120
+ await this.dataSource
121
+ .createQueryBuilder()
122
+ .insert()
123
+ .into('cr_entity_table_column')
124
+ .values(newColumn)
125
+ .execute();
126
+ }
139
127
  }
140
128
 
141
129
  return {