@rosoftlab/core 1.0.5-alpha-5 → 1.0.5-alpha-6

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,8 +1,11 @@
1
+ import * as i1$1 from '@angular/common/http';
2
+ import { HttpResponse, HttpHeaders, HttpParams, HttpClient, HttpClientModule } from '@angular/common/http';
1
3
  import * as i0 from '@angular/core';
2
- import { Injectable, InjectionToken, inject, Input, Component, HostBinding, Directive, Inject, Pipe, NgModule } from '@angular/core';
4
+ import { InjectionToken, Optional, Inject, Injectable, inject, Input, Component, HostBinding, Directive, Pipe, NgModule } from '@angular/core';
3
5
  import * as i1 from 'oidc-client-ts';
4
- import { UserManager } from 'oidc-client-ts';
5
- import { BehaviorSubject, Observable, throwError, of, ReplaySubject } from 'rxjs';
6
+ import { User as User$1, UserManager } from 'oidc-client-ts';
7
+ import { BehaviorSubject, firstValueFrom, Observable, of, throwError, ReplaySubject } from 'rxjs';
8
+ import { map, tap, catchError, filter } from 'rxjs/operators';
6
9
  import * as i5 from '@angular/common';
7
10
  import { Location, DatePipe, DecimalPipe, PercentPipe, CommonModule } from '@angular/common';
8
11
  import * as i1$2 from '@angular/forms';
@@ -11,17 +14,21 @@ import * as i2 from '@angular/router';
11
14
  import { Router, ActivatedRoute, UrlSegment, NavigationEnd } from '@angular/router';
12
15
  import * as i1$3 from '@ngx-translate/core';
13
16
  import { TranslateService, TranslateModule, TranslateLoader } from '@ngx-translate/core';
14
- import * as i1$1 from '@angular/common/http';
15
- import { HttpHeaders, HttpParams, HttpResponse, HttpClient, HttpClientModule } from '@angular/common/http';
17
+ import { parseISO } from 'date-fns';
16
18
  import { compare } from 'fast-json-patch';
17
19
  import queryString from 'query-string';
18
- import { map, catchError, tap, filter } from 'rxjs/operators';
19
- import { parseISO } from 'date-fns';
20
20
  import { __decorate, __metadata } from 'tslib';
21
21
 
22
+ class Tokens {
23
+ }
24
+ const OIDC_CLIENT_SETTINGS = new InjectionToken('OIDC_CLIENT_SETTINGS');
25
+ const OIDC_GUEST_CLIENT_SETTINGS = new InjectionToken('OIDC_GUEST_CLIENT_SETTINGS');
26
+
22
27
  class AuthService {
23
- constructor(manager) {
28
+ constructor(manager, http, guestSettings) {
24
29
  this.manager = manager;
30
+ this.http = http;
31
+ this.guestSettings = guestSettings;
25
32
  // Observable navItem source
26
33
  this._authNavStatusSource = new BehaviorSubject(false);
27
34
  // Observable navItem stream
@@ -93,17 +100,58 @@ class AuthService {
93
100
  async signout() {
94
101
  await this.manager.signoutRedirect();
95
102
  }
96
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: AuthService, deps: [{ token: i1.UserManager }], target: i0.ɵɵFactoryTarget.Injectable }); }
103
+ async loginWithGuest() {
104
+ const token = localStorage.getItem('guest_token');
105
+ if (!token) {
106
+ throw new Error('No guest token found in local storage');
107
+ }
108
+ const authUrlToUse = this.guestSettings?.authority || this.manager.settings.authority;
109
+ const body = new URLSearchParams();
110
+ body.set('grant_type', 'guest');
111
+ body.set('guest_token', token);
112
+ body.set('client_id', this.guestSettings?.client_id || this.manager.settings.client_id);
113
+ body.set('scope', this.guestSettings?.scope || 'openid profile offline_access');
114
+ await firstValueFrom(this.http.post(`${authUrlToUse}/connect/token`, body.toString(), {
115
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
116
+ }).pipe(map((response) => {
117
+ if (!response.access_token) {
118
+ throw new Error('Login failed');
119
+ }
120
+ const expires_at = response.expires_in ? Math.floor(Date.now() / 1000) + response.expires_in : 0;
121
+ const user = new User$1({
122
+ id_token: response.id_token || '',
123
+ session_state: null,
124
+ access_token: response.access_token,
125
+ refresh_token: response.refresh_token || '',
126
+ token_type: response.token_type || 'Bearer',
127
+ scope: response.scope || '',
128
+ profile: {
129
+ sub: 'guest', // Dummy sub for guest
130
+ iss: authUrlToUse,
131
+ aud: this.manager.settings.client_id,
132
+ exp: expires_at,
133
+ iat: Math.floor(Date.now() / 1000)
134
+ }, // Cast to any to avoid strict typing
135
+ expires_at: expires_at,
136
+ userState: null
137
+ });
138
+ this.manager.storeUser(user);
139
+ this.user = user;
140
+ this._authNavStatusSource.next(this.isAuthenticated());
141
+ })));
142
+ }
143
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: AuthService, deps: [{ token: i1.UserManager }, { token: i1$1.HttpClient }, { token: OIDC_GUEST_CLIENT_SETTINGS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
97
144
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: AuthService, providedIn: 'root' }); }
98
145
  }
99
146
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: AuthService, decorators: [{
100
147
  type: Injectable,
101
148
  args: [{ providedIn: 'root' }]
102
- }], ctorParameters: () => [{ type: i1.UserManager }] });
103
-
104
- class Tokens {
105
- }
106
- const OIDC_CLIENT_SETTINGS = new InjectionToken('OIDC_CLIENT_SETTINGS');
149
+ }], ctorParameters: () => [{ type: i1.UserManager }, { type: i1$1.HttpClient }, { type: undefined, decorators: [{
150
+ type: Optional
151
+ }, {
152
+ type: Inject,
153
+ args: [OIDC_GUEST_CLIENT_SETTINGS]
154
+ }] }] });
107
155
 
108
156
  // library/src/lib/auth/user-manager.factory.ts
109
157
  function provideOidcUserManager() {
@@ -113,10 +161,11 @@ function provideOidcUserManager() {
113
161
  };
114
162
  }
115
163
 
116
- function provideAuth(settings) {
164
+ function provideAuth(settings, guest_settings) {
117
165
  return [
118
166
  { provide: OIDC_CLIENT_SETTINGS, useValue: settings },
119
- provideOidcUserManager(),
167
+ { provide: OIDC_GUEST_CLIENT_SETTINGS, useValue: guest_settings },
168
+ provideOidcUserManager()
120
169
  ];
121
170
  }
122
171
 
@@ -296,1143 +345,1224 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
296
345
  args: ['class']
297
346
  }] } });
298
347
 
299
- class BaseQueryData {
300
- constructor(jsonApiModels, metaData) {
301
- this.jsonApiModels = jsonApiModels;
302
- this.metaData = metaData;
348
+ const DATASTORE_PORT = new InjectionToken('DATASTORE_PORT');
349
+
350
+ class BaseService {
351
+ constructor(datastore) {
352
+ this.datastore = datastore;
303
353
  }
304
- getModels() {
305
- return this.jsonApiModels;
354
+ setModelType(modelType) {
355
+ this.modelType = modelType;
306
356
  }
307
- getMeta() {
308
- return this.metaData;
357
+ get(id, customInclude = '') {
358
+ const response = this.datastore.findRecord(this.modelType, id, { customInclude });
359
+ return response;
309
360
  }
310
- }
311
-
312
- class MetadataStorage {
313
- static { this.metadataMap = new WeakMap(); }
314
- static getMetadata(key, target, propertyKey) {
315
- const metadata = this.metadataMap.get(target) || {};
316
- return propertyKey ? metadata[`${key}:${propertyKey}`] : metadata[key];
361
+ getAll(page, pageSize, sort = '', filters = '', customInclude = '') {
362
+ const response = this.datastore.findAll(this.modelType, {
363
+ Page: page,
364
+ PageSize: pageSize,
365
+ Sorts: sort,
366
+ Filters: filters,
367
+ customInclude
368
+ });
369
+ return response;
317
370
  }
318
- static setMetadata(key, value, target, propertyKey) {
319
- let metadata = this.metadataMap.get(target);
320
- if (!metadata) {
321
- metadata = {};
322
- this.metadataMap.set(target, metadata);
371
+ delete(id) {
372
+ const response = this.datastore.deleteRecord(this.modelType, id);
373
+ return response;
374
+ }
375
+ getCustom(params, headers, customUrl, customResponseType) {
376
+ return this.datastore.getCustom(this.modelType, params, headers, customUrl, customResponseType);
377
+ }
378
+ postCustom(body, params, headers, customUrl) {
379
+ return this.datastore.postCustom(this.modelType, body, params, headers, customUrl);
380
+ }
381
+ patchCustom(body, params, headers, customUrl) {
382
+ return this.datastore.patchCustom(this.modelType, body, params, headers, customUrl);
383
+ }
384
+ // checkIfPropertyUnique(property: string, value: any): Observable<boolean> {
385
+ // }
386
+ save(docTypeOrFormGroup, id, origModel) {
387
+ if (id == null) {
388
+ let fromModel;
389
+ if (docTypeOrFormGroup instanceof UntypedFormGroup) {
390
+ fromModel = this.fromFormGroup(docTypeOrFormGroup, id);
391
+ }
392
+ else {
393
+ fromModel = docTypeOrFormGroup;
394
+ }
395
+ return this.datastore.saveRecord(fromModel.attributeMetadata, fromModel);
323
396
  }
324
- if (propertyKey) {
325
- metadata[`${key}:${propertyKey}`] = value;
397
+ else {
398
+ return this.patch(docTypeOrFormGroup, origModel, id);
399
+ }
400
+ }
401
+ patch(docTypeOrFormGroup, origModel, id) {
402
+ let fromModel;
403
+ if (docTypeOrFormGroup instanceof UntypedFormGroup) {
404
+ fromModel = this.fromFormGroup(docTypeOrFormGroup, id);
326
405
  }
327
406
  else {
328
- metadata[key] = value;
407
+ fromModel = docTypeOrFormGroup;
329
408
  }
409
+ return this.datastore.patchRecord(fromModel.attributeMetadata, fromModel, origModel);
330
410
  }
331
- }
332
-
333
- class CacheService {
334
- constructor() {
335
- this.cache = {};
411
+ newModel(data) {
412
+ return new this.modelType(data);
336
413
  }
337
- get(key) {
338
- const cachedItem = this.cache[key];
339
- if (cachedItem && cachedItem.expiration > Date.now()) {
340
- return cachedItem.data;
414
+ toFormGroup(fb, fromModel) {
415
+ if (fromModel === undefined) {
416
+ fromModel = this.newModel();
341
417
  }
342
- this.delete(key);
343
- return null;
418
+ return fromModel.getFromGroup(fb);
344
419
  }
345
- set(key, data, expiresInMs) {
346
- const expiration = Date.now() + expiresInMs;
347
- this.cache[key] = { data, expiration };
420
+ fromFormGroup(formGroup, id) {
421
+ // const saveModel = this.newModel(formGroup.getRawValue());
422
+ // saveModel.id = id ? id : null;
423
+ // return saveModel;
424
+ const saveModel = this.newModel();
425
+ saveModel.getModelFromFormGroup(formGroup);
426
+ saveModel.id = id ? id : null;
427
+ return saveModel;
348
428
  }
349
- delete(key) {
350
- delete this.cache[key];
429
+ serializeModel(model) {
430
+ return this.datastore.modelToEntity(model, model.attributeMetadata, true);
351
431
  }
352
- clearCacheContainingKeyword(keyword) {
353
- const keysToDelete = Object.keys(this.cache).filter(key => key.includes(keyword));
354
- keysToDelete.forEach(key => this.delete(key));
432
+ getSelectValues(property) {
433
+ return null;
355
434
  }
356
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
357
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheService, providedIn: 'root' }); }
435
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseService, deps: [{ token: DATASTORE_PORT }], target: i0.ɵɵFactoryTarget.Injectable }); }
436
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseService, providedIn: 'root' }); }
358
437
  }
359
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheService, decorators: [{
438
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseService, decorators: [{
360
439
  type: Injectable,
361
440
  args: [{
362
441
  providedIn: 'root'
363
442
  }]
364
- }], ctorParameters: () => [] });
443
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
444
+ type: Inject,
445
+ args: [DATASTORE_PORT]
446
+ }] }] });
365
447
 
