@rosoftlab/core 0.0.100

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. package/README.md +6 -0
  2. package/esm2020/lib/base-components/base-form-edit.component.mjs +242 -0
  3. package/esm2020/lib/base-components/field-error-display/field-error-display.component.mjs +15 -0
  4. package/esm2020/lib/base-components/generic-table/generic-table.component.mjs +431 -0
  5. package/esm2020/lib/base-components/index.mjs +5 -0
  6. package/esm2020/lib/base-components/page-not-found/page-not-found.component.mjs +15 -0
  7. package/esm2020/lib/base-components/searchable-dropdown/searchable-dropdown.component.mjs +231 -0
  8. package/esm2020/lib/base-components/under-construction/under-construction.component.mjs +12 -0
  9. package/esm2020/lib/constants/symbols.mjs +3 -0
  10. package/esm2020/lib/converters/date/date.converter.mjs +12 -0
  11. package/esm2020/lib/decorators/attribute.decorator.mjs +85 -0
  12. package/esm2020/lib/decorators/base-datastore-config.decorator.mjs +7 -0
  13. package/esm2020/lib/decorators/base-model-config.decorator.mjs +10 -0
  14. package/esm2020/lib/decorators/custom.type.decorator.mjs +11 -0
  15. package/esm2020/lib/decorators/grid-layout.decorator.mjs +23 -0
  16. package/esm2020/lib/directives/translated-content.directive.mjs +96 -0
  17. package/esm2020/lib/directives/translated-element.directive.mjs +20 -0
  18. package/esm2020/lib/index.mjs +29 -0
  19. package/esm2020/lib/interfaces/attribute-decorator-options.interface.mjs +2 -0
  20. package/esm2020/lib/interfaces/datastore-config.interface.mjs +2 -0
  21. package/esm2020/lib/interfaces/model-config.interface.mjs +2 -0
  22. package/esm2020/lib/interfaces/overrides.interface.mjs +2 -0
  23. package/esm2020/lib/interfaces/property-converter.interface.mjs +2 -0
  24. package/esm2020/lib/material.mjs +94 -0
  25. package/esm2020/lib/models/base-meta.model.mjs +7 -0
  26. package/esm2020/lib/models/base-query-data.mjs +13 -0
  27. package/esm2020/lib/models/base.model.mjs +171 -0
  28. package/esm2020/lib/models/error-response.model.mjs +9 -0
  29. package/esm2020/lib/models/grid-layout-format.enum.mjs +15 -0
  30. package/esm2020/lib/models/grid-layout.mjs +18 -0
  31. package/esm2020/lib/models/rule.mjs +6 -0
  32. package/esm2020/lib/module.mjs +55 -0
  33. package/esm2020/lib/pipes/Nl2brPipe.pipe.mjs +21 -0
  34. package/esm2020/lib/pipes/input-error.pipe.mjs +37 -0
  35. package/esm2020/lib/providers.mjs +10 -0
  36. package/esm2020/lib/services/base-datastore.service.mjs +333 -0
  37. package/esm2020/lib/services/base.service.mjs +95 -0
  38. package/esm2020/lib/services/dialog.service.mjs +150 -0
  39. package/esm2020/lib/services/grid-layout.service.mjs +21 -0
  40. package/esm2020/lib/services/index.mjs +5 -0
  41. package/esm2020/lib/validators/pattern-validator.mjs +15 -0
  42. package/esm2020/public-api.mjs +12 -0
  43. package/esm2020/rosoftlab-core.mjs +5 -0
  44. package/fesm2015/rosoftlab-core.mjs +2217 -0
  45. package/fesm2015/rosoftlab-core.mjs.map +1 -0
  46. package/fesm2020/rosoftlab-core.mjs +2210 -0
  47. package/fesm2020/rosoftlab-core.mjs.map +1 -0
  48. package/lib/base-components/base-form-edit.component.d.ts +58 -0
  49. package/lib/base-components/field-error-display/field-error-display.component.d.ts +7 -0
  50. package/lib/base-components/generic-table/generic-table.component.d.ts +93 -0
  51. package/lib/base-components/index.d.ts +4 -0
  52. package/lib/base-components/page-not-found/page-not-found.component.d.ts +8 -0
  53. package/lib/base-components/searchable-dropdown/searchable-dropdown.component.d.ts +62 -0
  54. package/lib/base-components/under-construction/under-construction.component.d.ts +6 -0
  55. package/lib/constants/symbols.d.ts +1 -0
  56. package/lib/converters/date/date.converter.d.ts +5 -0
  57. package/lib/decorators/attribute.decorator.d.ts +2 -0
  58. package/lib/decorators/base-datastore-config.decorator.d.ts +1 -0
  59. package/lib/decorators/base-model-config.decorator.d.ts +1 -0
  60. package/lib/decorators/custom.type.decorator.d.ts +1 -0
  61. package/lib/decorators/grid-layout.decorator.d.ts +2 -0
  62. package/lib/directives/translated-content.directive.d.ts +21 -0
  63. package/lib/directives/translated-element.directive.d.ts +10 -0
  64. package/lib/index.d.ts +27 -0
  65. package/lib/interfaces/attribute-decorator-options.interface.d.ts +8 -0
  66. package/lib/interfaces/datastore-config.interface.d.ts +8 -0
  67. package/lib/interfaces/model-config.interface.d.ts +8 -0
  68. package/lib/interfaces/overrides.interface.d.ts +5 -0
  69. package/lib/interfaces/property-converter.interface.d.ts +4 -0
  70. package/lib/material.d.ts +42 -0
  71. package/lib/models/base-meta.model.d.ts +5 -0
  72. package/lib/models/base-query-data.d.ts +7 -0
  73. package/lib/models/base.model.d.ts +33 -0
  74. package/lib/models/error-response.model.d.ts +17 -0
  75. package/lib/models/grid-layout-format.enum.d.ts +12 -0
  76. package/lib/models/grid-layout.d.ts +13 -0
  77. package/lib/models/rule.d.ts +5 -0
  78. package/lib/module.d.ts +14 -0
  79. package/lib/pipes/Nl2brPipe.pipe.d.ts +7 -0
  80. package/lib/pipes/input-error.pipe.d.ts +10 -0
  81. package/lib/providers.d.ts +2 -0
  82. package/lib/services/base-datastore.service.d.ts +45 -0
  83. package/lib/services/base.service.d.ts +26 -0
  84. package/lib/services/dialog.service.d.ts +21 -0
  85. package/lib/services/grid-layout.service.d.ts +9 -0
  86. package/lib/services/index.d.ts +4 -0
  87. package/lib/validators/pattern-validator.d.ts +4 -0
  88. package/package.json +53 -0
  89. package/public-api.d.ts +7 -0
  90. package/rosoftlab-core.d.ts +5 -0
