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