366
- class BaseDatastore {
367
- // tslint:enable:max-line-length
368
- get getDirtyAttributes() {
369
- if (this.datastoreConfig.overrides
370
- && this.datastoreConfig.overrides.getDirtyAttributes) {
371
- return this.datastoreConfig.overrides.getDirtyAttributes;
372
- }
373
- else {
374
- return BaseDatastore.getDirtyAttributes;
375
- }
448
+ const DialogSERVICE = new InjectionToken('DialogService');
449
+ class BaseFormEditComponent {
450
+ constructor(fb, router, route, modelService, dialogService, translate, location) {
451
+ this.fb = fb;
452
+ this.router = router;
453
+ this.route = route;
454
+ this.modelService = modelService;
455
+ this.dialogService = dialogService;
456
+ this.translate = translate;
457
+ this.location = location;
458
+ this.isLoading = true;
459
+ this.changeUrlRoute = true;
460
+ this.generateForm(this.modelService.newModel());
376
461
  }
377
- get getAllAttributes() {
378
- if (this.datastoreConfig.overrides
379
- && this.datastoreConfig.overrides.getAllAttributes) {
380
- return this.datastoreConfig.overrides.getAllAttributes;
381
- }
382
- else {
383
- return BaseDatastore.getAllAttributes;
384
- }
462
+ afterSave(model) {
463
+ return new Observable((observer) => {
464
+ observer.next(model);
465
+ observer.complete();
466
+ });
385
467
  }
386
- // protected config: DatastoreConfig;
387
- static getDirtyAttributes(attributesMetadata) {
388
- const dirtyData = {};
389
- for (const propertyName in attributesMetadata) {
390
- if (attributesMetadata.hasOwnProperty(propertyName)) {
391
- const metadata = attributesMetadata[propertyName];
392
- if (metadata.hasDirtyAttributes) {
393
- const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
394
- dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
468
+ beforeSave(model) {
469
+ return new Observable((observer) => {
470
+ observer.next(model);
471
+ observer.complete();
472
+ });
473
+ }
474
+ ngOnInit() {
475
+ this.initForm();
476
+ }
477
+ initForm(customInclude = '', newModelId = null, model = null) {
478
+ if (model === null) {
479
+ this.modelId = this.route.snapshot.paramMap.get('id') ?? newModelId;
480
+ this.isEdit = false;
481
+ if (this.modelId) {
482
+ this.modelService.get(this.modelId, customInclude).subscribe((value) => {
483
+ this.isEdit = true;
484
+ this.generateForm(value);
485
+ });
486
+ }
487
+ else {
488
+ if (this.changeUrlRoute) {
489
+ const addUrl = this.router.createUrlTree([]).toString();
490
+ this.editRoute = this.router.createUrlTree([addUrl.replace('add', 'edit')]).toString();
395
491
  }
492
+ // }
493
+ this.generateForm(this.modelService.newModel());
396
494
  }
397
495
  }
398
- return dirtyData;
399
- }
400
- static getAllAttributes(attributesMetadata) {
401
- const dirtyData = {};
402
- for (const propertyName in attributesMetadata) {
403
- if (attributesMetadata.hasOwnProperty(propertyName)) {
404
- const metadata = attributesMetadata[propertyName];
405
- const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
406
- dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
407
- }
496
+ else {
497
+ this.modelId = model.id;
498
+ this.isEdit = true;
499
+ this.generateForm(model);
408
500
  }
409
- return dirtyData;
410
- }
411
- constructor(httpClient, cacheService) {
412
- this.httpClient = httpClient;
413
- this.cacheService = cacheService;
414
- // tslint:disable-next-line:variable-name
415
- this._store = {};
416
- // tslint:enable:max-line-length
417
- // tslint:disable-next-line:ban-types
418
- this.toQueryString = this.datastoreConfig.overrides
419
- && this.datastoreConfig.overrides.toQueryString ?
420
- this.datastoreConfig.overrides.toQueryString : this._toQueryString;
421
501
  }
422
- findAll(modelType, params, headers, customUrl) {
423
- const customHeadhers = this.buildHeaders(headers);
424
- const htmlParams = this.buildParams(modelType, params);
425
- const url = this.buildUrl(modelType, customUrl);
426
- const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
427
- .pipe(map(res => this.extractQueryData(res, modelType)), catchError(this.handleError));
428
- return response;
502
+ generateForm(model) {
503
+ this.isLoading = false;
504
+ this.modelId = model.id;
505
+ this.model = model;
506
+ this.baseForm = this.modelService.toFormGroup(this.fb, model);
507
+ this.afterFormGenerated();
429
508
  }
430
- findRecord(modelType, id, params, headers, customUrl) {
431
- const customHeadhers = this.buildHeaders(headers);
432
- let url = this.buildUrl(modelType, customUrl);
433
- if (id) {
434
- url += '/' + id;
435
- }
436
- const htmlParams = this.buildParams(modelType, params);
437
- const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
438
- .pipe(map(res => this.entityToModel(res, modelType, undefined)), catchError(this.handleError));
439
- return response;
509
+ afterFormGenerated() {
440
510
  }
441
- getCustom(modelType, params, headers, customUrl, customResponseType) {
442
- const customHeadhers = this.buildHeaders(headers);
443
- const url = this.buildUrl(modelType, customUrl);
444
- const htmlParams = this.buildParams(modelType, params);
445
- if (!customResponseType)
446
- customResponseType = 'json';
447
- return this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true, responseType: customResponseType });
511
+ getFromGroup(formGroup = null) {
512
+ if (!formGroup)
513
+ return this.baseForm;
514
+ if (formGroup instanceof UntypedFormGroup)
515
+ return formGroup;
516
+ return this.baseForm.controls[formGroup];
448
517
  }
449
- postCustom(modelType, body, params, headers, customUrl) {
450
- const customHeadhers = this.buildHeaders(headers);
451
- const url = this.buildUrl(modelType, customUrl);
452
- const htmlParams = this.buildParams(modelType, params);
453
- return this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, reportProgress: true, withCredentials: true });
518
+ validateAllFormFields(formGroup = null) {
519
+ const fg = this.getFromGroup(formGroup);
520
+ Object.keys(fg.controls).forEach(field => {
521
+ // console.log(field);
522
+ const control = fg.get(field);
523
+ if (control instanceof UntypedFormControl) {
524
+ control.markAsTouched({ onlySelf: true });
525
+ }
526
+ else if (control instanceof UntypedFormGroup) {
527
+ this.validateAllFormFields(control);
528
+ }
529
+ });
454
530
  }
455
- patchCustom(modelType, body, params, headers, customUrl) {
456
- const customHeadhers = this.buildHeaders(headers);
457
- const url = this.buildUrl(modelType, customUrl);
458
- const htmlParams = this.buildParams(modelType, params);
459
- return this.httpClient.patch(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
531
+ isFieldValid(field, formGroup = null) {
532
+ const fg = this.getFromGroup(formGroup);
533
+ const filedControl = fg.get(field);
534
+ return !filedControl.valid && filedControl.touched;
460
535
  }
461
- createRecord(modelType, data) {
462
- return new modelType(this, data);
536
+ isFieldValidFromArray(arrayIndex, field, arrayName = 'formArray') {
537
+ const fieldControl = this.baseForm.get(arrayName).get([arrayIndex]).get(field);
538
+ return !fieldControl.valid && fieldControl.touched;
463
539
  }
464
- saveRecord(attributesMetadata, model, params, headers, customUrl, customBody) {
465
- const modelType = model.constructor;
466
- const modelConfig = model.modelConfig;
467
- const customHeadhers = this.buildHeaders(headers);
468
- const url = this.buildUrl(modelType, customUrl);
469
- const htmlParams = this.buildParams(modelType, params);
470
- let httpCall;
471
- const body = customBody || this.modelToEntity(model, attributesMetadata);
472
- if (model.id) {
473
- // tslint:disable-next-line:max-line-length
474
- httpCall = this.httpClient.patch(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
475
- }
476
- else {
477
- httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
478
- }
479
- return httpCall
480
- .pipe(map(res => {
481
- this.cacheService.clearCacheContainingKeyword(url);
482
- const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
483
- return this.entityToModel(data, modelType);
484
- }), catchError(this.handleError));
540
+ displayFieldCss(field) {
541
+ return {
542
+ 'has-error': this.isFieldValid(field),
543
+ 'has-feedback': this.isFieldValid(field)
544
+ };
485
545
  }
486
- patchRecord(attributesMetadata, model, origModel, params, headers, customUrl) {
487
- const modelType = model.constructor;
488
- const modelConfig = model.modelConfig;
489
- const customHeadhers = this.buildHeaders(headers);
490
- const url = this.buildUrl(modelType, customUrl);
491
- const htmlParams = this.buildParams(modelType, params);
492
- let httpCall;
493
- let origData = { id: '' };
494
- if (origModel)
495
- origData = this.modelToEntity(origModel, origModel.attributeMetadata, true);
496
- const newData = this.modelToEntity(model, attributesMetadata, true);
497
- newData.id = origData.id;
498
- const patch = compare(origData, newData);
499
- if (patch.length > 0) {
500
- httpCall = this.httpClient.patch(url + '/' + model.id, patch, { headers: customHeadhers, params: htmlParams, withCredentials: true });
501
- return httpCall
502
- .pipe(map(res => {
503
- this.cacheService.clearCacheContainingKeyword(url);
504
- const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
505
- return this.entityToModel(data, modelType);
506
- }), catchError(this.handleError));
507
- }
508
- else {
509
- return new Observable((observer) => {
510
- observer.next(model);
511
- observer.complete();
512
- });
513
- }
546
+ onCancel() {
547
+ this.router.navigate([this.cancelRoute]);
514
548
  }
515
- // getPatch<T extends BaseModel>(
516
- // model: T,
517
- // origModel: T): any {
518
- // }
519
- replaceRecord(attributesMetadata, model, params, headers, customUrl, customBody) {
520
- const modelType = model.constructor;
521
- const modelConfig = model.modelConfig;
522
- const customHeadhers = this.buildHeaders(headers);
523
- const url = this.buildUrl(modelType, customUrl);
524
- const htmlParams = this.buildParams(modelType, params);
525
- let httpCall;
526
- const body = customBody || this.modelToEntity(model, attributesMetadata, true);
527
- if (model.id) {
528
- httpCall = this.httpClient.put(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
529
- }
530
- else {
531
- httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
532
- }
533
- return httpCall
534
- .pipe(map(res => {
535
- this.cacheService.clearCacheContainingKeyword(url);
536
- const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
537
- return this.entityToModel(data, modelType);
538
- }), catchError(this.handleError));
549
+ onSave() {
550
+ this.saveModel(this.baseForm);
539
551
  }
540
- deleteRecord(modelType, id, headers, customUrl) {
541
- const customHeadhers = this.buildHeaders(headers);
542
- let url = this.buildUrl(modelType, customUrl);
543
- if (!url.includes('share')) {
544
- url = url + '/' + id;
552
+ saveModel(formGroup = null) {
553
+ const fg = this.getFromGroup(formGroup);
554
+ const that = this;
555
+ if (fg) {
556
+ if (fg.valid) {
557
+ this.beforeSave(this.model).subscribe(_ => {
558
+ this.modelService.save(this.baseForm, this.modelId, this.model).subscribe((newModel) => {
559
+ this.model = newModel;
560
+ this.modelId = newModel.id;
561
+ if (this.editRoute) {
562
+ this.isEdit = true;
563
+ if (this.changeUrlRoute) {
564
+ const url = this.router.createUrlTree([this.editRoute, this.modelId]).toString();
565
+ this.location.replaceState(url);
566
+ }
567
+ }
568
+ this.afterSave(newModel).subscribe((val) => {
569
+ this.dialogService.showSaveMessage('Your changes were saved successfully.').subscribe(d => {
570
+ fg.markAsPristine();
571
+ });
572
+ });
573
+ }, err => {
574
+ this.serverErrors(err);
575
+ });
576
+ });
577
+ }
578
+ else {
579
+ this.validateAllFormFields(formGroup);
580
+ }
545
581
  }
546
- // const idParam = new HttpParams().set('id', id);
547
- return this.httpClient.delete(url, { headers: customHeadhers, withCredentials: true })
548
- .pipe(map(res => {
549
- this.cacheService.clearCacheContainingKeyword(url);
550
- return res;
551
- }), catchError(this.handleError));
552
582
  }
553
- buildUrl(modelType, customUrl) {
554
- if (customUrl) {
555
- return customUrl;
583
+ serverErrors(err) {
584
+ if (err.error) {
585
+ if (err.error.errors) {
586
+ const validationErrors = err.error.errors;
587
+ if (Array.isArray(validationErrors)) {
588
+ validationErrors.forEach(prop => {
589
+ const formControl = this.baseForm.get(prop);
590
+ if (formControl) {
591
+ // activate the error message
592
+ formControl.setErrors({
593
+ serverError: validationErrors[prop].join('\n')
594
+ });
595
+ }
596
+ });
597
+ }
598
+ else {
599
+ const keys = Object.keys(validationErrors);
600
+ keys.forEach(prop => {
601
+ const formControl = this.baseForm.get(prop);
602
+ if (formControl) {
603
+ // activate the error message
604
+ formControl.setErrors({
605
+ serverError: validationErrors[prop].join('\n')
606
+ });
607
+ }
608
+ });
609
+ }
610
+ }
556
611
  }
557
- const modelConfig = MetadataStorage.getMetadata('BaseModelConfig', modelType);
558
- const baseUrl = modelConfig.baseUrl || this.datastoreConfig.baseUrl;
559
- const apiVersion = modelConfig.apiVersion || this.datastoreConfig.apiVersion;
560
- const modelEndpointUrl = modelConfig.modelEndpointUrl || modelConfig.type;
561
- const url = [baseUrl, apiVersion, modelEndpointUrl].filter((x) => x).join('/');
562
- return url;
563
612
  }
564
- extractQueryData(res, modelType) {
565
- let result;
566
- const body = res;
567
- const models = [];
568
- for (const data of body.data) {
569
- const model = this.entityToModel(data, modelType, undefined);
570
- models.push(model);
613
+ canDeactivate() {
614
+ // Allow synchronous navigation (`true`) if no crisis or the crisis is unchanged
615
+ if (!this.baseForm.dirty) {
616
+ return true;
571
617
  }
572
- result = new BaseQueryData(models, this.parseMeta(body, modelType));
573
- return result;
618
+ // Otherwise ask the user with the dialog service and return its
619
+ // observable which resolves to true or false when the user decides
620
+ return this.dialogService.confirm('Discard changes ?', null, 'Discard');
574
621
  }
575
- deserializeModel(modelType, data) {
576
- data = this.transformSerializedNamesToPropertyNames(modelType, data);
577
- return new modelType(this, data);
622
+ getFiledName(filedTranslationKey) {
623
+ return { field: this.translate.instant(filedTranslationKey) };
578
624
  }
579
- handleError(error) {
580
- if (error.error instanceof ErrorEvent) {
581
- // A client-side or network error occurred. Handle it accordingly.
582
- // console.error('An error occurred:', error.error.message);
583
- }
584
- else {
585
- // The backend returned an unsuccessful response code.
586
- // The response body may contain clues as to what went wrong,
587
- // console.error(
588
- // 'Backend returned code ${error.status}, ' +
589
- // 'body was: ${error.error}');
590
- }
591
- // return an observable with a user-facing error message
592
- return throwError(error);
625
+ getCustomErrorMessage(error, fieldLabel) {
626
+ return '';
593
627
  }
594
- parseMeta(body, modelType) {
595
- const metaModel = MetadataStorage.getMetadata('BaseModelConfig', modelType).meta;
596
- return new metaModel(body);
628
+ getErrorMessageFromArray(arrayIndex, field, filedTranslationKey, arrayName = 'formArray') {
629
+ const fieldControl = this.baseForm.get(arrayName).get([arrayIndex]).get(field);
630
+ return this.getErrorMessageForField(fieldControl, filedTranslationKey);
597
631
  }
598
- resetMetadataAttributes(res, attributesMetadata, modelType) {
599
- // TODO check why is attributesMetadata from the arguments never used
600
- for (const propertyName in attributesMetadata) {
601
- if (attributesMetadata.hasOwnProperty(propertyName)) {
602
- const metadata = attributesMetadata[propertyName];
603
- if (metadata.hasDirtyAttributes) {
604
- metadata.hasDirtyAttributes = false;
605
- }
606
- }
607
- }
608
- if (res) {
609
- res.attributeMetadata = attributesMetadata;
610
- }
611
- return res;
612
- }
613
- get datastoreConfig() {
614
- const configFromDecorator = MetadataStorage.getMetadata('BaseDatastoreConfig', this.constructor);
615
- return Object.assign(configFromDecorator, this.config);
632
+ getErrorMessage(field, filedTranslationKey, formGroup = null) {
633
+ const fg = this.getFromGroup(formGroup);
634
+ return this.getErrorMessageForField(fg.get(field), filedTranslationKey);
616
635
  }
617
- transformSerializedNamesToPropertyNames(modelType, attributes) {
618
- const serializedNameToPropertyName = this.getModelPropertyNames(modelType.prototype);
619
- const properties = {};
620
- Object.keys(serializedNameToPropertyName).forEach((serializedName) => {
621
- if (attributes[serializedName] !== null && attributes[serializedName] !== undefined) {
622
- properties[serializedNameToPropertyName[serializedName]] = attributes[serializedName];
636
+ getErrorMessageForField(fieldControl, filedTranslationKey) {
637
+ const error = fieldControl.errors;
638
+ const fieldLabel = this.translate.instant(filedTranslationKey);
639
+ let rvalue = '';
640
+ if (error !== null) {
641
+ if (error['required'] === true) {
642
+ rvalue = this.translate.instant('General.Field.Required', { field: fieldLabel });
643
+ }
644
+ if (error['minlength']) {
645
+ rvalue = this.translate.instant('General.Field.MinLength', { field: fieldLabel, requiredLength: error.minlength.requiredLength });
646
+ }
647
+ if (error['email'] === true) {
648
+ rvalue = this.translate.instant('General.Field.InvalidEmail');
649
+ }
650
+ if (error['url'] === true) {
651
+ rvalue = this.translate.instant('General.Field.InvalidUrl');
652
+ }
653
+ if (error['serverError']) {
654
+ rvalue = error['serverError'];
655
+ }
656
+ if (rvalue === '') {
657
+ rvalue = this.getCustomErrorMessage(error, fieldLabel);
623
658
  }
624
- });
625
- return properties;
626
- }
627
- getModelPropertyNames(model) {
628
- return MetadataStorage.getMetadata('AttributeMapping', model);
629
- }
630
- buildHeaders(customHeaders) {
631
- const headers = {
632
- Accept: 'application/json-patch+json',
633
- // 'Content-Type': 'application/vnd.api+json',
634
- 'Content-Type': 'application/json-patch+json'
635
- };
636
- if (customHeaders && customHeaders.keys().length) {
637
- // tslint:disable-next-line:variable-name
638
- Object.assign({}, headers, customHeaders.keys().map(header_name => {
639
- headers['' + header_name] = customHeaders.get(header_name);
640
- }));
641
- }
642
- return new HttpHeaders(headers);
643
- }
644
- buildParams(modelType, params) {
645
- let httpParams = new HttpParams();
646
- if (params) {
647
- Object.keys(params)
648
- .filter(key => {
649
- const v = params[key];
650
- return (Array.isArray(v) || typeof v === 'string') ?
651
- (v.length > 0) :
652
- (v !== null && v !== undefined);
653
- })
654
- .forEach(key => {
655
- httpParams = httpParams.set(key, params[key]);
656
- });
657
- }
658
- const modelConfig = MetadataStorage.getMetadata('BaseModelConfig', modelType);
659
- httpParams = httpParams.set('bypassCache', modelConfig.bypassCache || false);
660
- return httpParams;
661
- }
662
- entityToModel(res, modelType, model) {
663
- return this.extractRecordDataJson(res, modelType, model);
664
- }
665
- extractRecordDataJson(res, modelType, model) {
666
- const body = res;
667
- if (!body) {
668
- throw new Error('no body in response');
669
- }
670
- if (model) {
671
- Object.assign(model, body);
672
- }
673
- const deserializedModel = model || this.deserializeModel(modelType, body.data || body);
674
- return deserializedModel;
675
- }
676
- modelToEntity(model, attributesMetadata, allAttributes = false) {
677
- let attributes;
678
- if (allAttributes) {
679
- attributes = this.getAllAttributes(attributesMetadata, model);
680
- }
681
- else {
682
- attributes = this.getDirtyAttributes(attributesMetadata, model);
683
659
  }
684
- // this.getRelationships(model, attributes);
685
- return attributes;
686
- }
687
- _toQueryString(params) {
688
- return queryString.stringify(params, { arrayFormat: 'bracket' });
660
+ return rvalue;
689
661
  }
690
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseDatastore, deps: [{ token: i1$1.HttpClient }, { token: CacheService }], target: i0.ɵɵFactoryTarget.Injectable }); }
691
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseDatastore }); }
662
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseFormEditComponent, deps: [{ token: i1$2.UntypedFormBuilder }, { token: i2.Router }, { token: i2.ActivatedRoute }, { token: BaseService }, { token: DialogSERVICE }, { token: i1$3.TranslateService }, { token: i5.Location }], target: i0.ɵɵFactoryTarget.Component }); }
663
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.8", type: BaseFormEditComponent, isStandalone: false, selector: "app-base.form.edit", ngImport: i0, template: '', isInline: true }); }
692
664
  }
693
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseDatastore, decorators: [{
694
- type: Injectable
695
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: CacheService }] });
665
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseFormEditComponent, decorators: [{
666
+ type: Component,
667
+ args: [{
668
+ selector: 'app-base.form.edit',
669
+ template: '',
670
+ standalone: false
671
+ }]
672
+ }], ctorParameters: () => [{ type: i1$2.UntypedFormBuilder }, { type: i2.Router }, { type: i2.ActivatedRoute }, { type: BaseService }, { type: undefined, decorators: [{
673
+ type: Inject,
674
+ args: [DialogSERVICE]
675
+ }] }, { type: i1$3.TranslateService }, { type: i5.Location }] });
696
676
 
697
- class BaseService {
698
- constructor(datastore) {
699
- this.datastore = datastore;
700
- }
701
- setModelType(modelType) {
702
- this.modelType = modelType;
703
- }
704
- get(id, customInclude = '') {
705
- const response = this.datastore.findRecord(this.modelType, id, { customInclude });
706
- return response;
707
- }
708
- getAll(page, pageSize, sort = '', filters = '', customInclude = '') {
709
- const response = this.datastore.findAll(this.modelType, {
710
- Page: page,
711
- PageSize: pageSize,
712
- Sorts: sort,
713
- Filters: filters,
714
- customInclude
715
- });
716
- return response;
717
- }
718
- delete(id) {
719
- const response = this.datastore.deleteRecord(this.modelType, id);
720
- return response;
677
+ class BaseTableImplementation {
678
+ constructor() {
679
+ // Access the Router without a constructor
680
+ this.router = inject(Router);
681
+ this.translate = inject(TranslateService);
682
+ // Common Dependency Injection
683
+ this.dataService = inject(MODEL_SERVICE, { optional: true });
684
+ this.modelToken = inject(MODEL_TOKEN, { optional: true });
685
+ this.dialogService = inject(DIALOG_SERVICE_TOKEN, { optional: true });
686
+ this.basePath = '';
687
+ this.title = '';
688
+ // --- Configuration Inputs (Your previous snapshot keys) ---
689
+ this.model = null;
690
+ this.dictPath = null; //rdict
691
+ this.fileLayout = ''; //rdict
692
+ this.idProperty = 'id';
693
+ // Visibility & UI
694
+ this.showHeader = true;
695
+ this.showSearch = false;
696
+ this.searchFields = null;
697
+ // Data & Pagination
698
+ this.pageable = false;
699
+ this.pageSizes = [10, 20, 30, 50, 100];
700
+ this.defaultSort = null;
701
+ this.defaultSortDirection = null;
702
+ this.defaultFilter = null;
703
+ this.customInclude = null;
704
+ // Actions & Rules
705
+ this.hasAdd = true;
706
+ this.canDelete = true;
707
+ this.canEdit = true;
708
+ this.deletePropertyName = 'name';
709
+ // Edit Behavior
710
+ this.editOnClick = false;
711
+ this.editOnDblClick = false;
712
+ this.editColumn = null;
713
+ this.useView = false; //rdict
714
+ this.hostClass = '';
721
715
  }
722
- getCustom(params, headers, customUrl, customResponseType) {
723
- return this.datastore.getCustom(this.modelType, params, headers, customUrl, customResponseType);
716
+ ngOnInit() {
717
+ const urlTree = this.router.url.split('?')[0];
718
+ const currentUrlSegments = urlTree
719
+ .split('/')
720
+ .filter((segment) => segment !== '')
721
+ .map((segment) => new UrlSegment(segment, {}));
722
+ this.basePath = currentUrlSegments.map((segment) => segment.path).join('/');
724
723
  }
725
- postCustom(body, params, headers, customUrl) {
726
- return this.datastore.postCustom(this.modelType, body, params, headers, customUrl);
724
+ get hostClasses() {
725
+ return this.hostClass;
727
726
  }
728
- patchCustom(body, params, headers, customUrl) {
729
- return this.datastore.patchCustom(this.modelType, body, params, headers, customUrl);
727
+ addHandler() {
728
+ this.router.navigate([`${this.basePath}/add`]);
730
729
  }
731
- // checkIfPropertyUnique(property: string, value: any): Observable<boolean> {
732
- // }
733
- save(docTypeOrFormGroup, id, origModel) {
734
- if (id == null) {
735
- let fromModel;
736
- if (docTypeOrFormGroup instanceof UntypedFormGroup) {
737
- fromModel = this.fromFormGroup(docTypeOrFormGroup, id);
738
- }
739
- else {
740
- fromModel = docTypeOrFormGroup;
741
- }
742
- const data = this.datastore.createRecord(this.modelType, fromModel);
743
- return data.save();
730
+ edit(dataItem, column) {
731
+ // 1. Resolve the dynamic ID value from the object
732
+ const idValue = dataItem[this.idProperty];
733
+ if (idValue) {
734
+ // 2. Navigate using the resolved value
735
+ this.router.navigate([`${this.basePath}/edit/${idValue}`]);
744
736
  }
745
737
  else {
746
- return this.patch(docTypeOrFormGroup, origModel, id);
738
+ console.warn(`Property "${this.idProperty}" not found on data item:`, dataItem);
747
739
  }
748
740
  }
749
- patch(docTypeOrFormGroup, origModel, id) {
750
- let fromModel;
751
- if (docTypeOrFormGroup instanceof UntypedFormGroup) {
752
- fromModel = this.fromFormGroup(docTypeOrFormGroup, id);
753
- }
754
- else {
755
- fromModel = docTypeOrFormGroup;
741
+ /**
742
+ * Shared delete logic that can be called by any implementation
743
+ */
744
+ delete(dataItem) {
745
+ const idValue = Reflect.get(dataItem, this.idProperty);
746
+ const modelName = Reflect.get(dataItem, this.deletePropertyName);
747
+ const message = this.translate.instant('Are you sure you want to delete this {{modelName}}?', { modelName });
748
+ if (this.dialogService) {
749
+ // Use the generic confirm method
750
+ this.dialogService.confirmDelete().subscribe((confirmed) => {
751
+ if (confirmed)
752
+ this.performDelete(idValue);
753
+ });
756
754
  }
757
- const data = this.datastore.createRecord(this.modelType, fromModel);
758
- return data.patch(origModel);
759
- }
760
- newModel(data) {
761
- return new this.modelType(this.datastore, data);
762
- }
763
- toFormGroup(fb, fromModel) {
764
- if (fromModel === undefined) {
765
- fromModel = this.newModel();
755
+ else if (confirm(message)) {
756
+ // Fallback to browser confirm if no service is provided
757
+ this.performDelete(idValue);
766
758
  }
767
- return fromModel.getFromGroup(fb);
768
- }
769
- fromFormGroup(formGroup, id) {
770
- // const saveModel = this.newModel(formGroup.getRawValue());
771
- // saveModel.id = id ? id : null;
772
- // return saveModel;
773
- const saveModel = this.newModel();
774
- saveModel.getModelFromFormGroup(formGroup);
775
- saveModel.id = id ? id : null;
776
- return saveModel;
777
759
  }
778
- getSelectValues(property) {
779
- return null;
780
- }
781
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseService, deps: [{ token: BaseDatastore }], target: i0.ɵɵFactoryTarget.Injectable }); }
782
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseService, providedIn: 'root' }); }
760
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseTableImplementation, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
761
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.8", type: BaseTableImplementation, isStandalone: true, inputs: { model: "model", dictPath: "dictPath", fileLayout: "fileLayout", idProperty: "idProperty", showHeader: "showHeader", showSearch: "showSearch", searchFields: "searchFields", pageable: "pageable", pageSizes: "pageSizes", defaultSort: "defaultSort", defaultSortDirection: "defaultSortDirection", defaultFilter: "defaultFilter", customInclude: "customInclude", hasAdd: "hasAdd", canDelete: "canDelete", canEdit: "canEdit", deletePropertyName: "deletePropertyName", deleteDisableRule: "deleteDisableRule", editOnClick: "editOnClick", editOnDblClick: "editOnDblClick", editColumn: "editColumn", useView: "useView", hostClass: "hostClass" }, host: { properties: { "class": "this.hostClasses" } }, ngImport: i0 }); }
783
762
  }
784
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseService, decorators: [{
785
- type: Injectable,
786
- args: [{
787
- providedIn: 'root'
788
- }]
789
- }], ctorParameters: () => [{ type: BaseDatastore }] });
763
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseTableImplementation, decorators: [{
764
+ type: Directive
765
+ }], propDecorators: { model: [{
766
+ type: Input
767
+ }], dictPath: [{
768
+ type: Input
769
+ }], fileLayout: [{
770
+ type: Input
771
+ }], idProperty: [{
772
+ type: Input
773
+ }], showHeader: [{
774
+ type: Input
775
+ }], showSearch: [{
776
+ type: Input
777
+ }], searchFields: [{
778
+ type: Input
779
+ }], pageable: [{
780
+ type: Input
781
+ }], pageSizes: [{
782
+ type: Input
783
+ }], defaultSort: [{
784
+ type: Input
785
+ }], defaultSortDirection: [{
786
+ type: Input
787
+ }], defaultFilter: [{
788
+ type: Input
789
+ }], customInclude: [{
790
+ type: Input
791
+ }], hasAdd: [{
792
+ type: Input
793
+ }], canDelete: [{
794
+ type: Input
795
+ }], canEdit: [{
796
+ type: Input
797
+ }], deletePropertyName: [{
798
+ type: Input
799
+ }], deleteDisableRule: [{
800
+ type: Input
801
+ }], editOnClick: [{
802
+ type: Input
803
+ }], editOnDblClick: [{
804
+ type: Input
805
+ }], editColumn: [{
806
+ type: Input
807
+ }], useView: [{
808
+ type: Input
809
+ }], hostClass: [{
810
+ type: Input
811
+ }], hostClasses: [{
812
+ type: HostBinding,
813
+ args: ['class']
814
+ }] } });
790
815
 
791
- const DialogSERVICE = new InjectionToken('DialogService');
792
- class BaseFormEditComponent {
793
- constructor(fb, router, route, modelService, dialogService, translate, location) {
794
- this.fb = fb;
795
- this.router = router;
796
- this.route = route;
797
- this.modelService = modelService;
798
- this.dialogService = dialogService;
799
- this.translate = translate;
800
- this.location = location;
801
- this.isLoading = true;
802
- this.changeUrlRoute = true;
803
- this.generateForm(this.modelService.newModel());
804
- }
805
- afterSave(model) {
806
- return new Observable((observer) => {
807
- observer.next(model);
808
- observer.complete();
809
- });
810
- }
811
- beforeSave(model) {
812
- return new Observable((observer) => {
813
- observer.next(model);
814
- observer.complete();
815
- });
816
- }
817
- ngOnInit() {
818
- this.initForm();
816
+ class Configurations {
817
+ constructor() {
818
+ this.baseUrl = '';
819
+ this.authUrl = '';
820
+ this.apiVersion = 'api/v1';
819
821
  }
820
- initForm(customInclude = '', newModelId = null, model = null) {
821
- if (model === null) {
822
- this.modelId = this.route.snapshot.paramMap.get('id') ?? newModelId;
823
- this.isEdit = false;
824
- if (this.modelId) {
825
- this.modelService.get(this.modelId, customInclude).subscribe((value) => {
826
- this.isEdit = true;
827
- this.generateForm(value);
828
- });
829
- }
830
- else {
831
- if (this.changeUrlRoute) {
832
- const addUrl = this.router.createUrlTree([]).toString();
833
- this.editRoute = this.router.createUrlTree([addUrl.replace('add', 'edit')]).toString();
834
- }
835
- // }
836
- this.generateForm(this.modelService.newModel());
837
- }
822
+ }
823
+
824
+ var GridLayoutFormat;
825
+ (function (GridLayoutFormat) {
826
+ GridLayoutFormat[GridLayoutFormat["none"] = 0] = "none";
827
+ GridLayoutFormat[GridLayoutFormat["date"] = 1] = "date";
828
+ GridLayoutFormat[GridLayoutFormat["number"] = 2] = "number";
829
+ GridLayoutFormat[GridLayoutFormat["percent"] = 3] = "percent";
830
+ GridLayoutFormat[GridLayoutFormat["picture"] = 4] = "picture";
831
+ })(GridLayoutFormat || (GridLayoutFormat = {}));
832
+ var CellTextAlign;
833
+ (function (CellTextAlign) {
834
+ CellTextAlign["left"] = "left";
835
+ CellTextAlign["center"] = "center";
836
+ CellTextAlign["right"] = "right";
837
+ })(CellTextAlign || (CellTextAlign = {}));
838
+
839
+ // tslint:disable-next-line:variable-name
840
+ const AttributeMetadata = Symbol('AttributeMetadata');
841
+
842
+ class DateConverter {
843
+ mask(value) {
844
+ if (value instanceof Date && !isNaN(value.getTime())) {
845
+ return value;
846
+ }
847
+ const d = parseISO(value);
848
+ if (d instanceof Date && !isNaN(d.getTime())) {
849
+ return d;
838
850
  }
839
851
  else {
840
- this.modelId = model.id;
841
- this.isEdit = true;
842
- this.generateForm(model);
852
+ return value;
843
853
  }
844
854
  }
845
- generateForm(model) {
846
- this.isLoading = false;
847
- this.modelId = model.id;
848
- this.model = model;
849
- this.baseForm = this.modelService.toFormGroup(this.fb, model);
850
- this.afterFormGenerated();
851
- }
852
- afterFormGenerated() {
853
- }
854
- getFromGroup(formGroup = null) {
855
- if (!formGroup)
856
- return this.baseForm;
857
- if (formGroup instanceof UntypedFormGroup)
858
- return formGroup;
859
- return this.baseForm.controls[formGroup];
860
- }
861
- validateAllFormFields(formGroup = null) {
862
- const fg = this.getFromGroup(formGroup);
863
- Object.keys(fg.controls).forEach(field => {
864
- // console.log(field);
865
- const control = fg.get(field);
866
- if (control instanceof UntypedFormControl) {
867
- control.markAsTouched({ onlySelf: true });
868
- }
869
- else if (control instanceof UntypedFormGroup) {
870
- this.validateAllFormFields(control);
871
- }
872
- });
873
- }
874
- isFieldValid(field, formGroup = null) {
875
- const fg = this.getFromGroup(formGroup);
876
- const filedControl = fg.get(field);
877
- return !filedControl.valid && filedControl.touched;
878
- }
879
- isFieldValidFromArray(arrayIndex, field, arrayName = 'formArray') {
880
- const fieldControl = this.baseForm.get(arrayName).get([arrayIndex]).get(field);
881
- return !fieldControl.valid && fieldControl.touched;
882
- }
883
- displayFieldCss(field) {
884
- return {
885
- 'has-error': this.isFieldValid(field),
886
- 'has-feedback': this.isFieldValid(field)
887
- };
888
- }
889
- onCancel() {
890
- this.router.navigate([this.cancelRoute]);
855
+ unmask(value) {
856
+ // const result = format(value, 'YYYY-MM-DDTHH:mm:ssZ');
857
+ return value;
891
858
  }
892
- onSave() {
893
- this.saveModel(this.baseForm);
859
+ }
860
+
861
+ class MetadataStorage {
862
+ static { this.metadataMap = new WeakMap(); }
863
+ static getMetadata(key, target, propertyKey) {
864
+ const metadata = this.metadataMap.get(target) || {};
865
+ return propertyKey ? metadata[`${key}:${propertyKey}`] : metadata[key];
894
866
  }
895
- saveModel(formGroup = null) {
896
- const fg = this.getFromGroup(formGroup);
897
- const that = this;
898
- if (fg) {
899
- if (fg.valid) {
900
- this.beforeSave(this.model).subscribe(_ => {
901
- this.modelService.save(this.baseForm, this.modelId, this.model).subscribe((newModel) => {
902
- this.model = newModel;
903
- this.modelId = newModel.id;
904
- if (this.editRoute) {
905
- this.isEdit = true;
906
- if (this.changeUrlRoute) {
907
- const url = this.router.createUrlTree([this.editRoute, this.modelId]).toString();
908
- this.location.replaceState(url);
909
- }
910
- }
911
- this.afterSave(newModel).subscribe((val) => {
912
- this.dialogService.showSaveMessage('Your changes were saved successfully.').subscribe(d => {
913
- fg.markAsPristine();
914
- });
915
- });
916
- }, err => {
917
- this.serverErrors(err);
918
- });
919
- });
920
- }
921
- else {
922
- this.validateAllFormFields(formGroup);
923
- }
867
+ static setMetadata(key, value, target, propertyKey) {
868
+ let metadata = this.metadataMap.get(target);
869
+ if (!metadata) {
870
+ metadata = {};
871
+ this.metadataMap.set(target, metadata);
872
+ }
873
+ if (propertyKey) {
874
+ metadata[`${key}:${propertyKey}`] = value;
875
+ }
876
+ else {
877
+ metadata[key] = value;
924
878
  }
925
879
  }
926
- serverErrors(err) {
927
- if (err.error) {
928
- if (err.error.errors) {
929
- const validationErrors = err.error.errors;
930
- if (Array.isArray(validationErrors)) {
931
- validationErrors.forEach(prop => {
932
- const formControl = this.baseForm.get(prop);
933
- if (formControl) {
934
- // activate the error message
935
- formControl.setErrors({
936
- serverError: validationErrors[prop].join('\n')
937
- });
938
- }
939
- });
880
+ }
881
+
882
+ function Attribute(options = {}) {
883
+ return (target, propertyName) => {
884
+ const converter = (dataType, value, forSerialisation = false) => {
885
+ let attrConverter;
886
+ if (dataType) {
887
+ if (options.converter) {
888
+ attrConverter = options.converter;
889
+ }
890
+ else if (dataType === Date) {
891
+ attrConverter = new DateConverter();
940
892
  }
941
893
  else {
942
- const keys = Object.keys(validationErrors);
943
- keys.forEach(prop => {
944
- const formControl = this.baseForm.get(prop);
945
- if (formControl) {
946
- // activate the error message
947
- formControl.setErrors({
948
- serverError: validationErrors[prop].join('\n')
949
- });
950
- }
951
- });
894
+ const datatype = new dataType();
895
+ if (datatype.mask && datatype.unmask) {
896
+ attrConverter = datatype;
897
+ }
898
+ }
899
+ if (attrConverter) {
900
+ if (!forSerialisation) {
901
+ return attrConverter.mask(value);
902
+ }
903
+ return attrConverter.unmask(value);
952
904
  }
953
905
  }
954
- }
955
- }
956
- canDeactivate() {
957
- // Allow synchronous navigation (`true`) if no crisis or the crisis is unchanged
958
- if (!this.baseForm.dirty) {
959
- return true;
960
- }
961
- // Otherwise ask the user with the dialog service and return its
962
- // observable which resolves to true or false when the user decides
963
- return this.dialogService.confirm('Discard changes ?', null, 'Discard');
964
- }
965
- getFiledName(filedTranslationKey) {
966
- return { field: this.translate.instant(filedTranslationKey) };
967
- }
968
- getCustomErrorMessage(error, fieldLabel) {
969
- return '';
970
- }
971
- getErrorMessageFromArray(arrayIndex, field, filedTranslationKey, arrayName = 'formArray') {
972
- const fieldControl = this.baseForm.get(arrayName).get([arrayIndex]).get(field);
973
- return this.getErrorMessageForField(fieldControl, filedTranslationKey);
974
- }
975
- getErrorMessage(field, filedTranslationKey, formGroup = null) {
976
- const fg = this.getFromGroup(formGroup);
977
- return this.getErrorMessageForField(fg.get(field), filedTranslationKey);
978
- }
979
- getErrorMessageForField(fieldControl, filedTranslationKey) {
980
- const error = fieldControl.errors;
981
- const fieldLabel = this.translate.instant(filedTranslationKey);
982
- let rvalue = '';
983
- if (error !== null) {
984
- if (error['required'] === true) {
985
- rvalue = this.translate.instant('General.Field.Required', { field: fieldLabel });
986
- }
987
- if (error['minlength']) {
988
- rvalue = this.translate.instant('General.Field.MinLength', { field: fieldLabel, requiredLength: error.minlength.requiredLength });
989
- }
990
- if (error['email'] === true) {
991
- rvalue = this.translate.instant('General.Field.InvalidEmail');
992
- }
993
- if (error['url'] === true) {
994
- rvalue = this.translate.instant('General.Field.InvalidUrl');
995
- }
996
- if (error['serverError']) {
997
- rvalue = error['serverError'];
906
+ return value;
907
+ };
908
+ const saveAnnotations = () => {
909
+ const metadata = MetadataStorage.getMetadata('Attribute', target) || {};
910
+ metadata[propertyName] = {
911
+ marked: true
912
+ };
913
+ MetadataStorage.setMetadata('Attribute', metadata, target);
914
+ const mappingMetadata = MetadataStorage.getMetadata('AttributeMapping', target) || {};
915
+ const serializedPropertyName = options.serializedName !== undefined ? options.serializedName : propertyName;
916
+ mappingMetadata[serializedPropertyName] = propertyName;
917
+ MetadataStorage.setMetadata('AttributeMapping', mappingMetadata, target);
918
+ const requiredMetadata = MetadataStorage.getMetadata('AttributeRequired', target) || {};
919
+ requiredMetadata[serializedPropertyName] = options.required !== undefined ? options.required : false;
920
+ MetadataStorage.setMetadata('AttributeRequired', requiredMetadata, target);
921
+ const defaultMetadata = MetadataStorage.getMetadata('AttributedefaultValue', target) || {};
922
+ defaultMetadata[serializedPropertyName] = options.defaultValue !== undefined ? options.defaultValue : null;
923
+ MetadataStorage.setMetadata('AttributedefaultValue', defaultMetadata, target);
924
+ const formSubGroupMetadata = MetadataStorage.getMetadata('AttributeformSubGroup', target) || {};
925
+ formSubGroupMetadata[serializedPropertyName] = options.formSubGroup !== undefined ? options.formSubGroup : null;
926
+ MetadataStorage.setMetadata('AttributeformSubGroup', formSubGroupMetadata, target);
927
+ };
928
+ const setMetadata = (hasDirtyAttributes, instance, oldValue, newValue, isNew) => {
929
+ const targetType = MetadataStorage.getMetadata('design:type', target, propertyName);
930
+ if (!instance[AttributeMetadata]) {
931
+ instance[AttributeMetadata] = {};
998
932
  }
999
- if (rvalue === '') {
1000
- rvalue = this.getCustomErrorMessage(error, fieldLabel);
933
+ const propertyHasDirtyAttributes = typeof oldValue === 'undefined' && !isNew ? false : hasDirtyAttributes;
934
+ instance[AttributeMetadata][propertyName] = {
935
+ newValue,
936
+ oldValue,
937
+ serializedName: options.serializedName,
938
+ hasDirtyAttributes: propertyHasDirtyAttributes,
939
+ serialisationValue: converter(targetType, newValue, true)
940
+ };
941
+ };
942
+ const getter = function () {
943
+ return this['_' + propertyName];
944
+ };
945
+ const setter = function (newVal) {
946
+ const targetType = MetadataStorage.getMetadata('design:type', target, propertyName);
947
+ const convertedValue = converter(targetType, newVal);
948
+ if (convertedValue !== this['_' + propertyName]) {
949
+ setMetadata(true, this, this['_' + propertyName], newVal, !this.id);
950
+ this['_' + propertyName] = convertedValue;
1001
951
  }
952
+ };
953
+ if (delete target[propertyName]) {
954
+ saveAnnotations();
955
+ Object.defineProperty(target, propertyName, {
956
+ get: getter,
957
+ set: setter,
958
+ enumerable: true,
959
+ configurable: true
960
+ });
1002
961
  }
1003
- return rvalue;
1004
- }
1005
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseFormEditComponent, deps: [{ token: i1$2.UntypedFormBuilder }, { token: i2.Router }, { token: i2.ActivatedRoute }, { token: BaseService }, { token: DialogSERVICE }, { token: i1$3.TranslateService }, { token: i5.Location }], target: i0.ɵɵFactoryTarget.Component }); }
1006
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.8", type: BaseFormEditComponent, isStandalone: false, selector: "app-base.form.edit", ngImport: i0, template: '', isInline: true }); }
962
+ };
1007
963
  }
1008
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseFormEditComponent, decorators: [{
1009
- type: Component,
1010
- args: [{
1011
- selector: 'app-base.form.edit',
1012
- template: '',
1013
- standalone: false
1014
- }]
1015
- }], ctorParameters: () => [{ type: i1$2.UntypedFormBuilder }, { type: i2.Router }, { type: i2.ActivatedRoute }, { type: BaseService }, { type: undefined, decorators: [{
1016
- type: Inject,
1017
- args: [DialogSERVICE]
1018
- }] }, { type: i1$3.TranslateService }, { type: i5.Location }] });
1019
964
 
1020
- class BaseTableImplementation {
1021
- constructor() {
1022
- // Access the Router without a constructor
1023
- this.router = inject(Router);
1024
- this.translate = inject(TranslateService);
1025
- // Common Dependency Injection
1026
- this.dataService = inject(MODEL_SERVICE, { optional: true });
1027
- this.modelToken = inject(MODEL_TOKEN, { optional: true });
1028
- this.dialogService = inject(DIALOG_SERVICE_TOKEN, { optional: true });
1029
- this.basePath = '';
1030
- this.title = '';
1031
- // --- Configuration Inputs (Your previous snapshot keys) ---
1032
- this.model = null;
1033
- this.dictPath = null; //rdict
1034
- this.fileLayout = ''; //rdict
1035
- this.idProperty = 'id';
1036
- // Visibility & UI
1037
- this.showHeader = true;
1038
- this.showSearch = false;
1039
- this.searchFields = null;
1040
- // Data & Pagination
1041
- this.pageable = false;
1042
- this.pageSizes = [10, 20, 30, 50, 100];
1043
- this.defaultSort = null;
1044
- this.defaultSortDirection = null;
1045
- this.defaultFilter = null;
1046
- this.customInclude = null;
1047
- // Actions & Rules
1048
- this.hasAdd = true;
1049
- this.canDelete = true;
1050
- this.canEdit = true;
1051
- this.deletePropertyName = 'name';
1052
- // Edit Behavior
1053
- this.editOnClick = false;
1054
- this.editOnDblClick = false;
1055
- this.editColumn = null;
1056
- this.useView = false; //rdict
1057
- this.hostClass = '';
965
+ function BaseDatastoreConfig(config = {}) {
966
+ // tslint:disable-next-line:only-arrow-functions
967
+ return (target) => {
968
+ MetadataStorage.setMetadata('BaseDatastoreConfig', config, target);
969
+ };
970
+ }
971
+
972
+ class BaseMetaModel {
973
+ constructor(response) {
974
+ this.links = response.links || [];
975
+ this.meta = response.meta;
1058
976
  }
1059
- ngOnInit() {
1060
- const urlTree = this.router.url.split('?')[0];
1061
- const currentUrlSegments = urlTree
1062
- .split('/')
1063
- .filter((segment) => segment !== '')
1064
- .map((segment) => new UrlSegment(segment, {}));
1065
- this.basePath = currentUrlSegments.map((segment) => segment.path).join('/');
977
+ }
978
+
979
+ function BaseModelConfig(config = {}) {
980
+ return (target) => {
981
+ if (typeof config['meta'] === 'undefined' || config['meta'] == null) {
982
+ config['meta'] = BaseMetaModel;
983
+ }
984
+ MetadataStorage.setMetadata('BaseModelConfig', config, target);
985
+ };
986
+ }
987
+
988
+ function CustomType(config = {}) {
989
+ return (target, propertyName) => {
990
+ const annotations = MetadataStorage.getMetadata('CustomType', target) || [];
991
+ annotations.push({
992
+ propertyName,
993
+ relationship: config.key || propertyName
994
+ });
995
+ MetadataStorage.setMetadata('CustomType', annotations, target);
996
+ };
997
+ }
998
+
999
+ class CacheService {
1000
+ constructor() {
1001
+ this.cache = {};
1066
1002
  }
1067
- get hostClasses() {
1068
- return this.hostClass;
1003
+ get(key) {
1004
+ const cachedItem = this.cache[key];
1005
+ if (cachedItem && cachedItem.expiration > Date.now()) {
1006
+ return cachedItem.data;
1007
+ }
1008
+ this.delete(key);
1009
+ return null;
1069
1010
  }
1070
- addHandler() {
1071
- this.router.navigate([`${this.basePath}/add`]);
1011
+ set(key, data, expiresInMs) {
1012
+ const expiration = Date.now() + expiresInMs;
1013
+ this.cache[key] = { data, expiration };
1072
1014
  }
1073
- edit(dataItem, column) {
1074
- // 1. Resolve the dynamic ID value from the object
1075
- const idValue = dataItem[this.idProperty];
1076
- if (idValue) {
1077
- // 2. Navigate using the resolved value
1078
- this.router.navigate([`${this.basePath}/edit/${idValue}`]);
1079
- }
1080
- else {
1081
- console.warn(`Property "${this.idProperty}" not found on data item:`, dataItem);
1082
- }
1015
+ delete(key) {
1016
+ delete this.cache[key];
1083
1017
  }
1084
- /**
1085
- * Shared delete logic that can be called by any implementation
1086
- */
1087
- delete(dataItem) {
1088
- const idValue = Reflect.get(dataItem, this.idProperty);
1089
- const modelName = Reflect.get(dataItem, this.deletePropertyName);
1090
- const message = this.translate.instant('Are you sure you want to delete this {{modelName}}?', { modelName });
1091
- if (this.dialogService) {
1092
- // Use the generic confirm method
1093
- this.dialogService.confirmDelete().subscribe((confirmed) => {
1094
- if (confirmed)
1095
- this.performDelete(idValue);
1096
- });
1018
+ clearCacheContainingKeyword(keyword) {
1019
+ const keysToDelete = Object.keys(this.cache).filter(key => key.includes(keyword));
1020
+ keysToDelete.forEach(key => this.delete(key));
1021
+ }
1022
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1023
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheService, providedIn: 'root' }); }
1024
+ }
1025
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheService, decorators: [{
1026
+ type: Injectable,
1027
+ args: [{
1028
+ providedIn: 'root'
1029
+ }]
1030
+ }], ctorParameters: () => [] });
1031
+
1032
+ class CacheInterceptor {
1033
+ constructor(expirationTime, cacheService) {
1034
+ this.expirationTime = expirationTime;
1035
+ this.cacheService = cacheService;
1036
+ this.cache = new Map();
1037
+ }
1038
+ intercept(request, next) {
1039
+ const bypassCache = request.params.get('bypassCache') || false;
1040
+ if (bypassCache || request.method !== 'GET') {
1041
+ return next.handle(request);
1097
1042
  }
1098
- else if (confirm(message)) {
1099
- // Fallback to browser confirm if no service is provided
1100
- this.performDelete(idValue);
1043
+ if (!bypassCache) {
1044
+ const cachedResponse = this.cacheService.get(request.urlWithParams);
1045
+ if (cachedResponse) {
1046
+ return of(cachedResponse.clone());
1047
+ //return cachedResponse;
1048
+ }
1101
1049
  }
1050
+ return next.handle(request).pipe(tap((event) => {
1051
+ if (event instanceof HttpResponse) {
1052
+ this.cacheService.set(request.urlWithParams, event.clone(), this.expirationTime);
1053
+ }
1054
+ }));
1055
+ // const cachedItem = this.cache.get(request.url);
1056
+ // if (cachedItem && cachedItem.expiration > Date.now()) {
1057
+ // return of(cachedItem.response.clone());
1058
+ // }
1059
+ // return next.handle(request).pipe(
1060
+ // tap(event => {
1061
+ // if (event instanceof HttpResponse) {
1062
+ // this.cache.set(request.url, { response: event.clone(), expiration: Date.now() + this.expirationTime });
1063
+ // }
1064
+ // })
1065
+ // );
1102
1066
  }
1103
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseTableImplementation, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1104
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.8", type: BaseTableImplementation, isStandalone: true, inputs: { model: "model", dictPath: "dictPath", fileLayout: "fileLayout", idProperty: "idProperty", showHeader: "showHeader", showSearch: "showSearch", searchFields: "searchFields", pageable: "pageable", pageSizes: "pageSizes", defaultSort: "defaultSort", defaultSortDirection: "defaultSortDirection", defaultFilter: "defaultFilter", customInclude: "customInclude", hasAdd: "hasAdd", canDelete: "canDelete", canEdit: "canEdit", deletePropertyName: "deletePropertyName", deleteDisableRule: "deleteDisableRule", editOnClick: "editOnClick", editOnDblClick: "editOnDblClick", editColumn: "editColumn", useView: "useView", hostClass: "hostClass" }, host: { properties: { "class": "this.hostClasses" } }, ngImport: i0 }); }
1067
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheInterceptor, deps: [{ token: 'CACHE_EXPIRATION_TIME' }, { token: CacheService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1068
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheInterceptor }); }
1105
1069
  }
1106
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseTableImplementation, decorators: [{
1107
- type: Directive
1108
- }], propDecorators: { model: [{
1109
- type: Input
1110
- }], dictPath: [{
1111
- type: Input
1112
- }], fileLayout: [{
1113
- type: Input
1114
- }], idProperty: [{
1115
- type: Input
1116
- }], showHeader: [{
1117
- type: Input
1118
- }], showSearch: [{
1119
- type: Input
1120
- }], searchFields: [{
1121
- type: Input
1122
- }], pageable: [{
1123
- type: Input
1124
- }], pageSizes: [{
1125
- type: Input
1126
- }], defaultSort: [{
1127
- type: Input
1128
- }], defaultSortDirection: [{
1129
- type: Input
1130
- }], defaultFilter: [{
1131
- type: Input
1132
- }], customInclude: [{
1133
- type: Input
1134
- }], hasAdd: [{
1135
- type: Input
1136
- }], canDelete: [{
1137
- type: Input
1138
- }], canEdit: [{
1139
- type: Input
1140
- }], deletePropertyName: [{
1141
- type: Input
1142
- }], deleteDisableRule: [{
1143
- type: Input
1144
- }], editOnClick: [{
1145
- type: Input
1146
- }], editOnDblClick: [{
1147
- type: Input
1148
- }], editColumn: [{
1149
- type: Input
1150
- }], useView: [{
1151
- type: Input
1152
- }], hostClass: [{
1153
- type: Input
1154
- }], hostClasses: [{
1155
- type: HostBinding,
1156
- args: ['class']
1157
- }] } });
1070
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheInterceptor, decorators: [{
1071
+ type: Injectable
1072
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1073
+ type: Inject,
1074
+ args: ['CACHE_EXPIRATION_TIME']
1075
+ }] }, { type: CacheService }] });
1158
1076
 
1159
- class Configurations {
1160
- constructor() {
1161
- this.baseUrl = '';
1162
- this.authUrl = '';
1163
- this.apiVersion = 'api/v1';
1077
+ class BaseQueryData {
1078
+ constructor(jsonApiModels, metaData) {
1079
+ this.jsonApiModels = jsonApiModels;
1080
+ this.metaData = metaData;
1081
+ }
1082
+ getModels() {
1083
+ return this.jsonApiModels;
1084
+ }
1085
+ getMeta() {
1086
+ return this.metaData;
1164
1087
  }
1165
1088
  }
1166
1089
 
1167
- var GridLayoutFormat;
1168
- (function (GridLayoutFormat) {
1169
- GridLayoutFormat[GridLayoutFormat["none"] = 0] = "none";
1170
- GridLayoutFormat[GridLayoutFormat["date"] = 1] = "date";
1171
- GridLayoutFormat[GridLayoutFormat["number"] = 2] = "number";
1172
- GridLayoutFormat[GridLayoutFormat["percent"] = 3] = "percent";
1173
- GridLayoutFormat[GridLayoutFormat["picture"] = 4] = "picture";
1174
- })(GridLayoutFormat || (GridLayoutFormat = {}));
1175
- var CellTextAlign;
1176
- (function (CellTextAlign) {
1177
- CellTextAlign["left"] = "left";
1178
- CellTextAlign["center"] = "center";
1179
- CellTextAlign["right"] = "right";
1180
- })(CellTextAlign || (CellTextAlign = {}));
1181
-
1182
- // tslint:disable-next-line:variable-name
1183
- const AttributeMetadata = Symbol('AttributeMetadata');
1184
-
1185
- class DateConverter {
1186
- mask(value) {
1187
- if (value instanceof Date && !isNaN(value.getTime())) {
1188
- return value;
1090
+ class BaseModel {
1091
+ // tslint:disable-next-line:variable-name
1092
+ constructor(data) {
1093
+ if (data) {
1094
+ if (data.id) {
1095
+ this.id = data.id;
1096
+ }
1097
+ Object.assign(this, data);
1189
1098
  }
1190
- const d = parseISO(value);
1191
- if (d instanceof Date && !isNaN(d.getTime())) {
1192
- return d;
1099
+ }
1100
+ get attributeMetadata() {
1101
+ const attributesMetadata = this[AttributeMetadata];
1102
+ return attributesMetadata;
1103
+ }
1104
+ set attributeMetadata(val) {
1105
+ this[AttributeMetadata] = val;
1106
+ }
1107
+ get hasDirtyAttributes() {
1108
+ const attributesMetadata = this[AttributeMetadata];
1109
+ let hasDirtyAttributes = false;
1110
+ for (const propertyName in attributesMetadata) {
1111
+ if (attributesMetadata.hasOwnProperty(propertyName)) {
1112
+ const metadata = attributesMetadata[propertyName];
1113
+ if (metadata.hasDirtyAttributes) {
1114
+ hasDirtyAttributes = true;
1115
+ break;
1116
+ }
1117
+ }
1193
1118
  }
1194
- else {
1195
- return value;
1119
+ return hasDirtyAttributes;
1120
+ }
1121
+ rollbackAttributes() {
1122
+ const attributesMetadata = this[AttributeMetadata];
1123
+ let metadata;
1124
+ for (const propertyName in attributesMetadata) {
1125
+ if (attributesMetadata.hasOwnProperty(propertyName)) {
1126
+ if (attributesMetadata[propertyName].hasDirtyAttributes) {
1127
+ this[propertyName] = attributesMetadata[propertyName].oldValue;
1128
+ metadata = {
1129
+ hasDirtyAttributes: false,
1130
+ newValue: attributesMetadata[propertyName].oldValue,
1131
+ oldValue: undefined
1132
+ };
1133
+ attributesMetadata[propertyName] = metadata;
1134
+ }
1135
+ }
1196
1136
  }
1137
+ this[AttributeMetadata] = attributesMetadata;
1197
1138
  }
1198
- unmask(value) {
1199
- // const result = format(value, 'YYYY-MM-DDTHH:mm:ssZ');
1200
- return value;
1139
+ get modelConfig() {
1140
+ return MetadataStorage.getMetadata('BaseModelConfig', this.constructor);
1201
1141
  }
1202
- }
1203
-
1204
- function Attribute(options = {}) {
1205
- return (target, propertyName) => {
1206
- const converter = (dataType, value, forSerialisation = false) => {
1207
- let attrConverter;
1208
- if (dataType) {
1209
- if (options.converter) {
1210
- attrConverter = options.converter;
1211
- }
1212
- else if (dataType === Date) {
1213
- attrConverter = new DateConverter();
1142
+ deserializeModel(modelType, data) {
1143
+ data = this.transformSerializedNamesToPropertyNames(modelType, data);
1144
+ return new modelType(data);
1145
+ }
1146
+ transformSerializedNamesToPropertyNames(modelType, attributes) {
1147
+ const serializedNameToPropertyName = this.getModelPropertyNames(modelType.prototype);
1148
+ const properties = {};
1149
+ Object.keys(serializedNameToPropertyName).forEach((serializedName) => {
1150
+ if (attributes[serializedName] !== null && attributes[serializedName] !== undefined) {
1151
+ properties[serializedNameToPropertyName[serializedName]] = attributes[serializedName];
1152
+ }
1153
+ });
1154
+ return properties;
1155
+ }
1156
+ getModelPropertyNames(model) {
1157
+ return MetadataStorage.getMetadata('AttributeMapping', model);
1158
+ }
1159
+ getModelRequiredPropertyNames(model) {
1160
+ return MetadataStorage.getMetadata('AttributeRequired', model);
1161
+ }
1162
+ getModelDefaultPropertyValues(model) {
1163
+ return MetadataStorage.getMetadata('AttributedefaultValue', model);
1164
+ }
1165
+ getModelSubGroupPropertyNames(model) {
1166
+ return MetadataStorage.getMetadata('AttributeformSubGroup', model);
1167
+ }
1168
+ getFromGroup(fb) {
1169
+ const props = Object.keys(this.getModelPropertyNames(this));
1170
+ const requiredProps = this.getModelRequiredPropertyNames(this);
1171
+ const defaultValues = this.getModelDefaultPropertyValues(this);
1172
+ const formSubGroupsValues = this.getModelSubGroupPropertyNames(this);
1173
+ const controlsConfig = {};
1174
+ const that = this;
1175
+ if (props) {
1176
+ props.forEach((property) => {
1177
+ const value = that[property] !== undefined ? that[property] : defaultValues[property];
1178
+ const formSubGroup = formSubGroupsValues[property] ?? null;
1179
+ if (requiredProps[property]) {
1180
+ if (formSubGroup)
1181
+ this.getSubFromGroup(fb, controlsConfig, formSubGroup).addControl(property, fb.control(value, Validators.required));
1182
+ else
1183
+ controlsConfig[property] = [value, Validators.required];
1214
1184
  }
1215
1185
  else {
1216
- const datatype = new dataType();
1217
- if (datatype.mask && datatype.unmask) {
1218
- attrConverter = datatype;
1219
- }
1220
- }
1221
- if (attrConverter) {
1222
- if (!forSerialisation) {
1223
- return attrConverter.mask(value);
1224
- }
1225
- return attrConverter.unmask(value);
1186
+ if (formSubGroup)
1187
+ this.getSubFromGroup(fb, controlsConfig, formSubGroup).addControl(property, fb.control(value));
1188
+ else
1189
+ controlsConfig[property] = value;
1226
1190
  }
1191
+ });
1192
+ }
1193
+ return fb.group(controlsConfig);
1194
+ }
1195
+ getSubFromGroup(fb, controlsConfig, subGroup) {
1196
+ if (!controlsConfig[subGroup])
1197
+ controlsConfig[subGroup] = fb.group({});
1198
+ return controlsConfig[subGroup];
1199
+ }
1200
+ getModelFromFormGroup(formGroup, id) {
1201
+ try {
1202
+ const props = Object.keys(this.getModelPropertyNames(this));
1203
+ const formSubGroupsValues = this.getModelSubGroupPropertyNames(this);
1204
+ const data = {};
1205
+ if (id) {
1206
+ data.id = id;
1227
1207
  }
1228
- return value;
1229
- };
1230
- const saveAnnotations = () => {
1231
- const metadata = MetadataStorage.getMetadata('Attribute', target) || {};
1232
- metadata[propertyName] = {
1233
- marked: true
1234
- };
1235
- MetadataStorage.setMetadata('Attribute', metadata, target);
1236
- const mappingMetadata = MetadataStorage.getMetadata('AttributeMapping', target) || {};
1237
- const serializedPropertyName = options.serializedName !== undefined ? options.serializedName : propertyName;
1238
- mappingMetadata[serializedPropertyName] = propertyName;
1239
- MetadataStorage.setMetadata('AttributeMapping', mappingMetadata, target);
1240
- const requiredMetadata = MetadataStorage.getMetadata('AttributeRequired', target) || {};
1241
- requiredMetadata[serializedPropertyName] = options.required !== undefined ? options.required : false;
1242
- MetadataStorage.setMetadata('AttributeRequired', requiredMetadata, target);
1243
- const defaultMetadata = MetadataStorage.getMetadata('AttributedefaultValue', target) || {};
1244
- defaultMetadata[serializedPropertyName] = options.defaultValue !== undefined ? options.defaultValue : null;
1245
- MetadataStorage.setMetadata('AttributedefaultValue', defaultMetadata, target);
1246
- const formSubGroupMetadata = MetadataStorage.getMetadata('AttributeformSubGroup', target) || {};
1247
- formSubGroupMetadata[serializedPropertyName] = options.formSubGroup !== undefined ? options.formSubGroup : null;
1248
- MetadataStorage.setMetadata('AttributeformSubGroup', formSubGroupMetadata, target);
1249
- };
1250
- const setMetadata = (hasDirtyAttributes, instance, oldValue, newValue, isNew) => {
1251
- const targetType = MetadataStorage.getMetadata('design:type', target, propertyName);
1252
- if (!instance[AttributeMetadata]) {
1253
- instance[AttributeMetadata] = {};
1208
+ const that = this;
1209
+ if (props) {
1210
+ props.forEach((property) => {
1211
+ const formSubGroup = formSubGroupsValues[property] ?? null;
1212
+ if (!formSubGroup)
1213
+ data[property] = formGroup.controls[property].value ?? null;
1214
+ else
1215
+ data[property] = formGroup.controls[formSubGroup].controls[property].value ?? null;
1216
+ });
1254
1217
  }
1255
- const propertyHasDirtyAttributes = typeof oldValue === 'undefined' && !isNew ? false : hasDirtyAttributes;
1256
- instance[AttributeMetadata][propertyName] = {
1257
- newValue,
1258
- oldValue,
1259
- serializedName: options.serializedName,
1260
- hasDirtyAttributes: propertyHasDirtyAttributes,
1261
- serialisationValue: converter(targetType, newValue, true)
1262
- };
1263
- };
1264
- const getter = function () {
1265
- return this['_' + propertyName];
1266
- };
1267
- const setter = function (newVal) {
1268
- const targetType = MetadataStorage.getMetadata('design:type', target, propertyName);
1269
- const convertedValue = converter(targetType, newVal);
1270
- if (convertedValue !== this['_' + propertyName]) {
1271
- setMetadata(true, this, this['_' + propertyName], newVal, !this.id);
1272
- this['_' + propertyName] = convertedValue;
1218
+ if (data) {
1219
+ if (id) {
1220
+ this.id = id;
1221
+ }
1222
+ Object.assign(this, data);
1273
1223
  }
1274
- };
1275
- if (delete target[propertyName]) {
1276
- saveAnnotations();
1277
- Object.defineProperty(target, propertyName, {
1278
- get: getter,
1279
- set: setter,
1280
- enumerable: true,
1281
- configurable: true
1282
- });
1283
1224
  }
1284
- };
1225
+ catch (error) {
1226
+ Object.assign(this, formGroup.value);
1227
+ }
1228
+ }
1229
+ getCellClass(property) {
1230
+ return '';
1231
+ }
1285
1232
  }
1286
1233
 
1287
- function BaseDatastoreConfig(config = {}) {
1288
- // tslint:disable-next-line:only-arrow-functions
1289
- return (target) => {
1290
- MetadataStorage.setMetadata('BaseDatastoreConfig', config, target);
1291
- };
1234
+ class ErrorResponse {
1235
+ constructor(errors) {
1236
+ this.errors = [];
1237
+ if (errors) {
1238
+ this.errors = errors;
1239
+ }
1240
+ }
1292
1241
  }
1293
1242
 
1294
- class BaseMetaModel {
1295
- constructor(response) {
1296
- this.links = response.links || [];
1297
- this.meta = response.meta;
1243
+ class Rule {
1244
+ constructor() {
1245
+ this.parameters = [];
1298
1246
  }
1299
1247
  }
1300
1248
 
1301
- function BaseModelConfig(config = {}) {
1302
- return (target) => {
1303
- if (typeof config['meta'] === 'undefined' || config['meta'] == null) {
1304
- config['meta'] = BaseMetaModel;
1249
+ class InputErrorPipe {
1250
+ constructor(translate) {
1251
+ this.translate = translate;
1252
+ }
1253
+ transform(value, filedTranslationKey) {
1254
+ let rvalue = '';
1255
+ if (value !== null) {
1256
+ if (value['invalid'] === true) {
1257
+ rvalue = 'ERROR.INVALID';
1258
+ }
1259
+ if (value['mustMatch'] === true) {
1260
+ rvalue = 'Account.Password.MustMach';
1261
+ }
1262
+ if (value['required'] === true) {
1263
+ const field = this.translate.instant(filedTranslationKey.field);
1264
+ rvalue = this.translate.instant('General.Field.Required', { field });
1265
+ }
1266
+ if (value['minlength']) {
1267
+ const field = this.translate.instant(filedTranslationKey.field);
1268
+ rvalue = this.translate.instant('General.Field.MinLength', { field, requiredLength: value.minlength.requiredLength });
1269
+ }
1305
1270
  }
1306
- MetadataStorage.setMetadata('BaseModelConfig', config, target);
1307
- };
1271
+ return rvalue;
1272
+ }
1273
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: InputErrorPipe, deps: [{ token: i1$3.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe }); }
1274
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: InputErrorPipe, isStandalone: false, name: "inputError" }); }
1308
1275
  }
1276
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: InputErrorPipe, decorators: [{
1277
+ type: Pipe,
1278
+ args: [{
1279
+ name: 'inputError',
1280
+ standalone: false
1281
+ }]
1282
+ }], ctorParameters: () => [{ type: i1$3.TranslateService }] });
1309
1283
 
1310
- function CustomType(config = {}) {
1311
- return (target, propertyName) => {
1312
- const annotations = MetadataStorage.getMetadata('CustomType', target) || [];
1313
- annotations.push({
1314
- propertyName,
1315
- relationship: config.key || propertyName
1316
- });
1317
- MetadataStorage.setMetadata('CustomType', annotations, target);
1318
- };
1284
+ class Nl2brPipe {
1285
+ transform(value, args) {
1286
+ // return value.replace(/\n/g, '<br />');
1287
+ if (value) {
1288
+ value = value.replace(/(?:\r\n\r\n|\r\r|\n\n)/g, '</p><p>');
1289
+ return '<p>' + value.replace(/(?:\r\n|\r|\n)/g, '<br>') + '</p>';
1290
+ }
1291
+ return value;
1292
+ }
1293
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: Nl2brPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1294
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: Nl2brPipe, isStandalone: false, name: "nl2br" }); }
1319
1295
  }
1296
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: Nl2brPipe, decorators: [{
1297
+ type: Pipe,
1298
+ args: [{
1299
+ name: 'nl2br',
1300
+ standalone: false
1301
+ }]
1302
+ }] });
1320
1303
 
1321
- class CacheInterceptor {
1322
- constructor(expirationTime, cacheService) {
1323
- this.expirationTime = expirationTime;
1324
- this.cacheService = cacheService;
1325
- this.cache = new Map();
1304
+ class BaseDatastore {
1305
+ // tslint:enable:max-line-length
1306
+ get getDirtyAttributes() {
1307
+ if (this.datastoreConfig.overrides
1308
+ && this.datastoreConfig.overrides.getDirtyAttributes) {
1309
+ return this.datastoreConfig.overrides.getDirtyAttributes;
1310
+ }
1311
+ else {
1312
+ return BaseDatastore.getDirtyAttributes;
1313
+ }
1326
1314
  }
1327
- intercept(request, next) {
1328
- const bypassCache = request.params.get('bypassCache') || false;
1329
- if (bypassCache || request.method !== 'GET') {
1330
- return next.handle(request);
1315
+ get getAllAttributes() {
1316
+ if (this.datastoreConfig.overrides
1317
+ && this.datastoreConfig.overrides.getAllAttributes) {
1318
+ return this.datastoreConfig.overrides.getAllAttributes;
1331
1319
  }
1332
- if (!bypassCache) {
1333
- const cachedResponse = this.cacheService.get(request.urlWithParams);
1334
- if (cachedResponse) {
1335
- return of(cachedResponse.clone());
1336
- //return cachedResponse;
1337
- }
1320
+ else {
1321
+ return BaseDatastore.getAllAttributes;
1338
1322
  }
1339
- return next.handle(request).pipe(tap((event) => {
1340
- if (event instanceof HttpResponse) {
1341
- this.cacheService.set(request.urlWithParams, event.clone(), this.expirationTime);
1323
+ }
1324
+ // protected config: DatastoreConfig;
1325
+ static getDirtyAttributes(attributesMetadata) {
1326
+ const dirtyData = {};
1327
+ for (const propertyName in attributesMetadata) {
1328
+ if (attributesMetadata.hasOwnProperty(propertyName)) {
1329
+ const metadata = attributesMetadata[propertyName];
1330
+ if (metadata.hasDirtyAttributes) {
1331
+ const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
1332
+ dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
1333
+ }
1342
1334
  }
1343
- }));
1344
- // const cachedItem = this.cache.get(request.url);
1345
- // if (cachedItem && cachedItem.expiration > Date.now()) {
1346
- // return of(cachedItem.response.clone());
1347
- // }
1348
- // return next.handle(request).pipe(
1349
- // tap(event => {
1350
- // if (event instanceof HttpResponse) {
1351
- // this.cache.set(request.url, { response: event.clone(), expiration: Date.now() + this.expirationTime });
1352
- // }
1353
- // })
1354
- // );
1335
+ }
1336
+ return dirtyData;
1355
1337
  }
1356
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheInterceptor, deps: [{ token: 'CACHE_EXPIRATION_TIME' }, { token: CacheService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1357
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheInterceptor }); }
1358
- }
1359
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheInterceptor, decorators: [{
1360
- type: Injectable
1361
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1362
- type: Inject,
1363
- args: ['CACHE_EXPIRATION_TIME']
1364
- }] }, { type: CacheService }] });
1365
-
1366
- class BaseModel {
1367
- // tslint:disable-next-line:variable-name
1368
- constructor(_datastore, data) {
1369
- this._datastore = _datastore;
1370
- if (data) {
1371
- if (data.id) {
1372
- this.id = data.id;
1338
+ static getAllAttributes(attributesMetadata) {
1339
+ const dirtyData = {};
1340
+ for (const propertyName in attributesMetadata) {
1341
+ if (attributesMetadata.hasOwnProperty(propertyName)) {
1342
+ const metadata = attributesMetadata[propertyName];
1343
+ const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
1344
+ dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
1373
1345
  }
1374
- Object.assign(this, data);
1375
1346
  }
1347
+ return dirtyData;
1376
1348
  }
1377
- save(params, headers, customUrl, customBody) {
1378
- const attributesMetadata = this[AttributeMetadata];
1379
- return this._datastore.saveRecord(attributesMetadata, this, params, headers, customUrl, customBody);
1349
+ constructor(httpClient, cacheService) {
1350
+ this.httpClient = httpClient;
1351
+ this.cacheService = cacheService;
1352
+ // tslint:disable-next-line:variable-name
1353
+ this._store = {};
1354
+ // tslint:enable:max-line-length
1355
+ // tslint:disable-next-line:ban-types
1356
+ this.toQueryString = this.datastoreConfig.overrides
1357
+ && this.datastoreConfig.overrides.toQueryString ?
1358
+ this.datastoreConfig.overrides.toQueryString : this._toQueryString;
1380
1359
  }
1381
- patch(origModel, params, headers, customUrl) {
1382
- const attributesMetadata = this[AttributeMetadata];
1383
- return this._datastore.patchRecord(attributesMetadata, this, origModel, params, headers, customUrl);
1360
+ findAll(modelType, params, headers, customUrl) {
1361
+ const customHeadhers = this.buildHeaders(headers);
1362
+ const htmlParams = this.buildParams(modelType, params);
1363
+ const url = this.buildUrl(modelType, customUrl);
1364
+ const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
1365
+ .pipe(map(res => this.extractQueryData(res, modelType)), catchError(this.handleError));
1366
+ return response;
1384
1367
  }
1385
- replace(params, headers, customUrl, customBody) {
1386
- const attributesMetadata = this[AttributeMetadata];
1387
- return this._datastore.replaceRecord(attributesMetadata, this, params, headers, customUrl, customBody);
1368
+ findRecord(modelType, id, params, headers, customUrl) {
1369
+ const customHeadhers = this.buildHeaders(headers);
1370
+ let url = this.buildUrl(modelType, customUrl);
1371
+ if (id) {
1372
+ url += '/' + id;
1373
+ }
1374
+ const htmlParams = this.buildParams(modelType, params);
1375
+ const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
1376
+ .pipe(map(res => this.entityToModel(res, modelType, undefined)), catchError(this.handleError));
1377
+ return response;
1378
+ }
1379
+ getCustom(modelType, params, headers, customUrl, customResponseType) {
1380
+ const customHeadhers = this.buildHeaders(headers);
1381
+ const url = this.buildUrl(modelType, customUrl);
1382
+ const htmlParams = this.buildParams(modelType, params);
1383
+ if (!customResponseType)
1384
+ customResponseType = 'json';
1385
+ return this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true, responseType: customResponseType });
1386
+ }
1387
+ postCustom(modelType, body, params, headers, customUrl) {
1388
+ const customHeadhers = this.buildHeaders(headers);
1389
+ const url = this.buildUrl(modelType, customUrl);
1390
+ const htmlParams = this.buildParams(modelType, params);
1391
+ return this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, reportProgress: true, withCredentials: true });
1392
+ }
1393
+ patchCustom(modelType, body, params, headers, customUrl) {
1394
+ const customHeadhers = this.buildHeaders(headers);
1395
+ const url = this.buildUrl(modelType, customUrl);
1396
+ const htmlParams = this.buildParams(modelType, params);
1397
+ return this.httpClient.patch(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
1398
+ }
1399
+ createRecord(modelType, data) {
1400
+ return new modelType(data);
1401
+ }
1402
+ saveRecord(attributesMetadata, model, params, headers, customUrl, customBody) {
1403
+ const modelType = model.constructor;
1404
+ const modelConfig = model.modelConfig;
1405
+ const customHeadhers = this.buildHeaders(headers);
1406
+ const url = this.buildUrl(modelType, customUrl);
1407
+ const htmlParams = this.buildParams(modelType, params);
1408
+ let httpCall;
1409
+ const body = customBody || this.modelToEntity(model, attributesMetadata);
1410
+ if (model.id) {
1411
+ // tslint:disable-next-line:max-line-length
1412
+ httpCall = this.httpClient.patch(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
1413
+ }
1414
+ else {
1415
+ httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
1416
+ }
1417
+ return httpCall
1418
+ .pipe(map(res => {
1419
+ this.cacheService.clearCacheContainingKeyword(url);
1420
+ const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
1421
+ return this.entityToModel(data, modelType);
1422
+ }), catchError(this.handleError));
1423
+ }
1424
+ patchRecord(attributesMetadata, model, origModel, params, headers, customUrl) {
1425
+ const modelType = model.constructor;
1426
+ const modelConfig = model.modelConfig;
1427
+ const customHeadhers = this.buildHeaders(headers);
1428
+ const url = this.buildUrl(modelType, customUrl);
1429
+ const htmlParams = this.buildParams(modelType, params);
1430
+ let httpCall;
1431
+ let origData = { id: '' };
1432
+ if (origModel)
1433
+ origData = this.modelToEntity(origModel, origModel.attributeMetadata, true);
1434
+ const newData = this.modelToEntity(model, attributesMetadata, true);
1435
+ newData.id = origData.id;
1436
+ const patch = compare(origData, newData);
1437
+ if (patch.length > 0) {
1438
+ httpCall = this.httpClient.patch(url + '/' + model.id, patch, { headers: customHeadhers, params: htmlParams, withCredentials: true });
1439
+ return httpCall
1440
+ .pipe(map(res => {
1441
+ this.cacheService.clearCacheContainingKeyword(url);
1442
+ const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
1443
+ return this.entityToModel(data, modelType);
1444
+ }), catchError(this.handleError));
1445
+ }
1446
+ else {
1447
+ return new Observable((observer) => {
1448
+ observer.next(model);
1449
+ observer.complete();
1450
+ });
1451
+ }
1452
+ }
1453
+ // getPatch<T extends BaseModel>(
1454
+ // model: T,
1455
+ // origModel: T): any {
1456
+ // }
1457
+ replaceRecord(attributesMetadata, model, params, headers, customUrl, customBody) {
1458
+ const modelType = model.constructor;
1459
+ const modelConfig = model.modelConfig;
1460
+ const customHeadhers = this.buildHeaders(headers);
1461
+ const url = this.buildUrl(modelType, customUrl);
1462
+ const htmlParams = this.buildParams(modelType, params);
1463
+ let httpCall;
1464
+ const body = customBody || this.modelToEntity(model, attributesMetadata, true);
1465
+ if (model.id) {
1466
+ httpCall = this.httpClient.put(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
1467
+ }
1468
+ else {
1469
+ httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
1470
+ }
1471
+ return httpCall
1472
+ .pipe(map(res => {
1473
+ this.cacheService.clearCacheContainingKeyword(url);
1474
+ const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
1475
+ return this.entityToModel(data, modelType);
1476
+ }), catchError(this.handleError));
1477
+ }
1478
+ deleteRecord(modelType, id, headers, customUrl) {
1479
+ const customHeadhers = this.buildHeaders(headers);
1480
+ let url = this.buildUrl(modelType, customUrl);
1481
+ if (!url.includes('share')) {
1482
+ url = url + '/' + id;
1483
+ }
1484
+ // const idParam = new HttpParams().set('id', id);
1485
+ return this.httpClient.delete(url, { headers: customHeadhers, withCredentials: true })
1486
+ .pipe(map(res => {
1487
+ this.cacheService.clearCacheContainingKeyword(url);
1488
+ return res;
1489
+ }), catchError(this.handleError));
1490
+ }
1491
+ buildUrl(modelType, customUrl) {
1492
+ if (customUrl) {
1493
+ return customUrl;
1494
+ }
1495
+ const modelConfig = MetadataStorage.getMetadata('BaseModelConfig', modelType);
1496
+ const baseUrl = modelConfig.baseUrl || this.datastoreConfig.baseUrl;
1497
+ const apiVersion = modelConfig.apiVersion || this.datastoreConfig.apiVersion;
1498
+ const modelEndpointUrl = modelConfig.modelEndpointUrl || modelConfig.type;
1499
+ const url = [baseUrl, apiVersion, modelEndpointUrl].filter((x) => x).join('/');
1500
+ return url;
1501
+ }
1502
+ extractQueryData(res, modelType) {
1503
+ let result;
1504
+ const body = res;
1505
+ const models = [];
1506
+ for (const data of body.data) {
1507
+ const model = this.entityToModel(data, modelType, undefined);
1508
+ models.push(model);
1509
+ }
1510
+ result = new BaseQueryData(models, this.parseMeta(body, modelType));
1511
+ return result;
1512
+ }
1513
+ deserializeModel(modelType, data) {
1514
+ data = this.transformSerializedNamesToPropertyNames(modelType, data);
1515
+ return new modelType(data);
1388
1516
  }
1389
- get attributeMetadata() {
1390
- const attributesMetadata = this[AttributeMetadata];
1391
- return attributesMetadata;
1517
+ handleError(error) {
1518
+ if (error.error instanceof ErrorEvent) {
1519
+ // A client-side or network error occurred. Handle it accordingly.
1520
+ // console.error('An error occurred:', error.error.message);
1521
+ }
1522
+ else {
1523
+ // The backend returned an unsuccessful response code.
1524
+ // The response body may contain clues as to what went wrong,
1525
+ // console.error(
1526
+ // 'Backend returned code ${error.status}, ' +
1527
+ // 'body was: ${error.error}');
1528
+ }
1529
+ // return an observable with a user-facing error message
1530
+ return throwError(error);
1392
1531
  }
1393
- set attributeMetadata(val) {
1394
- this[AttributeMetadata] = val;
1532
+ parseMeta(body, modelType) {
1533
+ const metaModel = MetadataStorage.getMetadata('BaseModelConfig', modelType).meta;
1534
+ return new metaModel(body);
1395
1535
  }
1396
- get hasDirtyAttributes() {
1397
- const attributesMetadata = this[AttributeMetadata];
1398
- let hasDirtyAttributes = false;
1536
+ resetMetadataAttributes(res, attributesMetadata, modelType) {
1537
+ // TODO check why is attributesMetadata from the arguments never used
1399
1538
  for (const propertyName in attributesMetadata) {
1400
1539
  if (attributesMetadata.hasOwnProperty(propertyName)) {
1401
1540
  const metadata = attributesMetadata[propertyName];
1402
1541
  if (metadata.hasDirtyAttributes) {
1403
- hasDirtyAttributes = true;
1404
- break;
1542
+ metadata.hasDirtyAttributes = false;
1405
1543
  }
1406
1544
  }
1407
1545
  }
1408
- return hasDirtyAttributes;
1409
- }
1410
- rollbackAttributes() {
1411
- const attributesMetadata = this[AttributeMetadata];
1412
- let metadata;
1413
- for (const propertyName in attributesMetadata) {
1414
- if (attributesMetadata.hasOwnProperty(propertyName)) {
1415
- if (attributesMetadata[propertyName].hasDirtyAttributes) {
1416
- this[propertyName] = attributesMetadata[propertyName].oldValue;
1417
- metadata = {
1418
- hasDirtyAttributes: false,
1419
- newValue: attributesMetadata[propertyName].oldValue,
1420
- oldValue: undefined
1421
- };
1422
- attributesMetadata[propertyName] = metadata;
1423
- }
1424
- }
1546
+ if (res) {
1547
+ res.attributeMetadata = attributesMetadata;
1425
1548
  }
1426
- this[AttributeMetadata] = attributesMetadata;
1427
- }
1428
- get modelConfig() {
1429
- return MetadataStorage.getMetadata('BaseModelConfig', this.constructor);
1549
+ return res;
1430
1550
  }
1431
- deserializeModel(modelType, data) {
1432
- data = this.transformSerializedNamesToPropertyNames(modelType, data);
1433
- return new modelType(this._datastore, data);
1551
+ get datastoreConfig() {
1552
+ const configFromDecorator = MetadataStorage.getMetadata('BaseDatastoreConfig', this.constructor);
1553
+ return Object.assign(configFromDecorator, this.config);
1434
1554
  }
1435
1555
  transformSerializedNamesToPropertyNames(modelType, attributes) {
1556
+ const apiFieldMap = this.getApiFieldMap(modelType);
1557
+ if (apiFieldMap) {
1558
+ const properties = {};
1559
+ Object.keys(apiFieldMap).forEach((serializedName) => {
1560
+ if (attributes[serializedName] !== null && attributes[serializedName] !== undefined) {
1561
+ properties[apiFieldMap[serializedName]] = attributes[serializedName];
1562
+ }
1563
+ });
1564
+ return properties;
1565
+ }
1436
1566
  const serializedNameToPropertyName = this.getModelPropertyNames(modelType.prototype);
1437
1567
  const properties = {};
1438
1568
  Object.keys(serializedNameToPropertyName).forEach((serializedName) => {
@@ -1445,154 +1575,75 @@ class BaseModel {
1445
1575
  getModelPropertyNames(model) {
1446
1576
  return MetadataStorage.getMetadata('AttributeMapping', model);
1447
1577
  }
1448
- getModelRequiredPropertyNames(model) {
1449
- return MetadataStorage.getMetadata('AttributeRequired', model);
1450
- }
1451
- getModelDefaultPropertyValues(model) {
1452
- return MetadataStorage.getMetadata('AttributedefaultValue', model);
1578
+ getApiFieldMap(modelType) {
1579
+ return modelType.apiFieldMap || null;
1453
1580
  }
1454
- getModelSubGroupPropertyNames(model) {
1455
- return MetadataStorage.getMetadata('AttributeformSubGroup', model);
1581
+ buildHeaders(customHeaders) {
1582
+ const headers = {
1583
+ Accept: 'application/json-patch+json',
1584
+ // 'Content-Type': 'application/vnd.api+json',
1585
+ 'Content-Type': 'application/json-patch+json'
1586
+ };
1587
+ if (customHeaders && customHeaders.keys().length) {
1588
+ // tslint:disable-next-line:variable-name
1589
+ Object.assign({}, headers, customHeaders.keys().map(header_name => {
1590
+ headers['' + header_name] = customHeaders.get(header_name);
1591
+ }));
1592
+ }
1593
+ return new HttpHeaders(headers);
1456
1594
  }
1457
- getFromGroup(fb) {
1458
- const props = Object.keys(this.getModelPropertyNames(this));
1459
- const requiredProps = this.getModelRequiredPropertyNames(this);
1460
- const defaultValues = this.getModelDefaultPropertyValues(this);
1461
- const formSubGroupsValues = this.getModelSubGroupPropertyNames(this);
1462
- const controlsConfig = {};
1463
- const that = this;
1464
- if (props) {
1465
- props.forEach((property) => {
1466
- const value = that[property] !== undefined ? that[property] : defaultValues[property];
1467
- const formSubGroup = formSubGroupsValues[property] ?? null;
1468
- if (requiredProps[property]) {
1469
- if (formSubGroup)
1470
- this.getSubFromGroup(fb, controlsConfig, formSubGroup).addControl(property, fb.control(value, Validators.required));
1471
- else
1472
- controlsConfig[property] = [value, Validators.required];
1473
- }
1474
- else {
1475
- if (formSubGroup)
1476
- this.getSubFromGroup(fb, controlsConfig, formSubGroup).addControl(property, fb.control(value));
1477
- else
1478
- controlsConfig[property] = value;
1479
- }
1595
+ buildParams(modelType, params) {
1596
+ let httpParams = new HttpParams();
1597
+ if (params) {
1598
+ Object.keys(params)
1599
+ .filter(key => {
1600
+ const v = params[key];
1601
+ return (Array.isArray(v) || typeof v === 'string') ?
1602
+ (v.length > 0) :
1603
+ (v !== null && v !== undefined);
1604
+ })
1605
+ .forEach(key => {
1606
+ httpParams = httpParams.set(key, params[key]);
1480
1607
  });
1481
1608
  }
1482
- return fb.group(controlsConfig);
1609
+ const modelConfig = MetadataStorage.getMetadata('BaseModelConfig', modelType);
1610
+ httpParams = httpParams.set('bypassCache', modelConfig.bypassCache || false);
1611
+ return httpParams;
1483
1612
  }
1484
- getSubFromGroup(fb, controlsConfig, subGroup) {
1485
- if (!controlsConfig[subGroup])
1486
- controlsConfig[subGroup] = fb.group({});
1487
- return controlsConfig[subGroup];
1613
+ entityToModel(res, modelType, model) {
1614
+ return this.extractRecordDataJson(res, modelType, model);
1488
1615
  }
1489
- getModelFromFormGroup(formGroup, id) {
1490
- try {
1491
- const props = Object.keys(this.getModelPropertyNames(this));
1492
- const formSubGroupsValues = this.getModelSubGroupPropertyNames(this);
1493
- const data = {};
1494
- if (id) {
1495
- data.id = id;
1496
- }
1497
- const that = this;
1498
- if (props) {
1499
- props.forEach((property) => {
1500
- const formSubGroup = formSubGroupsValues[property] ?? null;
1501
- if (!formSubGroup)
1502
- data[property] = formGroup.controls[property].value ?? null;
1503
- else
1504
- data[property] = formGroup.controls[formSubGroup].controls[property].value ?? null;
1505
- });
1506
- }
1507
- if (data) {
1508
- if (id) {
1509
- this.id = id;
1510
- }
1511
- Object.assign(this, data);
1512
- }
1616
+ extractRecordDataJson(res, modelType, model) {
1617
+ const body = res;
1618
+ if (!body) {
1619
+ throw new Error('no body in response');
1513
1620
  }
1514
- catch (error) {
1515
- Object.assign(this, formGroup.value);
1621
+ if (model) {
1622
+ Object.assign(model, body);
1516
1623
  }
1624
+ const deserializedModel = model || this.deserializeModel(modelType, body.data || body);
1625
+ return deserializedModel;
1517
1626
  }
1518
- getSerializedModel() {
1519
- const attributesMetadata = this[AttributeMetadata];
1520
- return this._datastore.modelToEntity(this, attributesMetadata, true);
1521
- }
1522
- getCellClass(property) {
1523
- return '';
1524
- }
1525
- }
1526
-
1527
- class ErrorResponse {
1528
- constructor(errors) {
1529
- this.errors = [];
1530
- if (errors) {
1531
- this.errors = errors;
1627
+ modelToEntity(model, attributesMetadata, allAttributes = false) {
1628
+ let attributes;
1629
+ if (allAttributes) {
1630
+ attributes = this.getAllAttributes(attributesMetadata, model);
1532
1631
  }
1533
- }
1534
- }
1535
-
1536
- class Rule {
1537
- constructor() {
1538
- this.parameters = [];
1539
- }
1540
- }
1541
-
1542
- class InputErrorPipe {
1543
- constructor(translate) {
1544
- this.translate = translate;
1545
- }
1546
- transform(value, filedTranslationKey) {
1547
- let rvalue = '';
1548
- if (value !== null) {
1549
- if (value['invalid'] === true) {
1550
- rvalue = 'ERROR.INVALID';
1551
- }
1552
- if (value['mustMatch'] === true) {
1553
- rvalue = 'Account.Password.MustMach';
1554
- }
1555
- if (value['required'] === true) {
1556
- const field = this.translate.instant(filedTranslationKey.field);
1557
- rvalue = this.translate.instant('General.Field.Required', { field });
1558
- }
1559
- if (value['minlength']) {
1560
- const field = this.translate.instant(filedTranslationKey.field);
1561
- rvalue = this.translate.instant('General.Field.MinLength', { field, requiredLength: value.minlength.requiredLength });
1562
- }
1632
+ else {
1633
+ attributes = this.getDirtyAttributes(attributesMetadata, model);
1563
1634
  }
1564
- return rvalue;
1635
+ // this.getRelationships(model, attributes);
1636
+ return attributes;
1565
1637
  }
1566
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: InputErrorPipe, deps: [{ token: i1$3.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe }); }
1567
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: InputErrorPipe, isStandalone: false, name: "inputError" }); }
1568
- }
1569
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: InputErrorPipe, decorators: [{
1570
- type: Pipe,
1571
- args: [{
1572
- name: 'inputError',
1573
- standalone: false
1574
- }]
1575
- }], ctorParameters: () => [{ type: i1$3.TranslateService }] });
1576
-
1577
- class Nl2brPipe {
1578
- transform(value, args) {
1579
- // return value.replace(/\n/g, '<br />');
1580
- if (value) {
1581
- value = value.replace(/(?:\r\n\r\n|\r\r|\n\n)/g, '</p><p>');
1582
- return '<p>' + value.replace(/(?:\r\n|\r|\n)/g, '<br>') + '</p>';
1583
- }
1584
- return value;
1638
+ _toQueryString(params) {
1639
+ return queryString.stringify(params, { arrayFormat: 'bracket' });
1585
1640
  }
1586
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: Nl2brPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1587
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: Nl2brPipe, isStandalone: false, name: "nl2br" }); }
1641
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseDatastore, deps: [{ token: i1$1.HttpClient }, { token: CacheService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1642
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseDatastore }); }
1588
1643
  }
1589
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: Nl2brPipe, decorators: [{
1590
- type: Pipe,
1591
- args: [{
1592
- name: 'nl2br',
1593
- standalone: false
1594
- }]
1595
- }] });
1644
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseDatastore, decorators: [{
1645
+ type: Injectable
1646
+ }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: CacheService }] });
1596
1647
 
1597
1648
  let DatastoreCore = class DatastoreCore extends BaseDatastore {
1598
1649
  constructor(http, cacheService, configExt) {
@@ -1821,7 +1872,7 @@ class EmployeeService extends BaseService {
1821
1872
  super(datastore);
1822
1873
  this.setModelType(Employee);
1823
1874
  }
1824
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: EmployeeService, deps: [{ token: DatastoreCore }], target: i0.ɵɵFactoryTarget.Injectable }); }
1875
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: EmployeeService, deps: [{ token: DATASTORE_PORT }], target: i0.ɵɵFactoryTarget.Injectable }); }
1825
1876
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: EmployeeService, providedIn: 'root' }); }
1826
1877
  }
1827
1878
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: EmployeeService, decorators: [{
@@ -1829,7 +1880,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
1829
1880
  args: [{
1830
1881
  providedIn: 'root'
1831
1882
  }]
1832
- }], ctorParameters: () => [{ type: DatastoreCore }] });
1883
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1884
+ type: Inject,
1885
+ args: [DATASTORE_PORT]
1886
+ }] }] });
1833
1887
 
1834
1888
  class LocalFileService {
1835
1889
  constructor(http) {
@@ -1871,7 +1925,7 @@ class RoleService extends BaseService {
1871
1925
  const url = `${this.datastore.buildUrl(Role)}/${roleId}/rights`;
1872
1926
  return this.getCustom(null, null, url);
1873
1927
  }
1874
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: RoleService, deps: [{ token: DatastoreCore }], target: i0.ɵɵFactoryTarget.Injectable }); }
1928
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: RoleService, deps: [{ token: DATASTORE_PORT }], target: i0.ɵɵFactoryTarget.Injectable }); }
1875
1929
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: RoleService, providedIn: 'root' }); }
1876
1930
  }
1877
1931
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: RoleService, decorators: [{
@@ -1879,7 +1933,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
1879
1933
  args: [{
1880
1934
  providedIn: 'root'
1881
1935
  }]
1882
- }], ctorParameters: () => [{ type: DatastoreCore }] });
1936
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1937
+ type: Inject,
1938
+ args: [DATASTORE_PORT]
1939
+ }] }] });
1883
1940
 
1884
1941
  class RouteHistoryService {
1885
1942
  constructor(router) {
@@ -1961,7 +2018,7 @@ class UserService extends BaseService {
1961
2018
  const response = this.datastore.findAll(Menu);
1962
2019
  return response;
1963
2020
  }
1964
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: UserService, deps: [{ token: DatastoreCore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2021
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: UserService, deps: [{ token: DATASTORE_PORT }], target: i0.ɵɵFactoryTarget.Injectable }); }
1965
2022
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: UserService, providedIn: 'root' }); }
1966
2023
  }
1967
2024
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: UserService, decorators: [{
@@ -1969,11 +2026,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
1969
2026
  args: [{
1970
2027
  providedIn: 'root'
1971
2028
  }]
1972
- }], ctorParameters: () => [{ type: DatastoreCore }] });
2029
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2030
+ type: Inject,
2031
+ args: [DATASTORE_PORT]
2032
+ }] }] });
1973
2033
 
