rez_core 2.1.48 → 2.1.49
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.d.ts +1 -1
- package/dist/module/filter/repository/saved-filter.repository.d.ts +1 -1
- package/dist/module/filter/repository/saved-filter.repository.js +2 -4
- package/dist/module/filter/repository/saved-filter.repository.js.map +1 -1
- package/dist/module/filter/service/filter.service.js +71 -6
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/filter/service/saved-filter.service.d.ts +2 -1
- package/dist/module/filter/service/saved-filter.service.js +13 -0
- package/dist/module/filter/service/saved-filter.service.js.map +1 -1
- package/dist/module/meta/controller/entity.controller.d.ts +5 -0
- package/dist/module/meta/controller/entity.controller.js +29 -0
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +12 -1
- 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/repository/saved-filter.repository.ts +3 -5
- package/src/module/filter/service/filter.service.ts +81 -39
- package/src/module/filter/service/saved-filter.service.ts +24 -1
- package/src/module/meta/controller/entity.controller.ts +41 -0
- package/src/module/meta/service/entity-service-impl.service.ts +21 -5
package/package.json
CHANGED
|
@@ -77,7 +77,7 @@ export class SavedFilterRepositoryService {
|
|
|
77
77
|
status: 'ACTIVE',
|
|
78
78
|
},
|
|
79
79
|
order: {
|
|
80
|
-
|
|
80
|
+
created_date: 'DESC',
|
|
81
81
|
},
|
|
82
82
|
});
|
|
83
83
|
|
|
@@ -91,7 +91,7 @@ export class SavedFilterRepositoryService {
|
|
|
91
91
|
{
|
|
92
92
|
filter_attribute: string;
|
|
93
93
|
filter_operator: string;
|
|
94
|
-
filter_value:
|
|
94
|
+
filter_value: any;
|
|
95
95
|
}[]
|
|
96
96
|
> {
|
|
97
97
|
const saveFilterMasterData = await this.savedFilterMasterRepo.findOne({
|
|
@@ -112,9 +112,7 @@ export class SavedFilterRepositoryService {
|
|
|
112
112
|
? detail.filter_value?.trim() === ''
|
|
113
113
|
? []
|
|
114
114
|
: detail.filter_value.split(',')
|
|
115
|
-
: detail.filter_value
|
|
116
|
-
? []
|
|
117
|
-
: detail.filter_value,
|
|
115
|
+
: detail.filter_value,
|
|
118
116
|
}));
|
|
119
117
|
}
|
|
120
118
|
}
|
|
@@ -194,10 +194,10 @@ export class FilterService {
|
|
|
194
194
|
|
|
195
195
|
// Separate out 'all' tab before sorting
|
|
196
196
|
const allTab = filteredTabs.find(
|
|
197
|
-
(tab) => tab.tab_value
|
|
197
|
+
(tab) => tab.tab_value?.toLowerCase() === 'all',
|
|
198
198
|
);
|
|
199
199
|
filteredTabs = filteredTabs.filter(
|
|
200
|
-
(tab) => tab.tab_value
|
|
200
|
+
(tab) => tab.tab_value?.toLowerCase() !== 'all',
|
|
201
201
|
);
|
|
202
202
|
|
|
203
203
|
// SORTING LOGIC
|
|
@@ -273,7 +273,8 @@ export class FilterService {
|
|
|
273
273
|
{
|
|
274
274
|
filter_attribute: tabs.columnName,
|
|
275
275
|
filter_operator: 'not_equal',
|
|
276
|
-
filter_value: value,
|
|
276
|
+
filter_value: [value],
|
|
277
|
+
skip_id: true,
|
|
277
278
|
},
|
|
278
279
|
tabAttrMeta,
|
|
279
280
|
);
|
|
@@ -288,7 +289,8 @@ export class FilterService {
|
|
|
288
289
|
{
|
|
289
290
|
filter_attribute: tabs.columnName,
|
|
290
291
|
filter_operator: 'equal',
|
|
291
|
-
filter_value: tabs.value,
|
|
292
|
+
filter_value: [tabs.value],
|
|
293
|
+
skip_id: true,
|
|
292
294
|
},
|
|
293
295
|
tabAttrMeta,
|
|
294
296
|
);
|
|
@@ -359,40 +361,31 @@ export class FilterService {
|
|
|
359
361
|
// Get paginated data
|
|
360
362
|
const entity_list = await qb.getRawMany();
|
|
361
363
|
|
|
362
|
-
// const formatDatesInRow = (row: any) => {
|
|
363
|
-
// const formattedRow = { ...row };
|
|
364
|
-
// for (const key of Object.keys(row)) {
|
|
365
|
-
// if (key.endsWith('_date') && row[key]) {
|
|
366
|
-
// formattedRow[key] = moment(row[key]).format('MMM DD, YYYY');
|
|
367
|
-
// }
|
|
368
|
-
// }
|
|
369
|
-
// return formattedRow;
|
|
370
|
-
// };
|
|
371
|
-
|
|
372
364
|
// 1. Extract all date-type attribute keys
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
//
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
//
|
|
365
|
+
const dateAttributes = Object.entries(attributeMetaMap)
|
|
366
|
+
.filter(([_, attr]) => attr.data_type === 'date')
|
|
367
|
+
.map(([key]) => key);
|
|
368
|
+
|
|
369
|
+
// 2. Format function using moment
|
|
370
|
+
const formatDate = (dateStr: string | null): string | null => {
|
|
371
|
+
if (!dateStr) return '';
|
|
372
|
+
const date = moment(dateStr).format('DD-MM-YYYY'); // converted
|
|
373
|
+
return date;
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
// 3. Function to format only those keys in each entity row
|
|
377
|
+
const formatDatesInRow = (row: any): any => {
|
|
378
|
+
const formattedRow = { ...row };
|
|
379
|
+
for (const key of dateAttributes) {
|
|
380
|
+
if (formattedRow[key]) {
|
|
381
|
+
formattedRow[key] = formatDate(formattedRow[key]);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return formattedRow;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// 4. Final transformation
|
|
388
|
+
const formattedEntityList = entity_list.map(formatDatesInRow);
|
|
396
389
|
|
|
397
390
|
// Count query (without pagination)
|
|
398
391
|
const countQb = this.dataSource
|
|
@@ -409,7 +402,7 @@ export class FilterService {
|
|
|
409
402
|
success: true,
|
|
410
403
|
data: {
|
|
411
404
|
entity_tabs: filteredTabs,
|
|
412
|
-
entity_list,
|
|
405
|
+
entity_list: formattedEntityList,
|
|
413
406
|
pagination: {
|
|
414
407
|
total,
|
|
415
408
|
page,
|
|
@@ -469,7 +462,8 @@ export class FilterService {
|
|
|
469
462
|
const op = filter.filter_operator;
|
|
470
463
|
const key = `param_${attr}_${Math.random().toString(36).substring(2, 8)}`;
|
|
471
464
|
|
|
472
|
-
if (meta.data_source_type === 'entity'
|
|
465
|
+
if (meta.data_source_type === 'entity' && !filter.skip_id)
|
|
466
|
+
attr = `${attr}_id`;
|
|
473
467
|
|
|
474
468
|
switch (meta.data_type) {
|
|
475
469
|
case 'text':
|
|
@@ -482,6 +476,10 @@ export class FilterService {
|
|
|
482
476
|
return this.buildMultiSelectCondition(attr, op, val, key);
|
|
483
477
|
case 'multiselect':
|
|
484
478
|
return this.buildMultiSelectCondition(attr, op, val, key);
|
|
479
|
+
case 'checkbox':
|
|
480
|
+
return this.buildMultiSelectCondition(attr, op, val, key);
|
|
481
|
+
case 'radio':
|
|
482
|
+
return this.buildMultiSelectCondition(attr, op, val, key);
|
|
485
483
|
case 'year':
|
|
486
484
|
return this.buildYearCondition(attr, op, val, key);
|
|
487
485
|
default:
|
|
@@ -536,6 +534,15 @@ export class FilterService {
|
|
|
536
534
|
return { query: `e.${attr} > :${key}`, params: { [key]: val } };
|
|
537
535
|
case 'less_than':
|
|
538
536
|
return { query: `e.${attr} < :${key}`, params: { [key]: val } };
|
|
537
|
+
case 'less_than_qual_to':
|
|
538
|
+
return { query: `e.${attr} <= :${key}`, params: { [key]: val } };
|
|
539
|
+
case 'greater_than_qual_to':
|
|
540
|
+
return { query: `e.${attr} >= :${key}`, params: { [key]: val } };
|
|
541
|
+
case 'empty':
|
|
542
|
+
return { query: `e.${attr} IS NULL`, params: {} };
|
|
543
|
+
case 'not_empty':
|
|
544
|
+
return { query: `e.${attr} IS NOT NULL`, params: {} };
|
|
545
|
+
|
|
539
546
|
default:
|
|
540
547
|
throw new BadRequestException(`Unsupported operator for number: ${op}`);
|
|
541
548
|
}
|
|
@@ -564,6 +571,31 @@ export class FilterService {
|
|
|
564
571
|
},
|
|
565
572
|
};
|
|
566
573
|
}
|
|
574
|
+
|
|
575
|
+
case 'today': {
|
|
576
|
+
const today = new Date().toISOString().split('T')[0]; // 'YYYY-MM-DD'
|
|
577
|
+
|
|
578
|
+
return {
|
|
579
|
+
query: `DATE(e.${attr}) = :today`,
|
|
580
|
+
params: {
|
|
581
|
+
today,
|
|
582
|
+
},
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
case 'empty': {
|
|
587
|
+
return {
|
|
588
|
+
query: `e.${attr} IS NULL`,
|
|
589
|
+
params: {},
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
case 'not_empty': {
|
|
594
|
+
return {
|
|
595
|
+
query: `e.${attr} IS NOT NULL`,
|
|
596
|
+
params: {},
|
|
597
|
+
};
|
|
598
|
+
}
|
|
567
599
|
default:
|
|
568
600
|
throw new BadRequestException(`Unsupported operator for date: ${op}`);
|
|
569
601
|
}
|
|
@@ -616,6 +648,16 @@ export class FilterService {
|
|
|
616
648
|
query: `e.${attr} NOT IN (:${key})`,
|
|
617
649
|
params: { [key]: val },
|
|
618
650
|
};
|
|
651
|
+
case 'contains':
|
|
652
|
+
return {
|
|
653
|
+
query: `e.${attr} LIKE :${key}`,
|
|
654
|
+
params: { [key]: `%${val}%` },
|
|
655
|
+
};
|
|
656
|
+
case 'not_contains':
|
|
657
|
+
return {
|
|
658
|
+
query: `e.${attr} NOT LIKE :${key}`,
|
|
659
|
+
params: { [key]: `%${val}%` },
|
|
660
|
+
};
|
|
619
661
|
case 'empty':
|
|
620
662
|
return { query: `e.${attr} IS NULL`, params: {} };
|
|
621
663
|
case 'not_empty':
|
|
@@ -6,7 +6,6 @@ import { SavedFilterMaster } from '../entity/saved-filter-master.entity';
|
|
|
6
6
|
import { SavedFilterDetail } from '../entity/saved-filter-detail.entity';
|
|
7
7
|
import { ENTITYTYPE_SAVEDFILTERMASTER } from 'src/constant/global.constant';
|
|
8
8
|
import { SavedFilterRepositoryService } from '../repository/saved-filter.repository';
|
|
9
|
-
import { isArray } from 'class-validator';
|
|
10
9
|
|
|
11
10
|
@Injectable()
|
|
12
11
|
export class SavedFilterService extends EntityServiceImpl {
|
|
@@ -112,6 +111,30 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
112
111
|
return updated;
|
|
113
112
|
}
|
|
114
113
|
|
|
114
|
+
async deleteEntity(entityType: string, entityId: number) {
|
|
115
|
+
const entityMaster =
|
|
116
|
+
await this.entityMasterService.getEntityData(entityType);
|
|
117
|
+
|
|
118
|
+
const repoService = this.reflectionHelper.getRepoService(
|
|
119
|
+
entityMaster.entity_data_class,
|
|
120
|
+
);
|
|
121
|
+
if (!repoService) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`Repository service not found for entityType: ${entityType}`,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const entityData = await repoService.findOne({ where: { id: entityId } });
|
|
128
|
+
|
|
129
|
+
if (!entityData) {
|
|
130
|
+
throw new Error(`Entity not found for entityType: ${entityType}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
await this.savedFilterRepo.deleteDetailsByCode(entityData.code);
|
|
134
|
+
|
|
135
|
+
await repoService.delete(entityId);
|
|
136
|
+
}
|
|
137
|
+
|
|
115
138
|
async getDetailsByCode(code: string): Promise<SavedFilterDetail[]> {
|
|
116
139
|
return this.savedFilterRepo.getDetailsByCode(code);
|
|
117
140
|
}
|
|
@@ -144,6 +144,47 @@ export class EntityController {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
@Post('delete/:id')
|
|
148
|
+
@HttpCode(200)
|
|
149
|
+
async delete(
|
|
150
|
+
@Param('id') id: number,
|
|
151
|
+
@Query('entity_type') entityType: string,
|
|
152
|
+
@Req() req: Request & { user: any },
|
|
153
|
+
) {
|
|
154
|
+
const loggedInUser = req.user.userData;
|
|
155
|
+
|
|
156
|
+
if (!entityType) {
|
|
157
|
+
throw new BadRequestException(
|
|
158
|
+
'Query parameter "entity_type" is required',
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const entityMaster =
|
|
163
|
+
await this.entityMasterService.getEntityData(entityType);
|
|
164
|
+
|
|
165
|
+
const entityService =
|
|
166
|
+
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
167
|
+
entityMaster.entity_service,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
if (!entityService) {
|
|
171
|
+
throw new InternalServerErrorException(
|
|
172
|
+
`No service found for entity_type "${entityType}"`,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const existingEntity = await entityService.getEntityData(entityType, id);
|
|
177
|
+
if (!existingEntity) {
|
|
178
|
+
throw new NotFoundException(`No entity found for id "${id}"`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
await entityService.deleteEntity(entityType, id);
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
success: true,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
147
188
|
@Post('getFilteredDataWithTabs/:entity_type')
|
|
148
189
|
async getFilterDataWithTabs(
|
|
149
190
|
@Param('entity_type') entityType: string,
|
|
@@ -94,11 +94,27 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
94
94
|
return repo.save(entityData);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
deleteEntity(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
async deleteEntity(entityType: string, entityId: number) {
|
|
98
|
+
const entityMaster =
|
|
99
|
+
await this.entityMasterService.getEntityData(entityType);
|
|
100
|
+
|
|
101
|
+
const repoService = this.reflectionHelper.getRepoService(
|
|
102
|
+
entityMaster.entity_data_class,
|
|
103
|
+
);
|
|
104
|
+
if (!repoService) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Repository service not found for entityType: ${entityType}`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const entityData = await repoService.findOne({ where: { id: entityId } });
|
|
111
|
+
|
|
112
|
+
if (!entityData) {
|
|
113
|
+
throw new Error(`Entity not found for entityType: ${entityType}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await repoService.delete(entityId);
|
|
117
|
+
}
|
|
102
118
|
|
|
103
119
|
async findByCode(entityType: string, code: string): Promise<BaseEntity> {
|
|
104
120
|
const entityData = await this.entityMasterService.getEntityData(entityType);
|