rez_core 1.1.0 → 1.1.2
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/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/service/filter.service.js +31 -11
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/filter/service/saved-filter.service.d.ts +2 -2
- package/dist/module/filter/service/saved-filter.service.js +6 -0
- package/dist/module/filter/service/saved-filter.service.js.map +1 -1
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +1 -0
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/controller/filter.controller.ts +2 -0
- package/src/module/filter/service/filter.service.ts +50 -12
- package/src/module/filter/service/saved-filter.service.ts +8 -2
- package/src/module/meta/controller/entity.controller.ts +30 -12
- package/src/module/meta/service/entity-service-impl.service.ts +2 -0
package/package.json
CHANGED
|
@@ -100,11 +100,11 @@ export class FilterService {
|
|
|
100
100
|
// Get and parse filters
|
|
101
101
|
const savedFilters = await this.getSavedFilters(savedFilterCode);
|
|
102
102
|
const baseFilters = [
|
|
103
|
-
...(quickFilter || []).filter(f => f.filter_value !==
|
|
104
|
-
...savedFilters.filter(f => f.filter_value !==
|
|
105
|
-
...(attributeFilter || []).filter(f => f.filter_value !==
|
|
103
|
+
...(quickFilter || []).filter((f) => f.filter_value !== ''),
|
|
104
|
+
...savedFilters.filter((f) => f.filter_value !== ''),
|
|
105
|
+
...(attributeFilter || []).filter((f) => f.filter_value !== ''),
|
|
106
106
|
];
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
const baseWhere = this.buildWhereClauses(baseFilters, attributeMetaMap);
|
|
109
109
|
|
|
110
110
|
// Build query for tab counts (no tab.value filter here)
|
|
@@ -229,7 +229,7 @@ export class FilterService {
|
|
|
229
229
|
case 'select':
|
|
230
230
|
return this.buildSelectCondition(attr, op, val, key);
|
|
231
231
|
case 'multiselect':
|
|
232
|
-
return this.buildMultiSelectCondition(attr, val, key);
|
|
232
|
+
return this.buildMultiSelectCondition(attr, op, val, key);
|
|
233
233
|
default:
|
|
234
234
|
return null;
|
|
235
235
|
}
|
|
@@ -310,18 +310,56 @@ export class FilterService {
|
|
|
310
310
|
case 'equal':
|
|
311
311
|
return { query: `e.${attr} = :${key}`, params: { [key]: val } };
|
|
312
312
|
|
|
313
|
+
case 'not_equal':
|
|
314
|
+
return { query: `e.${attr} != :${key}`, params: { [key]: val } };
|
|
315
|
+
|
|
316
|
+
case 'empty':
|
|
317
|
+
return { query: `e.${attr} IS NULL`, params: {} };
|
|
318
|
+
|
|
319
|
+
case 'not_empty':
|
|
320
|
+
return { query: `e.${attr} IS NOT NULL`, params: {} };
|
|
321
|
+
|
|
313
322
|
default:
|
|
314
323
|
throw new BadRequestException(`Unsupported operator for select: ${op}`);
|
|
315
324
|
}
|
|
316
325
|
}
|
|
317
326
|
|
|
318
|
-
private buildMultiSelectCondition(
|
|
319
|
-
|
|
320
|
-
|
|
327
|
+
private buildMultiSelectCondition(
|
|
328
|
+
attr: string,
|
|
329
|
+
op: string,
|
|
330
|
+
val: any,
|
|
331
|
+
key: string,
|
|
332
|
+
) {
|
|
333
|
+
switch (op) {
|
|
334
|
+
case 'equal':
|
|
335
|
+
if (!Array.isArray(val)) {
|
|
336
|
+
throw new BadRequestException(
|
|
337
|
+
`Value for multi-select must be an array for operator: ${op}`,
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
return { query: `e.${attr} IN (:...${key})`, params: { [key]: val } };
|
|
341
|
+
|
|
342
|
+
case 'not_equal':
|
|
343
|
+
if (!Array.isArray(val)) {
|
|
344
|
+
throw new BadRequestException(
|
|
345
|
+
`Value for multi-select must be an array for operator: ${op}`,
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
query: `e.${attr} NOT IN (:...${key})`,
|
|
350
|
+
params: { [key]: val },
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
case 'empty':
|
|
354
|
+
return { query: `e.${attr} IS NULL`, params: {} };
|
|
355
|
+
|
|
356
|
+
case 'not_empty':
|
|
357
|
+
return { query: `e.${attr} IS NOT NULL`, params: {} };
|
|
358
|
+
|
|
359
|
+
default:
|
|
360
|
+
throw new BadRequestException(
|
|
361
|
+
`Unsupported operator for multiselect: ${op}`,
|
|
362
|
+
);
|
|
321
363
|
}
|
|
322
|
-
return {
|
|
323
|
-
query: `e.${attr} IN (:...${key})`,
|
|
324
|
-
params: { [key]: val },
|
|
325
|
-
};
|
|
326
364
|
}
|
|
327
365
|
}
|
|
@@ -15,8 +15,11 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
15
15
|
|
|
16
16
|
async createEntity(
|
|
17
17
|
entityData: BaseEntity,
|
|
18
|
-
loggedInUser: UserData
|
|
18
|
+
loggedInUser: UserData,
|
|
19
19
|
): Promise<BaseEntity> {
|
|
20
|
+
entityData.organization_id = loggedInUser?.organization_id;
|
|
21
|
+
entityData.enterprise_id = loggedInUser?.enterprise_id;
|
|
22
|
+
(entityData as any).user_id = loggedInUser?.id;
|
|
20
23
|
const master = entityData as SavedFilterMaster;
|
|
21
24
|
|
|
22
25
|
const exists = await this.savedFilterRepo.isFilterNameExists(
|
|
@@ -55,8 +58,11 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
55
58
|
|
|
56
59
|
async updateEntity(
|
|
57
60
|
entityData: BaseEntity,
|
|
58
|
-
loggedInUser: UserData
|
|
61
|
+
loggedInUser: UserData,
|
|
59
62
|
): Promise<BaseEntity> {
|
|
63
|
+
entityData.organization_id = loggedInUser?.organization_id;
|
|
64
|
+
entityData.enterprise_id = loggedInUser?.enterprise_id;
|
|
65
|
+
(entityData as any).user_id = loggedInUser?.id;
|
|
60
66
|
const master = entityData as SavedFilterMaster;
|
|
61
67
|
|
|
62
68
|
const existing = await this.getEntityData(
|
|
@@ -2,14 +2,16 @@ import {
|
|
|
2
2
|
BadRequestException,
|
|
3
3
|
Body,
|
|
4
4
|
Controller,
|
|
5
|
-
Get,
|
|
5
|
+
Get,
|
|
6
|
+
HttpCode,
|
|
6
7
|
HttpStatus,
|
|
7
8
|
Param,
|
|
8
9
|
Post,
|
|
9
10
|
Query,
|
|
10
11
|
Res,
|
|
11
12
|
Req,
|
|
12
|
-
UseGuards,
|
|
13
|
+
UseGuards,
|
|
14
|
+
Inject,
|
|
13
15
|
} from '@nestjs/common';
|
|
14
16
|
import { EntityServiceImpl } from '../service/entity-service-impl.service';
|
|
15
17
|
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
@@ -62,10 +64,13 @@ export class EntityController {
|
|
|
62
64
|
@Body() entityData: BaseEntity,
|
|
63
65
|
@Query('entity_type') entityType: string,
|
|
64
66
|
@Res() res: Response,
|
|
65
|
-
@Req() req: Request & {user: any}
|
|
67
|
+
@Req() req: Request & { user: any },
|
|
66
68
|
) {
|
|
67
69
|
let requestedUser = req.user;
|
|
68
|
-
let loggedInUser = await this.entityService.getEntityData(
|
|
70
|
+
let loggedInUser = await this.entityService.getEntityData(
|
|
71
|
+
ENTITYTYPE_USER,
|
|
72
|
+
requestedUser.userId,
|
|
73
|
+
);
|
|
69
74
|
|
|
70
75
|
if (!entityType) {
|
|
71
76
|
throw new BadRequestException(
|
|
@@ -83,7 +88,12 @@ export class EntityController {
|
|
|
83
88
|
if (entityService) {
|
|
84
89
|
return res
|
|
85
90
|
.status(HttpStatus.OK)
|
|
86
|
-
.json(
|
|
91
|
+
.json(
|
|
92
|
+
await entityService.createEntity(
|
|
93
|
+
entityData,
|
|
94
|
+
loggedInUser as UserData,
|
|
95
|
+
),
|
|
96
|
+
);
|
|
87
97
|
}
|
|
88
98
|
}
|
|
89
99
|
|
|
@@ -93,10 +103,13 @@ export class EntityController {
|
|
|
93
103
|
@Body() entityData: BaseEntity,
|
|
94
104
|
@Query('entity_type') entityType: string,
|
|
95
105
|
@Res() response: Response,
|
|
96
|
-
@Req() req: Request & {user: any}
|
|
106
|
+
@Req() req: Request & { user: any },
|
|
97
107
|
) {
|
|
98
108
|
let requestedUser = req.user;
|
|
99
|
-
let loggedInUser = await this.entityService.getEntityData(
|
|
109
|
+
let loggedInUser = await this.entityService.getEntityData(
|
|
110
|
+
ENTITYTYPE_USER,
|
|
111
|
+
requestedUser.userId,
|
|
112
|
+
);
|
|
100
113
|
if (!entityType) {
|
|
101
114
|
throw new BadRequestException(
|
|
102
115
|
'Query parameter "entity_type" is required',
|
|
@@ -117,7 +130,10 @@ export class EntityController {
|
|
|
117
130
|
}
|
|
118
131
|
// let mergeEntity = JsonUtil.merge(existingEntity, entityData);
|
|
119
132
|
|
|
120
|
-
entityData = await entityService.updateEntity(
|
|
133
|
+
entityData = await entityService.updateEntity(
|
|
134
|
+
entityData,
|
|
135
|
+
loggedInUser as UserData,
|
|
136
|
+
);
|
|
121
137
|
return response.status(HttpStatus.OK).json(entityData);
|
|
122
138
|
}
|
|
123
139
|
}
|
|
@@ -147,7 +163,7 @@ export class EntityController {
|
|
|
147
163
|
page,
|
|
148
164
|
size,
|
|
149
165
|
tabColumn,
|
|
150
|
-
tabValue
|
|
166
|
+
tabValue,
|
|
151
167
|
),
|
|
152
168
|
);
|
|
153
169
|
}
|
|
@@ -164,13 +180,12 @@ export class EntityController {
|
|
|
164
180
|
@Res() res: Response, // Express Response for file handling
|
|
165
181
|
) {
|
|
166
182
|
try {
|
|
167
|
-
|
|
168
183
|
const filePath = await this.entityService.generateExcelReport(
|
|
169
184
|
entityType,
|
|
170
185
|
filterCriteria,
|
|
171
186
|
listEntityType,
|
|
172
187
|
displayType,
|
|
173
|
-
sampleExport
|
|
188
|
+
sampleExport,
|
|
174
189
|
);
|
|
175
190
|
|
|
176
191
|
if (!filePath || !fs.existsSync(filePath)) {
|
|
@@ -181,7 +196,10 @@ export class EntityController {
|
|
|
181
196
|
'Content-Disposition',
|
|
182
197
|
`attachment; filename=${path.basename(filePath)}`,
|
|
183
198
|
);
|
|
184
|
-
res.setHeader(
|
|
199
|
+
res.setHeader(
|
|
200
|
+
'Content-Type',
|
|
201
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
202
|
+
);
|
|
185
203
|
|
|
186
204
|
const fileStream = fs.createReadStream(filePath);
|
|
187
205
|
fileStream.pipe(res);
|
|
@@ -73,6 +73,8 @@ protected readonly entityValidationService: EntityValidationService;
|
|
|
73
73
|
entityData.code = entityData.entity_type + maxSeqNo;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
entityData.status = "ACTIVE";
|
|
77
|
+
|
|
76
78
|
entityData.created_date = new Date();
|
|
77
79
|
if (loggedInUser) {
|
|
78
80
|
entityData.created_by = loggedInUser.id;
|