@mediusinc/mng-commons-audit 4.1.0-rc.0 → 5.0.0-rc.0-c31d5206

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.
@@ -1,18 +1,92 @@
1
- import { TypeName, TypeRegistry, MediusFilterMatchType, AMngBaseApiService, MngConfigurationService, MngInternalError, AMngTableviewRouteComponent, LookupDataProvider, TableviewDescriptor, TableviewDataProvider, MediusQueryResult, ActionEditorDetailsDescriptor, MngDropdownComponent, MngTableviewRouteComponent, AMngFormlyCustomFieldComponent, TableDescriptor, TablePaginationModeEnum, MngTableComponent, ModelDescriptor, EditorDescriptor, TableviewEditorTypeEnum, TableFilterDisplayEnum, itemIdToDefined, MngTableviewComponent, RouteBuilder, TableviewRouteBuilder, RoutesBuilder } from '@mediusinc/mng-commons';
1
+ import { TypeName, TypeRegistry, MngConfigurationService, enumModel, LookupDataProvider, enumModelGeneric, DataListParamsUtil, MngInternalError, TableviewDescriptor, TableviewDataProvider, ActionEditorDetailsDescriptor, MngDropdownComponent, MngTableviewComponent, MngTableviewRouteComponent, AMngFormlyCustomFieldComponent, TableDescriptor, TablePaginationModeEnum, MngTableComponent, ModelDescriptor, EditorDescriptor, TableviewEditorTypeEnum, itemIdToDefined, RouteBuilder, TableviewRouteBuilder, RoutesBuilder } from '@mediusinc/mng-commons';
2
2
  import * as i0 from '@angular/core';
3
- import { InjectionToken, inject, Injectable, Component, DestroyRef, signal, Input, Injector, ChangeDetectionStrategy } from '@angular/core';
3
+ import { InjectionToken, inject, Injectable, Component, ChangeDetectionStrategy, computed, signal, effect, DestroyRef, Input, Injector } from '@angular/core';
4
+ import { shareReplay, throwError, BehaviorSubject } from 'rxjs';
4
5
  import { map } from 'rxjs/operators';
6
+ import { AMngBaseObsoleteV1ApiService } from '@mediusinc/mng-commons/data-api/class-dto/obsolete';
5
7
  import { __decorate } from 'tslib';
6
- import { of, shareReplay, combineLatest, throwError, BehaviorSubject } from 'rxjs';
7
- import * as i1 from '@angular/router';
8
- import { RouterOutlet } from '@angular/router';
8
+ import { RouterOutlet, Router, ActivatedRoute } from '@angular/router';
9
9
  import { AsyncPipe, JsonPipe } from '@angular/common';
10
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
11
- import * as i2 from '@angular/forms';
10
+ import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
11
+ import * as i1 from '@angular/forms';
12
12
  import { FormsModule } from '@angular/forms';
13
13
  import { FormlyModule } from '@ngx-formly/core';
14
- import * as i3 from '@ngx-translate/core';
15
- import { TranslateModule } from '@ngx-translate/core';
14
+ import * as i2 from '@ngx-translate/core';
15
+ import { TranslateService, TranslateModule } from '@ngx-translate/core';
16
+ import { HttpParams } from '@angular/common/http';
17
+
18
+ const MNG_AUDIT_MODULE_CONFIG_IT = new InjectionToken('MngAuditModuleConfig');
19
+
20
+ var MngGuiEntityModelDto_1;
21
+ let MngGuiEntityModelDto = class MngGuiEntityModelDto {
22
+ static { MngGuiEntityModelDto_1 = this; }
23
+ static { this.attributeTypeMap = [
24
+ {
25
+ name: 'entityName',
26
+ baseName: 'entityName',
27
+ type: 'string'
28
+ },
29
+ {
30
+ name: 'properties',
31
+ baseName: 'properties',
32
+ type: 'Array<GuiPropertyModel>'
33
+ }
34
+ ]; }
35
+ static getAttributeTypeMap() {
36
+ return MngGuiEntityModelDto_1.attributeTypeMap;
37
+ }
38
+ };
39
+ MngGuiEntityModelDto = MngGuiEntityModelDto_1 = __decorate([
40
+ TypeName('MngGuiEntityModelDto')
41
+ ], MngGuiEntityModelDto);
42
+ TypeRegistry.get().registerType(MngGuiEntityModelDto);
43
+
44
+ class MngAuditService extends AMngBaseObsoleteV1ApiService {
45
+ constructor() {
46
+ super();
47
+ this.CACHE_SIZE = 1;
48
+ this.moduleConfig = inject(MNG_AUDIT_MODULE_CONFIG_IT);
49
+ this.configService = MngConfigurationService.get();
50
+ }
51
+ getServiceBasePath() {
52
+ return this.moduleConfig.apiServiceBasePath ?? '';
53
+ }
54
+ getBasePath() {
55
+ return `${this.configService.getConfigValue(this.moduleConfig.apiBasePathConfigKey)}`;
56
+ }
57
+ get revModel$() {
58
+ if (!this.revModelObs) {
59
+ this.revModelObs = this.requestRevModel().pipe(shareReplay(this.CACHE_SIZE));
60
+ }
61
+ return this.revModelObs;
62
+ }
63
+ get auditModel$() {
64
+ if (!this.auditModelObs) {
65
+ this.auditModelObs = this.requestAuditModel().pipe(shareReplay(this.CACHE_SIZE));
66
+ }
67
+ return this.auditModelObs;
68
+ }
69
+ requestRevModel() {
70
+ return this.http.get(this.getUrl('/rev-model'));
71
+ }
72
+ requestAuditModel() {
73
+ return this.http.get(this.getUrl('/audit-models')).pipe(map(response => this.deserializeClassArray(response, MngGuiEntityModelDto)));
74
+ }
75
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
76
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditService }); }
77
+ }
78
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditService, decorators: [{
79
+ type: Injectable
80
+ }], ctorParameters: () => [] });
81
+
82
+ class MngAuditPageComponent {
83
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
84
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: MngAuditPageComponent, isStandalone: true, selector: "mng-audit-page", ngImport: i0, template: "<router-outlet></router-outlet>\n", dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
85
+ }
86
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditPageComponent, decorators: [{
87
+ type: Component,
88
+ args: [{ standalone: true, selector: 'mng-audit-page', imports: [RouterOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: "<router-outlet></router-outlet>\n" }]
89
+ }] });
16
90
 
17
91
  var MngRevEntityWithStateDto_1;