1974
2034
  const PROVIDERS = [
1975
2035
  BaseDatastore,
1976
2036
  DatastoreCore,
2037
+ { provide: DATASTORE_PORT, useExisting: DatastoreCore },
1977
2038
  DatePipe,
1978
2039
  DecimalPipe,
1979
2040
  PercentPipe
@@ -2097,7 +2158,7 @@ class RightService extends BaseService {
2097
2158
  super(datastore);
2098
2159
  this.setModelType(Right);
2099
2160
  }
2100
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: RightService, deps: [{ token: DatastoreCore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2161
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: RightService, deps: [{ token: DATASTORE_PORT }], target: i0.ɵɵFactoryTarget.Injectable }); }
2101
2162
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: RightService, providedIn: 'root' }); }
2102
2163
  }
2103
2164
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: RightService, decorators: [{
@@ -2105,7 +2166,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
2105
2166
  args: [{
2106
2167
  providedIn: 'root'
2107
2168
  }]
2108
- }], ctorParameters: () => [{ type: DatastoreCore }] });
2169
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2170
+ type: Inject,
2171
+ args: [DATASTORE_PORT]
2172
+ }] }] });
2109
2173
 
2110
2174
  function readFileAsync(file) {
2111
2175
  return new Promise((resolve, reject) => {
@@ -2142,5 +2206,5 @@ function getValueFromJsonData(jsonData, key) {
2142
2206
  * Generated bundle index. Do not edit.
2143
2207
  */
2144
2208
 
2145
- export { Attribute, AuthService, BaseCrudImplementation, BaseDatastore, BaseDatastoreConfig, BaseFormEditComponent, BaseMetaModel, BaseModel, BaseModelConfig, BaseQueryData, BaseService, BaseTableImplementation, CacheInterceptor, CacheService, CellTextAlign, Configurations, CustomType, CustomValidators, DIALOG_SERVICE_TOKEN, DatastoreCore, DynamicallyModelResolver, DynamicallyServiceResolver, Employee, EmployeeService, ErrorResponse, FieldErrorDisplayComponent, GridLayoutFormat, InputErrorPipe, LocalFileService, MODEL_SERVICE, MODEL_TOKEN, Menu, MetadataStorage, Nl2brPipe, OIDC_CLIENT_SETTINGS, PROVIDERS, PageNotFoundComponent, RSL_FORM_IMPLEMENTATIONS_TOKEN, Right, RightService, Role, RoleService, RouteHistoryService, RslBaseModule, Rule, Tokens, TranslateloaderService, UnderConstructionComponent, User, UserService, getValueFromJsonData, provideAuth, provideOidcUserManager, readFileAsync };
2209
+ export { Attribute, AuthService, BaseCrudImplementation, BaseDatastore, BaseDatastoreConfig, BaseFormEditComponent, BaseMetaModel, BaseModel, BaseModelConfig, BaseQueryData, BaseService, BaseTableImplementation, CacheInterceptor, CacheService, CellTextAlign, Configurations, CustomType, CustomValidators, DATASTORE_PORT, DIALOG_SERVICE_TOKEN, DatastoreCore, DynamicallyModelResolver, DynamicallyServiceResolver, Employee, EmployeeService, ErrorResponse, FieldErrorDisplayComponent, GridLayoutFormat, InputErrorPipe, LocalFileService, MODEL_SERVICE, MODEL_TOKEN, Menu, MetadataStorage, Nl2brPipe, OIDC_CLIENT_SETTINGS, OIDC_GUEST_CLIENT_SETTINGS, PROVIDERS, PageNotFoundComponent, RSL_FORM_IMPLEMENTATIONS_TOKEN, Right, RightService, Role, RoleService, RouteHistoryService, RslBaseModule, Rule, Tokens, TranslateloaderService, UnderConstructionComponent, User, UserService, getValueFromJsonData, provideAuth, provideOidcUserManager, readFileAsync };
2146
2210
  //# sourceMappingURL=rosoftlab-core.mjs.map