@@ -0,0 +1,2217 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Component, Input, EventEmitter, Optional, Self, Output, Injectable, ElementRef, ViewEncapsulation, ViewChild, Directive, ContentChildren, NgModule, Pipe } from '@angular/core';
3
+ import { coerceBooleanProperty } from '@angular/cdk/coercion';
4
+ import * as i2 from '@angular/forms';
5
+ import { FormControl, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
6
+ import { Subject, Observable, throwError, from, merge, of, fromEvent, BehaviorSubject, combineLatest } from 'rxjs';
7
+ import { filter, debounceTime, tap, switchMap, finalize, takeUntil, map, catchError, distinctUntilChanged, startWith } from 'rxjs/operators';
8
+ import * as i1 from '@angular/cdk/a11y';
9
+ import * as i3 from '@angular/material/form-field';
10
+ import * as i4 from '@angular/material/button';
11
+ import { MatButtonModule } from '@angular/material/button';
12
+ import * as i5 from '@angular/material/icon';
13
+ import { MatIconModule } from '@angular/material/icon';
14
+ import * as i6 from '@angular/material/autocomplete';
15
+ import { MatAutocompleteModule } from '@angular/material/autocomplete';
16
+ import * as i7 from '@angular/material/core';
17
+ import { MatNativeDateModule, MatRippleModule, MatOptionModule } from '@angular/material/core';
18
+ import * as i8 from '@angular/material/input';
19
+ import { MatInputModule } from '@angular/material/input';
20
+ import * as i3$1 from '@angular/common';
21
+ import { DatePipe, DecimalPipe, PercentPipe, CommonModule } from '@angular/common';
22
+ import * as i1$1 from '@ngx-translate/core';
23
+ import { TranslateModule } from '@ngx-translate/core';
24
+ import { __decorate } from 'tslib';
25
+ import * as i2$2 from 'ng-block-ui';
26
+ import { BlockUI, BlockUIModule } from 'ng-block-ui';
27
+ import * as i2$1 from '@angular/router';
28
+ import * as i1$2 from '@angular/common/http';
29
+ import { HttpHeaders, HttpParams, HttpErrorResponse, HttpClientModule } from '@angular/common/http';
30
+ import { compare } from 'fast-json-patch';
31
+ import * as qs from 'qs';
32
+ import Swal from 'sweetalert2';
33
+ import * as i12 from '@angular/cdk/drag-drop';
34
+ import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
35
+ import * as i9 from '@angular/material/paginator';
36
+ import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
37
+ import * as i8$1 from '@angular/material/sort';
38
+ import { MatSort, MatSortModule } from '@angular/material/sort';
39
+ import * as i6$1 from '@angular/material/table';
40
+ import { MatTableDataSource, MatTableModule } from '@angular/material/table';
41
+ import * as jsonLogic from 'json-logic-js/logic.js';
42
+ import * as i5$1 from '@angular/material/progress-spinner';
43
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
44
+ import * as i13 from '@angular/material/tooltip';
45
+ import { MatTooltipModule } from '@angular/material/tooltip';
46
+ import { parseISO } from 'date-fns';
47
+ import { MatButtonToggleModule } from '@angular/material/button-toggle';
48
+ import { MatCheckboxModule } from '@angular/material/checkbox';
49
+ import { MatChipsModule } from '@angular/material/chips';
50
+ import { MatGridListModule } from '@angular/material/grid-list';
51
+ import { MatMenuModule } from '@angular/material/menu';
52
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
53
+ import { MatSelectModule } from '@angular/material/select';
54
+ import { MatSidenavModule } from '@angular/material/sidenav';
55
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
56
+ import { MatSliderModule } from '@angular/material/slider';
57
+ import { MatSnackBarModule } from '@angular/material/snack-bar';
58
+ import { MatToolbarModule } from '@angular/material/toolbar';
59
+ import { MatCardModule } from '@angular/material/card';
60
+ import { MatTabsModule } from '@angular/material/tabs';
61
+ import { MatExpansionModule } from '@angular/material/expansion';
62
+ import { MatRadioModule } from '@angular/material/radio';
63
+ import { MatDatepickerModule } from '@angular/material/datepicker';
64
+ import { MatDividerModule } from '@angular/material/divider';
65
+ import { MatListModule } from '@angular/material/list';
66
+ import { MatDialogModule } from '@angular/material/dialog';
67
+ import { PortalModule } from '@angular/cdk/portal';
68
+ import { MatTreeModule } from '@angular/material/tree';
69
+ import { MatBadgeModule } from '@angular/material/badge';
70
+ import { MatStepperModule } from '@angular/material/stepper';
71
+ import { CdkStepperModule } from '@angular/cdk/stepper';
72
+
73
+ class FieldErrorDisplayComponent {
74
+ }
75
+ FieldErrorDisplayComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: FieldErrorDisplayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
76
+ FieldErrorDisplayComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.0", type: FieldErrorDisplayComponent, selector: "rsl-field-error-display", inputs: { errorMsg: "errorMsg", displayError: "displayError" }, ngImport: i0, template: "<div *ngIf=\"displayError\" >\n <!-- <span class=\"glyphicon glyphicon-remove form-control-feedback fix-error-icon\"></span> -->\n <span class=\"sr-only\">(error)</span>\n <div class=\"error-msg\">\n {{ errorMsg }}\n </div>\n</div>\n", styles: [".error-msg{color:red}.fix-error-icon{top:27px}\n"] });
77
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: FieldErrorDisplayComponent, decorators: [{
78
+ type: Component,
79
+ args: [{ selector: 'rsl-field-error-display', template: "<div *ngIf=\"displayError\" >\n <!-- <span class=\"glyphicon glyphicon-remove form-control-feedback fix-error-icon\"></span> -->\n <span class=\"sr-only\">(error)</span>\n <div class=\"error-msg\">\n {{ errorMsg }}\n </div>\n</div>\n", styles: [".error-msg{color:red}.fix-error-icon{top:27px}\n"] }]
80
+ }], propDecorators: { errorMsg: [{
81
+ type: Input
82
+ }], displayError: [{
83
+ type: Input
84
+ }] } });
85
+
86
+ class PageNotFoundComponent {
87
+ constructor() {
88
+ }
89
+ ngOnInit() {
90
+ }
91
+ }
92
+ PageNotFoundComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: PageNotFoundComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
93
+ PageNotFoundComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.0", type: PageNotFoundComponent, selector: "rsl-page-not-found", ngImport: i0, template: "<div class=\"forms-view-container\">\n <div class=\"under-construction-view-container\">\n Page not found\n </div>\n</div>", styles: [".under-construction-view-container{height:calc(100vh - 250px);margin:60px 0 0;padding:0;display:flex;justify-content:center;align-items:center;box-sizing:border-box;font-size:1.8em;line-height:1.3em;font-weight:300;color:#58585b;text-align:center}\n"] });
94
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: PageNotFoundComponent, decorators: [{
95
+ type: Component,
96
+ args: [{ selector: 'rsl-page-not-found', template: "<div class=\"forms-view-container\">\n <div class=\"under-construction-view-container\">\n Page not found\n </div>\n</div>", styles: [".under-construction-view-container{height:calc(100vh - 250px);margin:60px 0 0;padding:0;display:flex;justify-content:center;align-items:center;box-sizing:border-box;font-size:1.8em;line-height:1.3em;font-weight:300;color:#58585b;text-align:center}\n"] }]
97
+ }], ctorParameters: function () { return []; } });
98
+
99
+ class SearchableDropdownComponent {
100
+ constructor(_focusMonitor, _elementRef, ngControl) {
101
+ this._focusMonitor = _focusMonitor;
102
+ this._elementRef = _elementRef;
103
+ this.ngControl = ngControl;
104
+ this.onChange = (_) => { };
105
+ this.onTouched = () => { };
106
+ this.stateChanges = new Subject();
107
+ this.focused = false;
108
+ this.errorState = false;
109
+ this.id = `rsl-searchable-dropdown-${SearchableDropdownComponent.nextId++}`;
110
+ // label for the search dropdown
111
+ this.label = '';
112
+ //Fields for sorting the API data
113
+ this.sortFields = '';
114
+ // The value used to populate the control value
115
+ this.valueField = 'id';
116
+ // The minumum char for search
117
+ this.minLengthTerm = 3;
118
+ this.modelSelected = new EventEmitter();
119
+ this._required = false;
120
+ this._disabled = false;
121
+ this.showSerach = true;
122
+ this.isLoading = false;
123
+ this.options = [];
124
+ this.filteredOptions = [];
125
+ /** Subject that emits when the component has been destroyed. */
126
+ this._onDestroy = new Subject();
127
+ this.searchControl = new FormControl('');
128
+ _focusMonitor.monitor(_elementRef, true).subscribe(origin => {
129
+ if (this.focused && !origin) {
130
+ this.onTouched();
131
+ }
132
+ this.focused = !!origin;
133
+ this.stateChanges.next();
134
+ });
135
+ if (this.ngControl) {
136
+ this.ngControl.valueAccessor = this;
137
+ }
138
+ }
139
+ get empty() {
140
+ return !this.value;
141
+ }
142
+ get required() { return this._required; }
143
+ set required(value) {
144
+ this._required = coerceBooleanProperty(value);
145
+ this.stateChanges.next();
146
+ }
147
+ get disabled() { return this._disabled; }
148
+ set disabled(value) {
149
+ this._disabled = coerceBooleanProperty(value);
150
+ this.stateChanges.next();
151
+ }
152
+ get value() {
153
+ return this._value;
154
+ }
155
+ set value(value) {
156
+ if (value)
157
+ if (this._value !== value) {
158
+ this.loadModel(value);
159
+ }
160
+ this._value = value;
161
+ this.stateChanges.next();
162
+ }
163
+ ngOnInit() {
164
+ if (!this.displayFields)
165
+ this.displayFields = this.searchFields;
166
+ this.loadModel(this.ngControl.value);
167
+ if (this.preloadElementsCount) {
168
+ this.serviceRef.getAll(1, this.preloadElementsCount).subscribe({
169
+ next: (data) => {
170
+ this.showSerach = false;
171
+ this.options = data.getModels();
172
+ this.filteredOptions = this.options;
173
+ }
174
+ });
175
+ }
176
+ this.searchControl.valueChanges
177
+ .pipe(filter((res) => {
178
+ const result = res !== null && res.length >= this.minLengthTerm;
179
+ if (!result) {
180
+ this.options = [];
181
+ this.filteredOptions = [];
182
+ }
183
+ this.showSerach = !result;
184
+ return result;
185
+ }), debounceTime(300), tap(() => {
186
+ this.filteredOptions = [];
187
+ this.isLoading = true;
188
+ }), switchMap((value) => this.serviceRef
189
+ .getAll(1, 10, this.sortFields, `${this.searchFields.replace(',', '|')}@=*${value}`)
190
+ .pipe(finalize(() => {
191
+ this.isLoading = false;
192
+ }))), takeUntil(this._onDestroy))
193
+ .subscribe((options) => {
194
+ this.filteredOptions = options.getModels();
195
+ });
196
+ }
197
+ onSelected($event) {
198
+ const value = $event.option.value;
199
+ this.searchControl.setValue(value);
200
+ this.modelSelected.emit(value);
201
+ if (this.valueField in value) {
202
+ this.setControlValue(value[this.valueField]);
203
+ }
204
+ }
205
+ setControlValue(value) {
206
+ this.value = value;
207
+ this.ngControl.control.setValue(value);
208
+ }
209
+ displayWith(value) {
210
+ return this.getConcatedFields(value);
211
+ }
212
+ clearSelection() {
213
+ this.modelSelected.emit(null);
214
+ this.setControlValue(null);
215
+ this.searchControl.setValue(null);
216
+ this.filteredOptions = this.options;
217
+ }
218
+ getConcatedFields(option) {
219
+ if (!option)
220
+ return null;
221
+ const filtersArr = this.displayFields.split(',');
222
+ return filtersArr.reduce((acc, cv) => {
223
+ return acc.concat(option[cv] + ' ');
224
+ }, '');
225
+ }
226
+ ngOnDestroy() {
227
+ this.searchControl = null;
228
+ this.stateChanges.complete();
229
+ this._focusMonitor.stopMonitoring(this._elementRef);
230
+ this._onDestroy.next();
231
+ this._onDestroy.complete();
232
+ }
233
+ getSearchText() {
234
+ return `Enter ${this.minLengthTerm} characters to start search`;
235
+ }
236
+ writeValue(model) {
237
+ console.log(model);
238
+ this.value = model;
239
+ }
240
+ registerOnChange(fn) {
241
+ this.onChange = fn;
242
+ }
243
+ registerOnTouched(fn) {
244
+ this.onTouched = fn;
245
+ }
246
+ setDisabledState(isDisabled) {
247
+ this.disabled = isDisabled;
248
+ }
249
+ loadModel(id) {
250
+ //Load the model from API to display the value
251
+ let needLoad = false;
252
+ if (id) {
253
+ if (!this.searchControl.value)
254
+ needLoad = true;
255
+ else {
256
+ if (this.searchControl.value[this.valueField] !== id) {
257
+ needLoad = true;
258
+ }
259
+ }
260
+ }
261
+ if (needLoad) {
262
+ this.serviceRef.get(id).subscribe({
263
+ next: (model) => {
264
+ this.options.push(model);
265
+ this.filteredOptions = this.options;
266
+ this.searchControl.setValue(model);
267
+ }
268
+ });
269
+ }
270
+ }
271
+ }
272
+ SearchableDropdownComponent.nextId = 0;
273
+ SearchableDropdownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: SearchableDropdownComponent, deps: [{ token: i1.FocusMonitor }, { token: i0.ElementRef }, { token: i2.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component });
274
+ SearchableDropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.0", type: SearchableDropdownComponent, selector: "rsl-searchable-dropdown", inputs: { label: "label", fControlName: "fControlName", serviceRef: "serviceRef", searchFields: "searchFields", displayFields: "displayFields", sortFields: "sortFields", valueField: "valueField", minLengthTerm: "minLengthTerm", preloadElementsCount: "preloadElementsCount", required: "required", disabled: "disabled", value: "value" }, outputs: { modelSelected: "modelSelected" }, host: { properties: { "class.example-floating": "shouldLabelFloat", "id": "id", "attr.aria-describedby": "describedBy" } }, ngImport: i0, template: "<div class=\"form-group\">\r\n <label>{{label | translate}}</label>\r\n <mat-form-field appearance=\"outline\" fxFlex>\r\n <input matInput [matAutocomplete]=\"auto\" [formControl]=\"searchControl\">\r\n <button *ngIf=\"searchControl.value\" matSuffix mat-icon-button aria-label=\"Clear\" (click)=\"clearSelection()\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onSelected($event)\"\r\n [displayWith]=\"displayWith.bind(this)\">\r\n <mat-option *ngIf=\"isLoading\">Loading...</mat-option>\r\n <mat-option *ngIf=\"!isLoading && filteredOptions.length == 0 && !showSerach\" disabled>Not found</mat-option>\r\n <mat-option *ngIf=\"showSerach\" disabled>{{getSearchText()}}</mat-option>\r\n <ng-container *ngIf=\"!isLoading && filteredOptions.length > 0\">\r\n <mat-option *ngFor=\"let option of filteredOptions\" [value]=\"option\">\r\n <span><b>{{getConcatedFields(option)}}</b></span>\r\n </mat-option>\r\n </ng-container>\r\n\r\n </mat-autocomplete>\r\n </mat-form-field>\r\n</div>", components: [{ type: i3.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i6.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i7.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i6.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i3$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.MatSuffix, selector: "[matSuffix]" }, { type: i3$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "translate": i1$1.TranslatePipe } });
275
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: SearchableDropdownComponent, decorators: [{
276
+ type: Component,
277
+ args: [{ selector: 'rsl-searchable-dropdown', host: {
278
+ '[class.example-floating]': 'shouldLabelFloat',
279
+ '[id]': 'id',
280
+ '[attr.aria-describedby]': 'describedBy',
281
+ }, template: "<div class=\"form-group\">\r\n <label>{{label | translate}}</label>\r\n <mat-form-field appearance=\"outline\" fxFlex>\r\n <input matInput [matAutocomplete]=\"auto\" [formControl]=\"searchControl\">\r\n <button *ngIf=\"searchControl.value\" matSuffix mat-icon-button aria-label=\"Clear\" (click)=\"clearSelection()\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onSelected($event)\"\r\n [displayWith]=\"displayWith.bind(this)\">\r\n <mat-option *ngIf=\"isLoading\">Loading...</mat-option>\r\n <mat-option *ngIf=\"!isLoading && filteredOptions.length == 0 && !showSerach\" disabled>Not found</mat-option>\r\n <mat-option *ngIf=\"showSerach\" disabled>{{getSearchText()}}</mat-option>\r\n <ng-container *ngIf=\"!isLoading && filteredOptions.length > 0\">\r\n <mat-option *ngFor=\"let option of filteredOptions\" [value]=\"option\">\r\n <span><b>{{getConcatedFields(option)}}</b></span>\r\n </mat-option>\r\n </ng-container>\r\n\r\n </mat-autocomplete>\r\n </mat-form-field>\r\n</div>" }]
282
+ }], ctorParameters: function () {
283
+ return [{ type: i1.FocusMonitor }, { type: i0.ElementRef }, { type: i2.NgControl, decorators: [{
284
+ type: Optional
285
+ }, {
286
+ type: Self
287
+ }] }];
288
+ }, propDecorators: { label: [{
289
+ type: Input
290
+ }], fControlName: [{
291
+ type: Input
292
+ }], serviceRef: [{
293
+ type: Input
294
+ }], searchFields: [{
295
+ type: Input
296
+ }], displayFields: [{
297
+ type: Input
298
+ }], sortFields: [{
299
+ type: Input
300
+ }], valueField: [{
301
+ type: Input
302
+ }], minLengthTerm: [{
303
+ type: Input
304
+ }], preloadElementsCount: [{
305
+ type: Input
306
+ }], modelSelected: [{
307
+ type: Output
308
+ }], required: [{
309
+ type: Input
310
+ }], disabled: [{
311
+ type: Input
312
+ }], value: [{
313
+ type: Input
314
+ }] } });
315
+
316
+ class UnderConstructionComponent {
317
+ constructor() { }
318
+ }
319
+ UnderConstructionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: UnderConstructionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
320
+ UnderConstructionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.0", type: UnderConstructionComponent, selector: "rsl-under-construction", ngImport: i0, template: "<div class=\"forms-view-container\">\n <div class=\"under-construction-view-container\">\n Page under construction\n </div>\n</div>", styles: [".under-construction-view-container{height:calc(100vh - 250px);margin:60px 0 0;padding:0;display:flex;justify-content:center;align-items:center;box-sizing:border-box;font-size:1.8em;line-height:1.3em;font-weight:300;color:#58585b;text-align:center}\n"] });
321
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: UnderConstructionComponent, decorators: [{
322
+ type: Component,
323
+ args: [{ selector: 'rsl-under-construction', template: "<div class=\"forms-view-container\">\n <div class=\"under-construction-view-container\">\n Page under construction\n </div>\n</div>", styles: [".under-construction-view-container{height:calc(100vh - 250px);margin:60px 0 0;padding:0;display:flex;justify-content:center;align-items:center;box-sizing:border-box;font-size:1.8em;line-height:1.3em;font-weight:300;color:#58585b;text-align:center}\n"] }]
324
+ }], ctorParameters: function () { return []; } });
325
+
326
+ class BaseQueryData {
327
+ constructor(jsonApiModels, metaData) {
328
+ this.jsonApiModels = jsonApiModels;
329
+ this.metaData = metaData;
330
+ }
331
+ getModels() {
332
+ return this.jsonApiModels;
333
+ }
334
+ getMeta() {
335
+ return this.metaData;
336
+ }
337
+ }
338
+
339
+ class BaseDatastore {
340
+ constructor(httpClient) {
341
+ this.httpClient = httpClient;
342
+ // tslint:disable-next-line:variable-name
343
+ this._store = {};
344
+ // tslint:enable:max-line-length
345
+ // tslint:disable-next-line:ban-types
346
+ this.toQueryString = this.datastoreConfig.overrides
347
+ && this.datastoreConfig.overrides.toQueryString ?
348
+ this.datastoreConfig.overrides.toQueryString : this._toQueryString;
349
+ }
350
+ // tslint:enable:max-line-length
351
+ get getDirtyAttributes() {
352
+ if (this.datastoreConfig.overrides
353
+ && this.datastoreConfig.overrides.getDirtyAttributes) {
354
+ return this.datastoreConfig.overrides.getDirtyAttributes;
355
+ }
356
+ else {
357
+ return BaseDatastore.getDirtyAttributes;
358
+ }
359
+ }
360
+ get getAllAttributes() {
361
+ if (this.datastoreConfig.overrides
362
+ && this.datastoreConfig.overrides.getAllAttributes) {
363
+ return this.datastoreConfig.overrides.getAllAttributes;
364
+ }
365
+ else {
366
+ return BaseDatastore.getAllAttributes;
367
+ }
368
+ }
369
+ // protected config: DatastoreConfig;
370
+ static getDirtyAttributes(attributesMetadata) {
371
+ const dirtyData = {};
372
+ for (const propertyName in attributesMetadata) {
373
+ if (attributesMetadata.hasOwnProperty(propertyName)) {
374
+ const metadata = attributesMetadata[propertyName];
375
+ if (metadata.hasDirtyAttributes) {
376
+ const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
377
+ dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
378
+ }
379
+ }
380
+ }
381
+ return dirtyData;
382
+ }
383
+ static getAllAttributes(attributesMetadata) {
384
+ const dirtyData = {};
385
+ for (const propertyName in attributesMetadata) {
386
+ if (attributesMetadata.hasOwnProperty(propertyName)) {
387
+ const metadata = attributesMetadata[propertyName];
388
+ const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
389
+ dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
390
+ }
391
+ }
392
+ return dirtyData;
393
+ }
394
+ findAll(modelType, params, headers, customUrl) {
395
+ const customHeadhers = this.buildHeaders(headers);
396
+ const htmlParams = this.buildParams(params);
397
+ const url = this.buildUrl(modelType, customUrl);
398
+ const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
399
+ .pipe(map(res => this.extractQueryData(res, modelType)), catchError(this.handleError));
400
+ return response;
401
+ }
402
+ findRecord(modelType, id, params, headers, customUrl) {
403
+ const customHeadhers = this.buildHeaders(headers);
404
+ let url = this.buildUrl(modelType, customUrl);
405
+ if (id) {
406
+ url += '/' + id;
407
+ }
408
+ const htmlParams = this.buildParams(params, undefined);
409
+ return this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
410
+ .pipe(map(res => this.entityToModel(res, modelType, undefined)), catchError(this.handleError));
411
+ }
412
+ getCustom(modelType, params, headers, customUrl, customResponseType) {
413
+ const customHeadhers = this.buildHeaders(headers);
414
+ const url = this.buildUrl(modelType, customUrl);
415
+ const htmlParams = this.buildParams(params, undefined);
416
+ if (!customResponseType)
417
+ customResponseType = 'json';
418
+ return this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true, responseType: customResponseType });
419
+ }
420
+ postCustom(modelType, body, params, headers, customUrl) {
421
+ const customHeadhers = this.buildHeaders(headers);
422
+ const url = this.buildUrl(modelType, customUrl);
423
+ const htmlParams = this.buildParams(params, undefined);
424
+ return this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, reportProgress: true, withCredentials: true });
425
+ }
426
+ patchCustom(modelType, body, params, headers, customUrl) {
427
+ const customHeadhers = this.buildHeaders(headers);
428
+ const url = this.buildUrl(modelType, customUrl);
429
+ const htmlParams = this.buildParams(params, undefined);
430
+ return this.httpClient.patch(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
431
+ }
432
+ createRecord(modelType, data) {
433
+ return new modelType(this, data);
434
+ }
435
+ saveRecord(attributesMetadata, model, params, headers, customUrl, customBody) {
436
+ const modelType = model.constructor;
437
+ const modelConfig = model.modelConfig;
438
+ const customHeadhers = this.buildHeaders(headers);
439
+ const url = this.buildUrl(modelType, customUrl);
440
+ const htmlParams = this.buildParams(params);
441
+ let httpCall;
442
+ const body = customBody || this.modelToEntity(model, attributesMetadata);
443
+ if (model.id) {
444
+ // tslint:disable-next-line:max-line-length
445
+ httpCall = this.httpClient.patch(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
446
+ }
447
+ else {
448
+ httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
449
+ }
450
+ return httpCall
451
+ .pipe(map(res => {
452
+ const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
453
+ return this.entityToModel(data, modelType);
454
+ }), catchError(this.handleError));
455
+ }
456
+ patchRecord(attributesMetadata, model, origModel, params, headers, customUrl) {
457
+ const modelType = model.constructor;
458
+ const modelConfig = model.modelConfig;
459
+ const customHeadhers = this.buildHeaders(headers);
460
+ const url = this.buildUrl(modelType, customUrl);
461
+ const htmlParams = this.buildParams(params);
462
+ let httpCall;
463
+ let origData = { id: '' };
464
+ if (origModel)
465
+ origData = this.modelToEntity(origModel, origModel.attributeMetadata, true);
466
+ const newData = this.modelToEntity(model, attributesMetadata, true);
467
+ newData.id = origData.id;
468
+ const patch = compare(origData, newData);
469
+ if (patch.length > 0) {
470
+ httpCall = this.httpClient.patch(url + '/' + model.id, patch, { headers: customHeadhers, params: htmlParams, withCredentials: true });
471
+ return httpCall
472
+ .pipe(map(res => {
473
+ const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
474
+ return this.entityToModel(data, modelType);
475
+ }), catchError(this.handleError));
476
+ }
477
+ else {
478
+ return new Observable((observer) => {
479
+ observer.next(model);
480
+ observer.complete();
481
+ });
482
+ }
483
+ }
484
+ // getPatch<T extends BaseModel>(
485
+ // model: T,
486
+ // origModel: T): any {
487
+ // }
488
+ replaceRecord(attributesMetadata, model, params, headers, customUrl, customBody) {
489
+ const modelType = model.constructor;
490
+ const modelConfig = model.modelConfig;
491
+ const customHeadhers = this.buildHeaders(headers);
492
+ const url = this.buildUrl(modelType, customUrl);
493
+ const htmlParams = this.buildParams(params);
494
+ let httpCall;
495
+ const body = customBody || this.modelToEntity(model, attributesMetadata, true);
496
+ if (model.id) {
497
+ httpCall = this.httpClient.put(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
498
+ }
499
+ else {
500
+ httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
501
+ }
502
+ return httpCall
503
+ .pipe(map(res => {
504
+ const data = this.resetMetadataAttributes(res, attributesMetadata, modelType);
505
+ return this.entityToModel(data, modelType);
506
+ }), catchError(this.handleError));
507
+ }
508
+ deleteRecord(modelType, id, headers, customUrl) {
509
+ const customHeadhers = this.buildHeaders(headers);
510
+ let url = this.buildUrl(modelType, customUrl);
511
+ if (!url.includes('share')) {
512
+ url = url + '/' + id;
513
+ }
514
+ // const idParam = new HttpParams().set('id', id);
515
+ return this.httpClient.delete(url, { headers: customHeadhers, withCredentials: true })
516
+ .pipe(catchError(this.handleError));
517
+ }
518
+ buildUrl(modelType, customUrl) {
519
+ if (customUrl) {
520
+ return customUrl;
521
+ }
522
+ const modelConfig = Reflect.getMetadata('BaseModelConfig', modelType);
523
+ const baseUrl = modelConfig.baseUrl || this.datastoreConfig.baseUrl;
524
+ const apiVersion = modelConfig.apiVersion || this.datastoreConfig.apiVersion;
525
+ const modelEndpointUrl = modelConfig.modelEndpointUrl || modelConfig.type;
526
+ const url = [baseUrl, apiVersion, modelEndpointUrl].filter((x) => x).join('/');
527
+ return url;
528
+ }
529
+ extractQueryData(res, modelType) {
530
+ let result;
531
+ const body = res;
532
+ const models = [];
533
+ for (const data of body.data) {
534
+ const model = this.entityToModel(data, modelType, undefined);
535
+ models.push(model);
536
+ }
537
+ result = new BaseQueryData(models, this.parseMeta(body, modelType));
538
+ return result;
539
+ }
540
+ deserializeModel(modelType, data) {
541
+ data = this.transformSerializedNamesToPropertyNames(modelType, data);
542
+ return new modelType(this, data);
543
+ }
544
+ handleError(error) {
545
+ if (error.error instanceof ErrorEvent) {
546
+ // A client-side or network error occurred. Handle it accordingly.
547
+ // console.error('An error occurred:', error.error.message);
548
+ }
549
+ else {
550
+ // The backend returned an unsuccessful response code.
551
+ // The response body may contain clues as to what went wrong,
552
+ // console.error(
553
+ // 'Backend returned code ${error.status}, ' +
554
+ // 'body was: ${error.error}');
555
+ }
556
+ // return an observable with a user-facing error message
557
+ return throwError(error);
558
+ }
559
+ parseMeta(body, modelType) {
560
+ const metaModel = Reflect.getMetadata('BaseModelConfig', modelType).meta;
561
+ return new metaModel(body);
562
+ }
563
+ resetMetadataAttributes(res, attributesMetadata, modelType) {
564
+ // TODO check why is attributesMetadata from the arguments never used
565
+ for (const propertyName in attributesMetadata) {
566
+ if (attributesMetadata.hasOwnProperty(propertyName)) {
567
+ const metadata = attributesMetadata[propertyName];
568
+ if (metadata.hasDirtyAttributes) {
569
+ metadata.hasDirtyAttributes = false;
570
+ }
571
+ }
572
+ }
573
+ if (res) {
574
+ res.attributeMetadata = attributesMetadata;
575
+ }
576
+ return res;
577
+ }
578
+ get datastoreConfig() {
579
+ const configFromDecorator = Reflect.getMetadata('BaseDatastoreConfig', this.constructor);
580
+ return Object.assign(configFromDecorator, this.config);
581
+ }
582
+ transformSerializedNamesToPropertyNames(modelType, attributes) {
583
+ const serializedNameToPropertyName = this.getModelPropertyNames(modelType.prototype);
584
+ const properties = {};
585
+ Object.keys(serializedNameToPropertyName).forEach((serializedName) => {
586
+ if (attributes[serializedName] !== null && attributes[serializedName] !== undefined) {
587
+ properties[serializedNameToPropertyName[serializedName]] = attributes[serializedName];
588
+ }
589
+ });
590
+ return properties;
591
+ }
592
+ getModelPropertyNames(model) {
593
+ return Reflect.getMetadata('AttributeMapping', model);
594
+ }
595
+ buildHeaders(customHeaders) {
596
+ const headers = {
597
+ Accept: 'application/json-patch+json',
598
+ // 'Content-Type': 'application/vnd.api+json',
599
+ 'Content-Type': 'application/json-patch+json'
600
+ };
601
+ if (customHeaders && customHeaders.keys().length) {
602
+ // tslint:disable-next-line:variable-name
603
+ Object.assign({}, headers, customHeaders.keys().map(header_name => {
604
+ headers['' + header_name] = customHeaders.get(header_name);
605
+ }));
606
+ }
607
+ return new HttpHeaders(headers);
608
+ }
609
+ buildParams(params, id) {
610
+ let httpParams = new HttpParams();
611
+ if (id) {
612
+ httpParams = httpParams.set('id', id);
613
+ }
614
+ if (params) {
615
+ Object.keys(params)
616
+ .filter(key => {
617
+ const v = params[key];
618
+ return (Array.isArray(v) || typeof v === 'string') ?
619
+ (v.length > 0) :
620
+ (v !== null && v !== undefined);
621
+ })
622
+ .forEach(key => {
623
+ httpParams = httpParams.set(key, params[key]);
624
+ });
625
+ }
626
+ return httpParams;
627
+ }
628
+ entityToModel(res, modelType, model) {
629
+ return this.extractRecordDataJson(res, modelType, model);
630
+ }
631
+ extractRecordDataJson(res, modelType, model) {
632
+ const body = res;
633
+ if (!body) {
634
+ throw new Error('no body in response');
635
+ }
636
+ if (model) {
637
+ Object.assign(model, body);
638
+ }
639
+ const deserializedModel = model || this.deserializeModel(modelType, body.data || body);
640
+ return deserializedModel;
641
+ }
642
+ modelToEntity(model, attributesMetadata, allAttributes = false) {
643
+ let attributes;
644
+ if (allAttributes) {
645
+ attributes = this.getAllAttributes(attributesMetadata, model);
646
+ }
647
+ else {
648
+ attributes = this.getDirtyAttributes(attributesMetadata, model);
649
+ }
650
+ // this.getRelationships(model, attributes);
651
+ return attributes;
652
+ }
653
+ _toQueryString(params) {
654
+ return qs.stringify(params, { arrayFormat: 'brackets' });
655
+ }
656
+ }
657
+ BaseDatastore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseDatastore, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
658
+ BaseDatastore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseDatastore });
659
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseDatastore, decorators: [{
660
+ type: Injectable
661
+ }], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; } });
662
+
663
+ class BaseService {
664
+ constructor(datastore) {
665
+ this.datastore = datastore;
666
+ }
667
+ setModelType(modelType) {
668
+ this.modelType = modelType;
669
+ }
670
+ get(id, customInclude = '') {
671
+ const response = this.datastore.findRecord(this.modelType, id, { customInclude });
672
+ return response;
673
+ }
674
+ getAll(page, pageSize, sort = '', filters = '', customInclude = '') {
675
+ const response = this.datastore.findAll(this.modelType, {
676
+ Page: page,
677
+ PageSize: pageSize,
678
+ Sorts: sort,
679
+ Filters: filters,
680
+ customInclude
681
+ });
682
+ return response;
683
+ }
684
+ delete(id) {
685
+ const response = this.datastore.deleteRecord(this.modelType, id);
686
+ return response;
687
+ }
688
+ getCustom(params, headers, customUrl, customResponseType) {
689
+ return this.datastore.getCustom(this.modelType, params, headers, customUrl, customResponseType);
690
+ }
691
+ postCustom(body, params, headers, customUrl) {
692
+ return this.datastore.postCustom(this.modelType, body, params, headers, customUrl);
693
+ }
694
+ patchCustom(body, params, headers, customUrl) {
695
+ return this.datastore.patchCustom(this.modelType, body, params, headers, customUrl);
696
+ }
697
+ // checkIfPropertyUnique(property: string, value: any): Observable<boolean> {
698
+ // }
699
+ save(docTypeOrFormGroup, id, origModel) {
700
+ if (id == null) {
701
+ let fromModel;
702
+ if (docTypeOrFormGroup instanceof FormGroup) {
703
+ fromModel = this.fromFormGroup(docTypeOrFormGroup, id);
704
+ }
705
+ else {
706
+ fromModel = docTypeOrFormGroup;
707
+ }
708
+ const data = this.datastore.createRecord(this.modelType, fromModel);
709
+ return data.save();
710
+ }
711
+ else {
712
+ return this.patch(docTypeOrFormGroup, origModel, id);
713
+ }
714
+ }
715
+ patch(docTypeOrFormGroup, origModel, id) {
716
+ let fromModel;
717
+ if (docTypeOrFormGroup instanceof FormGroup) {
718
+ fromModel = this.fromFormGroup(docTypeOrFormGroup, id);
719
+ }
720
+ else {
721
+ fromModel = docTypeOrFormGroup;
722
+ }
723
+ const data = this.datastore.createRecord(this.modelType, fromModel);
724
+ return data.patch(origModel);
725
+ }
726
+ newModel(data) {
727
+ return new this.modelType(this.datastore, data);
728
+ }
729
+ toFormGroup(fb, fromModel) {
730
+ if (fromModel === undefined) {
731
+ fromModel = this.newModel();
732
+ }
733
+ return fromModel.getFromGroup(fb);
734
+ }
735
+ fromFormGroup(formGroup, id) {
736
+ // const saveModel = this.newModel(formGroup.getRawValue());
737
+ // saveModel.id = id ? id : null;
738
+ // return saveModel;
739
+ const saveModel = this.newModel();
740
+ saveModel.getModelFromFormGroup(formGroup);
741
+ saveModel.id = id ? id : null;
742
+ return saveModel;
743
+ }
744
+ }
745
+ BaseService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseService, deps: [{ token: BaseDatastore }], target: i0.ɵɵFactoryTarget.Injectable });
746
+ BaseService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseService, providedIn: 'root' });
747
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseService, decorators: [{
748
+ type: Injectable,
749
+ args: [{
750
+ providedIn: 'root'
751
+ }]
752
+ }], ctorParameters: function () { return [{ type: BaseDatastore }]; } });
753
+
754
+ /**
755
+ * Async modal dialog service
756
+ * DialogService makes this app easier to test by faking this service.
757
+ * TODO: better modal implementation that doesn't use window.confirm
758
+ */
759
+ class DialogService {
760
+ /**
761
+ * Ask user to confirm an action. `message` explains the action and choices.
762
+ * Returns observable resolving to `true`=confirm or `false`=cancel
763
+ */
764
+ constructor() { }
765
+ confirm(message, text, confirmButtonText = 'Delete', cancelButtonText = 'Cancel') {
766
+ const confirmation = Swal.fire({
767
+ title: message || 'Are you sure?',
768
+ icon: 'warning',
769
+ text: text || '',
770
+ showCancelButton: true,
771
+ confirmButtonText: confirmButtonText,
772
+ cancelButtonText: cancelButtonText,
773
+ customClass: {
774
+ confirmButton: 'btn btn-red btn-fill btn-wd',
775
+ cancelButton: 'btn btn-grey btn-fill btn-wd',
776
+ },
777
+ buttonsStyling: false,
778
+ reverseButtons: true
779
+ })
780
+ .then((result) => {
781
+ if (result.value) {
782
+ return true;
783
+ }
784
+ else {
785
+ return false;
786
+ }
787
+ }).catch();
788
+ return from(confirmation);
789
+ }
790
+ showSaveMessage(message, title) {
791
+ const confirmation = Swal.fire({
792
+ icon: 'success',
793
+ title: message,
794
+ timer: 2000,
795
+ showConfirmButton: false,
796
+ // customClass: 'overflow-hidden',
797
+ buttonsStyling: false
798
+ }).then(() => {
799
+ return true;
800
+ }, () => {
801
+ return false;
802
+ }).catch();
803
+ return from(confirmation);
804
+ }
805
+ showRegisteredMessage(message, title) {
806
+ const confirmation = Swal.fire({
807
+ icon: 'success',
808
+ title: message,
809
+ showConfirmButton: true,
810
+ customClass: {
811
+ confirmButton: 'btn btn-success',
812
+ },
813
+ buttonsStyling: false
814
+ }).then(() => {
815
+ return true;
816
+ }, () => {
817
+ return false;
818
+ }).catch();
819
+ return from(confirmation);
820
+ }
821
+ // notification(message?: string, type?: NotificationType, fromPosition?: NotificationFrom, align?: NotificationAlign, timer?: number) {
822
+ // if (!type) {
823
+ // type = NotificationType.success;
824
+ // }
825
+ // if (!fromPosition) {
826
+ // fromPosition = NotificationFrom.bottom;
827
+ // }
828
+ // if (!align) {
829
+ // align = NotificationAlign.center;
830
+ // }
831
+ // if (!timer) {
832
+ // timer = 3000;
833
+ // }
834
+ // $.notify({
835
+ // icon: 'notifications',
836
+ // message: message
837
+ // }, {
838
+ // type: type,
839
+ // timer: 3000,
840
+ // placement: {
841
+ // from: from,
842
+ // align: align
843
+ // }
844
+ // });
845
+ // }
846
+ showErrorMessage(e, message) {
847
+ if (!message) {
848
+ message = 'Validation errors';
849
+ }
850
+ if (e instanceof HttpErrorResponse) {
851
+ // Validation errors
852
+ if (e.status === 400) {
853
+ const errors = e.error.errors;
854
+ if (errors) {
855
+ errors.forEach(error => {
856
+ message += error.field + ' ' + error.detail + '\n';
857
+ });
858
+ // message = errors.detail;
859
+ // if (detail.relationships) {
860
+ // detail.relationships.forEach(relation => {
861
+ // console.log(relation);
862
+ // });
863
+ // }
864
+ }
865
+ }
866
+ }
867
+ const confirmation = Swal.fire({
868
+ icon: 'error',
869
+ title: message,
870
+ // timer: 2000,
871
+ showConfirmButton: true,
872
+ customClass: {
873
+ confirmButton: 'btn btn-success',
874
+ },
875
+ buttonsStyling: false
876
+ }).then(() => {
877
+ return true;
878
+ }, () => {
879
+ return false;
880
+ }).catch();
881
+ return from(confirmation);
882
+ }
883
+ getTextTranslation(translationKey) {
884
+ // // const result = await promise;
885
+ // // return result;
886
+ // const result = this.translate.instant(translationKey);
887
+ // if (result === translationKey) {
888
+ return translationKey;
889
+ // }
890
+ // return result;
891
+ }
892
+ }
893
+ DialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
894
+ DialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DialogService });
895
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DialogService, decorators: [{
896
+ type: Injectable
897
+ }], ctorParameters: function () { return []; } });
898
+
899
+ class BaseFormEditComponent {
900
+ constructor(fb, router, route, modelService, dialogService, translate, location) {
901
+ this.fb = fb;
902
+ this.router = router;
903
+ this.route = route;
904
+ this.modelService = modelService;
905
+ this.dialogService = dialogService;
906
+ this.translate = translate;
907
+ this.location = location;
908
+ this.isLoading = true;
909
+ this.changeUrlRoute = true;
910
+ this.generateForm(this.modelService.newModel());
911
+ }
912
+ afterSave(model) {
913
+ return new Observable((observer) => {
914
+ observer.next(model);
915
+ observer.complete();
916
+ });
917
+ }
918
+ beforeSave(model) {
919
+ return new Observable((observer) => {
920
+ observer.next(model);
921
+ observer.complete();
922
+ });
923
+ }
924
+ ngOnInit() {
925
+ this.initForm();
926
+ }
927
+ initForm(customInclude = '', newModelId = null, model = null) {
928
+ var _a;
929
+ if (model === null) {
930
+ this.modelId = (_a = this.route.snapshot.paramMap.get('id')) !== null && _a !== void 0 ? _a : newModelId;
931
+ this.isEdit = false;
932
+ if (this.modelId) {
933
+ this.modelService.get(this.modelId, customInclude).subscribe((value) => {
934
+ this.isEdit = true;
935
+ this.generateForm(value);
936
+ });
937
+ }
938
+ else {
939
+ if (this.changeUrlRoute) {
940
+ const addUrl = this.router.createUrlTree([]).toString();
941
+ this.editRoute = this.router.createUrlTree([addUrl.replace('add', 'edit')]).toString();
942
+ }
943
+ // }
944
+ this.generateForm(this.modelService.newModel());
945
+ }
946
+ }
947
+ else {
948
+ this.modelId = model.id;
949
+ this.isEdit = true;
950
+ this.generateForm(model);
951
+ }
952
+ }
953
+ generateForm(model) {
954
+ this.isLoading = false;
955
+ this.modelId = model.id;
956
+ this.model = model;
957
+ this.baseForm = this.modelService.toFormGroup(this.fb, model);
958
+ this.afterFormGenerated();
959
+ }
960
+ afterFormGenerated() {
961
+ }
962
+ getFromGroup(formGroup = null) {
963
+ if (!formGroup)
964
+ return this.baseForm;
965
+ if (formGroup instanceof FormGroup)
966
+ return formGroup;
967
+ return this.baseForm.controls[formGroup];
968
+ }
969
+ validateAllFormFields(formGroup = null) {
970
+ const fg = this.getFromGroup(formGroup);
971
+ Object.keys(fg.controls).forEach(field => {
972
+ // console.log(field);
973
+ const control = fg.get(field);
974
+ if (control instanceof FormControl) {
975
+ control.markAsTouched({ onlySelf: true });
976
+ }
977
+ else if (control instanceof FormGroup) {
978
+ this.validateAllFormFields(control);
979
+ }
980
+ });
981
+ }
982
+ isFieldValid(field, formGroup = null) {
983
+ const fg = this.getFromGroup(formGroup);
984
+ const filedControl = fg.get(field);
985
+ return !filedControl.valid && filedControl.touched;
986
+ }
987
+ isFieldValidFromArray(arrayIndex, field, arrayName = 'formArray') {
988
+ const fieldControl = this.baseForm.get(arrayName).get([arrayIndex]).get(field);
989
+ return !fieldControl.valid && fieldControl.touched;
990
+ }
991
+ displayFieldCss(field) {
992
+ return {
993
+ 'has-error': this.isFieldValid(field),
994
+ 'has-feedback': this.isFieldValid(field)
995
+ };
996
+ }
997
+ onCancel() {
998
+ this.router.navigate([this.cancelRoute]);
999
+ }
1000
+ onSave() {
1001
+ this.saveModel(this.baseForm);
1002
+ }
1003
+ saveModel(formGroup = null) {
1004
+ const fg = this.getFromGroup(formGroup);
1005
+ const that = this;
1006
+ if (fg) {
1007
+ if (fg.valid) {
1008
+ that.blockUI.start('Saving ...');
1009
+ this.beforeSave(this.model).subscribe(_ => {
1010
+ this.modelService.save(this.baseForm, this.modelId, this.model).subscribe((newModel) => {
1011
+ this.model = newModel;
1012
+ this.modelId = newModel.id;
1013
+ if (this.editRoute) {
1014
+ this.isEdit = true;
1015
+ if (this.changeUrlRoute) {
1016
+ const url = this.router.createUrlTree([this.editRoute, this.modelId]).toString();
1017
+ this.location.replaceState(url);
1018
+ }
1019
+ }
1020
+ this.afterSave(newModel).subscribe((val) => {
1021
+ this.blockUI.stop();
1022
+ this.dialogService.showSaveMessage('Your changes were saved successfully.').subscribe(d => {
1023
+ fg.markAsPristine();
1024
+ });
1025
+ });
1026
+ }, err => {
1027
+ this.serverErrors(err);
1028
+ this.blockUI.stop();
1029
+ });
1030
+ });
1031
+ }
1032
+ else {
1033
+ this.validateAllFormFields(formGroup);
1034
+ }
1035
+ }
1036
+ }
1037
+ serverErrors(err) {
1038
+ if (err.error) {
1039
+ if (err.error.errors) {
1040
+ const validationErrors = err.error.errors;
1041
+ if (Array.isArray(validationErrors)) {
1042
+ validationErrors.forEach(prop => {
1043
+ const formControl = this.baseForm.get(prop);
1044
+ if (formControl) {
1045
+ // activate the error message
1046
+ formControl.setErrors({
1047
+ serverError: validationErrors[prop].join('\n')
1048
+ });
1049
+ }
1050
+ });
1051
+ }
1052
+ else {
1053
+ const keys = Object.keys(validationErrors);
1054
+ keys.forEach(prop => {
1055
+ const formControl = this.baseForm.get(prop);
1056
+ if (formControl) {
1057
+ // activate the error message
1058
+ formControl.setErrors({
1059
+ serverError: validationErrors[prop].join('\n')
1060
+ });
1061
+ }
1062
+ });
1063
+ }
1064
+ }
1065
+ }
1066
+ }
1067
+ canDeactivate() {
1068
+ // Allow synchronous navigation (`true`) if no crisis or the crisis is unchanged
1069
+ if (!this.baseForm.dirty) {
1070
+ return true;
1071
+ }
1072
+ // Otherwise ask the user with the dialog service and return its
1073
+ // observable which resolves to true or false when the user decides
1074
+ return this.dialogService.confirm('Discard changes ?', null, 'Discard');
1075
+ }
1076
+ getFiledName(filedTranslationKey) {
1077
+ return { field: this.translate.instant(filedTranslationKey) };
1078
+ }
1079
+ getCustomErrorMessage(error, fieldLabel) {
1080
+ return '';
1081
+ }
1082
+ getErrorMessageFromArray(arrayIndex, field, filedTranslationKey, arrayName = 'formArray') {
1083
+ const fieldControl = this.baseForm.get(arrayName).get([arrayIndex]).get(field);
1084
+ return this.getErrorMessageForField(fieldControl, filedTranslationKey);
1085
+ }
1086
+ getErrorMessage(field, filedTranslationKey, formGroup = null) {
1087
+ const fg = this.getFromGroup(formGroup);
1088
+ return this.getErrorMessageForField(fg.get(field), filedTranslationKey);
1089
+ }
1090
+ getErrorMessageForField(fieldControl, filedTranslationKey) {
1091
+ const error = fieldControl.errors;
1092
+ const fieldLabel = this.translate.instant(filedTranslationKey);
1093
+ let rvalue = '';
1094
+ if (error !== null) {
1095
+ if (error['required'] === true) {
1096
+ rvalue = this.translate.instant('General.Field.Required', { field: fieldLabel });
1097
+ }
1098
+ if (error['minlength']) {
1099
+ rvalue = this.translate.instant('General.Field.MinLength', { field: fieldLabel, requiredLength: error.minlength.requiredLength });
1100
+ }
1101
+ if (error['email'] === true) {
1102
+ rvalue = this.translate.instant('General.Field.InvalidEmail');
1103
+ }
1104
+ if (error['url'] === true) {
1105
+ rvalue = this.translate.instant('General.Field.InvalidUrl');
1106
+ }
1107
+ if (error['serverError']) {
1108
+ rvalue = error['serverError'];
1109
+ }
1110
+ if (rvalue === '') {
1111
+ rvalue = this.getCustomErrorMessage(error, fieldLabel);
1112
+ }
1113
+ }
1114
+ return rvalue;
1115
+ }
1116
+ }
1117
+ BaseFormEditComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseFormEditComponent, deps: [{ token: i2.FormBuilder }, { token: i2$1.Router }, { token: i2$1.ActivatedRoute }, { token: BaseService }, { token: DialogService }, { token: i1$1.TranslateService }, { token: i3$1.Location }], target: i0.ɵɵFactoryTarget.Component });
1118
+ BaseFormEditComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.0", type: BaseFormEditComponent, selector: "app-base.form.edit", ngImport: i0, template: '', isInline: true });
1119
+ __decorate([
1120
+ BlockUI()
1121
+ ], BaseFormEditComponent.prototype, "blockUI", void 0);
1122
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseFormEditComponent, decorators: [{
1123
+ type: Component,
1124
+ args: [{
1125
+ selector: 'app-base.form.edit',
1126
+ template: ''
1127
+ }]
1128
+ }], ctorParameters: function () { return [{ type: i2.FormBuilder }, { type: i2$1.Router }, { type: i2$1.ActivatedRoute }, { type: BaseService }, { type: DialogService }, { type: i1$1.TranslateService }, { type: i3$1.Location }]; }, propDecorators: { blockUI: [] } });
1129
+
1130
+ var GridLayoutFormat;
1131
+ (function (GridLayoutFormat) {
1132
+ GridLayoutFormat[GridLayoutFormat["none"] = 0] = "none";
1133
+ GridLayoutFormat[GridLayoutFormat["date"] = 1] = "date";
1134
+ GridLayoutFormat[GridLayoutFormat["number"] = 2] = "number";
1135
+ GridLayoutFormat[GridLayoutFormat["percent"] = 3] = "percent";
1136
+ GridLayoutFormat[GridLayoutFormat["picture"] = 4] = "picture";
1137
+ })(GridLayoutFormat || (GridLayoutFormat = {}));
1138
+ var CellTextAlign;
1139
+ (function (CellTextAlign) {
1140
+ CellTextAlign["left"] = "left";
1141
+ CellTextAlign["center"] = "center";
1142
+ CellTextAlign["right"] = "right";
1143
+ })(CellTextAlign || (CellTextAlign = {}));
1144
+
1145
+ class GenericTableComponent {
1146
+ // ruleEngineService: RuleEngineService<T>;
1147
+ constructor(dialogService, router, datePipe, numberPipe, percentPipe, renderer) {
1148
+ this.dialogService = dialogService;
1149
+ this.router = router;
1150
+ this.datePipe = datePipe;
1151
+ this.numberPipe = numberPipe;
1152
+ this.percentPipe = percentPipe;
1153
+ this.renderer = renderer;
1154
+ this.defaultSort = null;
1155
+ this.defaultSortDirection = null;
1156
+ this.deletePropertyName = 'name';
1157
+ this.stickyColumns = null;
1158
+ this.editOnClick = false;
1159
+ this.editOnDblClick = false;
1160
+ this.allowEdit = true;
1161
+ this.popupEdit = false;
1162
+ this.customInclude = null;
1163
+ this.infiniteScroll = false;
1164
+ this.dataSource = new MatTableDataSource();
1165
+ this.resultsLength = 0;
1166
+ this.isLoadingResults = true;
1167
+ this.isRateLimitReached = false;
1168
+ this.filterChanged = new Subject();
1169
+ this.selectedObject = new EventEmitter();
1170
+ this.click = new EventEmitter();
1171
+ this.editModel = new EventEmitter();
1172
+ }
1173
+ ngOnChanges() {
1174
+ if (this.baseService !== undefined || this.baseService !== null) {
1175
+ if (this.gridLayoutService != null) {
1176
+ this.gridLayout = this.gridLayoutService.getGridLayout();
1177
+ }
1178
+ else {
1179
+ const model = this.baseService.newModel();
1180
+ this.gridLayout = model.getGridLayout();
1181
+ }
1182
+ this.displayedColumns = [];
1183
+ if (this.allowReorderItems) {
1184
+ this.displayedColumns.push('position');
1185
+ }
1186
+ this.displayedColumns.push.apply(this.displayedColumns, this.gridLayout.map(x => x.propertyName));
1187
+ if (!this.editOnClick && !this.editOnDblClick && this.allowEdit) {
1188
+ this.displayedColumns.push('delete');
1189
+ }
1190
+ }
1191
+ }
1192
+ ngOnInit() {
1193
+ this.filterChangedSubscription = this.filterChanged
1194
+ .pipe(debounceTime(300), distinctUntilChanged())
1195
+ .subscribe(newText => {
1196
+ if (newText.length >= 3 || newText.length == 0) {
1197
+ this.filterValue = newText;
1198
+ this.paginator.pageIndex = 0;
1199
+ this.refreshForm();
1200
+ }
1201
+ });
1202
+ // this.getGridLayout();
1203
+ this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
1204
+ this.paginator.pageSize = 15;
1205
+ if (this.defaultSort) {
1206
+ this.sort.active = this.defaultSort;
1207
+ if (this.defaultSortDirection) {
1208
+ this.sort.direction = this.defaultSortDirection;
1209
+ }
1210
+ else {
1211
+ this.sort.direction = 'asc';
1212
+ }
1213
+ }
1214
+ // this.dataSource.paginator = this.paginator;
1215
+ merge(this.sort.sortChange, this.paginator.page)
1216
+ .pipe(startWith({}), switchMap(() => {
1217
+ this.isLoadingResults = true;
1218
+ return this.getData();
1219
+ }), map(data => {
1220
+ // Flip flag to show that loading has finished.
1221
+ this.isLoadingResults = false;
1222
+ this.isRateLimitReached = false;
1223
+ if (data) {
1224
+ this.resultsLength = data.getMeta().meta.count;
1225
+ return data.getModels();
1226
+ }
1227
+ else {
1228
+ this.resultsLength = 0;
1229
+ return [];
1230
+ }
1231
+ }), catchError(() => {
1232
+ this.isLoadingResults = false;
1233
+ // Catch if the GitHub API has reached its rate limit. Return empty data.
1234
+ this.isRateLimitReached = true;
1235
+ return of([]);
1236
+ })).subscribe(data => {
1237
+ // if (this.infiniteScroll) {
1238
+ // let oldData = this.dataSource.data ?? null;
1239
+ // // if (oldData.length === 0) {
1240
+ // // oldData = data;
1241
+ // // } else {
1242
+ // oldData=oldData.concat(data);
1243
+ // // }
1244
+ // this.dataSource.data = oldData;
1245
+ // }
1246
+ // else {
1247
+ this.dataSource.data = data;
1248
+ // }
1249
+ });
1250
+ // this.paginator.nextPage()
1251
+ }
1252
+ getData() {
1253
+ this.isLoadingResults = true;
1254
+ const pageIndex = (this.paginator.pageIndex || 0) + 1;
1255
+ const pageSize = this.paginator.pageSize || 20;
1256
+ const filters = [];
1257
+ let sorts = '';
1258
+ if (this.sort.active) {
1259
+ if (this.sort.direction === 'desc') {
1260
+ sorts = '-' + this.sort.active;
1261
+ }
1262
+ else {
1263
+ sorts = this.sort.active;
1264
+ }
1265
+ }
1266
+ if (this.hasSearch) {
1267
+ if (this.filterValue) {
1268
+ // const filtersArr = this.searchFields.split(",");
1269
+ // filtersArr.forEach(element => {
1270
+ // filters.push(element + '@=*' + this.filterValue);
1271
+ // });
1272
+ const y = '(' + this.searchFields.replace(',', '|') + ')';
1273
+ filters.push(y + '@=*' + this.filterValue);
1274
+ }
1275
+ }
1276
+ if (this.defaultFilter) {
1277
+ filters.push(this.defaultFilter);
1278
+ }
1279
+ const filtersValue = filters.join(', ');
1280
+ return this.baseService.getAll(pageIndex, pageSize, sorts, filtersValue, this.customInclude);
1281
+ }
1282
+ refreshForm() {
1283
+ this.getData().subscribe(data => {
1284
+ if (data) {
1285
+ this.isLoadingResults = false;
1286
+ this.isRateLimitReached = false;
1287
+ this.resultsLength = data.getMeta().meta.count;
1288
+ this.dataSource.data = data.getModels();
1289
+ }
1290
+ else {
1291
+ this.isLoadingResults = false;
1292
+ this.isRateLimitReached = false;
1293
+ this.resultsLength = 0;
1294
+ this.dataSource.data = [];
1295
+ }
1296
+ });
1297
+ }
1298
+ highlight(element) {
1299
+ if (this.selectedItem) {
1300
+ this.selectedItem.highlighted = element.highlighted;
1301
+ }
1302
+ this.selectedItem = null;
1303
+ element.highlighted = !element.highlighted;
1304
+ if (element.highlighted) {
1305
+ this.selectedItem = element;
1306
+ this.selectedObject.emit(element);
1307
+ }
1308
+ else {
1309
+ this.selectedObject.emit(null);
1310
+ }
1311
+ }
1312
+ deleteObject(model) {
1313
+ const msg = 'Do you want to delete ' + model[this.deletePropertyName] + '?';
1314
+ this.dialogService.confirm(msg).subscribe((response) => {
1315
+ if (response) {
1316
+ this.baseService.delete(model.id).subscribe(() => {
1317
+ const tempData = [];
1318
+ this.selectedObject.emit(null);
1319
+ this.dataSource.data.map((item) => {
1320
+ if (item.id !== model.id) {
1321
+ tempData.push(item);
1322
+ }
1323
+ });
1324
+ this.dataSource.data = tempData;
1325
+ });
1326
+ }
1327
+ });
1328
+ }
1329
+ editObject(model) {
1330
+ if (!this.popupEdit) {
1331
+ const id = model.id;
1332
+ this.router.navigate([this.editLink, id]);
1333
+ }
1334
+ else {
1335
+ this.editModel.emit(model);
1336
+ }
1337
+ }
1338
+ getFlexStyle(column) {
1339
+ if (column.width) {
1340
+ const style = column.grow + ' ' + column.shrink + ' ' + column.width + 'px';
1341
+ return style;
1342
+ }
1343
+ return null;
1344
+ }
1345
+ getCellTextAlign(column) {
1346
+ var _a;
1347
+ return (_a = column.textAlign) !== null && _a !== void 0 ? _a : CellTextAlign.left;
1348
+ }
1349
+ showPictureCell(column) {
1350
+ var _a;
1351
+ return ((_a = column === null || column === void 0 ? void 0 : column.formating) !== null && _a !== void 0 ? _a : GridLayoutFormat.none) === GridLayoutFormat.picture;
1352
+ }
1353
+ deleteDisabled(model) {
1354
+ if (this.deleteDisableRule) {
1355
+ return this.evaluateRule(this.deleteDisableRule, model);
1356
+ }
1357
+ else {
1358
+ return false;
1359
+ }
1360
+ }
1361
+ cellClick(model, propertyName) {
1362
+ this.click.emit({ propertyName, model });
1363
+ }
1364
+ evaluateRule(rules, model) {
1365
+ let result = true;
1366
+ rules.forEach(rule => {
1367
+ let jsonRule;
1368
+ if (typeof rule.rule === 'string') {
1369
+ jsonRule = JSON.parse(rule.rule);
1370
+ }
1371
+ else {
1372
+ jsonRule = rule.rule;
1373
+ }
1374
+ if (rule.parameters) {
1375
+ const data = '{' + rule.parameters.map((item) => {
1376
+ return '"' + item + '":"' + model[item] + '"';
1377
+ }).join(',') + '}';
1378
+ result = jsonLogic.apply(jsonRule, JSON.parse(data));
1379
+ }
1380
+ else {
1381
+ result = jsonLogic.apply(jsonRule);
1382
+ }
1383
+ });
1384
+ return result;
1385
+ }
1386
+ getCelValue(row, propertyName) {
1387
+ if (!row)
1388
+ return "";
1389
+ // if (propertyName == 'kompetenzenStdev')
1390
+ // console.log(propertyName);
1391
+ if (propertyName.indexOf('.') === -1) {
1392
+ var gridLayout = this.gridLayout.find(f => f.propertyName.indexOf(propertyName) > -1);
1393
+ return this.getFormatedValue(gridLayout, row[propertyName]);
1394
+ }
1395
+ else {
1396
+ const prop = propertyName.split('.')[0];
1397
+ const subProp = propertyName.replace(prop + '.', '');
1398
+ return this.getCelValue(row[prop], subProp);
1399
+ }
1400
+ }
1401
+ getFormatedValue(gridLayout, value) {
1402
+ if (gridLayout) {
1403
+ switch (gridLayout.formating) {
1404
+ case GridLayoutFormat.date:
1405
+ return this.datePipe.transform(value, gridLayout.format);
1406
+ break;
1407
+ case GridLayoutFormat.number:
1408
+ return this.numberPipe.transform(value, gridLayout.format);
1409
+ case GridLayoutFormat.percent:
1410
+ const valuePrc = value / 100;
1411
+ return this.percentPipe.transform(valuePrc, gridLayout.format);
1412
+ default:
1413
+ return value;
1414
+ break;
1415
+ }
1416
+ }
1417
+ return value;
1418
+ }
1419
+ applyFilter(event) {
1420
+ }
1421
+ dropTable(event) {
1422
+ if (this.changeItemPosition) {
1423
+ const prevItem = this.dataSource.data[event.previousIndex];
1424
+ const currentItem = this.dataSource.data[event.currentIndex];
1425
+ if (this.changeItemPosition(prevItem, currentItem)) {
1426
+ const prevIndex = this.dataSource.data.findIndex((d) => d === event.item.data);
1427
+ moveItemInArray(this.dataSource.data, prevIndex, event.currentIndex);
1428
+ this.table.renderRows();
1429
+ }
1430
+ }
1431
+ }
1432
+ isColumnSticky(name) {
1433
+ if (this.stickyColumns) {
1434
+ const filtersArr = this.stickyColumns.split(",");
1435
+ return filtersArr.findIndex(f => f == name) !== -1;
1436
+ }
1437
+ return false;
1438
+ }
1439
+ updateElement(model) {
1440
+ //Find if element exist
1441
+ var currentElement = this.dataSource.data.find(f => f.id === model.id);
1442
+ if (currentElement !== null) {
1443
+ const index = this.dataSource.data.indexOf(currentElement);
1444
+ this.dataSource.data[index] = model;
1445
+ }
1446
+ else {
1447
+ this.dataSource.data.push(model);
1448
+ }
1449
+ const newData = [...this.dataSource.data];
1450
+ this.dataSource.data = newData;
1451
+ this.dataSource._updateChangeSubscription();
1452
+ }
1453
+ ngAfterViewInit() {
1454
+ fromEvent(this.matTableRef.nativeElement, 'scroll')
1455
+ .pipe(debounceTime(700))
1456
+ .subscribe((e) => this.onTableScroll(e));
1457
+ }
1458
+ onTableScroll(e) {
1459
+ const tableViewHeight = e.target.offsetHeight; // viewport: ~500px
1460
+ const tableScrollHeight = e.target.scrollHeight; // length of all table
1461
+ const scrollLocation = e.target.scrollTop; // how far user scrolled
1462
+ // If the user has scrolled within 200px of the bottom, add more data
1463
+ const scrollThreshold = 200;
1464
+ const scrollUpLimit = scrollThreshold;
1465
+ if (scrollLocation < scrollUpLimit && this.paginator.pageIndex > 0) {
1466
+ // this.firstPage--;
1467
+ console.log(`onTableScroll() UP: firstPage decreased to ${this.paginator.pageIndex}. Now fetching data...`);
1468
+ // this.fetchData();
1469
+ this.scrollTo(tableScrollHeight / 2 - 2 * tableViewHeight);
1470
+ }
1471
+ const scrollDownLimit = tableScrollHeight - tableViewHeight - scrollThreshold;
1472
+ if (scrollLocation > scrollDownLimit && this.paginator.pageIndex < this.paginator.getNumberOfPages()) {
1473
+ // this.firstPage++;
1474
+ console.log(`onTableScroll(): firstPage increased to ${this.paginator.pageIndex}. Now fetching data...`);
1475
+ this.paginator.nextPage();
1476
+ // this.scrollTo(tableScrollHeight / 2 + tableViewHeight);
1477
+ }
1478
+ }
1479
+ scrollTo(position) {
1480
+ this.renderer.setProperty(this.matTableRef.nativeElement, 'scrollTop', position);
1481
+ }
1482
+ getCellClass(model, property) {
1483
+ return model.getCellClass(property);
1484
+ }
1485
+ }
1486
+ GenericTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GenericTableComponent, deps: [{ token: DialogService }, { token: i2$1.Router }, { token: i3$1.DatePipe }, { token: i3$1.DecimalPipe }, { token: i3$1.PercentPipe }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
1487
+ GenericTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.0", type: GenericTableComponent, selector: "rsl-generic-table", inputs: { modelType: "modelType", baseService: "baseService", gridLayoutService: "gridLayoutService", editLink: "editLink", defaultSort: "defaultSort", defaultSortDirection: "defaultSortDirection", deleteDisableRule: "deleteDisableRule", deletePropertyName: "deletePropertyName", hasSearch: "hasSearch", searchFields: "searchFields", defaultFilter: "defaultFilter", allowReorderItems: "allowReorderItems", stickyColumns: "stickyColumns", editOnClick: "editOnClick", editOnDblClick: "editOnDblClick", allowEdit: "allowEdit", popupEdit: "popupEdit", customInclude: "customInclude", changeItemPosition: "changeItemPosition", infiniteScroll: "infiniteScroll" }, outputs: { selectedObject: "selectedObject", click: "click", editModel: "editModel" }, viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true, static: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true, static: true }, { propertyName: "filter", first: true, predicate: ElementRef, descendants: true }, { propertyName: "table", first: true, predicate: ["table"], descendants: true }, { propertyName: "matTableRef", first: true, predicate: ["table"], descendants: true, read: ElementRef }], usesOnChanges: true, ngImport: i0, template: "<div class=\"containerX\" *ngIf=\"hasSearch\">\r\n <div fxLayout=\"row\" fxLayout.xs=\"column\" fxLayout.sm=\"column\" fxFlexFill>\r\n <mat-form-field fxFlex>\r\n <mat-label>Filter</mat-label>\r\n <input matInput [ngModel]='filterValue' (ngModelChange)='filterChanged.next($event)' #filter>\r\n </mat-form-field>\r\n </div>\r\n</div>\r\n\r\n<div class=\"table-container\">\r\n <div class=\"mat-elevation-z2\">\r\n <!-- #applicationsContainer -->\r\n <div class=\"example-loading-shade\" *ngIf=\"isLoadingResults || isRateLimitReached\">\r\n <mat-spinner *ngIf=\"isLoadingResults\"></mat-spinner>\r\n <div class=\"example-rate-limit-reached\" *ngIf=\"isRateLimitReached\">\r\n {{'General.LoadingData' | translate}}\r\n </div>\r\n </div>\r\n\r\n\r\n <mat-table fxFlex #table [dataSource]=\"dataSource\" id=\"tempalte-forms-table\" matSort matSortDisableClear\r\n matSortDirection=\"asc\" cdkDropList [cdkDropListData]=\"dataSource\" (cdkDropListDropped)=\"dropTable($event)\">\r\n <!-- (scroll)=\"onTableScroll($event)\" -->\r\n\r\n\r\n <ng-container matColumnDef=\"position\">\r\n <mat-header-cell *matHeaderCellDef disableClear=\"true\">\r\n <!-- {{'General.Order' | translate}} -->\r\n </mat-header-cell>\r\n <mat-cell fxFlex *matCellDef=\"let element;\">\r\n <mat-icon cdkDragHandle>reorder</mat-icon>\r\n </mat-cell>\r\n </ng-container>\r\n\r\n\r\n <ng-container *ngFor=\"let column of gridLayout\" [matColumnDef]=\"column.propertyName\"\r\n [sticky]=\"isColumnSticky(column.propertyName)\">\r\n <mat-header-cell mat-sort-header disableClear [style.flex]=\"getFlexStyle(column)\" *matHeaderCellDef>\r\n {{column.translateKey | translate}}\r\n </mat-header-cell>\r\n <mat-cell matTooltip={{getCelValue(row,column.propertyName)}} [style.flex]=\"getFlexStyle(column)\"\r\n [style.text-align]=\"getCellTextAlign(column)\" *matCellDef=\"let row\" (click)=\"cellClick(row,column.propertyName)\">\r\n <div [ngClass]=\"getCellClass(row,column.propertyName)\" *ngIf=\"!showPictureCell(column)\">\r\n {{getCelValue(row,column.propertyName)}}\r\n </div>\r\n <img [ngClass]=\"getCellClass(row,column.propertyName)\" *ngIf=\"showPictureCell(column)\">\r\n </mat-cell>\r\n </ng-container>\r\n\r\n\r\n <ng-container matColumnDef=\"delete\" stickyEnd *ngIf=\"!editOnClick && !editOnDblClick\">\r\n <mat-header-cell *matHeaderCellDef disableClear=\"true\">\r\n </mat-header-cell>\r\n <mat-cell *matCellDef=\"let row\">\r\n <button class=\"btn btn-green btn-fill btn-wd btn-just-icon\" (click)=\"editObject(row)\"\r\n matTooltip=\"{{'General.Edit' | translate}}\">\r\n <!-- <mat-icon>edit</mat-icon> -->\r\n <i class=\"material-icons\">edit</i>\r\n <div class=\"ripple-container\"></div>\r\n </button>\r\n <button class=\"btn btn-red btn-fill btn-wd btn-just-icon\" (click)=\"deleteObject(row)\"\r\n [disabled]=\"deleteDisabled(row)\" matTooltip=\"{{'General.Delete' | translate}}\">\r\n <i class=\"material-icons\">delete</i>\r\n <div class=\"ripple-container\"></div>\r\n </button>\r\n </mat-cell>\r\n </ng-container>\r\n\r\n <mat-header-row *matHeaderRowDef=\"displayedColumns;sticky: true\"></mat-header-row>\r\n\r\n <ng-container *ngIf=\"!editOnClick && !editOnDblClick\">\r\n <mat-row *matRowDef=\"let row;let index = dataIndex; columns: displayedColumns;\" cdkDrag [cdkDragData]=\"row\"\r\n [ngClass]=\"{hovered: row.hovered, highlighted: row.highlighted}\" (click)=\"highlight(row)\"\r\n (mouseover)=\"row.hovered = true\" (mouseout)=\"row.hovered = false\">\r\n </mat-row>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"editOnClick && !editOnDblClick\">\r\n <mat-row *matRowDef=\"let row;let index = dataIndex; columns: displayedColumns;\" cdkDrag [cdkDragData]=\"row\"\r\n [ngClass]=\"{hovered: row.hovered, highlighted: row.highlighted}\" (click)=\"editObject(row)\"\r\n (mouseover)=\"row.hovered = true\" (mouseout)=\"row.hovered = false\" style=\"cursor: pointer;\"></mat-row>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"!editOnClick && editOnDblClick\">\r\n <mat-row *matRowDef=\"let row;let index = dataIndex; columns: displayedColumns;\" cdkDrag [cdkDragData]=\"row\"\r\n [ngClass]=\"{hovered: row.hovered, highlighted: row.highlighted}\" (dblclick)=\"editObject(row)\"\r\n (click)=\"highlight(row)\" (mouseover)=\"row.hovered = true\" (mouseout)=\"row.hovered = false\"\r\n style=\"cursor: pointer;\"></mat-row>\r\n </ng-container>\r\n\r\n <!-- [ngClass]=\"{hovered: row.hovered, highlighted: row.highlighted}\"\r\n (click)=\"highlight(row)\" (mouseover)=\"row.hovered = true\" (mouseout)=\"row.hovered = false\" -->\r\n </mat-table>\r\n <mat-paginator #paginator [hidden]=\"infiniteScroll\" [length]=\"resultsLength\" [pageSize]=\"15\"\r\n [pageSizeOptions]=\"[15, 30, 100]\" [showFirstLastButtons]=\"true\">\r\n </mat-paginator>\r\n </div>\r\n</div>", styles: [".mat-column-delete{flex:0 0 90px;padding-right:30px}.mat-sort-header-button{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mat-column-position{flex:0 0 60px!important}.mat-table{overflow-x:auto}[hidden]{display:none!important}\n"], components: [{ type: i3.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i5$1.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "diameter", "strokeWidth", "mode", "value"], exportAs: ["matProgressSpinner"] }, { type: i6$1.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i8$1.MatSortHeader, selector: "[mat-sort-header]", inputs: ["disabled", "mat-sort-header", "arrowPosition", "start", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { type: i6$1.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i6$1.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { type: i9.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }], directives: [{ type: i3$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.MatLabel, selector: "mat-label" }, { type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i8$1.MatSort, selector: "[matSort]", inputs: ["matSortDisabled", "matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { type: i12.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { type: i6$1.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i6$1.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i6$1.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i6$1.MatCellDef, selector: "[matCellDef]" }, { type: i6$1.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i12.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { type: i3$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i13.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i3$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i6$1.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i6$1.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { type: i12.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }], pipes: { "translate": i1$1.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
1488
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GenericTableComponent, decorators: [{
1489
+ type: Component,
1490
+ args: [{ selector: 'rsl-generic-table', encapsulation: ViewEncapsulation.None, template: "<div class=\"containerX\" *ngIf=\"hasSearch\">\r\n <div fxLayout=\"row\" fxLayout.xs=\"column\" fxLayout.sm=\"column\" fxFlexFill>\r\n <mat-form-field fxFlex>\r\n <mat-label>Filter</mat-label>\r\n <input matInput [ngModel]='filterValue' (ngModelChange)='filterChanged.next($event)' #filter>\r\n </mat-form-field>\r\n </div>\r\n</div>\r\n\r\n<div class=\"table-container\">\r\n <div class=\"mat-elevation-z2\">\r\n <!-- #applicationsContainer -->\r\n <div class=\"example-loading-shade\" *ngIf=\"isLoadingResults || isRateLimitReached\">\r\n <mat-spinner *ngIf=\"isLoadingResults\"></mat-spinner>\r\n <div class=\"example-rate-limit-reached\" *ngIf=\"isRateLimitReached\">\r\n {{'General.LoadingData' | translate}}\r\n </div>\r\n </div>\r\n\r\n\r\n <mat-table fxFlex #table [dataSource]=\"dataSource\" id=\"tempalte-forms-table\" matSort matSortDisableClear\r\n matSortDirection=\"asc\" cdkDropList [cdkDropListData]=\"dataSource\" (cdkDropListDropped)=\"dropTable($event)\">\r\n <!-- (scroll)=\"onTableScroll($event)\" -->\r\n\r\n\r\n <ng-container matColumnDef=\"position\">\r\n <mat-header-cell *matHeaderCellDef disableClear=\"true\">\r\n <!-- {{'General.Order' | translate}} -->\r\n </mat-header-cell>\r\n <mat-cell fxFlex *matCellDef=\"let element;\">\r\n <mat-icon cdkDragHandle>reorder</mat-icon>\r\n </mat-cell>\r\n </ng-container>\r\n\r\n\r\n <ng-container *ngFor=\"let column of gridLayout\" [matColumnDef]=\"column.propertyName\"\r\n [sticky]=\"isColumnSticky(column.propertyName)\">\r\n <mat-header-cell mat-sort-header disableClear [style.flex]=\"getFlexStyle(column)\" *matHeaderCellDef>\r\n {{column.translateKey | translate}}\r\n </mat-header-cell>\r\n <mat-cell matTooltip={{getCelValue(row,column.propertyName)}} [style.flex]=\"getFlexStyle(column)\"\r\n [style.text-align]=\"getCellTextAlign(column)\" *matCellDef=\"let row\" (click)=\"cellClick(row,column.propertyName)\">\r\n <div [ngClass]=\"getCellClass(row,column.propertyName)\" *ngIf=\"!showPictureCell(column)\">\r\n {{getCelValue(row,column.propertyName)}}\r\n </div>\r\n <img [ngClass]=\"getCellClass(row,column.propertyName)\" *ngIf=\"showPictureCell(column)\">\r\n </mat-cell>\r\n </ng-container>\r\n\r\n\r\n <ng-container matColumnDef=\"delete\" stickyEnd *ngIf=\"!editOnClick && !editOnDblClick\">\r\n <mat-header-cell *matHeaderCellDef disableClear=\"true\">\r\n </mat-header-cell>\r\n <mat-cell *matCellDef=\"let row\">\r\n <button class=\"btn btn-green btn-fill btn-wd btn-just-icon\" (click)=\"editObject(row)\"\r\n matTooltip=\"{{'General.Edit' | translate}}\">\r\n <!-- <mat-icon>edit</mat-icon> -->\r\n <i class=\"material-icons\">edit</i>\r\n <div class=\"ripple-container\"></div>\r\n </button>\r\n <button class=\"btn btn-red btn-fill btn-wd btn-just-icon\" (click)=\"deleteObject(row)\"\r\n [disabled]=\"deleteDisabled(row)\" matTooltip=\"{{'General.Delete' | translate}}\">\r\n <i class=\"material-icons\">delete</i>\r\n <div class=\"ripple-container\"></div>\r\n </button>\r\n </mat-cell>\r\n </ng-container>\r\n\r\n <mat-header-row *matHeaderRowDef=\"displayedColumns;sticky: true\"></mat-header-row>\r\n\r\n <ng-container *ngIf=\"!editOnClick && !editOnDblClick\">\r\n <mat-row *matRowDef=\"let row;let index = dataIndex; columns: displayedColumns;\" cdkDrag [cdkDragData]=\"row\"\r\n [ngClass]=\"{hovered: row.hovered, highlighted: row.highlighted}\" (click)=\"highlight(row)\"\r\n (mouseover)=\"row.hovered = true\" (mouseout)=\"row.hovered = false\">\r\n </mat-row>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"editOnClick && !editOnDblClick\">\r\n <mat-row *matRowDef=\"let row;let index = dataIndex; columns: displayedColumns;\" cdkDrag [cdkDragData]=\"row\"\r\n [ngClass]=\"{hovered: row.hovered, highlighted: row.highlighted}\" (click)=\"editObject(row)\"\r\n (mouseover)=\"row.hovered = true\" (mouseout)=\"row.hovered = false\" style=\"cursor: pointer;\"></mat-row>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"!editOnClick && editOnDblClick\">\r\n <mat-row *matRowDef=\"let row;let index = dataIndex; columns: displayedColumns;\" cdkDrag [cdkDragData]=\"row\"\r\n [ngClass]=\"{hovered: row.hovered, highlighted: row.highlighted}\" (dblclick)=\"editObject(row)\"\r\n (click)=\"highlight(row)\" (mouseover)=\"row.hovered = true\" (mouseout)=\"row.hovered = false\"\r\n style=\"cursor: pointer;\"></mat-row>\r\n </ng-container>\r\n\r\n <!-- [ngClass]=\"{hovered: row.hovered, highlighted: row.highlighted}\"\r\n (click)=\"highlight(row)\" (mouseover)=\"row.hovered = true\" (mouseout)=\"row.hovered = false\" -->\r\n </mat-table>\r\n <mat-paginator #paginator [hidden]=\"infiniteScroll\" [length]=\"resultsLength\" [pageSize]=\"15\"\r\n [pageSizeOptions]=\"[15, 30, 100]\" [showFirstLastButtons]=\"true\">\r\n </mat-paginator>\r\n </div>\r\n</div>", styles: [".mat-column-delete{flex:0 0 90px;padding-right:30px}.mat-sort-header-button{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mat-column-position{flex:0 0 60px!important}.mat-table{overflow-x:auto}[hidden]{display:none!important}\n"] }]
1491
+ }], ctorParameters: function () { return [{ type: DialogService }, { type: i2$1.Router }, { type: i3$1.DatePipe }, { type: i3$1.DecimalPipe }, { type: i3$1.PercentPipe }, { type: i0.Renderer2 }]; }, propDecorators: { modelType: [{
1492
+ type: Input
1493
+ }], baseService: [{
1494
+ type: Input
1495
+ }], gridLayoutService: [{
1496
+ type: Input
1497
+ }], editLink: [{
1498
+ type: Input
1499
+ }], defaultSort: [{
1500
+ type: Input
1501
+ }], defaultSortDirection: [{
1502
+ type: Input
1503
+ }], deleteDisableRule: [{
1504
+ type: Input
1505
+ }], deletePropertyName: [{
1506
+ type: Input
1507
+ }], hasSearch: [{
1508
+ type: Input
1509
+ }], searchFields: [{
1510
+ type: Input
1511
+ }], defaultFilter: [{
1512
+ type: Input
1513
+ }], allowReorderItems: [{
1514
+ type: Input
1515
+ }], stickyColumns: [{
1516
+ type: Input
1517
+ }], editOnClick: [{
1518
+ type: Input
1519
+ }], editOnDblClick: [{
1520
+ type: Input
1521
+ }], allowEdit: [{
1522
+ type: Input
1523
+ }], popupEdit: [{
1524
+ type: Input
1525
+ }], customInclude: [{
1526
+ type: Input
1527
+ }], changeItemPosition: [{
1528
+ type: Input
1529
+ }], infiniteScroll: [{
1530
+ type: Input
1531
+ }], paginator: [{
1532
+ type: ViewChild,
1533
+ args: [MatPaginator, { static: true }]
1534
+ }], sort: [{
1535
+ type: ViewChild,
1536
+ args: [MatSort, { static: true }]
1537
+ }], filter: [{
1538
+ type: ViewChild,
1539
+ args: [ElementRef, { static: false }]
1540
+ }], table: [{
1541
+ type: ViewChild,
1542
+ args: ['table']
1543
+ }], matTableRef: [{
1544
+ type: ViewChild,
1545
+ args: ['table', { read: ElementRef }]
1546
+ }], selectedObject: [{
1547
+ type: Output
1548
+ }], click: [{
1549
+ type: Output
1550
+ }], editModel: [{
1551
+ type: Output
1552
+ }] } });
1553
+
1554
+ // tslint:disable-next-line:variable-name
1555
+ const AttributeMetadata = Symbol('AttributeMetadata');
1556
+
1557
+ class DateConverter {
1558
+ mask(value) {
1559
+ const d = parseISO(value);
1560
+ return d;
1561
+ }
1562
+ unmask(value) {
1563
+ // const result = format(value, 'YYYY-MM-DDTHH:mm:ssZ');
1564
+ return value;
1565
+ }
1566
+ }
1567
+
1568
+ function Attribute(options = {}) {
1569
+ return (target, propertyName) => {
1570
+ const converter = (dataType, value, forSerialisation = false) => {
1571
+ let attrConverter;
1572
+ if (dataType) {
1573
+ if (options.converter) {
1574
+ attrConverter = options.converter;
1575
+ }
1576
+ else if (dataType === Date) {
1577
+ attrConverter = new DateConverter();
1578
+ }
1579
+ else {
1580
+ const datatype = new dataType();
1581
+ if (datatype.mask && datatype.unmask) {
1582
+ attrConverter = datatype;
1583
+ }
1584
+ }
1585
+ if (attrConverter) {
1586
+ if (!forSerialisation) {
1587
+ return attrConverter.mask(value);
1588
+ }
1589
+ return attrConverter.unmask(value);
1590
+ }
1591
+ }
1592
+ return value;
1593
+ };
1594
+ const saveAnnotations = () => {
1595
+ const metadata = Reflect.getMetadata('Attribute', target) || {};
1596
+ metadata[propertyName] = {
1597
+ marked: true
1598
+ };
1599
+ Reflect.defineMetadata('Attribute', metadata, target);
1600
+ const mappingMetadata = Reflect.getMetadata('AttributeMapping', target) || {};
1601
+ const serializedPropertyName = options.serializedName !== undefined ? options.serializedName : propertyName;
1602
+ mappingMetadata[serializedPropertyName] = propertyName;
1603
+ Reflect.defineMetadata('AttributeMapping', mappingMetadata, target);
1604
+ const requiredMetadata = Reflect.getMetadata('AttributeRequired', target) || {};
1605
+ requiredMetadata[serializedPropertyName] = options.required !== undefined ? options.required : false;
1606
+ Reflect.defineMetadata('AttributeRequired', requiredMetadata, target);
1607
+ const defaultMetadata = Reflect.getMetadata('AttributedefaultValue', target) || {};
1608
+ defaultMetadata[serializedPropertyName] = options.defaultValue !== undefined ? options.defaultValue : null;
1609
+ Reflect.defineMetadata('AttributedefaultValue', defaultMetadata, target);
1610
+ const formSubGroupMetadata = Reflect.getMetadata('AttributeformSubGroup', target) || {};
1611
+ formSubGroupMetadata[serializedPropertyName] = options.formSubGroup !== undefined ? options.formSubGroup : null;
1612
+ Reflect.defineMetadata('AttributeformSubGroup', formSubGroupMetadata, target);
1613
+ };
1614
+ const setMetadata = (hasDirtyAttributes, instance, oldValue, newValue, isNew) => {
1615
+ const targetType = Reflect.getMetadata('design:type', target, propertyName);
1616
+ if (!instance[AttributeMetadata]) {
1617
+ instance[AttributeMetadata] = {};
1618
+ }
1619
+ const propertyHasDirtyAttributes = typeof oldValue === 'undefined' && !isNew ? false : hasDirtyAttributes;
1620
+ instance[AttributeMetadata][propertyName] = {
1621
+ newValue,
1622
+ oldValue,
1623
+ serializedName: options.serializedName,
1624
+ hasDirtyAttributes: propertyHasDirtyAttributes,
1625
+ serialisationValue: converter(targetType, newValue, true)
1626
+ };
1627
+ };
1628
+ const getter = function () {
1629
+ return this['_' + propertyName];
1630
+ };
1631
+ const setter = function (newVal) {
1632
+ const targetType = Reflect.getMetadata('design:type', target, propertyName);
1633
+ const convertedValue = converter(targetType, newVal);
1634
+ if (convertedValue !== this['_' + propertyName]) {
1635
+ setMetadata(true, this, this['_' + propertyName], newVal, !this.id);
1636
+ this['_' + propertyName] = convertedValue;
1637
+ }
1638
+ };
1639
+ if (delete target[propertyName]) {
1640
+ saveAnnotations();
1641
+ Object.defineProperty(target, propertyName, {
1642
+ get: getter,
1643
+ set: setter,
1644
+ enumerable: true,
1645
+ configurable: true
1646
+ });
1647
+ }
1648
+ };
1649
+ }
1650
+
1651
+ function BaseDatastoreConfig(config = {}) {
1652
+ // tslint:disable-next-line:only-arrow-functions
1653
+ return (target) => {
1654
+ Reflect.defineMetadata('BaseDatastoreConfig', config, target);
1655
+ };
1656
+ }
1657
+
1658
+ class BaseMetaModel {
1659
+ constructor(response) {
1660
+ this.links = response.links || [];
1661
+ this.meta = response.meta;
1662
+ }
1663
+ }
1664
+
1665
+ function BaseModelConfig(config = {}) {
1666
+ return (target) => {
1667
+ if (typeof config['meta'] === 'undefined' || config['meta'] == null) {
1668
+ config['meta'] = BaseMetaModel;
1669
+ }
1670
+ Reflect.defineMetadata('BaseModelConfig', config, target);
1671
+ };
1672
+ }
1673
+
1674
+ function CustomType(config = {}) {
1675
+ return (target, propertyName) => {
1676
+ const annotations = Reflect.getMetadata('CustomType', target) || [];
1677
+ annotations.push({
1678
+ propertyName,
1679
+ relationship: config.key || propertyName
1680
+ });
1681
+ Reflect.defineMetadata('CustomType', annotations, target);
1682
+ };
1683
+ }
1684
+
1685
+ function GridLayout(translateKey, width, grow = 0, shrink = 0, subProperty, formating = GridLayoutFormat.none, format = '', order = 0, textAlign = CellTextAlign.left) {
1686
+ return (target, propertyName) => {
1687
+ const annotations = Reflect.getMetadata('GridLayout', target) || [];
1688
+ let propName = propertyName;
1689
+ if (subProperty) {
1690
+ propName = propertyName.toString() + '.' + subProperty;
1691
+ }
1692
+ annotations.push({
1693
+ propertyName: propName,
1694
+ translateKey,
1695
+ width,
1696
+ grow,
1697
+ shrink,
1698
+ formating,
1699
+ format,
1700
+ order,
1701
+ textAlign
1702
+ });
1703
+ Reflect.defineMetadata('GridLayout', annotations, target);
1704
+ };
1705
+ }
1706
+
1707
+ class TranslatedElementDirective {
1708
+ constructor(viewRef, templateRef) {
1709
+ this.viewRef = viewRef;
1710
+ this.templateRef = templateRef;
1711
+ }
1712
+ }
1713
+ TranslatedElementDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TranslatedElementDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
1714
+ TranslatedElementDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.0", type: TranslatedElementDirective, selector: "[translatedElement]", inputs: { elementKey: ["translatedElement", "elementKey"] }, ngImport: i0 });
1715
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TranslatedElementDirective, decorators: [{
1716
+ type: Directive,
1717
+ args: [{
1718
+ selector: '[translatedElement]',
1719
+ }]
1720
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }]; }, propDecorators: { elementKey: [{
1721
+ type: Input,
1722
+ args: ['translatedElement']
1723
+ }] } });
1724
+
1725
+ const TOKEN_START_DEMARC = '{{';
1726
+ const TOKEN_END_DEMARC = '}}';
1727
+ // adapted from @kasperlauge's solution in https://github.com/ngx-translate/core/issues/223
1728
+ class TranslatedContentDirective {
1729
+ constructor(viewRef, renderer, translateService, changeDetectorRef) {
1730
+ this.viewRef = viewRef;
1731
+ this.renderer = renderer;
1732
+ this.translateService = translateService;
1733
+ this.changeDetectorRef = changeDetectorRef;
1734
+ this.subs = [];
1735
+ }
1736
+ ngOnInit() {
1737
+ this.rawTranslation = merge(this.translateService.get(this.translationKey), this.translateService.onLangChange.asObservable().pipe(switchMap(() => this.translateService.get(this.translationKey))));
1738
+ }
1739
+ ngAfterContentInit() {
1740
+ // QueryList.changes doesn't re-emit after its initial value, which we have by now
1741
+ // BehaviorSubjects re-emit their initial value on subscription, so we get what we need by merging
1742
+ // the BehaviorSubject and the QueryList.changes observable
1743
+ const elementsSubject = new BehaviorSubject(this.elements.toArray());
1744
+ const elementsChanges = merge(elementsSubject, this.elements.changes);
1745
+ this.translationData = combineLatest(this.rawTranslation, elementsChanges)
1746
+ .pipe(map(([rawTranslation]) => {
1747
+ return {
1748
+ elements: this.elements.toArray(),
1749
+ rawTranslation,
1750
+ };
1751
+ }));
1752
+ this.subs.push(this.translationData.subscribe(this.render.bind(this)));
1753
+ }
1754
+ render(translationData) {
1755
+ if (!translationData.rawTranslation || translationData.rawTranslation === this.translationKey) {
1756
+ throw new Error(`No resource matching the key '${this.translationKey}'`);
1757
+ }
1758
+ while (this.viewRef.element.nativeElement.firstChild) {
1759
+ this.renderer.removeChild(this.viewRef.element.nativeElement, this.viewRef.element.nativeElement.firstChild);
1760
+ }
1761
+ let lastTokenEnd = 0;
1762
+ while (lastTokenEnd < translationData.rawTranslation.length) {
1763
+ const tokenStartDemarc = translationData.rawTranslation.indexOf(TOKEN_START_DEMARC, lastTokenEnd);
1764
+ if (tokenStartDemarc < 0) {
1765
+ break;
1766
+ }
1767
+ const tokenStart = tokenStartDemarc + TOKEN_START_DEMARC.length;
1768
+ const tokenEnd = translationData.rawTranslation.indexOf(TOKEN_END_DEMARC, tokenStart);
1769
+ if (tokenEnd < 0) {
1770
+ throw new Error(`Encountered unterminated token in translation string '${this.translationKey}'`);
1771
+ }
1772
+ const tokenEndDemarc = tokenEnd + TOKEN_END_DEMARC.length;
1773
+ const precedingText = translationData.rawTranslation.substring(lastTokenEnd, tokenStartDemarc);
1774
+ const precedingTextElement = this.renderer.createText(precedingText);
1775
+ this.renderer.appendChild(this.viewRef.element.nativeElement, precedingTextElement);
1776
+ const elementKey = translationData.rawTranslation.substring(tokenStart, tokenEnd);
1777
+ const embeddedElementTemplate = translationData.elements.find(element => element.elementKey === elementKey);
1778
+ if (embeddedElementTemplate) {
1779
+ const embeddedElementView = embeddedElementTemplate.viewRef.createEmbeddedView(embeddedElementTemplate.templateRef);
1780
+ this.renderer.appendChild(this.viewRef.element.nativeElement, embeddedElementView.rootNodes[0]);
1781
+ }
1782
+ else {
1783
+ const missingTokenText = translationData.rawTranslation.substring(tokenStartDemarc, tokenEndDemarc);
1784
+ const missingTokenElement = this.renderer.createText(missingTokenText);
1785
+ this.renderer.appendChild(this.viewRef.element.nativeElement, missingTokenElement);
1786
+ }
1787
+ lastTokenEnd = tokenEndDemarc;
1788
+ }
1789
+ const trailingText = translationData.rawTranslation.substring(lastTokenEnd);
1790
+ const trailingTextElement = this.renderer.createText(trailingText);
1791
+ this.renderer.appendChild(this.viewRef.element.nativeElement, trailingTextElement);
1792
+ // in case the rendering happens outside of a change detection event, this ensures that any translations in the
1793
+ // embedded elements are rendered
1794
+ this.changeDetectorRef.detectChanges();
1795
+ }
1796
+ ngOnDestroy() {
1797
+ this.subs.forEach(sub => sub.unsubscribe());
1798
+ }
1799
+ }
1800
+ TranslatedContentDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TranslatedContentDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Renderer2 }, { token: i1$1.TranslateService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1801
+ TranslatedContentDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.0", type: TranslatedContentDirective, selector: "[appTranslatedContent]", inputs: { translationKey: ["appTranslatedContent", "translationKey"] }, queries: [{ propertyName: "elements", predicate: TranslatedElementDirective }], ngImport: i0 });
1802
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TranslatedContentDirective, decorators: [{
1803
+ type: Directive,
1804
+ args: [{
1805
+ selector: '[appTranslatedContent]',
1806
+ }]
1807
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.Renderer2 }, { type: i1$1.TranslateService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { translationKey: [{
1808
+ type: Input,
1809
+ args: ['appTranslatedContent']
1810
+ }], elements: [{
1811
+ type: ContentChildren,
1812
+ args: [TranslatedElementDirective]
1813
+ }] } });
1814
+
1815
+ class GridLayoutModel {
1816
+ constructor(propertyName, translateKey = null, width = null, grow = 0, shrink = 0, formating = GridLayoutFormat.none, format = '', order = 0, textAlign = CellTextAlign.left) {
1817
+ this.formating = GridLayoutFormat.none;
1818
+ this.order = 0;
1819
+ this.textAlign = CellTextAlign.left;
1820
+ this.propertyName = propertyName;
1821
+ this.translateKey = translateKey;
1822
+ this.width = width;
1823
+ this.grow = grow;
1824
+ this.shrink = shrink;
1825
+ this.formating = formating;
1826
+ this.format = format;
1827
+ this.order = order;
1828
+ this.textAlign = textAlign;
1829
+ }
1830
+ }
1831
+
1832
+ class BaseModel {
1833
+ // tslint:disable-next-line:variable-name
1834
+ constructor(_datastore, data) {
1835
+ this._datastore = _datastore;
1836
+ if (data) {
1837
+ if (data.id) {
1838
+ this.id = data.id;
1839
+ }
1840
+ Object.assign(this, data);
1841
+ }
1842
+ }
1843
+ save(params, headers, customUrl, customBody) {
1844
+ const attributesMetadata = this[AttributeMetadata];
1845
+ return this._datastore.saveRecord(attributesMetadata, this, params, headers, customUrl, customBody);
1846
+ }
1847
+ patch(origModel, params, headers, customUrl) {
1848
+ const attributesMetadata = this[AttributeMetadata];
1849
+ return this._datastore.patchRecord(attributesMetadata, this, origModel, params, headers, customUrl);
1850
+ }
1851
+ replace(params, headers, customUrl, customBody) {
1852
+ const attributesMetadata = this[AttributeMetadata];
1853
+ return this._datastore.replaceRecord(attributesMetadata, this, params, headers, customUrl, customBody);
1854
+ }
1855
+ get attributeMetadata() {
1856
+ const attributesMetadata = this[AttributeMetadata];
1857
+ return attributesMetadata;
1858
+ }
1859
+ set attributeMetadata(val) {
1860
+ this[AttributeMetadata] = val;
1861
+ }
1862
+ get hasDirtyAttributes() {
1863
+ const attributesMetadata = this[AttributeMetadata];
1864
+ let hasDirtyAttributes = false;
1865
+ for (const propertyName in attributesMetadata) {
1866
+ if (attributesMetadata.hasOwnProperty(propertyName)) {
1867
+ const metadata = attributesMetadata[propertyName];
1868
+ if (metadata.hasDirtyAttributes) {
1869
+ hasDirtyAttributes = true;
1870
+ break;
1871
+ }
1872
+ }
1873
+ }
1874
+ return hasDirtyAttributes;
1875
+ }
1876
+ rollbackAttributes() {
1877
+ const attributesMetadata = this[AttributeMetadata];
1878
+ let metadata;
1879
+ for (const propertyName in attributesMetadata) {
1880
+ if (attributesMetadata.hasOwnProperty(propertyName)) {
1881
+ if (attributesMetadata[propertyName].hasDirtyAttributes) {
1882
+ this[propertyName] = attributesMetadata[propertyName].oldValue;
1883
+ metadata = {
1884
+ hasDirtyAttributes: false,
1885
+ newValue: attributesMetadata[propertyName].oldValue,
1886
+ oldValue: undefined
1887
+ };
1888
+ attributesMetadata[propertyName] = metadata;
1889
+ }
1890
+ }
1891
+ }
1892
+ this[AttributeMetadata] = attributesMetadata;
1893
+ }
1894
+ get modelConfig() {
1895
+ return Reflect.getMetadata('BaseModelConfig', this.constructor);
1896
+ }
1897
+ deserializeModel(modelType, data) {
1898
+ data = this.transformSerializedNamesToPropertyNames(modelType, data);
1899
+ return new modelType(this._datastore, data);
1900
+ }
1901
+ transformSerializedNamesToPropertyNames(modelType, attributes) {
1902
+ const serializedNameToPropertyName = this.getModelPropertyNames(modelType.prototype);
1903
+ const properties = {};
1904
+ Object.keys(serializedNameToPropertyName).forEach((serializedName) => {
1905
+ if (attributes[serializedName] !== null && attributes[serializedName] !== undefined) {
1906
+ properties[serializedNameToPropertyName[serializedName]] = attributes[serializedName];
1907
+ }
1908
+ });
1909
+ return properties;
1910
+ }
1911
+ getModelPropertyNames(model) {
1912
+ return Reflect.getMetadata('AttributeMapping', model);
1913
+ }
1914
+ getModelRequiredPropertyNames(model) {
1915
+ return Reflect.getMetadata('AttributeRequired', model);
1916
+ }
1917
+ getModelDefaultPropertyValues(model) {
1918
+ return Reflect.getMetadata('AttributedefaultValue', model);
1919
+ }
1920
+ getModelSubGroupPropertyNames(model) {
1921
+ return Reflect.getMetadata('AttributeformSubGroup', model);
1922
+ }
1923
+ getFromGroup(fb) {
1924
+ const props = Object.keys(this.getModelPropertyNames(this));
1925
+ const requiredProps = this.getModelRequiredPropertyNames(this);
1926
+ const defaultValues = this.getModelDefaultPropertyValues(this);
1927
+ const formSubGroupsValues = this.getModelSubGroupPropertyNames(this);
1928
+ const controlsConfig = {};
1929
+ const that = this;
1930
+ if (props) {
1931
+ props.forEach(property => {
1932
+ var _a;
1933
+ const value = that[property] !== undefined ? that[property] : defaultValues[property];
1934
+ const formSubGroup = (_a = formSubGroupsValues[property]) !== null && _a !== void 0 ? _a : null;
1935
+ if (requiredProps[property]) {
1936
+ if (formSubGroup)
1937
+ this.getSubFromGroup(fb, controlsConfig, formSubGroup).addControl(property, fb.control(value, Validators.required));
1938
+ else
1939
+ controlsConfig[property] = [value, Validators.required];
1940
+ }
1941
+ else {
1942
+ if (formSubGroup)
1943
+ this.getSubFromGroup(fb, controlsConfig, formSubGroup).addControl(property, fb.control(value));
1944
+ else
1945
+ controlsConfig[property] = value;
1946
+ }
1947
+ });
1948
+ }
1949
+ return fb.group(controlsConfig);
1950
+ }
1951
+ getSubFromGroup(fb, controlsConfig, subGroup) {
1952
+ if (!controlsConfig[subGroup])
1953
+ controlsConfig[subGroup] = fb.group({});
1954
+ return controlsConfig[subGroup];
1955
+ }
1956
+ getModelFromFormGroup(formGroup, id) {
1957
+ const props = Object.keys(this.getModelPropertyNames(this));
1958
+ const formSubGroupsValues = this.getModelSubGroupPropertyNames(this);
1959
+ const data = {};
1960
+ if (id) {
1961
+ data.id = id;
1962
+ }
1963
+ const that = this;
1964
+ if (props) {
1965
+ props.forEach(property => {
1966
+ var _a, _b, _c;
1967
+ const formSubGroup = (_a = formSubGroupsValues[property]) !== null && _a !== void 0 ? _a : null;
1968
+ if (!formSubGroup)
1969
+ data[property] = (_b = formGroup.controls[property].value) !== null && _b !== void 0 ? _b : null;
1970
+ else
1971
+ data[property] = (_c = formGroup.controls[formSubGroup].controls[property].value) !== null && _c !== void 0 ? _c : null;
1972
+ });
1973
+ }
1974
+ if (data) {
1975
+ if (id) {
1976
+ this.id = id;
1977
+ }
1978
+ Object.assign(this, data);
1979
+ }
1980
+ }
1981
+ getGridLayout() {
1982
+ const result = Array();
1983
+ const gridLayout = Reflect.getMetadata('GridLayout', this);
1984
+ if (gridLayout) {
1985
+ for (const layout of gridLayout) {
1986
+ const data = new GridLayoutModel(layout.propertyName, layout.translateKey, layout.width, layout.shrink, layout.grow, layout.formating, layout.format, layout.order, layout.textAlign);
1987
+ result.push(data);
1988
+ }
1989
+ }
1990
+ return result.sort(function (a, b) { return a.order - b.order; });
1991
+ //result;
1992
+ }
1993
+ getSerializedModel() {
1994
+ const attributesMetadata = this[AttributeMetadata];
1995
+ return this._datastore.modelToEntity(this, attributesMetadata, true);
1996
+ }
1997
+ getCellClass(property) {
1998
+ return '';
1999
+ }
2000
+ }
2001
+
2002
+ class ErrorResponse {
2003
+ constructor(errors) {
2004
+ this.errors = [];
2005
+ if (errors) {
2006
+ this.errors = errors;
2007
+ }
2008
+ }
2009
+ }
2010
+
2011
+ class Rule {
2012
+ constructor() {
2013
+ this.parameters = [];
2014
+ }
2015
+ }
2016
+
2017
+ class MaterialModule {
2018
+ }
2019
+ MaterialModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MaterialModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2020
+ MaterialModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MaterialModule, imports: [MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule,
2021
+ MatDialogModule, MatExpansionModule, MatGridListModule, MatIconModule,
2022
+ MatInputModule, MatListModule, MatMenuModule, MatNativeDateModule,
2023
+ MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule,
2024
+ MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule,
2025
+ MatTooltipModule, MatOptionModule, DragDropModule, MatDividerModule, PortalModule, MatTreeModule, MatBadgeModule, MatStepperModule,
2026
+ CdkStepperModule], exports: [MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule,
2027
+ MatDialogModule, MatExpansionModule, MatGridListModule, MatIconModule,
2028
+ MatInputModule, MatListModule, MatMenuModule, MatNativeDateModule,
2029
+ MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule,
2030
+ MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule,
2031
+ MatTooltipModule, MatOptionModule, DragDropModule, MatDividerModule, PortalModule, MatTreeModule, MatBadgeModule, MatStepperModule,
2032
+ CdkStepperModule] });
2033
+ MaterialModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MaterialModule, imports: [[
2034
+ MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule,
2035
+ MatDialogModule, MatExpansionModule, MatGridListModule, MatIconModule,
2036
+ MatInputModule, MatListModule, MatMenuModule, MatNativeDateModule,
2037
+ MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule,
2038
+ MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule,
2039
+ MatTooltipModule, MatOptionModule, DragDropModule, MatDividerModule, PortalModule, MatTreeModule, MatBadgeModule, MatStepperModule,
2040
+ CdkStepperModule
2041
+ ], MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule,
2042
+ MatDialogModule, MatExpansionModule, MatGridListModule, MatIconModule,
2043
+ MatInputModule, MatListModule, MatMenuModule, MatNativeDateModule,
2044
+ MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule,
2045
+ MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule,
2046
+ MatTooltipModule, MatOptionModule, DragDropModule, MatDividerModule, PortalModule, MatTreeModule, MatBadgeModule, MatStepperModule,
2047
+ CdkStepperModule] });
2048
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MaterialModule, decorators: [{
2049
+ type: NgModule,
2050
+ args: [{
2051
+ imports: [
2052
+ MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule,
2053
+ MatDialogModule, MatExpansionModule, MatGridListModule, MatIconModule,
2054
+ MatInputModule, MatListModule, MatMenuModule, MatNativeDateModule,
2055
+ MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule,
2056
+ MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule,
2057
+ MatTooltipModule, MatOptionModule, DragDropModule, MatDividerModule, PortalModule, MatTreeModule, MatBadgeModule, MatStepperModule,
2058
+ CdkStepperModule
2059
+ ],
2060
+ exports: [
2061
+ MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule,
2062
+ MatDialogModule, MatExpansionModule, MatGridListModule, MatIconModule,
2063
+ MatInputModule, MatListModule, MatMenuModule, MatNativeDateModule,
2064
+ MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule,
2065
+ MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule,
2066
+ MatTooltipModule, MatOptionModule, DragDropModule, MatDividerModule, PortalModule, MatTreeModule, MatBadgeModule, MatStepperModule,
2067
+ CdkStepperModule
2068
+ ],
2069
+ }]
2070
+ }] });
2071
+
2072
+ class GridLayoutService {
2073
+ constructor(baseService) {
2074
+ this.baseService = baseService;
2075
+ }
2076
+ getGridLayout() {
2077
+ var model = this.baseService.newModel();
2078
+ return model.getGridLayout();
2079
+ }
2080
+ }
2081
+ GridLayoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GridLayoutService, deps: [{ token: BaseService }], target: i0.ɵɵFactoryTarget.Injectable });
2082
+ GridLayoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GridLayoutService, providedIn: 'root' });
2083
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GridLayoutService, decorators: [{
2084
+ type: Injectable,
2085
+ args: [{
2086
+ providedIn: 'root'
2087
+ }]
2088
+ }], ctorParameters: function () { return [{ type: BaseService }]; } });
2089
+
2090
+ const PROVIDERS = [
2091
+ BaseDatastore,
2092
+ DatePipe,
2093
+ DecimalPipe,
2094
+ PercentPipe,
2095
+ ];
2096
+
2097
+ class RslBaseModule {
2098
+ }
2099
+ RslBaseModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: RslBaseModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2100
+ RslBaseModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: RslBaseModule, declarations: [GenericTableComponent,
2101
+ SearchableDropdownComponent], imports: [CommonModule, i1$1.TranslateModule, MaterialModule,
2102
+ ReactiveFormsModule, i2$2.BlockUIModule], exports: [HttpClientModule,
2103
+ GenericTableComponent,
2104
+ SearchableDropdownComponent] });
2105
+ RslBaseModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: RslBaseModule, providers: [
2106
+ PROVIDERS
2107
+ ], imports: [[
2108
+ CommonModule,
2109
+ TranslateModule.forChild({}),
2110
+ MaterialModule,
2111
+ ReactiveFormsModule,
2112
+ BlockUIModule.forRoot(),
2113
+ ], HttpClientModule] });
2114
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: RslBaseModule, decorators: [{
2115
+ type: NgModule,
2116
+ args: [{
2117
+ declarations: [
2118
+ GenericTableComponent,
2119
+ SearchableDropdownComponent
2120
+ ],
2121
+ imports: [
2122
+ CommonModule,
2123
+ TranslateModule.forChild({}),
2124
+ MaterialModule,
2125
+ ReactiveFormsModule,
2126
+ BlockUIModule.forRoot(),
2127
+ ],
2128
+ providers: [
2129
+ PROVIDERS
2130
+ ],
2131
+ exports: [
2132
+ HttpClientModule,
2133
+ GenericTableComponent,
2134
+ SearchableDropdownComponent
2135
+ ]
2136
+ }]
2137
+ }] });
2138
+
2139
+ class InputErrorPipe {
2140
+ constructor(translate) {
2141
+ this.translate = translate;
2142
+ }
2143
+ transform(value, filedTranslationKey) {
2144
+ let rvalue = '';
2145
+ if (value !== null) {
2146
+ if (value['invalid'] === true) {
2147
+ rvalue = 'ERROR.INVALID';
2148
+ }
2149
+ if (value['mustMatch'] === true) {
2150
+ rvalue = 'Account.Password.MustMach';
2151
+ }
2152
+ if (value['required'] === true) {
2153
+ const field = this.translate.instant(filedTranslationKey.field);
2154
+ rvalue = this.translate.instant('General.Field.Required', { field });
2155
+ }
2156
+ if (value['minlength']) {
2157
+ const field = this.translate.instant(filedTranslationKey.field);
2158
+ rvalue = this.translate.instant('General.Field.MinLength', { field, requiredLength: value.minlength.requiredLength });
2159
+ }
2160
+ }
2161
+ return rvalue;
2162
+ }
2163
+ }
2164
+ InputErrorPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: InputErrorPipe, deps: [{ token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
2165
+ InputErrorPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: InputErrorPipe, name: "inputError" });
2166
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: InputErrorPipe, decorators: [{
2167
+ type: Pipe,
2168
+ args: [{
2169
+ name: 'inputError'
2170
+ }]
2171
+ }], ctorParameters: function () { return [{ type: i1$1.TranslateService }]; } });
2172
+
2173
+ class Nl2brPipe {
2174
+ transform(value, args) {
2175
+ // return value.replace(/\n/g, '<br />');
2176
+ if (value) {
2177
+ value = value.replace(/(?:\r\n\r\n|\r\r|\n\n)/g, '</p><p>');
2178
+ return '<p>' + value.replace(/(?:\r\n|\r|\n)/g, '<br>') + '</p>';
2179
+ }
2180
+ return value;
2181
+ }
2182
+ }
2183
+ Nl2brPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: Nl2brPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2184
+ Nl2brPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: Nl2brPipe, name: "nl2br" });
2185
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: Nl2brPipe, decorators: [{
2186
+ type: Pipe,
2187
+ args: [{
2188
+ name: 'nl2br'
2189
+ }]
2190
+ }] });
2191
+
2192
+ class CustomValidators {
2193
+ static patternValidator(regex, error) {
2194
+ return (control) => {
2195
+ if (!control.value) {
2196
+ // if control is empty return no error
2197
+ return null;
2198
+ }
2199
+ // test the value of the control against the regexp supplied
2200
+ const valid = regex.test(control.value);
2201
+ // if true, return no error (no error), else return error passed in the second parameter
2202
+ return valid ? null : error;
2203
+ };
2204
+ }
2205
+ }
2206
+
2207
+ /*
2208
+ * Public API Surface of core
2209
+ */
2210
+ // export * from './lib/services/base-datastore.service';
2211
+
2212
+ /**
2213
+ * Generated bundle index. Do not edit.
2214
+ */
2215
+
2216
+ export { Attribute, BaseDatastore, BaseDatastoreConfig, BaseFormEditComponent, BaseMetaModel, BaseModel, BaseModelConfig, BaseQueryData, BaseService, CellTextAlign, CustomType, CustomValidators, DialogService, ErrorResponse, FieldErrorDisplayComponent, GenericTableComponent, GridLayout, GridLayoutFormat, GridLayoutModel, GridLayoutService, InputErrorPipe, MaterialModule, Nl2brPipe, PROVIDERS, PageNotFoundComponent, RslBaseModule, Rule, SearchableDropdownComponent, TranslatedContentDirective, TranslatedElementDirective, UnderConstructionComponent };
2217
+ //# sourceMappingURL=rosoftlab-core.mjs.map