18
92
  let MngRevEntityWithStateDto = class MngRevEntityWithStateDto {
@@ -55,8 +129,6 @@ MngRevEntityWithId = __decorate([
55
129
  ], MngRevEntityWithId);
56
130
  TypeRegistry.get().registerType(MngRevEntityWithId);
57
131
 
58
- const MNG_AUDIT_MODULE_CONFIG_IT = new InjectionToken('MngAuditModuleConfig');
59
-
60
132
  /**
61
133
  * Medius quarkus sampler
62
134
  * Sampler OPENAPI definition
@@ -98,6 +170,7 @@ var MngRevisionTypeDto;
98
170
  MngRevisionTypeDto["Del"] = "DEL";
99
171
  })(MngRevisionTypeDto || (MngRevisionTypeDto = {}));
100
172
  TypeRegistry.get().registerEnum(MngRevisionTypeDto, 'MngRevisionTypeDto');
173
+ const revisionTypeEnum = enumModel(MngRevisionTypeDto.Add, MngRevisionTypeDto, 'MngRevisionTypeDto');
101
174
 
102
175
  let MngEntityRevisionChangeState = class MngEntityRevisionChangeState {
103
176
  };
@@ -111,25 +184,6 @@ MngEntityRevisionChanges = __decorate([
111
184
  TypeName('MngEntityChanges')
112
185
  ], MngEntityRevisionChanges);
113
186
 
114
- var NewMediusFilterMatchType;
115
- (function (NewMediusFilterMatchType) {
116
- NewMediusFilterMatchType["Equals"] = "eq";
117
- NewMediusFilterMatchType["NotEquals"] = "ne";
118
- NewMediusFilterMatchType["Between"] = "bt";
119
- NewMediusFilterMatchType["Contains"] = "cn";
120
- NewMediusFilterMatchType["NotContains"] = "nc";
121
- NewMediusFilterMatchType["StartsWith"] = "sw";
122
- NewMediusFilterMatchType["EndsWith"] = "ew";
123
- NewMediusFilterMatchType["In"] = "in";
124
- NewMediusFilterMatchType["NotIn"] = "ni";
125
- NewMediusFilterMatchType["LessThan"] = "lt";
126
- NewMediusFilterMatchType["LessThanOrEqualTo"] = "le";
127
- NewMediusFilterMatchType["GreaterThan"] = "gt";
128
- NewMediusFilterMatchType["GreaterThanOrEqualTo"] = "ge";
129
- NewMediusFilterMatchType["Exists"] = "ex";
130
- NewMediusFilterMatchType["DoesNotExist"] = "nx";
131
- })(NewMediusFilterMatchType || (NewMediusFilterMatchType = {}));
132
-
133
187
  class AuditUtil {
134
188
  static { this._dateRegex = /\d{4}-[01]\d-[0-3]\d/; }
135
189
  static addColumnsFromModel(descriptor, properties, modelType = undefined, addFilters = true, addSorts = true) {
@@ -144,17 +198,17 @@ class AuditUtil {
144
198
  if (!property.possibleEnumValues) {
145
199
  continue;
146
200
  }
147
- const enumType = AuditUtil.findEnumType(property);
148
- if (enumType) {
149
- column = descriptor.addColumnUnsafe(property.resolvedPropertyName).asEnum(enumType);
201
+ const enumModel = AuditUtil.findEnum(property);
202
+ if (enumModel) {
203
+ column = descriptor.addColumnEnum(property.resolvedPropertyName, enumModel);
150
204
  if (addFilters) {
151
- column.withFilterLookupEnum(property.possibleEnumValues);
205
+ descriptor.addFilterLookupEnum(column.property, enumModel, property.possibleEnumValues);
152
206
  }
153
207
  }
154
208
  else {
155
209
  column = descriptor.addColumnUnsafe(property.resolvedPropertyName);
156
210
  if (addFilters) {
157
- (column?.withFilterLookup()).withLookup(() => of(property.possibleEnumValues ?? []));
211
+ descriptor.addFilterLookupUnsafe(column.property, LookupDataProvider.create().withLookup(() => property.possibleEnumValues ?? []));
158
212
  }
159
213
  }
160
214
  }
@@ -179,10 +233,10 @@ class AuditUtil {
179
233
  }
180
234
  column.withTitle(AuditUtil.getPropertyTitleKey(property, modelType));
181
235
  if (!isEnum && addFilters) {
182
- column?.withFilter();
236
+ column?.withFilterUnsafe();
183
237
  }
184
238
  if (addSorts) {
185
- column?.withSort();
239
+ column?.withSortUnsafe();
186
240
  }
187
241
  }
188
242
  return descriptor;
@@ -200,12 +254,12 @@ class AuditUtil {
200
254
  }
201
255
  const fieldPrepend = `${modelType}.`;
202
256
  if (property.propertyType === MngGuiPropertyTypeDto.Enum) {
203
- const enumType = AuditUtil.findEnumType(property);
204
- if (enumType) {
257
+ const enumModel = AuditUtil.findEnum(property);
258
+ if (enumModel) {
205
259
  if (!property.possibleEnumValues) {
206
260
  continue;
207
261
  }
208
- descriptor.addFieldLookupEnumUnsafe(fieldPrepend + property.resolvedPropertyName, enumType, property.possibleEnumValues).withDisabled();
262
+ descriptor.addFieldLookupEnum((fieldPrepend + property.resolvedPropertyName), enumModel, property.possibleEnumValues).withDisabled();
209
263
  }
210
264
  else {
211
265
  descriptor.addFieldUnsafe(fieldPrepend + property.resolvedPropertyName).withLabel(AuditUtil.getPropertyTitleKey(property, modelType));
@@ -253,8 +307,8 @@ class AuditUtil {
253
307
  return descriptor;
254
308
  }
255
309
  static buildDescriptorForEntityRevision(descriptor, revModel, entityModel) {
256
- descriptor.addColumn('revType').withTitle('MngEntityRevisionChangeState.properties.revType').asEnum(MngRevisionTypeDto).withFilter();
257
- descriptor.addFieldLookupEnum('revType', MngRevisionTypeDto).withLabel('MngEntityRevisionChangeState.properties.revType');
310
+ descriptor.addColumnEnum('revType', revisionTypeEnum).withTitle('MngEntityRevisionChangeState.properties.revType').withFilterUnsafe();
311
+ descriptor.addFieldLookupEnum('revType', revisionTypeEnum).withLabel('MngEntityRevisionChangeState.properties.revType');
258
312
  if (revModel.properties) {
259
313
  AuditUtil.addColumnsFromModel(descriptor.table, revModel.properties, 'revEntity');
260
314
  AuditUtil.addFieldsFromModel(descriptor.detailsEditor, revModel.properties, 'revEntity');
@@ -265,15 +319,31 @@ class AuditUtil {
265
319
  }
266
320
  return descriptor;
267
321
  }
268
- static findEnumType(property) {
322
+ static findEnum(property) {
269
323
  if (!property.enumClassSimpleName) {
270
324
  return undefined;
271
325
  }
272
- let enumType = TypeRegistry.get().findEnum(property.enumClassSimpleName);
326
+ let i18n = property.enumClassSimpleName;
327
+ let enumType = TypeRegistry.get().findEnum(i18n);
273
328
  if (!enumType) {
274
- enumType = TypeRegistry.get().findEnum(property.enumClassSimpleName + 'Dto');
329
+ i18n = property.enumClassSimpleName + 'Dto';
330
+ enumType = TypeRegistry.get().findEnum(i18n);
275
331
  }
276
- return enumType;
332
+ if (!enumType && Array.isArray(property.possibleEnumValues)) {
333
+ i18n = null;
334
+ enumType = property.possibleEnumValues?.reduce((acc, v) => {
335
+ const constName = v
336
+ .split('_')
337
+ .map(s => (s.length > 1 ? s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase() : s))
338
+ .join('');
339
+ if (constName !== v) {
340
+ acc[constName] = v;
341
+ }
342
+ acc[v] = constName;
343
+ return acc;
344
+ }, {});
345
+ }
346
+ return enumModelGeneric(enumType, i18n);
277
347
  }
278
348
  static extractPropertyName(fullPropertyName) {
279
349
  if (fullPropertyName?.includes('entityState.')) {
@@ -284,81 +354,13 @@ class AuditUtil {
284
354
  }
285
355
  return fullPropertyName;
286
356
  }
287
- static appendMediusQueryParamsToUrl(queryParams) {
288
- let url = `?offset=${queryParams.itemsOffset}&limit=${queryParams.itemsPerPage}`;
289
- if (queryParams.sortProperty && queryParams.sortProperty.length > 0) {
290
- url += '&sort=';
291
- const sortingQPs = [];
292
- for (let i = 0; i < queryParams.sortProperty.length; i++) {
293
- sortingQPs.push(`${queryParams.sortAsc?.[i] ?? true ? 'asc' : 'desc'}:${this.extractPropertyName(queryParams.sortProperty[i])}`);
294
- }
295
- url += sortingQPs.join(',');
296
- }
297
- if (queryParams.filterParams && queryParams.filterParams.length > 0) {
298
- const filterQPs = [];
299
- for (const mfp of queryParams.filterParams) {
300
- switch (mfp.filterMatchType) {
301
- case MediusFilterMatchType.Equals: {
302
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.Equals}:${mfp.filterValue}`);
303
- break;
304
- }
305
- case MediusFilterMatchType.NotEquals: {
306
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.NotEquals}:${mfp.filterValue}`);
307
- break;
308
- }
309
- case MediusFilterMatchType.FromTo: {
310
- if (this._dateRegex.test(mfp.filterValue)) {
311
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.Between}:${new Date(mfp.filterValue).toISOString()},${new Date(mfp.filterValueTo).toISOString()}`);
312
- }
313
- else {
314
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.Between}:${mfp.filterValue},${mfp.filterValueTo}`);
315
- }
316
- break;
317
- }
318
- case MediusFilterMatchType.Contains: {
319
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.Contains}:${mfp.filterValue}`);
320
- break;
321
- }
322
- case MediusFilterMatchType.StartsWith: {
323
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.StartsWith}:${mfp.filterValue}`);
324
- break;
325
- }
326
- case MediusFilterMatchType.EndsWith: {
327
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.EndsWith}:${mfp.filterValue}`);
328
- break;
329
- }
330
- case MediusFilterMatchType.In: {
331
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.In}:${mfp.filterValue}`);
332
- break;
333
- }
334
- case MediusFilterMatchType.NotIn: {
335
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.NotIn}:${mfp.filterValue}`);
336
- break;
337
- }
338
- case MediusFilterMatchType.SmallerThan: {
339
- if (this._dateRegex.test(mfp.filterValue)) {
340
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.LessThan}:${new Date(mfp.filterValue).toISOString()}`);
341
- }
342
- else {
343
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.LessThan}:${mfp.filterValue}`);
344
- }
345
- break;
346
- }
347
- case MediusFilterMatchType.GreaterThan: {
348
- if (this._dateRegex.test(mfp.filterValue)) {
349
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.GreaterThan}:${new Date(mfp.filterValue).toISOString()}`);
350
- }
351
- else {
352
- filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.GreaterThan}:${mfp.filterValue}`);
353
- }
354
- break;
355
- }
356
- }
357
- }
358
- url += '&';
359
- url += filterQPs.join('&');
360
- }
361
- return url;
357
+ static paramsToHttpParams(params) {
358
+ const routeParams = DataListParamsUtil.toUrlQueryParams(params, null);
359
+ let httpParams = new HttpParams();
360
+ Object.entries(routeParams).forEach(([key, value]) => {
361
+ httpParams = httpParams.append(key, value);
362
+ });
363
+ return httpParams;
362
364
  }
363
365
  static mapItemsToEntityChangesArray(fieldValue) {
364
366
  const entityChanges = [];
@@ -400,7 +402,7 @@ class AuditUtil {
400
402
  }
401
403
  }
402
404
 
403
- class MngAuditRevisionsApiService extends AMngBaseApiService {
405
+ class MngAuditRevisionsApiService extends AMngBaseObsoleteV1ApiService {
404
406
  constructor() {
405
407
  super();
406
408
  this.moduleConfig = inject(MNG_AUDIT_MODULE_CONFIG_IT);
@@ -412,20 +414,28 @@ class MngAuditRevisionsApiService extends AMngBaseApiService {
412
414
  getBasePath() {
413
415
  return `${this.configService.getConfigValue(this.moduleConfig.apiBasePathConfigKey)}`;
414
416
  }
415
- getRevisionList(queryParams) {
416
- return this.http.get(this.getUrl(AuditUtil.appendMediusQueryParamsToUrl(queryParams)));
417
+ getRevisionList(params) {
418
+ return this.http.get(this.getUrl(''), {
419
+ params: AuditUtil.paramsToHttpParams(params)
420
+ });
417
421
  }
418
422
  getAllChangesForRevision(revId) {
419
423
  return this.http.get(this.getUrl(`/changes/${revId}`));
420
424
  }
421
- listRevisionsWithStateForEntityType(queryParams, entityType) {
422
- return this.http.get(this.getUrl(`/states/${entityType}`, AuditUtil.appendMediusQueryParamsToUrl(queryParams))).pipe(map(res => ({
423
- data: this.deserializeClassArray(res.data, MngRevEntityWithStateDto),
424
- totalCount: res.totalCount
425
- })));
425
+ listRevisionsWithStateForEntityType(params, entityType) {
426
+ return this.http
427
+ .get(this.getUrl(`/states/${entityType}`), {
428
+ params: AuditUtil.paramsToHttpParams(params)
429
+ })
430
+ .pipe(map(res => {
431
+ return {
432
+ data: this.deserializeClassArray(res.data, MngRevEntityWithStateDto),
433
+ totalCount: res.totalCount
434
+ };
435
+ }));
426
436
  }
427
437
  fetchRevisionsWithStateForEntityType(entityType, revId, itemId) {
428
- return this.http.get(this.getUrl(`/states/${entityType}?rev=eq:${revId}&id=eq:${itemId}`)).pipe(map(response => this.deserializeClassArray(response, MngRevEntityWithId).map(i => {
438
+ return this.http.get(this.getUrl(`/states/${entityType}?rev=eq:${revId}&id=eq:${itemId}`)).pipe(map(res => this.deserializeClassArray(res.data, MngRevEntityWithId).map(i => {
429
439
  i.mergedId = i.revEntity?.['rev'] + '_' + i.entityState?.['id'];
430
440
  return i;
431
441
  })), map(items => {
@@ -442,91 +452,92 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
442
452
  type: Injectable
443
453
  }], ctorParameters: () => [] });
444
454
 
445
- var MngGuiEntityModelDto_1;
446
- let MngGuiEntityModelDto = class MngGuiEntityModelDto {
447
- static { MngGuiEntityModelDto_1 = this; }
448
- static { this.attributeTypeMap = [
449
- {
450
- name: 'entityName',
451
- baseName: 'entityName',
452
- type: 'string'
453
- },
454
- {
455
- name: 'properties',
456
- baseName: 'properties',
457
- type: 'Array<GuiPropertyModel>'
458
- }
459
- ]; }
460
- static getAttributeTypeMap() {
461
- return MngGuiEntityModelDto_1.attributeTypeMap;
462
- }
463
- };
464
- MngGuiEntityModelDto = MngGuiEntityModelDto_1 = __decorate([
465
- TypeName('MngGuiEntityModelDto')
466
- ], MngGuiEntityModelDto);
467
- TypeRegistry.get().registerType(MngGuiEntityModelDto);
468
-
469
- class MngAuditService extends AMngBaseApiService {
470
- constructor() {
471
- super();
472
- this.CACHE_SIZE = 1;
473
- this.moduleConfig = inject(MNG_AUDIT_MODULE_CONFIG_IT);
474
- this.configService = MngConfigurationService.get();
475
- }
476
- getServiceBasePath() {
477
- return this.moduleConfig.apiServiceBasePath ?? '';
478
- }
479
- getBasePath() {
480
- return `${this.configService.getConfigValue(this.moduleConfig.apiBasePathConfigKey)}`;
481
- }
482
- get revModel$() {
483
- if (!this.revModelObs) {
484
- this.revModelObs = this.requestRevModel().pipe(shareReplay(this.CACHE_SIZE));
485
- }
486
- return this.revModelObs;
487
- }
488
- get auditModel$() {
489
- if (!this.auditModelObs) {
490
- this.auditModelObs = this.requestAuditModel().pipe(shareReplay(this.CACHE_SIZE));
491
- }
492
- return this.auditModelObs;
493
- }
494
- requestRevModel() {
495
- return this.http.get(this.getUrl('/rev-model'));
496
- }
497
- requestAuditModel() {
498
- return this.http.get(this.getUrl('/audit-models')).pipe(map(response => this.deserializeClassArray(response, MngGuiEntityModelDto)));
499
- }
500
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
501
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditService }); }
502
- }
503
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditService, decorators: [{
504
- type: Injectable
505
- }], ctorParameters: () => [] });
506
-
507
- class MngAuditPageComponent {
508
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
509
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: MngAuditPageComponent, isStandalone: true, selector: "mng-audit-page", ngImport: i0, template: "<router-outlet></router-outlet>\n", dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] }); }
510
- }
511
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditPageComponent, decorators: [{
512
- type: Component,
513
- args: [{ standalone: true, selector: 'mng-audit-page', imports: [RouterOutlet], template: "<router-outlet></router-outlet>\n" }]
514
- }] });
515
-
516
455
  let MngGuiEntityModelWithI18n = class MngGuiEntityModelWithI18n extends MngGuiEntityModelDto {
517
456
  };
518
457
  MngGuiEntityModelWithI18n = __decorate([
519
458
  TypeName('MngGuiEntityModelWithI18n')
520
459
  ], MngGuiEntityModelWithI18n);
521
460
 
522
- class MngAuditEntityRevisionsPageComponent extends AMngTableviewRouteComponent {
523
- constructor(router) {
524
- super();
525
- this.router = router;
526
- this.destroyRef = inject(DestroyRef);
461
+ class MngAuditEntityRevisionsPageComponent {
462
+ constructor() {
463
+ this.router = inject(Router);
464
+ this.route = inject(ActivatedRoute);
465
+ this.translate = inject(TranslateService);
527
466
  this.auditService = inject(MngAuditService);
528
- this.revisionsApiService = inject(MngAuditRevisionsApiService);
529
- this.showTableview = signal(false);
467
+ this.revModel = toSignal(this.auditService.revModel$);
468
+ this.auditModel = toSignal(this.auditService.auditModel$);
469
+ this.entityClass = toSignal(this.route.paramMap.pipe(map(pm => pm.get('entityClass') ?? undefined)));
470
+ this.selectedRevisionEntity = computed(() => {
471
+ const entities = this.auditModel();
472
+ const entityClass = this.entityClass();
473
+ if (entityClass && entities) {
474
+ for (const e of entities) {
475
+ if (e.entityName === entityClass) {
476
+ return e;
477
+ }
478
+ }
479
+ }
480
+ return undefined;
481
+ });
482
+ this.descriptor = computed(() => {
483
+ const revModel = this.revModel();
484
+ const selectedRevisionEntity = this.selectedRevisionEntity();
485
+ if (!revModel || !selectedRevisionEntity?.entityName) {
486
+ return undefined;
487
+ }
488
+ const desc = TableviewDescriptor.fromClass(MngRevEntityWithId, 'mergedId', undefined, selectedRevisionEntity.entityName);
489
+ AuditUtil.buildDescriptorForEntityRevision(desc, revModel, selectedRevisionEntity);
490
+ desc.table.withColumnsResizable();
491
+ desc.table.withCurrentColumnsReorderable();
492
+ desc.table.withCurrentColumnsToggleable();
493
+ return desc;
494
+ });
495
+ this.dataProvider = computed(() => {
496
+ const revModel = this.revModel();
497
+ const selectedRevisionEntity = this.selectedRevisionEntity();
498
+ if (!revModel || !selectedRevisionEntity?.entityName) {
499
+ return undefined;
500
+ }
501
+ const entityName = selectedRevisionEntity.entityName;
502
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
503
+ return TableviewDataProvider.fromClassWithService(MngRevEntityWithId, MngAuditRevisionsApiService).withGetAll((params, service) => selectedRevisionEntity.entityName
504
+ ? service.listRevisionsWithStateForEntityType(params, entityName).pipe(map(res => {
505
+ const revEntityWithStateAndIdList = [];
506
+ for (const revEntityWithState of res.data) {
507
+ const revEntityWithStateAndId = new MngRevEntityWithId();
508
+ revEntityWithStateAndId.mergedId = revEntityWithState.revEntity?.['rev'] + '_' + revEntityWithState.entityState?.['id'];
509
+ revEntityWithStateAndId.revType = revEntityWithState.revType;
510
+ revEntityWithStateAndId.revEntity = revEntityWithState.revEntity;
511
+ revEntityWithStateAndId.entityState = revEntityWithState.entityState;
512
+ revEntityWithStateAndId.entityClassName = revEntityWithState.entityClassName;
513
+ revEntityWithStateAndIdList.push(revEntityWithStateAndId);
514
+ }
515
+ return { data: revEntityWithStateAndIdList, totalCount: res.totalCount };
516
+ }))
517
+ : throwError(() => new MngInternalError('No revision entity is provided for list.')));
518
+ });
519
+ this.actions = computed(() => {
520
+ const selectedRevisionEntity = this.selectedRevisionEntity();
521
+ const descriptor = this.descriptor();
522
+ if (!selectedRevisionEntity?.entityName || !descriptor) {
523
+ return [];
524
+ }
525
+ const entityName = selectedRevisionEntity.entityName;
526
+ const detailsAction = ActionEditorDetailsDescriptor.createWithProvider(descriptor.detailsEditor, MngAuditRevisionsApiService)
527
+ .withFetchFunction(ctx => {
528
+ if (!entityName) {
529
+ return throwError(() => new MngInternalError('No revision entity is provided for details.'));
530
+ }
531
+ if (!ctx.parameters.itemId) {
532
+ return throwError(() => new MngInternalError('No item id for revision entity details is provided.'));
533
+ }
534
+ const revId = ctx.parameters.itemId.toString().split('_')[0];
535
+ const itemId = ctx.parameters.itemId.toString().split('_')[1];
536
+ return ctx.serviceInstance.fetchRevisionsWithStateForEntityType(entityName, revId, itemId);
537
+ })
538
+ .withEditorTitle('pages.entityRevisions.actions.details.editor.title');
539
+ return [detailsAction];
540
+ });
530
541
  this.revisionEntitiesLookupProvider = LookupDataProvider.fromClass(MngGuiEntityModelWithI18n).withLookup(() => this.auditService.auditModel$.pipe(map(model => {
531
542
  const modelI18n = model;
532
543
  modelI18n.sort((m1, m2) => {
@@ -541,97 +552,37 @@ class MngAuditEntityRevisionsPageComponent extends AMngTableviewRouteComponent {
541
552
  }
542
553
  });
543
554
  modelI18n.forEach(item => {
544
- const translatedEntityName = this.translateService.instant('AuditEntities.' + item.entityName);
555
+ const translatedEntityName = this.translate.instant('AuditEntities.' + item.entityName);
545
556
  item.entityNameI18n = translatedEntityName.includes('AuditEntities.') ? item.entityName : translatedEntityName;
546
557
  });
547
558
  return modelI18n;
548
559
  })));
549
- }
550
- ngOnInit() {
551
- this.route.paramMap.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(params => {
552
- const entityClass = params.get('entityClass');
553
- if (entityClass) {
554
- combineLatest([this.auditService.auditModel$, this.auditService.revModel$]).subscribe(([entities, revModel]) => {
555
- this.revModel = revModel;
556
- for (const e of entities) {
557
- if (e.entityName === entityClass) {
558
- this.selectedRevisionEntity = e;
559
- super.ngOnInit();
560
- setTimeout(() => this.showTableview.set(true));
561
- }
562
- }
560
+ this.showTableview = signal(false);
561
+ effect(() => {
562
+ const descriptor = this.descriptor();
563
+ if (descriptor) {
564
+ setTimeout(() => {
565
+ this.showTableview.set(true);
563
566
  });
564
567
  }
565
- });
568
+ }, { allowSignalWrites: true });
566
569
  }
567
- onRevisionEntityChange() {
570
+ onRevisionEntityChange(value) {
568
571
  this.showTableview.set(false);
569
- if (this.selectedRevisionEntity) {
570
- this.router.navigate(['/audit/entity-revisions/' + this.selectedRevisionEntity.entityName]);
572
+ if (value) {
573
+ this.router.navigate(['/audit/entity-revisions/' + value.entityName]);
571
574
  }
572
575
  else {
573
576
  this.router.navigate(['/audit/entity-revisions/']);
574
577
  }
575
578
  }
576
- createTableviewDescriptor() {
577
- if (!this.revModel || !this.selectedRevisionEntity?.entityName) {
578
- throw new MngInternalError('No revision model or revision entity is provided for tableview.');
579
- }
580
- const desc = TableviewDescriptor.fromClass(MngRevEntityWithId, 'mergedId', undefined, this.selectedRevisionEntity.entityName);
581
- AuditUtil.buildDescriptorForEntityRevision(desc, this.revModel, this.selectedRevisionEntity);
582
- desc.table.withColumnsResizable();
583
- desc.table.withCurrentColumnsReorderable();
584
- desc.table.withCurrentColumnsToggleable();
585
- return desc;
586
- }
587
- createTableviewDataProvider() {
588
- if (!this.revModel || !this.selectedRevisionEntity?.entityName) {
589
- throw new MngInternalError('No revision model or revision entity is provided for tableview.');
590
- }
591
- const entityName = this.selectedRevisionEntity.entityName;
592
- return TableviewDataProvider.fromClass(MngRevEntityWithId).withGetAll(qp => this.selectedRevisionEntity?.entityName
593
- ? this.revisionsApiService.listRevisionsWithStateForEntityType(qp, entityName).pipe(map(res => {
594
- const revEntityWithStateAndIdList = [];
595
- for (const revEntityWithState of res.data) {
596
- const revEntityWithStateAndId = new MngRevEntityWithId();
597
- revEntityWithStateAndId.mergedId = revEntityWithState.revEntity?.['rev'] + '_' + revEntityWithState.entityState?.['id'];
598
- revEntityWithStateAndId.revType = revEntityWithState.revType;
599
- revEntityWithStateAndId.revEntity = revEntityWithState.revEntity;
600
- revEntityWithStateAndId.entityState = revEntityWithState.entityState;
601
- revEntityWithStateAndId.entityClassName = revEntityWithState.entityClassName;
602
- revEntityWithStateAndIdList.push(revEntityWithStateAndId);
603
- }
604
- return MediusQueryResult.fromArray(revEntityWithStateAndIdList, res.totalCount);
605
- }))
606
- : throwError(() => new MngInternalError('No revision entity is provided for list.')));
607
- }
608
- createActionDescriptors() {
609
- if (!this.revModel || !this.selectedRevisionEntity?.entityName) {
610
- throw new MngInternalError('No revision model or revision entity is provided for tableview.');
611
- }
612
- const entityName = this.selectedRevisionEntity.entityName;
613
- const detailsAction = ActionEditorDetailsDescriptor.create(this.descriptor.detailsEditor)
614
- .withFetchFunction(ctx => {
615
- if (!entityName) {
616
- return throwError(() => new MngInternalError('No revision entity is provided for details.'));
617
- }
618
- if (!ctx.parameters.itemId) {
619
- return throwError(() => new MngInternalError('No item id for revision entity details is provided.'));
620
- }
621
- const revId = ctx.parameters.itemId.toString().split('_')[0];
622
- const itemId = ctx.parameters.itemId.toString().split('_')[1];
623
- return this.revisionsApiService.fetchRevisionsWithStateForEntityType(entityName, revId, itemId);
624
- })
625
- .withEditorTitle('pages.entityRevisions.actions.details.editor.title');
626
- return [detailsAction];
627
- }
628
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditEntityRevisionsPageComponent, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component }); }
629
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: MngAuditEntityRevisionsPageComponent, isStandalone: true, selector: "mng-audit-entity-revisions-page", usesInheritance: true, ngImport: i0, template: "<div class=\"card\">\n <div class=\"field mb-0\">\n <mng-dropdown\n id=\"revisionEntityDropdown\"\n [placeholder]=\"'pages.entityRevisions.dropdown.placeholder' | translate\"\n optionsLabelProperty=\"entityNameI18n\"\n [(ngModel)]=\"selectedRevisionEntity\"\n (valueChange)=\"onRevisionEntityChange()\"\n [dataProvider]=\"revisionEntitiesLookupProvider\"></mng-dropdown>\n @if (!selectedRevisionEntity) {\n <small class=\"block\">\n {{ 'pages.entityRevisions.dropdown.helpText' | translate }}\n </small>\n }\n </div>\n</div>\n@if (showTableview()) {\n <mng-tableview-route [descriptor]=\"descriptor\" [dataProvider]=\"dataProvider\" [actions]=\"actions\"></mng-tableview-route>\n}\n", dependencies: [{ kind: "component", type: MngDropdownComponent, selector: "mng-dropdown", inputs: ["dataProvider", "optionsTrackProperty", "optionsLabelProperty", "optionsLabelTranslate", "optionsValueProperty", "optionsDisabledProperty", "multiselect", "placeholder", "showClear", "selectFirstItem", "className", "dropdownClassName", "changeValueOnBlur"], outputs: ["valueChange"] }, { kind: "component", type: MngTableviewRouteComponent, selector: "mng-tableview-route", inputs: ["descriptor", "dataProvider", "actions"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: FormlyModule }] }); }
579
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditEntityRevisionsPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
580
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: MngAuditEntityRevisionsPageComponent, isStandalone: true, selector: "mng-audit-entity-revisions-page", providers: [MngAuditRevisionsApiService], ngImport: i0, template: "<div class=\"card\">\n <div class=\"field mb-0\">\n <mng-dropdown\n id=\"revisionEntityDropdown\"\n [placeholder]=\"'pages.entityRevisions.dropdown.placeholder' | translate\"\n optionsLabelProperty=\"entityNameI18n\"\n [ngModel]=\"selectedRevisionEntity()\"\n (valueChange)=\"onRevisionEntityChange($event)\"\n [dataProvider]=\"revisionEntitiesLookupProvider\"\n [showClear]=\"true\"></mng-dropdown>\n @if (!selectedRevisionEntity()) {\n <small class=\"block\">\n {{ 'pages.entityRevisions.dropdown.helpText' | translate }}\n </small>\n }\n </div>\n</div>\n@if (showTableview() && descriptor()) {\n <mng-tableview [descriptor]=\"descriptor()!\" [dataProvider]=\"dataProvider()\" [actions]=\"actions()\"></mng-tableview>\n}\n", dependencies: [{ kind: "component", type: MngDropdownComponent, selector: "mng-dropdown", inputs: ["dataProvider", "optionsTrackProperty", "optionsLabelProperty", "optionsLabelTranslate", "optionsValueProperty", "optionsDisabledProperty", "multiselect", "placeholder", "showClear", "selectFirstItem", "className", "dropdownClassName", "changeValueOnBlur"], outputs: ["valueChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: FormlyModule }, { kind: "component", type: MngTableviewComponent, selector: "mng-tableview", inputs: ["descriptor", "dataProvider", "actions"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
630
581
  }
631
582
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditEntityRevisionsPageComponent, decorators: [{
632
583
  type: Component,
633
- args: [{ standalone: true, selector: 'mng-audit-entity-revisions-page', imports: [MngDropdownComponent, MngTableviewRouteComponent, FormsModule, AsyncPipe, TranslateModule, FormlyModule], template: "<div class=\"card\">\n <div class=\"field mb-0\">\n <mng-dropdown\n id=\"revisionEntityDropdown\"\n [placeholder]=\"'pages.entityRevisions.dropdown.placeholder' | translate\"\n optionsLabelProperty=\"entityNameI18n\"\n [(ngModel)]=\"selectedRevisionEntity\"\n (valueChange)=\"onRevisionEntityChange()\"\n [dataProvider]=\"revisionEntitiesLookupProvider\"></mng-dropdown>\n @if (!selectedRevisionEntity) {\n <small class=\"block\">\n {{ 'pages.entityRevisions.dropdown.helpText' | translate }}\n </small>\n }\n </div>\n</div>\n@if (showTableview()) {\n <mng-tableview-route [descriptor]=\"descriptor\" [dataProvider]=\"dataProvider\" [actions]=\"actions\"></mng-tableview-route>\n}\n" }]
634
- }], ctorParameters: () => [{ type: i1.Router }] });
584
+ args: [{ standalone: true, selector: 'mng-audit-entity-revisions-page', imports: [MngDropdownComponent, MngTableviewRouteComponent, FormsModule, AsyncPipe, TranslateModule, FormlyModule, MngTableviewComponent], providers: [MngAuditRevisionsApiService], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"card\">\n <div class=\"field mb-0\">\n <mng-dropdown\n id=\"revisionEntityDropdown\"\n [placeholder]=\"'pages.entityRevisions.dropdown.placeholder' | translate\"\n optionsLabelProperty=\"entityNameI18n\"\n [ngModel]=\"selectedRevisionEntity()\"\n (valueChange)=\"onRevisionEntityChange($event)\"\n [dataProvider]=\"revisionEntitiesLookupProvider\"\n [showClear]=\"true\"></mng-dropdown>\n @if (!selectedRevisionEntity()) {\n <small class=\"block\">\n {{ 'pages.entityRevisions.dropdown.helpText' | translate }}\n </small>\n }\n </div>\n</div>\n@if (showTableview() && descriptor()) {\n <mng-tableview [descriptor]=\"descriptor()!\" [dataProvider]=\"dataProvider()\" [actions]=\"actions()\"></mng-tableview>\n}\n" }]
585
+ }], ctorParameters: () => [] });
635
586
 
636
587
  var MngRevEntityWithChangesDto_1;
637
588
  let MngRevEntityWithChangesDto = class MngRevEntityWithChangesDto {
@@ -709,7 +660,7 @@ class EntityChangesFieldComponent extends AMngFormlyCustomFieldComponent {
709
660
  if (guiEntityModel.entityName) {
710
661
  desc.withTitle(guiEntityModel.entityName);
711
662
  }
712
- desc.addColumn('revType').withTitle('MngEntityRevisionChangeState.properties.revType').asEnum(MngRevisionTypeDto);
663
+ desc.addColumnEnum('revType', revisionTypeEnum).withTitle('MngEntityRevisionChangeState.properties.revType');
713
664
  if (guiEntityModel.properties) {
714
665
  AuditUtil.addColumnsFromModel(desc, guiEntityModel.properties, undefined, false, false);
715
666
  }
@@ -726,83 +677,71 @@ class EntityChangesFieldComponent extends AMngFormlyCustomFieldComponent {
726
677
  return desc;
727
678
  }
728
679
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: EntityChangesFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
729
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: EntityChangesFieldComponent, isStandalone: true, selector: "mng-entity-changes-field", inputs: { injector: "injector" }, usesInheritance: true, ngImport: i0, template: "@if (modelFetched | async) {\n <div>\n @for (ec of entityChanges; track ec) {\n <mng-table [items]=\"ec.items\" [descriptor]=\"createDescriptor(ec)\"></mng-table>\n }\n </div>\n} @else {\n <div class=\"text-center\">\n <i class=\"pi pi-spin pi-spinner\" style=\"font-size: 2rem\"></i>\n </div>\n}\n", styles: ["::ng-deep tr.audit-row-deleted{background:#ff3d331a!important}::ng-deep tr.audit-row-deleted .audit-cell{background:#f6544c4d!important}::ng-deep tr.audit-row-added{background-color:#1bc5621a!important}::ng-deep tr.audit-row-added .audit-cell{background:#1bc5624d!important}\n"], dependencies: [{ kind: "component", type: MngTableComponent, selector: "mng-table", inputs: ["descriptor", "items", "queryResult", "loading", "dataProvider", "useQueryParams", "selectionMode", "selectionEnabled", "columnLastMinWidth", "captionComponent", "columnCustomLastComponent", "globalFilterFields"], outputs: ["tableLoad", "cellClick", "selectionChange", "captionComponentInstance", "columnCustomLastComponentInstance"] }, { kind: "pipe", type: AsyncPipe, name: "async" }] }); }
680
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: EntityChangesFieldComponent, isStandalone: true, selector: "mng-entity-changes-field", inputs: { injector: "injector" }, usesInheritance: true, ngImport: i0, template: "@if (modelFetched | async) {\n <div>\n @for (ec of entityChanges; track ec) {\n <mng-table [items]=\"ec.items\" [descriptor]=\"createDescriptor(ec)\"></mng-table>\n }\n </div>\n} @else {\n <div class=\"text-center\">\n <i class=\"pi pi-spin pi-spinner\" style=\"font-size: 2rem\"></i>\n </div>\n}\n", styles: ["::ng-deep tr.audit-row-deleted{background:#ff3d331a!important}::ng-deep tr.audit-row-deleted .audit-cell{background:#f6544c4d!important}::ng-deep tr.audit-row-added{background-color:#1bc5621a!important}::ng-deep tr.audit-row-added .audit-cell{background:#1bc5624d!important}\n"], dependencies: [{ kind: "component", type: MngTableComponent, selector: "mng-table", inputs: ["descriptor", "items", "result", "loading", "dataProvider", "useQueryParams", "selectionMode", "selectionEnabled", "columnLastMinWidth", "captionComponent", "columnCustomLastComponent", "globalFilterFields"], outputs: ["tableLoad", "cellClick", "selectionChange", "captionComponentInstance", "columnCustomLastComponentInstance"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
730
681
  }
731
682
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: EntityChangesFieldComponent, decorators: [{
732
683
  type: Component,
733
- args: [{ standalone: true, selector: 'mng-entity-changes-field', imports: [MngTableComponent, AsyncPipe], template: "@if (modelFetched | async) {\n <div>\n @for (ec of entityChanges; track ec) {\n <mng-table [items]=\"ec.items\" [descriptor]=\"createDescriptor(ec)\"></mng-table>\n }\n </div>\n} @else {\n <div class=\"text-center\">\n <i class=\"pi pi-spin pi-spinner\" style=\"font-size: 2rem\"></i>\n </div>\n}\n", styles: ["::ng-deep tr.audit-row-deleted{background:#ff3d331a!important}::ng-deep tr.audit-row-deleted .audit-cell{background:#f6544c4d!important}::ng-deep tr.audit-row-added{background-color:#1bc5621a!important}::ng-deep tr.audit-row-added .audit-cell{background:#1bc5624d!important}\n"] }]
684
+ args: [{ standalone: true, selector: 'mng-entity-changes-field', imports: [MngTableComponent, AsyncPipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (modelFetched | async) {\n <div>\n @for (ec of entityChanges; track ec) {\n <mng-table [items]=\"ec.items\" [descriptor]=\"createDescriptor(ec)\"></mng-table>\n }\n </div>\n} @else {\n <div class=\"text-center\">\n <i class=\"pi pi-spin pi-spinner\" style=\"font-size: 2rem\"></i>\n </div>\n}\n", styles: ["::ng-deep tr.audit-row-deleted{background:#ff3d331a!important}::ng-deep tr.audit-row-deleted .audit-cell{background:#f6544c4d!important}::ng-deep tr.audit-row-added{background-color:#1bc5621a!important}::ng-deep tr.audit-row-added .audit-cell{background:#1bc5624d!important}\n"] }]
734
685
  }], propDecorators: { injector: [{
735
686
  type: Input
736
687
  }] } });
737
688
 
738
- class MngAuditRevisionsPageComponent extends AMngTableviewRouteComponent {
689
+ class MngAuditRevisionsPageComponent {
739
690
  constructor() {
740
- super(...arguments);
741
- this.destroyRef = inject(DestroyRef);
742
691
  this.injector = inject(Injector);
743
692
  this.auditService = inject(MngAuditService);
744
- this.revisisonsApiService = inject(MngAuditRevisionsApiService);
745
- this.showTableview = signal(false);
746
- }
747
- ngOnInit() {
748
- this.auditService.revModel$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
749
- next: model => {
750
- this.revModel = model;
751
- super.ngOnInit();
752
- setTimeout(() => this.showTableview.set(true));
693
+ this.revModel = toSignal(this.auditService.revModel$);
694
+ this.showTableview = computed(() => this.revModel() != null);
695
+ this.descriptor = computed(() => {
696
+ const revModel = this.revModel();
697
+ if (revModel) {
698
+ const idProperty = revModel.properties?.filter(prop => prop.isId).map(prop => prop.resolvedPropertyName)[0];
699
+ const model = ModelDescriptor.fromClass(MngRevEntity);
700
+ if (revModel.entityName)
701
+ model.withI18nBase(revModel.entityName);
702
+ if (idProperty)
703
+ model.withIdPropertyUnsafe(idProperty);
704
+ const desc = TableviewDescriptor.fromModel(model);
705
+ const detailsDescriptor = EditorDescriptor.fromClass(MngRevEntityWithChangesDto, undefined, undefined, undefined, TableviewEditorTypeEnum.Details);
706
+ detailsDescriptor.model.withIdPropertyUnsafe('revEntity.' + idProperty);
707
+ if (revModel.properties) {
708
+ AuditUtil.addColumnsFromModel(desc.table, revModel.properties);
709
+ AuditUtil.addFieldsFromModel(detailsDescriptor, revModel.properties);
710
+ }
711
+ detailsDescriptor
712
+ .addField('entityNameChangesMap')
713
+ .asCustomComponent(EntityChangesFieldComponent, {
714
+ fieldWrappers: ['field-no-label'],
715
+ inputs: { injector: this.injector }
716
+ })
717
+ .withDisabled();
718
+ desc.withDetailsDescriptor(detailsDescriptor); // MngRevEntity is extended by MngRevEntityWithChangesDto, so no real harm here
719
+ return desc;
753
720
  }
721
+ return TableviewDescriptor.fromClass(MngRevEntity);
722
+ });
723
+ this.dataProvider = signal(TableviewDataProvider.fromClassWithService(MngRevEntity, MngAuditRevisionsApiService).withGetAll((params, service) => service.getRevisionList(params).pipe(map(res => ({ data: res.data, totalCount: res.totalCount })))));
724
+ this.actions = computed(() => {
725
+ console.log(this.descriptor());
726
+ const detailsAction = ActionEditorDetailsDescriptor.createWithProvider(this.descriptor().detailsEditor, MngAuditRevisionsApiService).withFetchFunction(ctx => {
727
+ console.log(ctx);
728
+ return ctx.serviceInstance.getAllChangesForRevision(itemIdToDefined(ctx.parameters.itemId)).pipe(map(item => {
729
+ const revEntityWithChanges = new MngRevEntityDetailed();
730
+ revEntityWithChanges.rev = ctx.parameters.itemId;
731
+ revEntityWithChanges.revEntity = item.revEntity;
732
+ revEntityWithChanges.entityNameChangesMap = item.entityNameChangesMap;
733
+ return revEntityWithChanges;
734
+ }));
735
+ });
736
+ return [detailsAction];
754
737
  });
755
738
  }
756
- createTableviewDescriptor() {
757
- if (this.revModel) {
758
- const idProperty = this.revModel.properties?.filter(prop => prop.isId).map(prop => prop.resolvedPropertyName)[0];
759
- const model = ModelDescriptor.fromClass(MngRevEntity);
760
- if (this.revModel.entityName)
761
- model.withI18nBase(this.revModel.entityName);
762
- if (idProperty)
763
- model.withIdPropertyUnsafe(idProperty);
764
- const desc = TableviewDescriptor.fromModel(model);
765
- const detailsDescriptor = EditorDescriptor.fromClass(MngRevEntityWithChangesDto, undefined, undefined, undefined, TableviewEditorTypeEnum.Details);
766
- detailsDescriptor.model.withIdPropertyUnsafe('revEntity.' + idProperty);
767
- if (this.revModel.properties) {
768
- AuditUtil.addColumnsFromModel(desc.table, this.revModel.properties);
769
- AuditUtil.addFieldsFromModel(detailsDescriptor, this.revModel.properties);
770
- }
771
- detailsDescriptor
772
- .addField('entityNameChangesMap')
773
- .asCustomComponent(EntityChangesFieldComponent, {
774
- fieldWrappers: ['field-no-label'],
775
- inputs: { injector: this.injector }
776
- })
777
- .withDisabled();
778
- desc.withDetailsDescriptor(detailsDescriptor); // MngRevEntity is extended by MngRevEntityWithChangesDto, so no real harm here
779
- desc.table.withFilterDisplay(TableFilterDisplayEnum.Row);
780
- return desc;
781
- }
782
- return TableviewDescriptor.fromClass(MngRevEntity);
783
- }
784
- createTableviewDataProvider() {
785
- if (this.revModel) {
786
- return TableviewDataProvider.fromClass(MngRevEntity).withGetAll(qp => this.revisisonsApiService.getRevisionList(qp).pipe(map(res => MediusQueryResult.fromArray(res.data, res.totalCount))));
787
- }
788
- return TableviewDataProvider.fromClass(MngRevEntity);
789
- }
790
- createActionDescriptors() {
791
- const detailsAction = ActionEditorDetailsDescriptor.create(this.descriptor.detailsEditor).withFetchFunction(ctx => this.revisisonsApiService.getAllChangesForRevision(itemIdToDefined(ctx.parameters.itemId)).pipe(map(item => {
792
- const revEntityWithChanges = new MngRevEntityDetailed();
793
- revEntityWithChanges.rev = ctx.parameters.itemId;
794
- revEntityWithChanges.revEntity = item.revEntity;
795
- revEntityWithChanges.entityNameChangesMap = item.entityNameChangesMap;
796
- return revEntityWithChanges;
797
- })));
798
- return [detailsAction];
799
- }
800
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditRevisionsPageComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
801
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: MngAuditRevisionsPageComponent, isStandalone: true, selector: "mng-audit-revisions-page", usesInheritance: true, ngImport: i0, template: "@if (showTableview()) {\n <mng-tableview-route [descriptor]=\"descriptor\" [dataProvider]=\"dataProvider\" [actions]=\"actions\"></mng-tableview-route>\n}\n", dependencies: [{ kind: "component", type: MngTableviewRouteComponent, selector: "mng-tableview-route", inputs: ["descriptor", "dataProvider", "actions"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
739
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditRevisionsPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
740
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: MngAuditRevisionsPageComponent, isStandalone: true, selector: "mng-audit-revisions-page", providers: [MngAuditRevisionsApiService], ngImport: i0, template: "@if (showTableview()) {\n <mng-tableview [descriptor]=\"descriptor()\" [dataProvider]=\"dataProvider()\" [actions]=\"actions()\"></mng-tableview>\n}\n", dependencies: [{ kind: "component", type: MngTableviewComponent, selector: "mng-tableview", inputs: ["descriptor", "dataProvider", "actions"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
802
741
  }
803
742
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditRevisionsPageComponent, decorators: [{
804
743
  type: Component,
805
- args: [{ standalone: true, selector: 'mng-audit-revisions-page', imports: [MngTableviewComponent, AsyncPipe, MngTableviewComponent, RouterOutlet, JsonPipe, MngTableviewRouteComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (showTableview()) {\n <mng-tableview-route [descriptor]=\"descriptor\" [dataProvider]=\"dataProvider\" [actions]=\"actions\"></mng-tableview-route>\n}\n" }]
744
+ args: [{ standalone: true, selector: 'mng-audit-revisions-page', imports: [MngTableviewComponent, AsyncPipe, RouterOutlet, JsonPipe], providers: [MngAuditRevisionsApiService], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (showTableview()) {\n <mng-tableview [descriptor]=\"descriptor()\" [dataProvider]=\"dataProvider()\" [actions]=\"actions()\"></mng-tableview>\n}\n" }]
806
745
  }] });
807
746
 
808
747
  /**
@@ -813,8 +752,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
813
752
  function provideMngAuditRoutes(config, routeConfig) {
814
753
  const routeBuilder = RouteBuilder.create('', config.rootPageComponent ?? MngAuditPageComponent)
815
754
  .withProvider(MngAuditService)
816
- .withProvider(MngAuditService)
817
- .withProvider(MngAuditRevisionsApiService)
818
755
  .withProvider({
819
756
  provide: MNG_AUDIT_MODULE_CONFIG_IT,
820
757
  useValue: config