@rosoftlab/core 1.0.5-alpha-5 → 1.0.5-alpha-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/rosoftlab-core.mjs +1242 -1178
- package/fesm2022/rosoftlab-core.mjs.map +1 -1
- package/lib/auth/auth.service.d.ts +9 -3
- package/lib/auth/provide-auth.d.ts +1 -1
- package/lib/auth/tokens.d.ts +1 -0
- package/lib/base-components/base-crud-implementation.d.ts +2 -2
- package/lib/base-components/base-table-implementation.d.ts +2 -2
- package/lib/index.d.ts +2 -0
- package/lib/models/base.model.d.ts +9 -16
- package/lib/models/employee.d.ts +0 -1
- package/lib/models/menu.d.ts +0 -1
- package/lib/models/metadata-storage.d.ts +1 -0
- package/lib/models/right.d.ts +0 -1
- package/lib/models/role.d.ts +0 -1
- package/lib/models/user.d.ts +0 -1
- package/lib/services/base-datastore.service.d.ts +4 -3
- package/lib/services/base.service.d.ts +5 -4
- package/lib/services/datastore-port.d.ts +19 -0
- package/lib/services/employee.service.d.ts +2 -2
- package/lib/services/right.service.d.ts +3 -2
- package/lib/services/role.service.d.ts +3 -2
- package/lib/services/user.service.d.ts +3 -2
- package/lib/tokens/datastore-token.d.ts +3 -0
- package/lib/tokens/dynamic-form-tokens.d.ts +2 -2
- package/package.json +1 -1
|
@@ -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 {
|
|
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,
|
|
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';
|
|
16
|
-
import { compare } from 'fast-json-patch';
|
|
17
|
-
import queryString from 'query-string';
|
|
18
|
-
import { map, catchError, tap, filter } from 'rxjs/operators';
|
|
19
17
|
import { parseISO } from 'date-fns';
|
|
20
18
|
import { __decorate, __metadata } from 'tslib';
|
|
19
|
+
import { compare } from 'fast-json-patch';
|
|
20
|
+
import queryString from 'query-string';
|
|
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');
|
|
21
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
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
167
|
+
{ provide: OIDC_GUEST_CLIENT_SETTINGS, useValue: guest_settings },
|
|
168
|
+
provideOidcUserManager()
|
|
120
169
|
];
|
|
121
170
|
}
|
|
122
171
|
|
|
@@ -296,1143 +345,1244 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
296
345
|
args: ['class']
|
|
297
346
|
}] } });
|
|
298
347
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
348
|
+
const DATASTORE_PORT = new InjectionToken('DATASTORE_PORT');
|
|
349
|
+
|
|
350
|
+
class BaseService {
|
|
351
|
+
constructor(datastore) {
|
|
352
|
+
this.datastore = datastore;
|
|
303
353
|
}
|
|
304
|
-
|
|
305
|
-
|
|
354
|
+
setModelType(modelType) {
|
|
355
|
+
this.modelType = modelType;
|
|
306
356
|
}
|
|
307
|
-
|
|
308
|
-
|
|
357
|
+
get(id, customInclude = '') {
|
|
358
|
+
const response = this.datastore.findRecord(this.modelType, id, { customInclude });
|
|
359
|
+
return response;
|
|
309
360
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
325
|
-
|
|
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
|
-
|
|
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
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return cachedItem.data;
|
|
414
|
+
toFormGroup(fb, fromModel) {
|
|
415
|
+
if (fromModel === undefined) {
|
|
416
|
+
fromModel = this.newModel();
|
|
341
417
|
}
|
|
342
|
-
|
|
343
|
-
return null;
|
|
418
|
+
return fromModel.getFromGroup(fb);
|
|
344
419
|
}
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
|
|
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
|
-
|
|
350
|
-
|
|
429
|
+
serializeModel(model) {
|
|
430
|
+
return this.datastore.modelToEntity(model, model.attributeMetadata, true);
|
|
351
431
|
}
|
|
352
|
-
|
|
353
|
-
|
|
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:
|
|
357
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type:
|
|
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:
|
|
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
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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
501
|
}
|
|
411
|
-
|
|
412
|
-
this.
|
|
413
|
-
this.
|
|
414
|
-
|
|
415
|
-
this.
|
|
416
|
-
|
|
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;
|
|
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();
|
|
421
508
|
}
|
|
422
|
-
|
|
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;
|
|
509
|
+
afterFormGenerated() {
|
|
429
510
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
if (
|
|
434
|
-
|
|
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;
|
|
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];
|
|
440
517
|
}
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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
|
+
});
|
|
448
530
|
}
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
return this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, reportProgress: true, 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;
|
|
454
535
|
}
|
|
455
|
-
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
const htmlParams = this.buildParams(modelType, params);
|
|
459
|
-
return this.httpClient.patch(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
536
|
+
isFieldValidFromArray(arrayIndex, field, arrayName = 'formArray') {
|
|
537
|
+
const fieldControl = this.baseForm.get(arrayName).get([arrayIndex]).get(field);
|
|
538
|
+
return !fieldControl.valid && fieldControl.touched;
|
|
460
539
|
}
|
|
461
|
-
|
|
462
|
-
return
|
|
540
|
+
displayFieldCss(field) {
|
|
541
|
+
return {
|
|
542
|
+
'has-error': this.isFieldValid(field),
|
|
543
|
+
'has-feedback': this.isFieldValid(field)
|
|
544
|
+
};
|
|
463
545
|
}
|
|
464
|
-
|
|
465
|
-
|
|
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));
|
|
546
|
+
onCancel() {
|
|
547
|
+
this.router.navigate([this.cancelRoute]);
|
|
485
548
|
}
|
|
486
|
-
|
|
487
|
-
|
|
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
|
-
}
|
|
549
|
+
onSave() {
|
|
550
|
+
this.saveModel(this.baseForm);
|
|
514
551
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
+
}
|
|
532
581
|
}
|
|
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));
|
|
539
582
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
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
|
+
}
|
|
545
611
|
}
|
|
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
612
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
613
|
+
canDeactivate() {
|
|
614
|
+
// Allow synchronous navigation (`true`) if no crisis or the crisis is unchanged
|
|
615
|
+
if (!this.baseForm.dirty) {
|
|
616
|
+
return true;
|
|
556
617
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const modelEndpointUrl = modelConfig.modelEndpointUrl || modelConfig.type;
|
|
561
|
-
const url = [baseUrl, apiVersion, modelEndpointUrl].filter((x) => x).join('/');
|
|
562
|
-
return url;
|
|
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');
|
|
563
621
|
}
|
|
564
|
-
|
|
565
|
-
|
|
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);
|
|
571
|
-
}
|
|
572
|
-
result = new BaseQueryData(models, this.parseMeta(body, modelType));
|
|
573
|
-
return result;
|
|
622
|
+
getFiledName(filedTranslationKey) {
|
|
623
|
+
return { field: this.translate.instant(filedTranslationKey) };
|
|
574
624
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
return new modelType(this, data);
|
|
625
|
+
getCustomErrorMessage(error, fieldLabel) {
|
|
626
|
+
return '';
|
|
578
627
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
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);
|
|
628
|
+
getErrorMessageFromArray(arrayIndex, field, filedTranslationKey, arrayName = 'formArray') {
|
|
629
|
+
const fieldControl = this.baseForm.get(arrayName).get([arrayIndex]).get(field);
|
|
630
|
+
return this.getErrorMessageForField(fieldControl, filedTranslationKey);
|
|
593
631
|
}
|
|
594
|
-
|
|
595
|
-
const
|
|
596
|
-
return
|
|
632
|
+
getErrorMessage(field, filedTranslationKey, formGroup = null) {
|
|
633
|
+
const fg = this.getFromGroup(formGroup);
|
|
634
|
+
return this.getErrorMessageForField(fg.get(field), filedTranslationKey);
|
|
597
635
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
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
|
-
|
|
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:
|
|
691
|
-
static { this.ɵ
|
|
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:
|
|
694
|
-
type:
|
|
695
|
-
|
|
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
|
|
698
|
-
constructor(
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
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
|
-
|
|
723
|
-
|
|
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
|
-
|
|
726
|
-
return this.
|
|
724
|
+
get hostClasses() {
|
|
725
|
+
return this.hostClass;
|
|
727
726
|
}
|
|
728
|
-
|
|
729
|
-
|
|
727
|
+
addHandler() {
|
|
728
|
+
this.router.navigate([`${this.basePath}/add`]);
|
|
730
729
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
if (
|
|
735
|
-
|
|
736
|
-
|
|
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
|
-
|
|
738
|
+
console.warn(`Property "${this.idProperty}" not found on data item:`, dataItem);
|
|
747
739
|
}
|
|
748
740
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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
|
-
|
|
758
|
-
|
|
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
759
|
}
|
|
769
|
-
|
|
770
|
-
|
|
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
|
-
}
|
|
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:
|
|
785
|
-
type:
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
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
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
this.
|
|
795
|
-
this.
|
|
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
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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
|
-
|
|
841
|
-
this.isEdit = true;
|
|
842
|
-
this.generateForm(model);
|
|
852
|
+
return value;
|
|
843
853
|
}
|
|
844
854
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
this.model = model;
|
|
849
|
-
this.baseForm = this.modelService.toFormGroup(this.fb, model);
|
|
850
|
-
this.afterFormGenerated();
|
|
851
|
-
}
|
|
852
|
-
afterFormGenerated() {
|
|
855
|
+
unmask(value) {
|
|
856
|
+
// const result = format(value, 'YYYY-MM-DDTHH:mm:ssZ');
|
|
857
|
+
return value;
|
|
853
858
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
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];
|
|
860
866
|
}
|
|
861
|
-
|
|
862
|
-
const
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
867
|
+
static getMergedMetadata(key, target) {
|
|
868
|
+
const chain = [];
|
|
869
|
+
let current = target;
|
|
870
|
+
while (current && current !== Object.prototype) {
|
|
871
|
+
chain.push(current);
|
|
872
|
+
current = Object.getPrototypeOf(current);
|
|
873
|
+
}
|
|
874
|
+
const merged = {};
|
|
875
|
+
for (let i = chain.length - 1; i >= 0; i--) {
|
|
876
|
+
const metadata = this.getMetadata(key, chain[i]);
|
|
877
|
+
if (metadata && typeof metadata === 'object') {
|
|
878
|
+
Object.assign(merged, metadata);
|
|
871
879
|
}
|
|
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]);
|
|
891
|
-
}
|
|
892
|
-
onSave() {
|
|
893
|
-
this.saveModel(this.baseForm);
|
|
880
|
+
}
|
|
881
|
+
return Object.keys(merged).length ? merged : undefined;
|
|
894
882
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
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
|
-
}
|
|
883
|
+
static setMetadata(key, value, target, propertyKey) {
|
|
884
|
+
let metadata = this.metadataMap.get(target);
|
|
885
|
+
if (!metadata) {
|
|
886
|
+
metadata = {};
|
|
887
|
+
this.metadataMap.set(target, metadata);
|
|
888
|
+
}
|
|
889
|
+
if (propertyKey) {
|
|
890
|
+
metadata[`${key}:${propertyKey}`] = value;
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
metadata[key] = value;
|
|
924
894
|
}
|
|
925
895
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
}
|
|
939
|
-
});
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
function Attribute(options = {}) {
|
|
899
|
+
return (target, propertyName) => {
|
|
900
|
+
const converter = (dataType, value, forSerialisation = false) => {
|
|
901
|
+
let attrConverter;
|
|
902
|
+
if (dataType) {
|
|
903
|
+
if (options.converter) {
|
|
904
|
+
attrConverter = options.converter;
|
|
905
|
+
}
|
|
906
|
+
else if (dataType === Date) {
|
|
907
|
+
attrConverter = new DateConverter();
|
|
940
908
|
}
|
|
941
909
|
else {
|
|
942
|
-
const
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
910
|
+
const datatype = new dataType();
|
|
911
|
+
if (datatype.mask && datatype.unmask) {
|
|
912
|
+
attrConverter = datatype;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
if (attrConverter) {
|
|
916
|
+
if (!forSerialisation) {
|
|
917
|
+
return attrConverter.mask(value);
|
|
918
|
+
}
|
|
919
|
+
return attrConverter.unmask(value);
|
|
952
920
|
}
|
|
953
921
|
}
|
|
922
|
+
return value;
|
|
923
|
+
};
|
|
924
|
+
const saveAnnotations = () => {
|
|
925
|
+
const metadata = MetadataStorage.getMetadata('Attribute', target) || {};
|
|
926
|
+
metadata[propertyName] = {
|
|
927
|
+
marked: true
|
|
928
|
+
};
|
|
929
|
+
MetadataStorage.setMetadata('Attribute', metadata, target);
|
|
930
|
+
const mappingMetadata = MetadataStorage.getMetadata('AttributeMapping', target) || {};
|
|
931
|
+
const serializedPropertyName = options.serializedName !== undefined ? options.serializedName : propertyName;
|
|
932
|
+
mappingMetadata[serializedPropertyName] = propertyName;
|
|
933
|
+
MetadataStorage.setMetadata('AttributeMapping', mappingMetadata, target);
|
|
934
|
+
const requiredMetadata = MetadataStorage.getMetadata('AttributeRequired', target) || {};
|
|
935
|
+
requiredMetadata[serializedPropertyName] = options.required !== undefined ? options.required : false;
|
|
936
|
+
MetadataStorage.setMetadata('AttributeRequired', requiredMetadata, target);
|
|
937
|
+
const defaultMetadata = MetadataStorage.getMetadata('AttributedefaultValue', target) || {};
|
|
938
|
+
defaultMetadata[serializedPropertyName] = options.defaultValue !== undefined ? options.defaultValue : null;
|
|
939
|
+
MetadataStorage.setMetadata('AttributedefaultValue', defaultMetadata, target);
|
|
940
|
+
const formSubGroupMetadata = MetadataStorage.getMetadata('AttributeformSubGroup', target) || {};
|
|
941
|
+
formSubGroupMetadata[serializedPropertyName] = options.formSubGroup !== undefined ? options.formSubGroup : null;
|
|
942
|
+
MetadataStorage.setMetadata('AttributeformSubGroup', formSubGroupMetadata, target);
|
|
943
|
+
};
|
|
944
|
+
const setMetadata = (hasDirtyAttributes, instance, oldValue, newValue, isNew) => {
|
|
945
|
+
const targetType = MetadataStorage.getMetadata('design:type', target, propertyName);
|
|
946
|
+
if (!instance[AttributeMetadata]) {
|
|
947
|
+
instance[AttributeMetadata] = {};
|
|
948
|
+
}
|
|
949
|
+
const propertyHasDirtyAttributes = typeof oldValue === 'undefined' && !isNew ? false : hasDirtyAttributes;
|
|
950
|
+
instance[AttributeMetadata][propertyName] = {
|
|
951
|
+
newValue,
|
|
952
|
+
oldValue,
|
|
953
|
+
serializedName: options.serializedName,
|
|
954
|
+
hasDirtyAttributes: propertyHasDirtyAttributes,
|
|
955
|
+
serialisationValue: converter(targetType, newValue, true)
|
|
956
|
+
};
|
|
957
|
+
};
|
|
958
|
+
const getter = function () {
|
|
959
|
+
return this['_' + propertyName];
|
|
960
|
+
};
|
|
961
|
+
const setter = function (newVal) {
|
|
962
|
+
const targetType = MetadataStorage.getMetadata('design:type', target, propertyName);
|
|
963
|
+
const convertedValue = converter(targetType, newVal);
|
|
964
|
+
if (convertedValue !== this['_' + propertyName]) {
|
|
965
|
+
setMetadata(true, this, this['_' + propertyName], newVal, !this.id);
|
|
966
|
+
this['_' + propertyName] = convertedValue;
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
if (delete target[propertyName]) {
|
|
970
|
+
saveAnnotations();
|
|
971
|
+
Object.defineProperty(target, propertyName, {
|
|
972
|
+
get: getter,
|
|
973
|
+
set: setter,
|
|
974
|
+
enumerable: true,
|
|
975
|
+
configurable: true
|
|
976
|
+
});
|
|
954
977
|
}
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
function BaseDatastoreConfig(config = {}) {
|
|
982
|
+
// tslint:disable-next-line:only-arrow-functions
|
|
983
|
+
return (target) => {
|
|
984
|
+
MetadataStorage.setMetadata('BaseDatastoreConfig', config, target);
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
class BaseMetaModel {
|
|
989
|
+
constructor(response) {
|
|
990
|
+
this.links = response.links || [];
|
|
991
|
+
this.meta = response.meta;
|
|
955
992
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
function BaseModelConfig(config = {}) {
|
|
996
|
+
return (target) => {
|
|
997
|
+
if (typeof config['meta'] === 'undefined' || config['meta'] == null) {
|
|
998
|
+
config['meta'] = BaseMetaModel;
|
|
960
999
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1000
|
+
MetadataStorage.setMetadata('BaseModelConfig', config, target);
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function CustomType(config = {}) {
|
|
1005
|
+
return (target, propertyName) => {
|
|
1006
|
+
const annotations = MetadataStorage.getMetadata('CustomType', target) || [];
|
|
1007
|
+
annotations.push({
|
|
1008
|
+
propertyName,
|
|
1009
|
+
relationship: config.key || propertyName
|
|
1010
|
+
});
|
|
1011
|
+
MetadataStorage.setMetadata('CustomType', annotations, target);
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
class CacheService {
|
|
1016
|
+
constructor() {
|
|
1017
|
+
this.cache = {};
|
|
964
1018
|
}
|
|
965
|
-
|
|
966
|
-
|
|
1019
|
+
get(key) {
|
|
1020
|
+
const cachedItem = this.cache[key];
|
|
1021
|
+
if (cachedItem && cachedItem.expiration > Date.now()) {
|
|
1022
|
+
return cachedItem.data;
|
|
1023
|
+
}
|
|
1024
|
+
this.delete(key);
|
|
1025
|
+
return null;
|
|
967
1026
|
}
|
|
968
|
-
|
|
969
|
-
|
|
1027
|
+
set(key, data, expiresInMs) {
|
|
1028
|
+
const expiration = Date.now() + expiresInMs;
|
|
1029
|
+
this.cache[key] = { data, expiration };
|
|
970
1030
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
return this.getErrorMessageForField(fieldControl, filedTranslationKey);
|
|
1031
|
+
delete(key) {
|
|
1032
|
+
delete this.cache[key];
|
|
974
1033
|
}
|
|
975
|
-
|
|
976
|
-
const
|
|
977
|
-
|
|
1034
|
+
clearCacheContainingKeyword(keyword) {
|
|
1035
|
+
const keysToDelete = Object.keys(this.cache).filter(key => key.includes(keyword));
|
|
1036
|
+
keysToDelete.forEach(key => this.delete(key));
|
|
978
1037
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1038
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1039
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheService, providedIn: 'root' }); }
|
|
1040
|
+
}
|
|
1041
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheService, decorators: [{
|
|
1042
|
+
type: Injectable,
|
|
1043
|
+
args: [{
|
|
1044
|
+
providedIn: 'root'
|
|
1045
|
+
}]
|
|
1046
|
+
}], ctorParameters: () => [] });
|
|
1047
|
+
|
|
1048
|
+
class CacheInterceptor {
|
|
1049
|
+
constructor(expirationTime, cacheService) {
|
|
1050
|
+
this.expirationTime = expirationTime;
|
|
1051
|
+
this.cacheService = cacheService;
|
|
1052
|
+
this.cache = new Map();
|
|
1053
|
+
}
|
|
1054
|
+
intercept(request, next) {
|
|
1055
|
+
const bypassCache = request.params.get('bypassCache') || false;
|
|
1056
|
+
if (bypassCache || request.method !== 'GET') {
|
|
1057
|
+
return next.handle(request);
|
|
1058
|
+
}
|
|
1059
|
+
if (!bypassCache) {
|
|
1060
|
+
const cachedResponse = this.cacheService.get(request.urlWithParams);
|
|
1061
|
+
if (cachedResponse) {
|
|
1062
|
+
return of(cachedResponse.clone());
|
|
1063
|
+
//return cachedResponse;
|
|
1001
1064
|
}
|
|
1002
1065
|
}
|
|
1003
|
-
return
|
|
1066
|
+
return next.handle(request).pipe(tap((event) => {
|
|
1067
|
+
if (event instanceof HttpResponse) {
|
|
1068
|
+
this.cacheService.set(request.urlWithParams, event.clone(), this.expirationTime);
|
|
1069
|
+
}
|
|
1070
|
+
}));
|
|
1071
|
+
// const cachedItem = this.cache.get(request.url);
|
|
1072
|
+
// if (cachedItem && cachedItem.expiration > Date.now()) {
|
|
1073
|
+
// return of(cachedItem.response.clone());
|
|
1074
|
+
// }
|
|
1075
|
+
// return next.handle(request).pipe(
|
|
1076
|
+
// tap(event => {
|
|
1077
|
+
// if (event instanceof HttpResponse) {
|
|
1078
|
+
// this.cache.set(request.url, { response: event.clone(), expiration: Date.now() + this.expirationTime });
|
|
1079
|
+
// }
|
|
1080
|
+
// })
|
|
1081
|
+
// );
|
|
1004
1082
|
}
|
|
1005
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type:
|
|
1006
|
-
static { this.ɵ
|
|
1083
|
+
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 }); }
|
|
1084
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheInterceptor }); }
|
|
1007
1085
|
}
|
|
1008
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type:
|
|
1009
|
-
type:
|
|
1010
|
-
|
|
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: [{
|
|
1086
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: CacheInterceptor, decorators: [{
|
|
1087
|
+
type: Injectable
|
|
1088
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1016
1089
|
type: Inject,
|
|
1017
|
-
args: [
|
|
1018
|
-
}] }, { type:
|
|
1090
|
+
args: ['CACHE_EXPIRATION_TIME']
|
|
1091
|
+
}] }, { type: CacheService }] });
|
|
1019
1092
|
|
|
1020
|
-
class
|
|
1021
|
-
constructor() {
|
|
1022
|
-
|
|
1023
|
-
this.
|
|
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 = '';
|
|
1093
|
+
class BaseQueryData {
|
|
1094
|
+
constructor(jsonApiModels, metaData) {
|
|
1095
|
+
this.jsonApiModels = jsonApiModels;
|
|
1096
|
+
this.metaData = metaData;
|
|
1058
1097
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
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('/');
|
|
1098
|
+
getModels() {
|
|
1099
|
+
return this.jsonApiModels;
|
|
1066
1100
|
}
|
|
1067
|
-
|
|
1068
|
-
return this.
|
|
1101
|
+
getMeta() {
|
|
1102
|
+
return this.metaData;
|
|
1069
1103
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
class BaseModel {
|
|
1107
|
+
// tslint:disable-next-line:variable-name
|
|
1108
|
+
constructor(data) {
|
|
1109
|
+
if (data) {
|
|
1110
|
+
if (data.id) {
|
|
1111
|
+
this.id = data.id;
|
|
1112
|
+
}
|
|
1113
|
+
Object.assign(this, data);
|
|
1114
|
+
}
|
|
1072
1115
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1116
|
+
get attributeMetadata() {
|
|
1117
|
+
const attributesMetadata = this[AttributeMetadata];
|
|
1118
|
+
return attributesMetadata;
|
|
1119
|
+
}
|
|
1120
|
+
set attributeMetadata(val) {
|
|
1121
|
+
this[AttributeMetadata] = val;
|
|
1122
|
+
}
|
|
1123
|
+
get hasDirtyAttributes() {
|
|
1124
|
+
const attributesMetadata = this[AttributeMetadata];
|
|
1125
|
+
let hasDirtyAttributes = false;
|
|
1126
|
+
for (const propertyName in attributesMetadata) {
|
|
1127
|
+
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1128
|
+
const metadata = attributesMetadata[propertyName];
|
|
1129
|
+
if (metadata.hasDirtyAttributes) {
|
|
1130
|
+
hasDirtyAttributes = true;
|
|
1131
|
+
break;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1079
1134
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1135
|
+
return hasDirtyAttributes;
|
|
1136
|
+
}
|
|
1137
|
+
rollbackAttributes() {
|
|
1138
|
+
const attributesMetadata = this[AttributeMetadata];
|
|
1139
|
+
let metadata;
|
|
1140
|
+
for (const propertyName in attributesMetadata) {
|
|
1141
|
+
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1142
|
+
if (attributesMetadata[propertyName].hasDirtyAttributes) {
|
|
1143
|
+
this[propertyName] = attributesMetadata[propertyName].oldValue;
|
|
1144
|
+
metadata = {
|
|
1145
|
+
hasDirtyAttributes: false,
|
|
1146
|
+
newValue: attributesMetadata[propertyName].oldValue,
|
|
1147
|
+
oldValue: undefined
|
|
1148
|
+
};
|
|
1149
|
+
attributesMetadata[propertyName] = metadata;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1082
1152
|
}
|
|
1153
|
+
this[AttributeMetadata] = attributesMetadata;
|
|
1083
1154
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1155
|
+
get modelConfig() {
|
|
1156
|
+
return MetadataStorage.getMetadata('BaseModelConfig', this.constructor);
|
|
1157
|
+
}
|
|
1158
|
+
deserializeModel(modelType, data) {
|
|
1159
|
+
data = this.transformSerializedNamesToPropertyNames(modelType, data);
|
|
1160
|
+
return new modelType(data);
|
|
1161
|
+
}
|
|
1162
|
+
transformSerializedNamesToPropertyNames(modelType, attributes) {
|
|
1163
|
+
const serializedNameToPropertyName = this.getModelPropertyNames(modelType.prototype);
|
|
1164
|
+
const properties = {};
|
|
1165
|
+
Object.keys(serializedNameToPropertyName).forEach((serializedName) => {
|
|
1166
|
+
if (attributes[serializedName] !== null && attributes[serializedName] !== undefined) {
|
|
1167
|
+
properties[serializedNameToPropertyName[serializedName]] = attributes[serializedName];
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
return properties;
|
|
1171
|
+
}
|
|
1172
|
+
getModelPropertyNames(model) {
|
|
1173
|
+
return MetadataStorage.getMergedMetadata('AttributeMapping', model);
|
|
1174
|
+
}
|
|
1175
|
+
getModelRequiredPropertyNames(model) {
|
|
1176
|
+
return MetadataStorage.getMergedMetadata('AttributeRequired', model);
|
|
1177
|
+
}
|
|
1178
|
+
getModelDefaultPropertyValues(model) {
|
|
1179
|
+
return MetadataStorage.getMergedMetadata('AttributedefaultValue', model);
|
|
1180
|
+
}
|
|
1181
|
+
getModelSubGroupPropertyNames(model) {
|
|
1182
|
+
return MetadataStorage.getMergedMetadata('AttributeformSubGroup', model);
|
|
1183
|
+
}
|
|
1184
|
+
getFromGroup(fb) {
|
|
1185
|
+
const props = Object.keys(this.getModelPropertyNames(this));
|
|
1186
|
+
const requiredProps = this.getModelRequiredPropertyNames(this);
|
|
1187
|
+
const defaultValues = this.getModelDefaultPropertyValues(this);
|
|
1188
|
+
const formSubGroupsValues = this.getModelSubGroupPropertyNames(this);
|
|
1189
|
+
const controlsConfig = {};
|
|
1190
|
+
const that = this;
|
|
1191
|
+
if (props) {
|
|
1192
|
+
props.forEach((property) => {
|
|
1193
|
+
const value = that[property] !== undefined ? that[property] : defaultValues[property];
|
|
1194
|
+
const formSubGroup = formSubGroupsValues[property] ?? null;
|
|
1195
|
+
if (requiredProps[property]) {
|
|
1196
|
+
if (formSubGroup)
|
|
1197
|
+
this.getSubFromGroup(fb, controlsConfig, formSubGroup).addControl(property, fb.control(value, Validators.required));
|
|
1198
|
+
else
|
|
1199
|
+
controlsConfig[property] = [value, Validators.required];
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
if (formSubGroup)
|
|
1203
|
+
this.getSubFromGroup(fb, controlsConfig, formSubGroup).addControl(property, fb.control(value));
|
|
1204
|
+
else
|
|
1205
|
+
controlsConfig[property] = value;
|
|
1206
|
+
}
|
|
1096
1207
|
});
|
|
1097
1208
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1209
|
+
return fb.group(controlsConfig);
|
|
1210
|
+
}
|
|
1211
|
+
getSubFromGroup(fb, controlsConfig, subGroup) {
|
|
1212
|
+
if (!controlsConfig[subGroup])
|
|
1213
|
+
controlsConfig[subGroup] = fb.group({});
|
|
1214
|
+
return controlsConfig[subGroup];
|
|
1215
|
+
}
|
|
1216
|
+
getModelFromFormGroup(formGroup, id) {
|
|
1217
|
+
try {
|
|
1218
|
+
const props = Object.keys(this.getModelPropertyNames(this));
|
|
1219
|
+
const formSubGroupsValues = this.getModelSubGroupPropertyNames(this);
|
|
1220
|
+
const data = {};
|
|
1221
|
+
if (id) {
|
|
1222
|
+
data.id = id;
|
|
1223
|
+
}
|
|
1224
|
+
const that = this;
|
|
1225
|
+
if (props) {
|
|
1226
|
+
props.forEach((property) => {
|
|
1227
|
+
const formSubGroup = formSubGroupsValues[property] ?? null;
|
|
1228
|
+
if (!formSubGroup)
|
|
1229
|
+
data[property] = formGroup.controls[property].value ?? null;
|
|
1230
|
+
else
|
|
1231
|
+
data[property] = formGroup.controls[formSubGroup].controls[property].value ?? null;
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
if (data) {
|
|
1235
|
+
if (id) {
|
|
1236
|
+
this.id = id;
|
|
1237
|
+
}
|
|
1238
|
+
Object.assign(this, data);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
catch (error) {
|
|
1242
|
+
Object.assign(this, formGroup.value);
|
|
1101
1243
|
}
|
|
1102
1244
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1245
|
+
getCellClass(property) {
|
|
1246
|
+
return '';
|
|
1247
|
+
}
|
|
1105
1248
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
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
|
-
}] } });
|
|
1249
|
+
__decorate([
|
|
1250
|
+
Attribute({ serializedName: 'id' }),
|
|
1251
|
+
__metadata("design:type", Object)
|
|
1252
|
+
], BaseModel.prototype, "id", void 0);
|
|
1158
1253
|
|
|
1159
|
-
class
|
|
1254
|
+
class ErrorResponse {
|
|
1255
|
+
constructor(errors) {
|
|
1256
|
+
this.errors = [];
|
|
1257
|
+
if (errors) {
|
|
1258
|
+
this.errors = errors;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
class Rule {
|
|
1160
1264
|
constructor() {
|
|
1161
|
-
this.
|
|
1162
|
-
this.authUrl = '';
|
|
1163
|
-
this.apiVersion = 'api/v1';
|
|
1265
|
+
this.parameters = [];
|
|
1164
1266
|
}
|
|
1165
1267
|
}
|
|
1166
1268
|
|
|
1167
|
-
|
|
1168
|
-
(
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1269
|
+
class InputErrorPipe {
|
|
1270
|
+
constructor(translate) {
|
|
1271
|
+
this.translate = translate;
|
|
1272
|
+
}
|
|
1273
|
+
transform(value, filedTranslationKey) {
|
|
1274
|
+
let rvalue = '';
|
|
1275
|
+
if (value !== null) {
|
|
1276
|
+
if (value['invalid'] === true) {
|
|
1277
|
+
rvalue = 'ERROR.INVALID';
|
|
1278
|
+
}
|
|
1279
|
+
if (value['mustMatch'] === true) {
|
|
1280
|
+
rvalue = 'Account.Password.MustMach';
|
|
1281
|
+
}
|
|
1282
|
+
if (value['required'] === true) {
|
|
1283
|
+
const field = this.translate.instant(filedTranslationKey.field);
|
|
1284
|
+
rvalue = this.translate.instant('General.Field.Required', { field });
|
|
1285
|
+
}
|
|
1286
|
+
if (value['minlength']) {
|
|
1287
|
+
const field = this.translate.instant(filedTranslationKey.field);
|
|
1288
|
+
rvalue = this.translate.instant('General.Field.MinLength', { field, requiredLength: value.minlength.requiredLength });
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
return rvalue;
|
|
1292
|
+
}
|
|
1293
|
+
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 }); }
|
|
1294
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: InputErrorPipe, isStandalone: false, name: "inputError" }); }
|
|
1295
|
+
}
|
|
1296
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: InputErrorPipe, decorators: [{
|
|
1297
|
+
type: Pipe,
|
|
1298
|
+
args: [{
|
|
1299
|
+
name: 'inputError',
|
|
1300
|
+
standalone: false
|
|
1301
|
+
}]
|
|
1302
|
+
}], ctorParameters: () => [{ type: i1$3.TranslateService }] });
|
|
1181
1303
|
|
|
1182
|
-
|
|
1183
|
-
|
|
1304
|
+
class Nl2brPipe {
|
|
1305
|
+
transform(value, args) {
|
|
1306
|
+
// return value.replace(/\n/g, '<br />');
|
|
1307
|
+
if (value) {
|
|
1308
|
+
value = value.replace(/(?:\r\n\r\n|\r\r|\n\n)/g, '</p><p>');
|
|
1309
|
+
return '<p>' + value.replace(/(?:\r\n|\r|\n)/g, '<br>') + '</p>';
|
|
1310
|
+
}
|
|
1311
|
+
return value;
|
|
1312
|
+
}
|
|
1313
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: Nl2brPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1314
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: Nl2brPipe, isStandalone: false, name: "nl2br" }); }
|
|
1315
|
+
}
|
|
1316
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: Nl2brPipe, decorators: [{
|
|
1317
|
+
type: Pipe,
|
|
1318
|
+
args: [{
|
|
1319
|
+
name: 'nl2br',
|
|
1320
|
+
standalone: false
|
|
1321
|
+
}]
|
|
1322
|
+
}] });
|
|
1184
1323
|
|
|
1185
|
-
class
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1324
|
+
class BaseDatastore {
|
|
1325
|
+
// tslint:enable:max-line-length
|
|
1326
|
+
get getDirtyAttributes() {
|
|
1327
|
+
if (this.datastoreConfig.overrides
|
|
1328
|
+
&& this.datastoreConfig.overrides.getDirtyAttributes) {
|
|
1329
|
+
return this.datastoreConfig.overrides.getDirtyAttributes;
|
|
1189
1330
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1331
|
+
else {
|
|
1332
|
+
return BaseDatastore.getDirtyAttributes;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
get getAllAttributes() {
|
|
1336
|
+
if (this.datastoreConfig.overrides
|
|
1337
|
+
&& this.datastoreConfig.overrides.getAllAttributes) {
|
|
1338
|
+
return this.datastoreConfig.overrides.getAllAttributes;
|
|
1339
|
+
}
|
|
1340
|
+
else {
|
|
1341
|
+
return BaseDatastore.getAllAttributes;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
// protected config: DatastoreConfig;
|
|
1345
|
+
static getDirtyAttributes(attributesMetadata) {
|
|
1346
|
+
const dirtyData = {};
|
|
1347
|
+
for (const propertyName in attributesMetadata) {
|
|
1348
|
+
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1349
|
+
const metadata = attributesMetadata[propertyName];
|
|
1350
|
+
if (metadata.hasDirtyAttributes) {
|
|
1351
|
+
const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
|
|
1352
|
+
dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
return dirtyData;
|
|
1357
|
+
}
|
|
1358
|
+
static getAllAttributes(attributesMetadata) {
|
|
1359
|
+
const dirtyData = {};
|
|
1360
|
+
for (const propertyName in attributesMetadata) {
|
|
1361
|
+
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1362
|
+
const metadata = attributesMetadata[propertyName];
|
|
1363
|
+
const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
|
|
1364
|
+
dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
return dirtyData;
|
|
1368
|
+
}
|
|
1369
|
+
constructor(httpClient, cacheService) {
|
|
1370
|
+
this.httpClient = httpClient;
|
|
1371
|
+
this.cacheService = cacheService;
|
|
1372
|
+
// tslint:disable-next-line:variable-name
|
|
1373
|
+
this._store = {};
|
|
1374
|
+
// tslint:enable:max-line-length
|
|
1375
|
+
// tslint:disable-next-line:ban-types
|
|
1376
|
+
this.toQueryString = this.datastoreConfig.overrides
|
|
1377
|
+
&& this.datastoreConfig.overrides.toQueryString ?
|
|
1378
|
+
this.datastoreConfig.overrides.toQueryString : this._toQueryString;
|
|
1379
|
+
}
|
|
1380
|
+
findAll(modelType, params, headers, customUrl) {
|
|
1381
|
+
const customHeadhers = this.buildHeaders(headers);
|
|
1382
|
+
const htmlParams = this.buildParams(modelType, params);
|
|
1383
|
+
const url = this.buildUrl(modelType, customUrl);
|
|
1384
|
+
const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
|
|
1385
|
+
.pipe(map(res => this.extractQueryData(res, modelType)), catchError(this.handleError));
|
|
1386
|
+
return response;
|
|
1387
|
+
}
|
|
1388
|
+
findRecord(modelType, id, params, headers, customUrl) {
|
|
1389
|
+
const customHeadhers = this.buildHeaders(headers);
|
|
1390
|
+
let url = this.buildUrl(modelType, customUrl);
|
|
1391
|
+
if (id) {
|
|
1392
|
+
url += '/' + id;
|
|
1393
|
+
}
|
|
1394
|
+
const htmlParams = this.buildParams(modelType, params);
|
|
1395
|
+
const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
|
|
1396
|
+
.pipe(map(res => this.entityToModel(res, modelType, undefined)), catchError(this.handleError));
|
|
1397
|
+
return response;
|
|
1398
|
+
}
|
|
1399
|
+
getCustom(modelType, params, headers, customUrl, customResponseType) {
|
|
1400
|
+
const customHeadhers = this.buildHeaders(headers);
|
|
1401
|
+
const url = this.buildUrl(modelType, customUrl);
|
|
1402
|
+
const htmlParams = this.buildParams(modelType, params);
|
|
1403
|
+
if (!customResponseType)
|
|
1404
|
+
customResponseType = 'json';
|
|
1405
|
+
return this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true, responseType: customResponseType });
|
|
1406
|
+
}
|
|
1407
|
+
postCustom(modelType, body, params, headers, customUrl) {
|
|
1408
|
+
const customHeadhers = this.buildHeaders(headers);
|
|
1409
|
+
const url = this.buildUrl(modelType, customUrl);
|
|
1410
|
+
const htmlParams = this.buildParams(modelType, params);
|
|
1411
|
+
return this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, reportProgress: true, withCredentials: true });
|
|
1412
|
+
}
|
|
1413
|
+
patchCustom(modelType, body, params, headers, customUrl) {
|
|
1414
|
+
const customHeadhers = this.buildHeaders(headers);
|
|
1415
|
+
const url = this.buildUrl(modelType, customUrl);
|
|
1416
|
+
const htmlParams = this.buildParams(modelType, params);
|
|
1417
|
+
return this.httpClient.patch(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1418
|
+
}
|
|
1419
|
+
createRecord(modelType, data) {
|
|
1420
|
+
return new modelType(data);
|
|
1421
|
+
}
|
|
1422
|
+
saveRecord(attributesMetadata, model, params, headers, customUrl, customBody) {
|
|
1423
|
+
const modelType = model.constructor;
|
|
1424
|
+
const modelConfig = model.modelConfig;
|
|
1425
|
+
const customHeadhers = this.buildHeaders(headers);
|
|
1426
|
+
const url = this.buildUrl(modelType, customUrl);
|
|
1427
|
+
const htmlParams = this.buildParams(modelType, params);
|
|
1428
|
+
let httpCall;
|
|
1429
|
+
const body = customBody || this.modelToEntity(model, attributesMetadata);
|
|
1430
|
+
if (model.id) {
|
|
1431
|
+
// tslint:disable-next-line:max-line-length
|
|
1432
|
+
httpCall = this.httpClient.patch(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1433
|
+
}
|
|
1434
|
+
else {
|
|
1435
|
+
httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1436
|
+
}
|
|
1437
|
+
return httpCall
|
|
1438
|
+
.pipe(map(res => {
|
|
1439
|
+
this.cacheService.clearCacheContainingKeyword(url);
|
|
1440
|
+
const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
|
|
1441
|
+
return this.entityToModel(data, modelType);
|
|
1442
|
+
}), catchError(this.handleError));
|
|
1443
|
+
}
|
|
1444
|
+
patchRecord(attributesMetadata, model, origModel, params, headers, customUrl) {
|
|
1445
|
+
const modelType = model.constructor;
|
|
1446
|
+
const modelConfig = model.modelConfig;
|
|
1447
|
+
const customHeadhers = this.buildHeaders(headers);
|
|
1448
|
+
const url = this.buildUrl(modelType, customUrl);
|
|
1449
|
+
const htmlParams = this.buildParams(modelType, params);
|
|
1450
|
+
let httpCall;
|
|
1451
|
+
let origData = { id: '' };
|
|
1452
|
+
if (origModel)
|
|
1453
|
+
origData = this.modelToEntity(origModel, origModel.attributeMetadata, true);
|
|
1454
|
+
const newData = this.modelToEntity(model, attributesMetadata, true);
|
|
1455
|
+
newData.id = origData.id;
|
|
1456
|
+
const patch = compare(origData, newData);
|
|
1457
|
+
if (patch.length > 0) {
|
|
1458
|
+
httpCall = this.httpClient.patch(url + '/' + model.id, patch, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1459
|
+
return httpCall
|
|
1460
|
+
.pipe(map(res => {
|
|
1461
|
+
this.cacheService.clearCacheContainingKeyword(url);
|
|
1462
|
+
const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
|
|
1463
|
+
return this.entityToModel(data, modelType);
|
|
1464
|
+
}), catchError(this.handleError));
|
|
1193
1465
|
}
|
|
1194
1466
|
else {
|
|
1195
|
-
return
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
unmask(value) {
|
|
1199
|
-
// const result = format(value, 'YYYY-MM-DDTHH:mm:ssZ');
|
|
1200
|
-
return value;
|
|
1201
|
-
}
|
|
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();
|
|
1214
|
-
}
|
|
1215
|
-
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);
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
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] = {};
|
|
1254
|
-
}
|
|
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;
|
|
1273
|
-
}
|
|
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
|
|
1467
|
+
return new Observable((observer) => {
|
|
1468
|
+
observer.next(model);
|
|
1469
|
+
observer.complete();
|
|
1282
1470
|
});
|
|
1283
1471
|
}
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
function BaseDatastoreConfig(config = {}) {
|
|
1288
|
-
// tslint:disable-next-line:only-arrow-functions
|
|
1289
|
-
return (target) => {
|
|
1290
|
-
MetadataStorage.setMetadata('BaseDatastoreConfig', config, target);
|
|
1291
|
-
};
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
class BaseMetaModel {
|
|
1295
|
-
constructor(response) {
|
|
1296
|
-
this.links = response.links || [];
|
|
1297
|
-
this.meta = response.meta;
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
function BaseModelConfig(config = {}) {
|
|
1302
|
-
return (target) => {
|
|
1303
|
-
if (typeof config['meta'] === 'undefined' || config['meta'] == null) {
|
|
1304
|
-
config['meta'] = BaseMetaModel;
|
|
1305
|
-
}
|
|
1306
|
-
MetadataStorage.setMetadata('BaseModelConfig', config, target);
|
|
1307
|
-
};
|
|
1308
|
-
}
|
|
1309
|
-
|
|
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
|
-
};
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
class CacheInterceptor {
|
|
1322
|
-
constructor(expirationTime, cacheService) {
|
|
1323
|
-
this.expirationTime = expirationTime;
|
|
1324
|
-
this.cacheService = cacheService;
|
|
1325
|
-
this.cache = new Map();
|
|
1326
1472
|
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1473
|
+
// getPatch<T extends BaseModel>(
|
|
1474
|
+
// model: T,
|
|
1475
|
+
// origModel: T): any {
|
|
1476
|
+
// }
|
|
1477
|
+
replaceRecord(attributesMetadata, model, params, headers, customUrl, customBody) {
|
|
1478
|
+
const modelType = model.constructor;
|
|
1479
|
+
const modelConfig = model.modelConfig;
|
|
1480
|
+
const customHeadhers = this.buildHeaders(headers);
|
|
1481
|
+
const url = this.buildUrl(modelType, customUrl);
|
|
1482
|
+
const htmlParams = this.buildParams(modelType, params);
|
|
1483
|
+
let httpCall;
|
|
1484
|
+
const body = customBody || this.modelToEntity(model, attributesMetadata, true);
|
|
1485
|
+
if (model.id) {
|
|
1486
|
+
httpCall = this.httpClient.put(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1331
1487
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
if (cachedResponse) {
|
|
1335
|
-
return of(cachedResponse.clone());
|
|
1336
|
-
//return cachedResponse;
|
|
1337
|
-
}
|
|
1488
|
+
else {
|
|
1489
|
+
httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1338
1490
|
}
|
|
1339
|
-
return
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
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
|
-
// );
|
|
1491
|
+
return httpCall
|
|
1492
|
+
.pipe(map(res => {
|
|
1493
|
+
this.cacheService.clearCacheContainingKeyword(url);
|
|
1494
|
+
const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
|
|
1495
|
+
return this.entityToModel(data, modelType);
|
|
1496
|
+
}), catchError(this.handleError));
|
|
1355
1497
|
}
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
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;
|
|
1373
|
-
}
|
|
1374
|
-
Object.assign(this, data);
|
|
1498
|
+
deleteRecord(modelType, id, headers, customUrl) {
|
|
1499
|
+
const customHeadhers = this.buildHeaders(headers);
|
|
1500
|
+
let url = this.buildUrl(modelType, customUrl);
|
|
1501
|
+
if (!url.includes('share')) {
|
|
1502
|
+
url = url + '/' + id;
|
|
1375
1503
|
}
|
|
1504
|
+
// const idParam = new HttpParams().set('id', id);
|
|
1505
|
+
return this.httpClient.delete(url, { headers: customHeadhers, withCredentials: true })
|
|
1506
|
+
.pipe(map(res => {
|
|
1507
|
+
this.cacheService.clearCacheContainingKeyword(url);
|
|
1508
|
+
return res;
|
|
1509
|
+
}), catchError(this.handleError));
|
|
1376
1510
|
}
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1511
|
+
buildUrl(modelType, customUrl) {
|
|
1512
|
+
if (customUrl) {
|
|
1513
|
+
return customUrl;
|
|
1514
|
+
}
|
|
1515
|
+
const modelConfig = MetadataStorage.getMetadata('BaseModelConfig', modelType);
|
|
1516
|
+
const baseUrl = modelConfig.baseUrl || this.datastoreConfig.baseUrl;
|
|
1517
|
+
const apiVersion = modelConfig.apiVersion || this.datastoreConfig.apiVersion;
|
|
1518
|
+
const modelEndpointUrl = modelConfig.modelEndpointUrl || modelConfig.type;
|
|
1519
|
+
const url = [baseUrl, apiVersion, modelEndpointUrl].filter((x) => x).join('/');
|
|
1520
|
+
return url;
|
|
1380
1521
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1522
|
+
extractQueryData(res, modelType) {
|
|
1523
|
+
let result;
|
|
1524
|
+
const body = res;
|
|
1525
|
+
const models = [];
|
|
1526
|
+
for (const data of body.data) {
|
|
1527
|
+
const model = this.entityToModel(data, modelType, undefined);
|
|
1528
|
+
models.push(model);
|
|
1529
|
+
}
|
|
1530
|
+
result = new BaseQueryData(models, this.parseMeta(body, modelType));
|
|
1531
|
+
return result;
|
|
1384
1532
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
return
|
|
1533
|
+
deserializeModel(modelType, data) {
|
|
1534
|
+
data = this.transformSerializedNamesToPropertyNames(modelType, data);
|
|
1535
|
+
return new modelType(data);
|
|
1388
1536
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1537
|
+
handleError(error) {
|
|
1538
|
+
if (error.error instanceof ErrorEvent) {
|
|
1539
|
+
// A client-side or network error occurred. Handle it accordingly.
|
|
1540
|
+
// console.error('An error occurred:', error.error.message);
|
|
1541
|
+
}
|
|
1542
|
+
else {
|
|
1543
|
+
// The backend returned an unsuccessful response code.
|
|
1544
|
+
// The response body may contain clues as to what went wrong,
|
|
1545
|
+
// console.error(
|
|
1546
|
+
// 'Backend returned code ${error.status}, ' +
|
|
1547
|
+
// 'body was: ${error.error}');
|
|
1548
|
+
}
|
|
1549
|
+
// return an observable with a user-facing error message
|
|
1550
|
+
return throwError(error);
|
|
1392
1551
|
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1552
|
+
parseMeta(body, modelType) {
|
|
1553
|
+
const metaModel = MetadataStorage.getMetadata('BaseModelConfig', modelType).meta;
|
|
1554
|
+
return new metaModel(body);
|
|
1395
1555
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
let hasDirtyAttributes = false;
|
|
1556
|
+
resetMetadataAttributes(res, attributesMetadata, modelType) {
|
|
1557
|
+
// TODO check why is attributesMetadata from the arguments never used
|
|
1399
1558
|
for (const propertyName in attributesMetadata) {
|
|
1400
1559
|
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1401
1560
|
const metadata = attributesMetadata[propertyName];
|
|
1402
1561
|
if (metadata.hasDirtyAttributes) {
|
|
1403
|
-
hasDirtyAttributes =
|
|
1404
|
-
break;
|
|
1562
|
+
metadata.hasDirtyAttributes = false;
|
|
1405
1563
|
}
|
|
1406
1564
|
}
|
|
1407
1565
|
}
|
|
1408
|
-
|
|
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
|
-
}
|
|
1566
|
+
if (res) {
|
|
1567
|
+
res.attributeMetadata = attributesMetadata;
|
|
1425
1568
|
}
|
|
1426
|
-
|
|
1427
|
-
}
|
|
1428
|
-
get modelConfig() {
|
|
1429
|
-
return MetadataStorage.getMetadata('BaseModelConfig', this.constructor);
|
|
1569
|
+
return res;
|
|
1430
1570
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
return
|
|
1571
|
+
get datastoreConfig() {
|
|
1572
|
+
const configFromDecorator = MetadataStorage.getMetadata('BaseDatastoreConfig', this.constructor);
|
|
1573
|
+
return Object.assign(configFromDecorator, this.config);
|
|
1434
1574
|
}
|
|
1435
1575
|
transformSerializedNamesToPropertyNames(modelType, attributes) {
|
|
1576
|
+
const apiFieldMap = this.getApiFieldMap(modelType);
|
|
1577
|
+
if (apiFieldMap) {
|
|
1578
|
+
const properties = {};
|
|
1579
|
+
Object.keys(apiFieldMap).forEach((serializedName) => {
|
|
1580
|
+
if (attributes[serializedName] !== null && attributes[serializedName] !== undefined) {
|
|
1581
|
+
properties[apiFieldMap[serializedName]] = attributes[serializedName];
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
return properties;
|
|
1585
|
+
}
|
|
1436
1586
|
const serializedNameToPropertyName = this.getModelPropertyNames(modelType.prototype);
|
|
1437
1587
|
const properties = {};
|
|
1438
1588
|
Object.keys(serializedNameToPropertyName).forEach((serializedName) => {
|
|
@@ -1443,156 +1593,77 @@ class BaseModel {
|
|
|
1443
1593
|
return properties;
|
|
1444
1594
|
}
|
|
1445
1595
|
getModelPropertyNames(model) {
|
|
1446
|
-
return MetadataStorage.
|
|
1447
|
-
}
|
|
1448
|
-
getModelRequiredPropertyNames(model) {
|
|
1449
|
-
return MetadataStorage.getMetadata('AttributeRequired', model);
|
|
1596
|
+
return MetadataStorage.getMergedMetadata('AttributeMapping', model);
|
|
1450
1597
|
}
|
|
1451
|
-
|
|
1452
|
-
return
|
|
1598
|
+
getApiFieldMap(modelType) {
|
|
1599
|
+
return modelType.apiFieldMap || null;
|
|
1453
1600
|
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1601
|
+
buildHeaders(customHeaders) {
|
|
1602
|
+
const headers = {
|
|
1603
|
+
Accept: 'application/json-patch+json',
|
|
1604
|
+
// 'Content-Type': 'application/vnd.api+json',
|
|
1605
|
+
'Content-Type': 'application/json-patch+json'
|
|
1606
|
+
};
|
|
1607
|
+
if (customHeaders && customHeaders.keys().length) {
|
|
1608
|
+
// tslint:disable-next-line:variable-name
|
|
1609
|
+
Object.assign({}, headers, customHeaders.keys().map(header_name => {
|
|
1610
|
+
headers['' + header_name] = customHeaders.get(header_name);
|
|
1611
|
+
}));
|
|
1612
|
+
}
|
|
1613
|
+
return new HttpHeaders(headers);
|
|
1456
1614
|
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
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
|
-
}
|
|
1615
|
+
buildParams(modelType, params) {
|
|
1616
|
+
let httpParams = new HttpParams();
|
|
1617
|
+
if (params) {
|
|
1618
|
+
Object.keys(params)
|
|
1619
|
+
.filter(key => {
|
|
1620
|
+
const v = params[key];
|
|
1621
|
+
return (Array.isArray(v) || typeof v === 'string') ?
|
|
1622
|
+
(v.length > 0) :
|
|
1623
|
+
(v !== null && v !== undefined);
|
|
1624
|
+
})
|
|
1625
|
+
.forEach(key => {
|
|
1626
|
+
httpParams = httpParams.set(key, params[key]);
|
|
1480
1627
|
});
|
|
1481
1628
|
}
|
|
1482
|
-
|
|
1629
|
+
const modelConfig = MetadataStorage.getMetadata('BaseModelConfig', modelType);
|
|
1630
|
+
httpParams = httpParams.set('bypassCache', modelConfig.bypassCache || false);
|
|
1631
|
+
return httpParams;
|
|
1483
1632
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
controlsConfig[subGroup] = fb.group({});
|
|
1487
|
-
return controlsConfig[subGroup];
|
|
1633
|
+
entityToModel(res, modelType, model) {
|
|
1634
|
+
return this.extractRecordDataJson(res, modelType, model);
|
|
1488
1635
|
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
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
|
-
}
|
|
1636
|
+
extractRecordDataJson(res, modelType, model) {
|
|
1637
|
+
const body = res;
|
|
1638
|
+
if (!body) {
|
|
1639
|
+
throw new Error('no body in response');
|
|
1513
1640
|
}
|
|
1514
|
-
|
|
1515
|
-
Object.assign(
|
|
1641
|
+
if (model) {
|
|
1642
|
+
Object.assign(model, body);
|
|
1516
1643
|
}
|
|
1644
|
+
const deserializedModel = model || this.deserializeModel(modelType, body.data || body);
|
|
1645
|
+
return deserializedModel;
|
|
1517
1646
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
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;
|
|
1647
|
+
modelToEntity(model, attributesMetadata, allAttributes = false) {
|
|
1648
|
+
let attributes;
|
|
1649
|
+
if (allAttributes) {
|
|
1650
|
+
attributes = this.getAllAttributes(attributesMetadata, model);
|
|
1532
1651
|
}
|
|
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
|
-
}
|
|
1652
|
+
else {
|
|
1653
|
+
attributes = this.getDirtyAttributes(attributesMetadata, model);
|
|
1563
1654
|
}
|
|
1564
|
-
|
|
1655
|
+
// this.getRelationships(model, attributes);
|
|
1656
|
+
return attributes;
|
|
1565
1657
|
}
|
|
1566
|
-
|
|
1567
|
-
|
|
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;
|
|
1658
|
+
_toQueryString(params) {
|
|
1659
|
+
return queryString.stringify(params, { arrayFormat: 'bracket' });
|
|
1585
1660
|
}
|
|
1586
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type:
|
|
1587
|
-
static { this.ɵ
|
|
1661
|
+
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 }); }
|
|
1662
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseDatastore }); }
|
|
1588
1663
|
}
|
|
1589
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type:
|
|
1590
|
-
type:
|
|
1591
|
-
|
|
1592
|
-
name: 'nl2br',
|
|
1593
|
-
standalone: false
|
|
1594
|
-
}]
|
|
1595
|
-
}] });
|
|
1664
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BaseDatastore, decorators: [{
|
|
1665
|
+
type: Injectable
|
|
1666
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: CacheService }] });
|
|
1596
1667
|
|
|
1597
1668
|
let DatastoreCore = class DatastoreCore extends BaseDatastore {
|
|
1598
1669
|
constructor(http, cacheService, configExt) {
|
|
@@ -1617,10 +1688,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
1617
1688
|
|
|
1618
1689
|
let Employee = class Employee extends BaseModel {
|
|
1619
1690
|
};
|
|
1620
|
-
__decorate([
|
|
1621
|
-
Attribute({ serializedName: 'id' }),
|
|
1622
|
-
__metadata("design:type", String)
|
|
1623
|
-
], Employee.prototype, "id", void 0);
|
|
1624
1691
|
__decorate([
|
|
1625
1692
|
Attribute({ serializedName: 'userName', required: true }),
|
|
1626
1693
|
__metadata("design:type", String)
|
|
@@ -1661,10 +1728,6 @@ Employee = __decorate([
|
|
|
1661
1728
|
|
|
1662
1729
|
let Menu = class Menu extends BaseModel {
|
|
1663
1730
|
};
|
|
1664
|
-
__decorate([
|
|
1665
|
-
Attribute({ serializedName: 'id' }),
|
|
1666
|
-
__metadata("design:type", String)
|
|
1667
|
-
], Menu.prototype, "id", void 0);
|
|
1668
1731
|
__decorate([
|
|
1669
1732
|
Attribute({ serializedName: 'header' }),
|
|
1670
1733
|
__metadata("design:type", String)
|
|
@@ -1718,10 +1781,6 @@ Menu = __decorate([
|
|
|
1718
1781
|
|
|
1719
1782
|
let Right = class Right extends BaseModel {
|
|
1720
1783
|
};
|
|
1721
|
-
__decorate([
|
|
1722
|
-
Attribute({ serializedName: 'id' }),
|
|
1723
|
-
__metadata("design:type", String)
|
|
1724
|
-
], Right.prototype, "id", void 0);
|
|
1725
1784
|
__decorate([
|
|
1726
1785
|
Attribute({ serializedName: 'name' }),
|
|
1727
1786
|
__metadata("design:type", String)
|
|
@@ -1771,10 +1830,6 @@ Right = __decorate([
|
|
|
1771
1830
|
|
|
1772
1831
|
let Role = class Role extends BaseModel {
|
|
1773
1832
|
};
|
|
1774
|
-
__decorate([
|
|
1775
|
-
Attribute({ serializedName: 'id' }),
|
|
1776
|
-
__metadata("design:type", String)
|
|
1777
|
-
], Role.prototype, "id", void 0);
|
|
1778
1833
|
__decorate([
|
|
1779
1834
|
Attribute({ serializedName: 'name' }),
|
|
1780
1835
|
__metadata("design:type", String)
|
|
@@ -1794,10 +1849,6 @@ let User = class User extends BaseModel {
|
|
|
1794
1849
|
return this.firstName + ' ' + this.lastName;
|
|
1795
1850
|
}
|
|
1796
1851
|
};
|
|
1797
|
-
__decorate([
|
|
1798
|
-
Attribute({ serializedName: 'id' }),
|
|
1799
|
-
__metadata("design:type", String)
|
|
1800
|
-
], User.prototype, "id", void 0);
|
|
1801
1852
|
__decorate([
|
|
1802
1853
|
Attribute({ serializedName: 'firstName' }),
|
|
1803
1854
|
__metadata("design:type", String)
|
|
@@ -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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|