@porscheinformatik/material-addons 10.4.1 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/fesm2015/porscheinformatik-material-addons.mjs +2984 -0
  2. package/fesm2015/porscheinformatik-material-addons.mjs.map +1 -0
  3. package/lib/button/button.d.ts +7 -0
  4. package/lib/button/button.d.ts.map +1 -0
  5. package/lib/button/button.module.d.ts +15 -0
  6. package/lib/button/button.module.d.ts.map +1 -0
  7. package/lib/button/danger-button/danger-button.component.d.ts +4 -0
  8. package/lib/button/danger-button/danger-button.component.d.ts.map +1 -0
  9. package/lib/button/flat-button/link-button.component.d.ts +4 -0
  10. package/lib/button/flat-button/link-button.component.d.ts.map +1 -0
  11. package/lib/button/icon-button/icon-button.component.d.ts +4 -0
  12. package/lib/button/icon-button/icon-button.component.d.ts.map +1 -0
  13. package/lib/button/mad-basic-button.d.ts +5 -1
  14. package/lib/button/mad-basic-button.d.ts.map +1 -0
  15. package/lib/button/outline-button/outline-button.component.d.ts +4 -0
  16. package/lib/button/outline-button/outline-button.component.d.ts.map +1 -0
  17. package/lib/button/primary-button/primary-button.component.d.ts +4 -0
  18. package/lib/button/primary-button/primary-button.component.d.ts.map +1 -0
  19. package/lib/card/card.component.d.ts +4 -0
  20. package/lib/card/card.component.d.ts.map +1 -0
  21. package/lib/card/card.d.ts +2 -0
  22. package/lib/card/card.d.ts.map +1 -0
  23. package/lib/card/card.module.d.ts +12 -0
  24. package/lib/card/card.module.d.ts.map +1 -0
  25. package/lib/content-panel/content-header/content-header.component.d.ts +4 -0
  26. package/lib/content-panel/content-header/content-header.component.d.ts.map +1 -0
  27. package/lib/content-panel/content-panel-container/content-panel-container.component.d.ts +4 -0
  28. package/lib/content-panel/content-panel-container/content-panel-container.component.d.ts.map +1 -0
  29. package/lib/content-panel/content-panel-container-content/content-panel-container-content.component.d.ts +4 -0
  30. package/lib/content-panel/content-panel-container-content/content-panel-container-content.component.d.ts.map +1 -0
  31. package/lib/content-panel/content-panel-container-footer/content-panel-container-footer.component.d.ts +4 -0
  32. package/lib/content-panel/content-panel-container-footer/content-panel-container-footer.component.d.ts.map +1 -0
  33. package/lib/content-panel/content-panel.module.d.ts +11 -0
  34. package/lib/content-panel/content-panel.module.d.ts.map +1 -0
  35. package/lib/content-panel/main-container/main-container.component.d.ts +4 -0
  36. package/lib/content-panel/main-container/main-container.component.d.ts.map +1 -0
  37. package/lib/data-table/data-table-action-type.d.ts +1 -0
  38. package/lib/data-table/data-table-action-type.d.ts.map +1 -0
  39. package/lib/data-table/data-table-action.d.ts +1 -0
  40. package/lib/data-table/data-table-action.d.ts.map +1 -0
  41. package/lib/data-table/data-table-column-definition.d.ts +1 -0
  42. package/lib/data-table/data-table-column-definition.d.ts.map +1 -0
  43. package/lib/data-table/data-table-column.d.ts +1 -0
  44. package/lib/data-table/data-table-column.d.ts.map +1 -0
  45. package/lib/data-table/data-table-columns-modal/data-table-columns-modal.component.d.ts +4 -0
  46. package/lib/data-table/data-table-columns-modal/data-table-columns-modal.component.d.ts.map +1 -0
  47. package/lib/data-table/data-table.component.d.ts +4 -0
  48. package/lib/data-table/data-table.component.d.ts.map +1 -0
  49. package/lib/data-table/data-table.d.ts +3 -0
  50. package/lib/data-table/data-table.d.ts.map +1 -0
  51. package/lib/data-table/data-table.module.d.ts +23 -0
  52. package/lib/data-table/data-table.module.d.ts.map +1 -0
  53. package/lib/flowbar/flowbar.component.d.ts +4 -0
  54. package/lib/flowbar/flowbar.component.d.ts.map +1 -0
  55. package/lib/flowbar/flowbar.module.d.ts +8 -0
  56. package/lib/flowbar/flowbar.module.d.ts.map +1 -0
  57. package/lib/material-action-button/material-action-button.component.d.ts +4 -0
  58. package/lib/material-action-button/material-action-button.component.d.ts.map +1 -0
  59. package/lib/material-action-button/material-action-button.module.d.ts +11 -0
  60. package/lib/material-action-button/material-action-button.module.d.ts.map +1 -0
  61. package/lib/material-addons.module.d.ts +13 -0
  62. package/lib/material-addons.module.d.ts.map +1 -0
  63. package/lib/numeric-field/number-format.service.d.ts +4 -0
  64. package/lib/numeric-field/number-format.service.d.ts.map +1 -0
  65. package/lib/numeric-field/numeric-field.d.ts +2 -0
  66. package/lib/numeric-field/numeric-field.d.ts.map +1 -0
  67. package/lib/numeric-field/numeric-field.directive.d.ts +4 -0
  68. package/lib/numeric-field/numeric-field.directive.d.ts.map +1 -0
  69. package/lib/numeric-field/numeric-field.module.d.ts +6 -0
  70. package/lib/numeric-field/numeric-field.module.d.ts.map +1 -0
  71. package/lib/quick-list/base-quick-list.component.d.ts +4 -0
  72. package/lib/quick-list/base-quick-list.component.d.ts.map +1 -0
  73. package/lib/quick-list/quick-list-compact/quick-list-compact.component.d.ts +4 -0
  74. package/lib/quick-list/quick-list-compact/quick-list-compact.component.d.ts.map +1 -0
  75. package/lib/quick-list/quick-list.component.d.ts +4 -0
  76. package/lib/quick-list/quick-list.component.d.ts.map +1 -0
  77. package/lib/quick-list/quick-list.d.ts +4 -0
  78. package/lib/quick-list/quick-list.d.ts.map +1 -0
  79. package/lib/quick-list/quick-list.module.d.ts +12 -0
  80. package/lib/quick-list/quick-list.module.d.ts.map +1 -0
  81. package/lib/readonly/readonly-form-field/readonly-form-field.component.d.ts +4 -0
  82. package/lib/readonly/readonly-form-field/readonly-form-field.component.d.ts.map +1 -0
  83. package/lib/readonly/readonly-form-field-wrapper/readonly-form-field-wrapper.component.d.ts +4 -0
  84. package/lib/readonly/readonly-form-field-wrapper/readonly-form-field-wrapper.component.d.ts.map +1 -0
  85. package/lib/readonly/readonly-form-field.module.d.ts +13 -0
  86. package/lib/readonly/readonly-form-field.module.d.ts.map +1 -0
  87. package/lib/stepper/mad-stepper-animation.d.ts +1 -0
  88. package/lib/stepper/mad-stepper-animation.d.ts.map +1 -0
  89. package/lib/stepper/step-header/step-header.component.d.ts +4 -0
  90. package/lib/stepper/step-header/step-header.component.d.ts.map +1 -0
  91. package/lib/stepper/stepper.component.d.ts +7 -1
  92. package/lib/stepper/stepper.component.d.ts.map +1 -0
  93. package/lib/stepper/stepper.module.d.ts +12 -0
  94. package/lib/stepper/stepper.module.d.ts.map +1 -0
  95. package/lib/table/column-header.d.ts +1 -0
  96. package/lib/table/column-header.d.ts.map +1 -0
  97. package/lib/table/table-action.d.ts +1 -0
  98. package/lib/table/table-action.d.ts.map +1 -0
  99. package/lib/table/table.component.d.ts +4 -0
  100. package/lib/table/table.component.d.ts.map +1 -0
  101. package/lib/table/table.d.ts +2 -0
  102. package/lib/table/table.d.ts.map +1 -0
  103. package/lib/table/table.module.d.ts +16 -0
  104. package/lib/table/table.module.d.ts.map +1 -0
  105. package/lib/throttle-click/throttle-click.directive.d.ts +4 -0
  106. package/lib/throttle-click/throttle-click.directive.d.ts.map +1 -0
  107. package/lib/throttle-click/throttle-click.module.d.ts +7 -0
  108. package/lib/throttle-click/throttle-click.module.d.ts.map +1 -0
  109. package/lib/toolbar/toolbar-action.interface.d.ts +1 -0
  110. package/lib/toolbar/toolbar-action.interface.d.ts.map +1 -0
  111. package/lib/toolbar/toolbar.component.d.ts +4 -0
  112. package/lib/toolbar/toolbar.component.d.ts.map +1 -0
  113. package/lib/toolbar/toolbar.module.d.ts +16 -0
  114. package/lib/toolbar/toolbar.module.d.ts.map +1 -0
  115. package/lib/toolbar/toolbar.service.d.ts +4 -0
  116. package/lib/toolbar/toolbar.service.d.ts.map +1 -0
  117. package/package.json +29 -16
  118. package/public-api.d.ts +5 -0
  119. package/themes/common/styles.scss +23 -22
  120. package/bundles/porscheinformatik-material-addons.umd.js +0 -3301
  121. package/bundles/porscheinformatik-material-addons.umd.js.map +0 -1
  122. package/bundles/porscheinformatik-material-addons.umd.min.js +0 -17
  123. package/bundles/porscheinformatik-material-addons.umd.min.js.map +0 -1
  124. package/esm2015/lib/button/button.module.js +0 -21
  125. package/esm2015/lib/button/danger-button/danger-button.component.js +0 -25
  126. package/esm2015/lib/button/flat-button/link-button.component.js +0 -25
  127. package/esm2015/lib/button/icon-button/icon-button.component.js +0 -25
  128. package/esm2015/lib/button/mad-basic-button.js +0 -28
  129. package/esm2015/lib/button/outline-button/outline-button.component.js +0 -25
  130. package/esm2015/lib/button/primary-button/primary-button.component.js +0 -25
  131. package/esm2015/lib/card/card.component.js +0 -86
  132. package/esm2015/lib/card/card.module.js +0 -18
  133. package/esm2015/lib/content-panel/content-header/content-header.component.js +0 -11
  134. package/esm2015/lib/content-panel/content-panel-container/content-panel-container.component.js +0 -11
  135. package/esm2015/lib/content-panel/content-panel-container-content/content-panel-container-content.component.js +0 -11
  136. package/esm2015/lib/content-panel/content-panel-container-footer/content-panel-container-footer.component.js +0 -11
  137. package/esm2015/lib/content-panel/content-panel.module.js +0 -29
  138. package/esm2015/lib/content-panel/main-container/main-container.component.js +0 -11
  139. package/esm2015/lib/data-table/data-table-action-type.js +0 -6
  140. package/esm2015/lib/data-table/data-table-action.js +0 -1
  141. package/esm2015/lib/data-table/data-table-column-definition.js +0 -1
  142. package/esm2015/lib/data-table/data-table-column.js +0 -1
  143. package/esm2015/lib/data-table/data-table-columns-modal/data-table-columns-modal.component.js +0 -93
  144. package/esm2015/lib/data-table/data-table.component.js +0 -459
  145. package/esm2015/lib/data-table/data-table.js +0 -1
  146. package/esm2015/lib/data-table/data-table.module.js +0 -46
  147. package/esm2015/lib/flowbar/flowbar.component.js +0 -182
  148. package/esm2015/lib/flowbar/flowbar.module.js +0 -14
  149. package/esm2015/lib/material-action-button/material-action-button.component.js +0 -25
  150. package/esm2015/lib/material-action-button/material-action-button.module.js +0 -17
  151. package/esm2015/lib/material-addons.module.js +0 -26
  152. package/esm2015/lib/numeric-field/number-format.service.js +0 -137
  153. package/esm2015/lib/numeric-field/numeric-field.directive.js +0 -275
  154. package/esm2015/lib/numeric-field/numeric-field.module.js +0 -19
  155. package/esm2015/lib/quick-list/base-quick-list.component.js +0 -91
  156. package/esm2015/lib/quick-list/quick-list-compact/quick-list-compact.component.js +0 -18
  157. package/esm2015/lib/quick-list/quick-list.component.js +0 -19
  158. package/esm2015/lib/quick-list/quick-list.module.js +0 -18
  159. package/esm2015/lib/readonly/readonly-form-field/readonly-form-field.component.js +0 -131
  160. package/esm2015/lib/readonly/readonly-form-field-wrapper/readonly-form-field-wrapper.component.js +0 -164
  161. package/esm2015/lib/readonly/readonly-form-field.module.js +0 -19
  162. package/esm2015/lib/stepper/mad-stepper-animation.js +0 -13
  163. package/esm2015/lib/stepper/step-header/step-header.component.js +0 -75
  164. package/esm2015/lib/stepper/stepper.component.js +0 -169
  165. package/esm2015/lib/stepper/stepper.module.js +0 -18
  166. package/esm2015/lib/table/column-header.js +0 -1
  167. package/esm2015/lib/table/table-action.js +0 -1
  168. package/esm2015/lib/table/table.component.js +0 -106
  169. package/esm2015/lib/table/table.js +0 -1
  170. package/esm2015/lib/table/table.module.js +0 -33
  171. package/esm2015/lib/throttle-click/throttle-click.directive.js +0 -32
  172. package/esm2015/lib/throttle-click/throttle-click.module.js +0 -13
  173. package/esm2015/lib/toolbar/toolbar-action.interface.js +0 -1
  174. package/esm2015/lib/toolbar/toolbar.component.js +0 -71
  175. package/esm2015/lib/toolbar/toolbar.module.js +0 -33
  176. package/esm2015/lib/toolbar/toolbar.service.js +0 -127
  177. package/esm2015/porscheinformatik-material-addons.js +0 -19
  178. package/esm2015/public-api.js +0 -37
  179. package/fesm2015/porscheinformatik-material-addons.js +0 -2658
  180. package/fesm2015/porscheinformatik-material-addons.js.map +0 -1
  181. package/porscheinformatik-material-addons.d.ts +0 -19
  182. package/porscheinformatik-material-addons.metadata.json +0 -1
@@ -1,2658 +0,0 @@
1
- import { Component, Input, NgModule, HostBinding, ViewChild, ElementRef, ChangeDetectorRef, ɵɵdefineInjectable, ɵɵinject, LOCALE_ID, Injectable, Inject, Renderer2, EventEmitter, Directive, forwardRef, Output, HostListener, ContentChild, TemplateRef, ViewChildren, ViewEncapsulation, ChangeDetectionStrategy, ViewContainerRef, QueryList, Optional, ContentChildren } from '@angular/core';
2
- import { CommonModule, DOCUMENT } from '@angular/common';
3
- import { RouterModule, NavigationEnd, Router } from '@angular/router';
4
- import { MatButtonModule } from '@angular/material/button';
5
- import { MatIconModule } from '@angular/material/icon';
6
- import { MatTooltipModule } from '@angular/material/tooltip';
7
- import { MatFormFieldModule } from '@angular/material/form-field';
8
- import { MatInputModule } from '@angular/material/input';
9
- import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
10
- import { Title } from '@angular/platform-browser';
11
- import { TranslateService, TranslateModule } from '@ngx-translate/core';
12
- import { of, Subject, Subscription } from 'rxjs';
13
- import { Breakpoints, BreakpointObserver } from '@angular/cdk/layout';
14
- import { map, throttleTime, switchMap, tap, startWith, takeUntil, distinctUntilChanged } from 'rxjs/operators';
15
- import { MatMenuModule } from '@angular/material/menu';
16
- import { MatToolbarModule } from '@angular/material/toolbar';
17
- import { MatBadgeModule } from '@angular/material/badge';
18
- import { MatCardModule } from '@angular/material/card';
19
- import { trigger, transition, style, animate, state } from '@angular/animations';
20
- import { MatTableDataSource, MatTableModule } from '@angular/material/table';
21
- import { MatSort, MatSortModule } from '@angular/material/sort';
22
- import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
23
- import { SelectionModel } from '@angular/cdk/collections';
24
- import { v4 } from 'uuid';
25
- import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
26
- import { moveItemInArray, transferArrayItem, DragDropModule } from '@angular/cdk/drag-drop';
27
- import { MatCheckboxModule } from '@angular/material/checkbox';
28
- import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
29
- import { Directionality } from '@angular/cdk/bidi';
30
- import { CdkStepHeader, STEP_STATE, CdkStep, CdkStepper, CdkStepperModule } from '@angular/cdk/stepper';
31
- import { FocusMonitor } from '@angular/cdk/a11y';
32
- import { FlexModule } from '@angular/flex-layout';
33
- import { MatStepperModule } from '@angular/material/stepper';
34
-
35
- class MaterialActionButtonComponent {
36
- constructor() {
37
- this.icon = 'add';
38
- // Sets the lower padding higher providing some bottom space for a fixed paginator
39
- this.liftHigher = true;
40
- this.liftHigher2 = false;
41
- }
42
- }
43
- MaterialActionButtonComponent.decorators = [
44
- { type: Component, args: [{
45
- selector: 'mad-material-action-button',
46
- template: "<div class=\"material-action-button {{ liftHigher ? 'lift-higher' : '' }} {{ liftHigher2 ? 'lift-higher-2' : '' }}\">\n <a [routerLink]=\"routerLink\">\n <button [id]=\"id\" mat-fab [matTooltipPosition]=\"'left'\" [matTooltip]=\"actionName\" color=\"primary\" *ngIf=\"!liftHigher2\">\n <mat-icon>{{ icon }}</mat-icon>\n </button>\n <button [id]=\"id\" mat-mini-fab [matTooltipPosition]=\"'left'\" [matTooltip]=\"actionName\" color=\"accent\" *ngIf=\"liftHigher2\">\n <mat-icon>{{ icon }}</mat-icon>\n </button>\n </a>\n</div>\n",
47
- styles: [".material-action-button{align-items:center;bottom:20px;display:flex;flex-direction:column-reverse;position:fixed;right:20px;z-index:100}.lift-higher{bottom:61px}.lift-higher-2{bottom:121px;right:28px}"]
48
- },] }
49
- ];
50
- MaterialActionButtonComponent.propDecorators = {
51
- actionName: [{ type: Input }],
52
- id: [{ type: Input }],
53
- icon: [{ type: Input }],
54
- routerLink: [{ type: Input }],
55
- liftHigher: [{ type: Input }],
56
- liftHigher2: [{ type: Input }]
57
- };
58
-
59
- class MaterialActionButtonModule {
60
- }
61
- MaterialActionButtonModule.decorators = [
62
- { type: NgModule, args: [{
63
- declarations: [MaterialActionButtonComponent],
64
- imports: [CommonModule, RouterModule, MatButtonModule, MatIconModule, MatTooltipModule],
65
- exports: [MaterialActionButtonComponent],
66
- },] }
67
- ];
68
-
69
- class MadBasicButton {
70
- constructor() {
71
- this.disableClick = (e) => e.stopPropagation();
72
- }
73
- get pointerEvent() {
74
- return this.disabled ? 'none' : 'auto';
75
- }
76
- get opacity() {
77
- return this.disabled ? '0.35' : '1';
78
- }
79
- ngOnChanges() {
80
- this.disableButton();
81
- }
82
- disableButton() {
83
- if (this.disabled) {
84
- this.button.nativeElement.addEventListener('click', this.disableClick);
85
- }
86
- else {
87
- this.button.nativeElement.removeEventListener('click', this.disableClick);
88
- }
89
- }
90
- }
91
- MadBasicButton.propDecorators = {
92
- pointerEvent: [{ type: HostBinding, args: ['style.pointer-events',] }],
93
- opacity: [{ type: HostBinding, args: ['style.opacity',] }]
94
- };
95
-
96
- class PrimaryButtonComponent extends MadBasicButton {
97
- constructor() {
98
- super();
99
- this.title = '';
100
- super.button = this.button;
101
- super.disabled = this.disabled;
102
- }
103
- }
104
- PrimaryButtonComponent.decorators = [
105
- { type: Component, args: [{
106
- selector: 'mad-primary-button',
107
- template: "<button mat-raised-button color=\"primary\" [type]=\"type\" [title]=\"title\" #btn>\n <ng-content></ng-content>\n</button>\n",
108
- styles: [""]
109
- },] }
110
- ];
111
- PrimaryButtonComponent.ctorParameters = () => [];
112
- PrimaryButtonComponent.propDecorators = {
113
- type: [{ type: Input }],
114
- disabled: [{ type: Input }],
115
- title: [{ type: Input }],
116
- button: [{ type: ViewChild, args: ['btn', { read: ElementRef, static: true },] }]
117
- };
118
-
119
- class OutlineButtonComponent extends MadBasicButton {
120
- constructor() {
121
- super();
122
- this.title = '';
123
- super.button = this.button;
124
- super.disabled = this.disabled;
125
- }
126
- }
127
- OutlineButtonComponent.decorators = [
128
- { type: Component, args: [{
129
- selector: 'mad-outline-button',
130
- template: "<button mat-stroked-button color=\"primary\" [type]=\"type\" [title]=\"title\" #btn>\n <ng-content></ng-content>\n</button>\n",
131
- styles: [""]
132
- },] }
133
- ];
134
- OutlineButtonComponent.ctorParameters = () => [];
135
- OutlineButtonComponent.propDecorators = {
136
- type: [{ type: Input }],
137
- disabled: [{ type: Input }],
138
- title: [{ type: Input }],
139
- button: [{ type: ViewChild, args: ['btn', { read: ElementRef, static: true },] }]
140
- };
141
-
142
- class LinkButtonComponent extends MadBasicButton {
143
- constructor() {
144
- super();
145
- this.title = '';
146
- super.button = this.button;
147
- super.disabled = this.disabled;
148
- }
149
- }
150
- LinkButtonComponent.decorators = [
151
- { type: Component, args: [{
152
- selector: 'mad-link-button',
153
- template: "<button [title]=\"title\" [type]=\"type\" color=\"primary\" #btn mat-button>\n <ng-content></ng-content>\n</button>\n",
154
- styles: [""]
155
- },] }
156
- ];
157
- LinkButtonComponent.ctorParameters = () => [];
158
- LinkButtonComponent.propDecorators = {
159
- type: [{ type: Input }],
160
- disabled: [{ type: Input }],
161
- title: [{ type: Input }],
162
- button: [{ type: ViewChild, args: ['btn', { read: ElementRef, static: true },] }]
163
- };
164
-
165
- class IconButtonComponent extends MadBasicButton {
166
- constructor() {
167
- super();
168
- this.title = '';
169
- super.button = this.button;
170
- super.disabled = this.disabled;
171
- }
172
- }
173
- IconButtonComponent.decorators = [
174
- { type: Component, args: [{
175
- selector: 'mad-icon-button',
176
- template: "<button mat-icon-button color=\"primary\" [type]=\"type\" [title]=\"title\" #btn>\n <ng-content></ng-content>\n</button>\n",
177
- styles: [""]
178
- },] }
179
- ];
180
- IconButtonComponent.ctorParameters = () => [];
181
- IconButtonComponent.propDecorators = {
182
- type: [{ type: Input }],
183
- disabled: [{ type: Input }],
184
- title: [{ type: Input }],
185
- button: [{ type: ViewChild, args: ['btn', { read: ElementRef, static: true },] }]
186
- };
187
-
188
- class DangerButtonComponent extends MadBasicButton {
189
- constructor() {
190
- super();
191
- this.title = '';
192
- super.button = this.button;
193
- super.disabled = this.disabled;
194
- }
195
- }
196
- DangerButtonComponent.decorators = [
197
- { type: Component, args: [{
198
- selector: 'mad-danger-button',
199
- template: "<button mat-raised-button color=\"warn\" [type]=\"type\" [title]=\"title\" #btn>\n <ng-content></ng-content>\n</button>\n",
200
- styles: [""]
201
- },] }
202
- ];
203
- DangerButtonComponent.ctorParameters = () => [];
204
- DangerButtonComponent.propDecorators = {
205
- type: [{ type: Input }],
206
- disabled: [{ type: Input }],
207
- title: [{ type: Input }],
208
- button: [{ type: ViewChild, args: ['btn', { read: ElementRef, static: true },] }]
209
- };
210
-
211
- class ButtonModule {
212
- }
213
- ButtonModule.decorators = [
214
- { type: NgModule, args: [{
215
- declarations: [PrimaryButtonComponent, OutlineButtonComponent, LinkButtonComponent, DangerButtonComponent, IconButtonComponent],
216
- imports: [CommonModule, RouterModule, MatButtonModule, MatIconModule, MatTooltipModule],
217
- exports: [PrimaryButtonComponent, OutlineButtonComponent, LinkButtonComponent, DangerButtonComponent, IconButtonComponent],
218
- },] }
219
- ];
220
-
221
- /**
222
- * Wraps a mat-form-field to replace it by a readOnly representation if necessary
223
- *
224
- * @author Stefan Laesser
225
- */
226
- class ReadOnlyFormFieldWrapperComponent {
227
- constructor(changeDetector, elementRef) {
228
- this.changeDetector = changeDetector;
229
- this.elementRef = elementRef;
230
- /**
231
- * If set to "false", the contained mat-form-field is rendered in all it's glory.
232
- * If set to "true", a readonly representation of the value is shown using the mat-form-fields label.
233
- */
234
- this.readonly = true;
235
- this.textAlign = 'left';
236
- this.formatNumber = false;
237
- this.decimalPlaces = 2;
238
- this.roundValue = false;
239
- this.autofillDecimals = false;
240
- this.unit = null;
241
- this.unitPosition = 'left';
242
- this.errorMessage = null;
243
- /**
244
- * If set to "false", a readonly input will be rendered.
245
- * If set to "true", a readonly textarea will be rendered instead.
246
- */
247
- this.multiline = false;
248
- /**
249
- * Defines the rows for the readonly textarea.
250
- */
251
- this.rows = 3;
252
- /**
253
- * If shrinkIfEmpty is set to "false", nothing changes
254
- * If set to "true" and multiline is also "true", the textarea will
255
- * shrink to one row, if value is empty/null/undefined.
256
- * Otherwise, the defined rows-value will be used
257
- */
258
- this.shrinkIfEmpty = false;
259
- this.toolTipForInputEnabled = false;
260
- }
261
- ngOnInit() {
262
- this.doRendering();
263
- }
264
- ngAfterViewInit() {
265
- this.setReadonlyFieldStyle();
266
- this.doRendering();
267
- }
268
- ngAfterViewChecked() {
269
- this.setReadonlyFieldStyle();
270
- this.setTooltipForOverflownField();
271
- }
272
- ngOnChanges(_) {
273
- this.doRendering();
274
- }
275
- getLabel() {
276
- if (!this.label) {
277
- this.extractLabel();
278
- }
279
- return this.label;
280
- }
281
- doRendering() {
282
- if (!this.originalContent) {
283
- return;
284
- }
285
- if (!this.readonly) {
286
- this.correctWidth();
287
- return;
288
- }
289
- this.changeDetector.detectChanges();
290
- }
291
- extractLabel() {
292
- if (!this.originalContent || !this.originalContent.nativeElement) {
293
- return null;
294
- }
295
- const labelElement = this.originalContent.nativeElement.querySelector('mat-label');
296
- this.label = labelElement ? labelElement.innerHTML : 'mat-label is missing!';
297
- }
298
- correctWidth() {
299
- const formField = this.originalContent.nativeElement.querySelector('mat-form-field');
300
- if (formField) {
301
- formField.setAttribute('style', 'width:100%');
302
- }
303
- }
304
- setReadonlyFieldStyle() {
305
- var _a, _b;
306
- const input = (_b = (_a = this.readOnlyContentWrapper) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.querySelector('input');
307
- if (input) {
308
- const textOverFlowStyleValue = this.getTextOverFlowStyleValue();
309
- if (textOverFlowStyleValue) {
310
- input.setAttribute('style', 'text-overflow: ' + textOverFlowStyleValue);
311
- }
312
- }
313
- }
314
- // Ellipsis is enabled by default as text-overflow behaviour
315
- getTextOverFlowStyleValue() {
316
- var _a, _b;
317
- // it works only if the style is added to the component directly. Should find a way for get it from the calculated
318
- // style. Than it would be possible to define the text-overflow in css for the whole application
319
- const textOverflow = (_b = (_a = this.elementRef) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.style.textOverflow;
320
- if (!textOverflow) {
321
- return 'ellipsis';
322
- }
323
- return textOverflow;
324
- }
325
- setTooltipForOverflownField() {
326
- var _a, _b;
327
- if (this.isEllipsisForTextOverflowEnabled()) {
328
- const input = (_b = (_a = this.readOnlyContentWrapper) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.querySelector('input');
329
- if (input) {
330
- this.toolTipForInputEnabled = this.isTextOverflown(input);
331
- if (this.toolTipForInputEnabled) {
332
- this.toolTipText = this.calculateToolTipText();
333
- }
334
- this.changeDetector.detectChanges();
335
- }
336
- }
337
- }
338
- isEllipsisForTextOverflowEnabled() {
339
- return this.getTextOverFlowStyleValue() === 'ellipsis';
340
- }
341
- isTextOverflown(input) {
342
- if (input) {
343
- return input.offsetWidth < input.scrollWidth;
344
- }
345
- return false;
346
- }
347
- calculateToolTipText() {
348
- if (!this.unit) {
349
- return this.value;
350
- }
351
- return this.unitPosition === 'left' ? this.unit + ' ' + this.value : this.value + ' ' + this.unit;
352
- }
353
- }
354
- ReadOnlyFormFieldWrapperComponent.decorators = [
355
- { type: Component, args: [{
356
- selector: 'mad-readonly-form-field-wrapper',
357
- template: "<div #contentWrapper [hidden]=\"readonly\">\n <ng-content></ng-content>\n</div>\n\n<div #readOnlyContentWrapper>\n <ng-container *ngIf=\"!!readonly\">\n <mad-readonly-form-field\n [label]=\"getLabel()\"\n [value]=\"value\"\n [textAlign]=\"textAlign\"\n [formatNumber]=\"formatNumber\"\n [decimalPlaces]=\"decimalPlaces\"\n [roundDisplayValue]=\"roundValue\"\n [autofillDecimals]=\"autofillDecimals\"\n [unit]=\"unit\"\n [unitPosition]=\"unitPosition\"\n [errorMessage]=\"errorMessage\"\n [multiline]=\"multiline\"\n [rows]=\"rows\"\n [shrinkIfEmpty]=\"shrinkIfEmpty\"\n [id]=\"id\"\n matTooltip=\"{{toolTipText}}\"\n matTooltipPosition=\"right\"\n matTooltipClass=\"custom-tooltip\"\n matTooltipDisabled=\"{{!toolTipForInputEnabled}}\">\n </mad-readonly-form-field>\n </ng-container>\n</div>\n",
358
- styles: ["div,mat-form-field{width:inherit}::ng-deep .custom-tooltip{font-size:14px!important;white-space:normal!important;word-break:break-all!important}"]
359
- },] }
360
- ];
361
- ReadOnlyFormFieldWrapperComponent.ctorParameters = () => [
362
- { type: ChangeDetectorRef },
363
- { type: ElementRef }
364
- ];
365
- ReadOnlyFormFieldWrapperComponent.propDecorators = {
366
- originalContent: [{ type: ViewChild, args: ['contentWrapper', { static: false },] }],
367
- readOnlyContentWrapper: [{ type: ViewChild, args: ['readOnlyContentWrapper', { static: false },] }],
368
- readonly: [{ type: Input }],
369
- value: [{ type: Input, args: ['value',] }],
370
- textAlign: [{ type: Input, args: ['textAlign',] }],
371
- formatNumber: [{ type: Input, args: ['formatNumber',] }],
372
- decimalPlaces: [{ type: Input, args: ['decimalPlaces',] }],
373
- roundValue: [{ type: Input, args: ['roundDisplayValue',] }],
374
- autofillDecimals: [{ type: Input, args: ['autofillDecimals',] }],
375
- unit: [{ type: Input, args: ['unit',] }],
376
- unitPosition: [{ type: Input, args: ['unitPosition',] }],
377
- errorMessage: [{ type: Input, args: ['errorMessage',] }],
378
- id: [{ type: Input }],
379
- multiline: [{ type: Input }],
380
- rows: [{ type: Input }],
381
- shrinkIfEmpty: [{ type: Input }]
382
- };
383
-
384
- class NumberFormatService {
385
- constructor(locale) {
386
- this.allowedKeys = [];
387
- // try to get the current formatting
388
- const localeDecimalSeparator = (1.1).toLocaleString(locale).charAt(1);
389
- this.decimalSeparator = localeDecimalSeparator === ',' ? ',' : '.';
390
- this.groupingSeparator = localeDecimalSeparator === ',' ? '.' : ',';
391
- this.allowedKeys = [...NumberFormatService.NUMBERS, NumberFormatService.NEGATIVE, this.decimalSeparator];
392
- }
393
- static valueIsSet(value) {
394
- return typeof value !== 'undefined' && value !== null && (typeof value !== 'string' || value.length !== 0);
395
- }
396
- format(value, options) {
397
- return NumberFormatService.valueIsSet(value)
398
- ? this.formatNumber(value.toString().replace(new RegExp('[.]', 'g'), this.decimalSeparator), options)
399
- : '';
400
- }
401
- formatNumber(value, options) {
402
- const autofillDecimals = this.valueOrDefault(options === null || options === void 0 ? void 0 : options.autofillDecimals, NumberFormatService.DEFAULT_AUTOFILL_DECIMALS);
403
- const decimalPlaces = this.valueOrDefault(options === null || options === void 0 ? void 0 : options.decimalPlaces, NumberFormatService.DEFAULT_DECIMAL_PLACES);
404
- const finalFormatting = this.valueOrDefault(options === null || options === void 0 ? void 0 : options.finalFormatting, NumberFormatService.DEFAULT_FINAL_FORMATTING);
405
- let result = this.strip(value, { decimalPlaces, removeLeadingZeros: finalFormatting });
406
- /* add grouping separator */
407
- const decimalIndex = result.indexOf(this.decimalSeparator);
408
- const isNegative = result.startsWith(NumberFormatService.NEGATIVE);
409
- let i = decimalIndex > -1 ? decimalIndex : result.length;
410
- while (i > (isNegative ? 4 : 3)) {
411
- i -= 3;
412
- result = result.substring(0, i) + this.groupingSeparator + result.substring(i, result.length);
413
- }
414
- if (finalFormatting) {
415
- if (decimalPlaces > 0 && !!result) {
416
- /* autofill decimal places */
417
- let actualDecimalIndex = result.indexOf(this.decimalSeparator);
418
- if (autofillDecimals) {
419
- if (actualDecimalIndex === -1) {
420
- actualDecimalIndex = result.length;
421
- result += this.decimalSeparator;
422
- }
423
- result = this.addMissingLeadingZero(result, actualDecimalIndex);
424
- actualDecimalIndex = result.indexOf(this.decimalSeparator);
425
- const actualDecimalPlaces = result.length - actualDecimalIndex - 1;
426
- for (let j = 0; j < decimalPlaces - actualDecimalPlaces; j++) {
427
- result += '0';
428
- }
429
- }
430
- else {
431
- result = this.addMissingLeadingZero(result, actualDecimalIndex);
432
- }
433
- }
434
- }
435
- return result;
436
- }
437
- strip(value, options) {
438
- const decimalPlaces = this.valueOrDefault(options === null || options === void 0 ? void 0 : options.decimalPlaces, NumberFormatService.DEFAULT_DECIMAL_PLACES);
439
- const removeLeadingZeros = this.valueOrDefault(options === null || options === void 0 ? void 0 : options.removeLeadingZeros, NumberFormatService.DEFAULT_REMOVE_LEADING_ZEROS);
440
- let result = '';
441
- let indexDecimalSep = -1;
442
- let j = -1;
443
- let ignoredChars = 0;
444
- for (const char of value) {
445
- j++;
446
- if (this.allowedKeys.includes(char)) {
447
- if (char === this.decimalSeparator) {
448
- if (decimalPlaces === 0) {
449
- /* dismiss content after a decimal separator, when no places allowed */
450
- break;
451
- }
452
- else if (indexDecimalSep > -1) {
453
- /* ignore subsequent decimal separators */
454
- continue;
455
- }
456
- indexDecimalSep = j;
457
- }
458
- if (char === '0' && removeLeadingZeros) {
459
- /* remove leading zero only if it's not the only zero in the 'value' string */
460
- if ((result.length === 0 && j + 1 !== value.length) || result === NumberFormatService.NEGATIVE) {
461
- ignoredChars++;
462
- continue;
463
- }
464
- }
465
- if (char === NumberFormatService.NEGATIVE && j > 0) {
466
- /* dismiss content after a negative sign not on first position */
467
- break;
468
- }
469
- if (indexDecimalSep > -1 && result.length + ignoredChars > indexDecimalSep + decimalPlaces) {
470
- /* dismiss content after maximum decimal places reached */
471
- break;
472
- }
473
- result += char;
474
- }
475
- else if (char === this.groupingSeparator) {
476
- if (indexDecimalSep === -1) {
477
- ignoredChars++;
478
- }
479
- }
480
- else {
481
- /* dismiss content after a invalid character */
482
- break;
483
- }
484
- }
485
- return result;
486
- }
487
- addMissingLeadingZero(result, actualDecimalIndex) {
488
- const isNegative = result.startsWith(NumberFormatService.NEGATIVE);
489
- /* autoadd a zero before decimal separator, when it's missing */
490
- if (actualDecimalIndex === 0) {
491
- result = '0' + result;
492
- }
493
- /* autoadd a zero before decimal separator, when it's missing, for negative values */
494
- if (actualDecimalIndex === 1 && isNegative) {
495
- result = result[0] + '0' + result.substring(1, result.length);
496
- }
497
- return result;
498
- }
499
- valueOrDefault(value, defaultValue) {
500
- return NumberFormatService.valueIsSet(value) ? value : defaultValue;
501
- }
502
- }
503
- NumberFormatService.NEGATIVE = '-';
504
- NumberFormatService.NUMBERS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
505
- NumberFormatService.DEFAULT_FINAL_FORMATTING = true;
506
- NumberFormatService.DEFAULT_DECIMAL_PLACES = 2;
507
- NumberFormatService.DEFAULT_AUTOFILL_DECIMALS = false;
508
- NumberFormatService.DEFAULT_REMOVE_LEADING_ZEROS = false;
509
- NumberFormatService.ɵprov = ɵɵdefineInjectable({ factory: function NumberFormatService_Factory() { return new NumberFormatService(ɵɵinject(LOCALE_ID)); }, token: NumberFormatService, providedIn: "any" });
510
- NumberFormatService.decorators = [
511
- { type: Injectable, args: [{
512
- providedIn: 'any',
513
- },] }
514
- ];
515
- NumberFormatService.ctorParameters = () => [
516
- { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
517
- ];
518
-
519
- /**
520
- * Read-only mat-form-field representation of provided value
521
- *
522
- * @author Stefan Laesser
523
- */
524
- class ReadOnlyFormFieldComponent {
525
- constructor(changeDetector, renderer, numberFormatService) {
526
- this.changeDetector = changeDetector;
527
- this.renderer = renderer;
528
- this.numberFormatService = numberFormatService;
529
- this.textAlign = 'left';
530
- this.formatNumber = false;
531
- this.decimalPlaces = 2;
532
- this.roundValue = false;
533
- this.autofillDecimals = false;
534
- this.unit = null;
535
- this.unitPosition = 'left';
536
- this.errorMessage = null;
537
- this.multiline = false;
538
- this.rows = 3;
539
- /*
540
- * If shrinkIfEmpty is set to "false", nothing changes
541
- * If set to "true" and multiline is also "true", the textarea will
542
- * shrink to one row, if value is empty/null/undefined.
543
- * Otherwise, the defined rows-value will be used
544
- */
545
- this.shrinkIfEmpty = false;
546
- this.errorMatcher = {
547
- isErrorState: () => !!this.errorMessage,
548
- };
549
- }
550
- ngOnChanges(_) {
551
- if (!NumberFormatService.valueIsSet(this.value)) {
552
- this.value = '-';
553
- if (this.shrinkIfEmpty) {
554
- this.rows = 1;
555
- }
556
- }
557
- else if (this.formatNumber && typeof this.value === 'number') {
558
- this.value = this.numberFormatService.format(this.value, {
559
- decimalPlaces: this.decimalPlaces,
560
- finalFormatting: true,
561
- autofillDecimals: this.autofillDecimals,
562
- });
563
- }
564
- this.changeDetector.detectChanges();
565
- }
566
- // TODO direct copy from NumericFieldDirective
567
- ngAfterViewChecked() {
568
- this.injectUnitSymbol();
569
- }
570
- injectUnitSymbol() {
571
- // Need to inject the unit symbol when the input element width is set to its actual value,
572
- // otherwise the icon wont show in the correct position
573
- if (!!this.unit && !this.unitSpan && this.inputEl.nativeElement.offsetWidth !== 0) {
574
- // Get the input wrapper and apply necessary styles
575
- const inputWrapper = this.inputEl.nativeElement.parentNode.parentNode;
576
- // Create the span with unit symbol and apply necessary styles
577
- this.unitSpan = this.renderer.createElement('span');
578
- if (this.unitPosition === 'left') {
579
- this.renderer.setAttribute(this.unitSpan, 'matPrefix', '');
580
- this.renderer.setStyle(this.unitSpan, 'padding-right', '5px');
581
- this.renderer.insertBefore(inputWrapper, this.unitSpan, inputWrapper.children[0]);
582
- }
583
- else {
584
- this.renderer.setAttribute(this.unitSpan, 'matSuffix', '');
585
- this.renderer.setStyle(this.unitSpan, 'padding-left', '5px');
586
- this.renderer.appendChild(inputWrapper, this.unitSpan);
587
- }
588
- }
589
- // special handling to move unit symbol along with display value
590
- if (!!this.unitSpan && this.textAlign === 'left' && this.unitPosition === 'right') {
591
- const inputStyles = window.getComputedStyle(this.inputEl.nativeElement.parentElement, null);
592
- this.unitSpan.style.position = 'absolute';
593
- this.unitSpan.style.marginTop = inputStyles.getPropertyValue('border-top-width');
594
- this.unitSpan.style.paddingTop = inputStyles.getPropertyValue('padding-top');
595
- this.unitSpan.style.paddingBottom = inputStyles.getPropertyValue('padding-bottom');
596
- if (!this.textSpan) {
597
- this.textSpan = document.createElement('span');
598
- document.body.appendChild(this.textSpan);
599
- this.textSpan.style.font = inputStyles.getPropertyValue('font');
600
- this.textSpan.style.fontSize = inputStyles.getPropertyValue('font-size');
601
- this.textSpan.style.height = 'auto';
602
- this.textSpan.style.width = 'auto';
603
- this.textSpan.style.position = 'absolute';
604
- this.textSpan.style.top = '0';
605
- this.textSpan.style.whiteSpace = 'no-wrap';
606
- this.textSpan.style.visibility = 'hidden';
607
- }
608
- this.textSpan.innerHTML = this.value;
609
- const width = Math.min(this.inputEl.nativeElement.clientWidth - this.unitSpan.clientWidth, Math.ceil(this.textSpan.clientWidth));
610
- this.unitSpan.style.left = width + 'px';
611
- }
612
- // always reset unit symbol
613
- if (!!this.unitSpan) {
614
- this.unitSpan.textContent = this.unit;
615
- }
616
- }
617
- }
618
- ReadOnlyFormFieldComponent.decorators = [
619
- { type: Component, args: [{
620
- selector: 'mad-readonly-form-field',
621
- template: "<mat-form-field class=\"form-group\" appearance=\"none\">\n <mat-label>{{ label }}</mat-label>\n <input\n *ngIf=\"!multiline\"\n [ngModel]=\"value\"\n [ngClass]=\"'text-' + textAlign\"\n [errorStateMatcher]=\"errorMatcher\"\n [id]=\"id\"\n readonly\n matInput\n #inputEl\n />\n\n <textarea\n *ngIf=\"multiline\"\n [rows]=\"rows\"\n [ngModel]=\"value\"\n class=\"multiline\"\n [errorStateMatcher]=\"errorMatcher\"\n [id]=\"id\"\n readonly\n matInput\n ></textarea>\n <mat-error>{{ errorMessage }}</mat-error>\n</mat-form-field>\n",
622
- styles: ["mat-form-field{width:100%;width:-moz-available;width:-webkit-fill-available;width:stretch}mat-label{line-height:1.4}span[matPrefix]{padding-right:5px}span[matSuffix]{padding-left:5px}.text-left{text-align:left}.text-right{text-align:right}.multiline{resize:none}"]
623
- },] }
624
- ];
625
- ReadOnlyFormFieldComponent.ctorParameters = () => [
626
- { type: ChangeDetectorRef },
627
- { type: Renderer2 },
628
- { type: NumberFormatService }
629
- ];
630
- ReadOnlyFormFieldComponent.propDecorators = {
631
- value: [{ type: Input, args: ['value',] }],
632
- label: [{ type: Input, args: ['label',] }],
633
- textAlign: [{ type: Input, args: ['textAlign',] }],
634
- formatNumber: [{ type: Input, args: ['formatNumber',] }],
635
- decimalPlaces: [{ type: Input, args: ['decimalPlaces',] }],
636
- roundValue: [{ type: Input, args: ['roundDisplayValue',] }],
637
- autofillDecimals: [{ type: Input, args: ['autofillDecimals',] }],
638
- unit: [{ type: Input, args: ['unit',] }],
639
- unitPosition: [{ type: Input, args: ['unitPosition',] }],
640
- errorMessage: [{ type: Input, args: ['errorMessage',] }],
641
- multiline: [{ type: Input }],
642
- rows: [{ type: Input }],
643
- id: [{ type: Input }],
644
- shrinkIfEmpty: [{ type: Input }],
645
- inputEl: [{ type: ViewChild, args: ['inputEl',] }]
646
- };
647
-
648
- class ReadOnlyFormFieldModule {
649
- }
650
- ReadOnlyFormFieldModule.decorators = [
651
- { type: NgModule, args: [{
652
- declarations: [ReadOnlyFormFieldComponent, ReadOnlyFormFieldWrapperComponent],
653
- imports: [CommonModule, RouterModule, MatFormFieldModule, MatInputModule, FormsModule, MatTooltipModule],
654
- exports: [ReadOnlyFormFieldComponent, ReadOnlyFormFieldWrapperComponent],
655
- },] }
656
- ];
657
-
658
- class ToolbarService {
659
- constructor(router, translate) {
660
- this.router = router;
661
- this.translate = translate;
662
- this.mainActions = []; // shown on the left, next to title, as big buttons
663
- this.toolbarActions = []; // shown on the right as icons
664
- this.toolbarActionsAlwaysAsMenu = false; // show the mobile view (burger menu) for toolbar actions
665
- this.toolbarActionsMenuTitle = 'More'; // title of the burger menu
666
- this.routerSubscription = this.router.events.subscribe(routingEvent => {
667
- if (routingEvent instanceof NavigationEnd) {
668
- if (this.currentUrl !== routingEvent.urlAfterRedirects) {
669
- this.clearToolbarActions();
670
- this.clearMainActions();
671
- delete this.backAction;
672
- delete this.dataTitle;
673
- }
674
- this.currentUrl = router.url;
675
- }
676
- });
677
- }
678
- get toolbarTitle() {
679
- return this.title;
680
- }
681
- set toolbarTitle(toolbarTitle) {
682
- this.title = toolbarTitle;
683
- }
684
- ngOnDestroy() {
685
- if (this.routerSubscription) {
686
- this.routerSubscription.unsubscribe();
687
- }
688
- }
689
- getToolbarActions() {
690
- return this.toolbarActions;
691
- }
692
- addToolbarAction(action) {
693
- this.translate
694
- .get(action.i18nActionKey)
695
- .toPromise()
696
- .then(translated => {
697
- action.actionName = translated;
698
- this.toolbarActions.push(action);
699
- });
700
- }
701
- setDataTitle(dataTitle) {
702
- this.dataTitle = dataTitle;
703
- }
704
- setToolbarActionsAlwaysAsMenu(toolbarActionsAlwaysAsMenu) {
705
- this.toolbarActionsAlwaysAsMenu = toolbarActionsAlwaysAsMenu;
706
- }
707
- getToolbarActionsAlwaysAsMenu() {
708
- return this.toolbarActionsAlwaysAsMenu;
709
- }
710
- getDataTitle() {
711
- return this.dataTitle;
712
- }
713
- clearToolbarActions() {
714
- this.toolbarActions = [];
715
- }
716
- getMainActions() {
717
- return this.mainActions;
718
- }
719
- getBackAction() {
720
- return this.backAction;
721
- }
722
- setToolbarActionsMenuTitle(toolbarActionsMenuTitle) {
723
- this.toolbarActionsMenuTitle = toolbarActionsMenuTitle;
724
- }
725
- getToolbarActionsMenuTitle() {
726
- return this.toolbarActionsMenuTitle;
727
- }
728
- addMainAction(mainAction) {
729
- this.translate
730
- .get(mainAction.i18nActionKey)
731
- .toPromise()
732
- .then(translated => {
733
- mainAction.actionName = translated;
734
- this.mainActions.push(mainAction);
735
- });
736
- }
737
- /**
738
- * Per default the goBackRoute is a routerLink. But if a href should be used (for absolute browser routing) then isAbsoluteUrl can be set to true.
739
- */
740
- addBackAction(goBackRoute, isAbsoluteUrl = false) {
741
- this.backAction = {
742
- matIcon: 'keyboard_backspace',
743
- i18nActionKey: '',
744
- };
745
- if (!isAbsoluteUrl) {
746
- this.backAction.routerLink = goBackRoute;
747
- }
748
- else {
749
- this.backAction.href = goBackRoute;
750
- }
751
- }
752
- addSimpleBackButton(overrideIfPresent = false) {
753
- if (this.getBackAction() && !overrideIfPresent) {
754
- return;
755
- }
756
- this.backAction = {
757
- matIcon: 'keyboard_backspace',
758
- i18nActionKey: '',
759
- action() {
760
- window.history.back();
761
- },
762
- };
763
- }
764
- clearMainActions() {
765
- this.mainActions = [];
766
- }
767
- }
768
- ToolbarService.ɵprov = ɵɵdefineInjectable({ factory: function ToolbarService_Factory() { return new ToolbarService(ɵɵinject(Router), ɵɵinject(TranslateService)); }, token: ToolbarService, providedIn: "root" });
769
- ToolbarService.decorators = [
770
- { type: Injectable, args: [{
771
- providedIn: 'root',
772
- },] }
773
- ];
774
- ToolbarService.ctorParameters = () => [
775
- { type: Router },
776
- { type: TranslateService }
777
- ];
778
-
779
- class ToolbarComponent {
780
- constructor(breakpointObserver, titleService, toolbarService) {
781
- this.breakpointObserver = breakpointObserver;
782
- this.titleService = titleService;
783
- this.toolbarService = toolbarService;
784
- this.isHandset$ = this.breakpointObserver.observe([Breakpoints.Handset]).pipe(map(result => result.matches));
785
- }
786
- getTitle() {
787
- const dataTitle = this.toolbarService.getDataTitle();
788
- const toolbarTitle = this.toolbarService.toolbarTitle;
789
- const title = !toolbarTitle || toolbarTitle.length <= 0 ? this.titleService.getTitle() : toolbarTitle;
790
- return !dataTitle || dataTitle.length <= 0 ? title : title + ': ' + dataTitle;
791
- }
792
- getToolbarActions() {
793
- return this.toolbarService.getToolbarActions();
794
- }
795
- getMainActions() {
796
- return this.toolbarService.getMainActions();
797
- }
798
- hasPermission(action) {
799
- if (!action || !action.showIf) {
800
- return of(true);
801
- }
802
- return action.showIf;
803
- }
804
- isRouterLink() {
805
- return this.toolbarService.getBackAction() && !!this.toolbarService.getBackAction().routerLink;
806
- }
807
- isAbsoluteLink() {
808
- return this.toolbarService.getBackAction() && !!this.toolbarService.getBackAction().href;
809
- }
810
- isAction() {
811
- return this.toolbarService.getBackAction() && !!this.toolbarService.getBackAction().action;
812
- }
813
- getBackAction() {
814
- return this.toolbarService.getBackAction();
815
- }
816
- getToolbarActionsAlwaysAsMenu() {
817
- return this.toolbarService.getToolbarActionsAlwaysAsMenu();
818
- }
819
- getToolbarActionsMenuTitle() {
820
- return this.toolbarService.getToolbarActionsMenuTitle();
821
- }
822
- showBadgeForMenu() {
823
- return (this.getToolbarActions()
824
- .slice(1) // the first icon is not shown in menu
825
- .filter(value => value.badge && value.badge.value).length > 0);
826
- }
827
- hasImportantToolbarActions() {
828
- return this.getToolbarActions().filter(value => !!value.importantAction).length > 0;
829
- }
830
- }
831
- ToolbarComponent.decorators = [
832
- { type: Component, args: [{
833
- selector: 'mad-toolbar',
834
- template: "<mat-toolbar class=\"content-toolbar\">\n <a [routerLink]=\"getBackAction().routerLink\" *ngIf=\"isRouterLink()\">\n <button [id]=\"'go-back'\" color=\"primary\" mat-icon-button class=\"go-back-button\">\n <mat-icon>{{ getBackAction().matIcon }}</mat-icon>\n </button>\n </a>\n <a [href]=\"getBackAction().href\" *ngIf=\"isAbsoluteLink()\">\n <button [id]=\"'go-back'\" class=\"go-back-button\" color=\"primary\" mat-icon-button>\n <mat-icon>{{ getBackAction().matIcon }}</mat-icon>\n </button>\n </a>\n <a (click)=\"getBackAction().action()\" *ngIf=\"isAction()\">\n <button [id]=\"'go-back'\" color=\"primary\" mat-icon-button class=\"go-back-button\">\n <mat-icon>{{ getBackAction().matIcon }}</mat-icon>\n </button>\n </a>\n\n <span class=\"toolbar-title\">{{ getTitle() }}</span>\n\n <ng-container *ngFor=\"let mainAction of getMainActions(); let i = index\">\n <ng-container *ngIf=\"hasPermission(mainAction) | async\">\n <div *ngIf=\"!(isHandset$ | async)\">\n <a [routerLink]=\"mainAction.routerLink\">\n <mad-primary-button [id]=\"mainAction.matIcon\" style=\"margin-left: 56px\">\n <mat-icon>{{ mainAction.matIcon }}</mat-icon>\n {{ mainAction.actionName }}\n </mad-primary-button>\n </a>\n </div>\n <div *ngIf=\"isHandset$ | async\">\n <mad-material-action-button\n [actionName]=\"mainAction.actionName\"\n [icon]=\"mainAction.matIcon\"\n [liftHigher]=\"mainAction.liftHigherOnMobile\"\n [liftHigher2]=\"i > 0\"\n [routerLink]=\"mainAction.routerLink\"\n [id]=\"mainAction.matIcon\"\n >\n </mad-material-action-button>\n </div>\n </ng-container>\n </ng-container>\n\n <div class=\"right-aligned no-print\">\n <ng-container *ngFor=\"let action of getToolbarActions(); let i = index\">\n <ng-container *ngIf=\"hasPermission(action) | async\">\n <mad-icon-button\n (click)=\"action.action()\"\n *ngIf=\"(!(isHandset$ | async) && !getToolbarActionsAlwaysAsMenu()) || i < (getToolbarActions().length > 2 ? (hasImportantToolbarActions() ? 0:1) : 2) || !!action.importantAction\"\n [id]=\"action.matIcon\"\n [matTooltip]=\"action.actionName\"\n type=\"button\">\n <mat-icon\n [matBadgeColor]=\"action.badge ? action.badge.color : 'primary'\"\n matBadgePosition=\"below after\"\n [matBadge]=\"action.badge ? action.badge.value : null\"\n >{{ action.matIcon }}</mat-icon>\n </mad-icon-button>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"(isHandset$ | async) || getToolbarActionsAlwaysAsMenu()\">\n <ng-container *ngIf=\"getToolbarActions().length > 2\">\n <mad-icon-button type=\"button\" [matMenuTriggerFor]=\"burgerMenu\" [matTooltip]=\"getToolbarActionsMenuTitle()\">\n <mat-icon\n matBadgeColor=\"warn\"\n [matBadge]=\"showBadgeForMenu() ? '&#8288;' : null\"\n matBadgeSize=\"small\"\n matBadgePosition=\"above after\"\n >more_vert\n </mat-icon>\n </mad-icon-button>\n <mat-menu #burgerMenu=\"matMenu\" class=\"no-print\">\n <ng-container *ngFor=\"let action of getToolbarActions(); let i = index\">\n <ng-container *ngIf=\"!action.importantAction\">\n <ng-container *ngIf=\"hasPermission(action) | async\">\n <button *ngIf=\"i >= (hasImportantToolbarActions() ? 0:1)\" mat-menu-item (click)=\"action.action()\">\n <mat-icon\n color=\"primary\"\n [matBadgeColor]=\"action.badge ? action.badge.color : 'primary'\"\n [matBadge]=\"action.badge ? action.badge.value : null\"\n matBadgePosition=\"below after\"\n >{{ action.matIcon }}</mat-icon\n >\n {{ action.actionName }}\n </button>\n </ng-container>\n </ng-container>\n </ng-container>\n </mat-menu>\n </ng-container>\n </ng-container>\n </div>\n</mat-toolbar>\n",
835
- styles: ["mat-toolbar{background:#fff}.content-toolbar{border-bottom:1px solid #dcdcdc;height:57px}.right-aligned{margin-left:auto;margin-right:0;overflow:hidden}.go-back-button{padding-left:0;padding-right:0}.toolbar-title{margin-right:72px}::ng-deep.mat-badge-content{bottom:-7px!important;right:-7px!important}"]
836
- },] }
837
- ];
838
- ToolbarComponent.ctorParameters = () => [
839
- { type: BreakpointObserver },
840
- { type: Title },
841
- { type: ToolbarService }
842
- ];
843
-
844
- class ToolbarModule {
845
- }
846
- ToolbarModule.decorators = [
847
- { type: NgModule, args: [{
848
- declarations: [ToolbarComponent],
849
- imports: [
850
- CommonModule,
851
- RouterModule,
852
- MatMenuModule,
853
- MatButtonModule,
854
- MatToolbarModule,
855
- MatIconModule,
856
- MaterialActionButtonModule,
857
- MatTooltipModule,
858
- ButtonModule,
859
- MatBadgeModule,
860
- ],
861
- exports: [ToolbarComponent],
862
- },] }
863
- ];
864
-
865
- /*
866
- * Copyright (c) 2018-2020 Porsche Informatik. All Rights Reserved.
867
- * This software is released under MIT license.
868
- * The full license information can be found in LICENSE in the root directory of this project.
869
- */
870
- const BACK_KEYCODE = 8;
871
- const SPACE_KEYCODE = 32;
872
- const DEL_KEYCODE = 46;
873
- const CONTROL_KEYCODES_UPPER_BORDER = 46;
874
- const OTHER_CONTROL_KEYS = new Set([224, 91, 93]);
875
- class NumericFieldDirective {
876
- constructor(renderer, inputEl, numberFormatService) {
877
- this.renderer = renderer;
878
- this.inputEl = inputEl;
879
- this.numberFormatService = numberFormatService;
880
- this.textAlign = 'right';
881
- this.decimalPlaces = 2;
882
- this.roundValue = false;
883
- this.autofillDecimals = false;
884
- this.unit = null;
885
- this.unitPosition = 'right';
886
- this.numericValueChanged = new EventEmitter();
887
- this.displayValue = '';
888
- this.originalValue = NaN;
889
- /* Control Values Accessor Stuff below */
890
- // eslint-disable-next-line
891
- this.onChange = () => { };
892
- // eslint-disable-next-line
893
- this.onTouched = () => { };
894
- }
895
- set numericValue(value) {
896
- if (this._numericValue !== value && !(isNaN(this._numericValue) && (isNaN(value) || value === null))) {
897
- this.originalValue = value;
898
- // Don't roundOrTruncate if value was set to empty otherwise input value will be set to 0 instead of empty
899
- // which happens when an input is being reset
900
- this._numericValue = value === null || value === undefined ? value : this.roundOrTruncate(value); // eslint-disable-line
901
- this.handleInputChanged();
902
- }
903
- }
904
- registerOnChange(fn) {
905
- this.onChange = fn;
906
- }
907
- registerOnTouched(fn) {
908
- this.onTouched = fn;
909
- }
910
- setDisabledState() {
911
- // Dont need to implement since its just a directive
912
- }
913
- writeValue(value) {
914
- this.numericValue = value;
915
- }
916
- ngOnInit() {
917
- /* needs to be parsed as number explicitly as it comes as string from user input */
918
- this.decimalPlaces = parseInt(this.decimalPlaces.toString(), 10);
919
- this.inputChangeListener = this.renderer.listen(this.inputEl.nativeElement, 'blur', event => {
920
- this.formatInput(event.target, true);
921
- });
922
- this.keyupListener = this.renderer.listen(this.inputEl.nativeElement, 'keyup', event => {
923
- if (event.keyCode === BACK_KEYCODE || (event.keyCode >= CONTROL_KEYCODES_UPPER_BORDER && !OTHER_CONTROL_KEYS.has(event.keyCode))) {
924
- this.formatInput(event.target, false);
925
- }
926
- });
927
- this.keydownListener = this.renderer.listen(this.inputEl.nativeElement, 'keydown', event => {
928
- const value = event.target.value;
929
- if (this.numberFormatService.allowedKeys.includes(event.key) ||
930
- (event.keyCode <= CONTROL_KEYCODES_UPPER_BORDER && event.keyCode > 0 && event.keyCode !== SPACE_KEYCODE) ||
931
- event.metaKey ||
932
- event.ctrlKey ||
933
- event.altKey) {
934
- /* allow negative sign only as first character and none exists outside of text selection */
935
- const indexNegativeSign = value.indexOf(NumberFormatService.NEGATIVE);
936
- if (event.key === NumberFormatService.NEGATIVE &&
937
- (event.target.selectionStart > 0 || indexNegativeSign > -1) &&
938
- (event.target.selectionStart === event.target.selectionEnd ||
939
- !(indexNegativeSign >= event.target.selectionStart && indexNegativeSign <= event.target.selectionEnd))) {
940
- return false;
941
- }
942
- /* no duplicate decimal separators */
943
- const indexDecimalSep = value.indexOf(this.numberFormatService.decimalSeparator);
944
- if (event.key === this.numberFormatService.decimalSeparator &&
945
- (indexDecimalSep > -1 || this.decimalPlaces === 0) &&
946
- (event.target.selectionStart === event.target.selectionEnd ||
947
- !(indexDecimalSep >= event.target.selectionStart && indexDecimalSep <= event.target.selectionEnd))) {
948
- return false;
949
- }
950
- /* prevent too many decimal places */
951
- if (NumberFormatService.NUMBERS.includes(event.key) &&
952
- indexDecimalSep > -1 &&
953
- indexDecimalSep < event.target.selectionStart &&
954
- event.target.selectionStart === event.target.selectionEnd &&
955
- value.length > indexDecimalSep + this.decimalPlaces) {
956
- return false;
957
- }
958
- /* when deleting thousand separator, remove the digit before or after it */
959
- const cursorStart = event.target.selectionStart;
960
- if (cursorStart === event.target.selectionEnd) {
961
- if (event.keyCode === BACK_KEYCODE && value.substr(cursorStart - 1, 1) === this.numberFormatService.groupingSeparator) {
962
- event.target.value = value.substring(0, cursorStart - 2) + value.substring(cursorStart - 1, value.length);
963
- event.target.selectionStart = event.target.selectionEnd = cursorStart - 1;
964
- return false;
965
- }
966
- else if (event.keyCode === DEL_KEYCODE && value.substr(cursorStart, 1) === this.numberFormatService.groupingSeparator) {
967
- event.target.value = value.substring(0, cursorStart + 1) + value.substring(cursorStart + 2, value.length);
968
- event.target.selectionStart = event.target.selectionEnd = cursorStart + 1;
969
- return false;
970
- }
971
- }
972
- this.originalValue = NaN;
973
- }
974
- else {
975
- return false;
976
- }
977
- return true;
978
- });
979
- }
980
- ngOnDestroy() {
981
- this.detachListener();
982
- }
983
- ngAfterViewChecked() {
984
- this.injectUnitSymbol();
985
- }
986
- handleInputChanged() {
987
- // Call in set timeout to avoid Expression has changed after it has been checked error.
988
- // Sometimes the value changes because we cut off decimal places
989
- setTimeout(() => {
990
- this.updateInput(this.numberFormatService.format(this._numericValue, {
991
- decimalPlaces: this.decimalPlaces,
992
- finalFormatting: false,
993
- autofillDecimals: this.autofillDecimals,
994
- }));
995
- }, 1);
996
- }
997
- formatInput(element, finalFormatting) {
998
- const cursorPos = element.selectionStart;
999
- const length = element.value.length;
1000
- const setCursor = this.displayValue !== element.value;
1001
- const textFormatted = this.numberFormatService.formatNumber(element.value, {
1002
- decimalPlaces: this.decimalPlaces,
1003
- finalFormatting,
1004
- autofillDecimals: this.autofillDecimals,
1005
- });
1006
- // special handling to move unit symbol along with display value
1007
- if (this.textAlign === 'left' && this.unitPosition === 'right') {
1008
- const inputStyles = window.getComputedStyle(this.inputEl.nativeElement.parentElement, null);
1009
- this.unitSpan.style.position = 'absolute';
1010
- this.unitSpan.style.marginTop = inputStyles.getPropertyValue('border-top-width');
1011
- this.unitSpan.style.paddingTop = inputStyles.getPropertyValue('padding-top');
1012
- this.unitSpan.style.paddingBottom = inputStyles.getPropertyValue('padding-bottom');
1013
- if (!this.textSpan) {
1014
- this.textSpan = document.createElement('span');
1015
- document.body.appendChild(this.textSpan);
1016
- this.textSpan.style.font = inputStyles.getPropertyValue('font');
1017
- this.textSpan.style.fontSize = inputStyles.getPropertyValue('font-size');
1018
- this.textSpan.style.height = 'auto';
1019
- this.textSpan.style.width = 'auto';
1020
- this.textSpan.style.position = 'absolute';
1021
- this.textSpan.style.top = '0';
1022
- this.textSpan.style.whiteSpace = 'no-wrap';
1023
- this.textSpan.style.visibility = 'hidden';
1024
- }
1025
- this.textSpan.innerHTML = textFormatted;
1026
- const width = Math.min(this.inputEl.nativeElement.clientWidth - this.unitSpan.clientWidth, Math.ceil(this.textSpan.clientWidth));
1027
- this.unitSpan.style.left = width + 'px';
1028
- }
1029
- this.updateInput(textFormatted);
1030
- if (setCursor) {
1031
- element.selectionStart = element.selectionEnd = Math.max(cursorPos + element.value.length - length, 0);
1032
- }
1033
- }
1034
- updateInput(value) {
1035
- this.displayValue = value;
1036
- this.inputEl.nativeElement.value = value;
1037
- this._numericValue = parseFloat(this.numberFormatService.strip(value, { decimalPlaces: this.decimalPlaces }).replace(this.numberFormatService.decimalSeparator, '.'));
1038
- if (this._numericValue !== this.roundOrTruncate(this.originalValue)) {
1039
- this.originalValue = this._numericValue;
1040
- this.numericValueChanged.emit(this._numericValue);
1041
- }
1042
- }
1043
- getValueForFormControl() {
1044
- this.formatInput(this.inputEl.nativeElement, false);
1045
- if (isNaN(this._numericValue)) {
1046
- // Return undefined instead of NaN to support the default required validator.
1047
- return undefined; // eslint-disable-line
1048
- }
1049
- return this._numericValue;
1050
- }
1051
- injectUnitSymbol() {
1052
- // Need to inject the unit symbol when the input element width is set to its actual value,
1053
- // otherwise the icon wont show in the correct position
1054
- if (!!this.unit && !this.unitSpan && this.inputEl.nativeElement.offsetWidth !== 0) {
1055
- // Get the input wrapper and apply necessary styles
1056
- const inputWrapper = this.inputEl.nativeElement.parentNode.parentNode;
1057
- // Create the span with unit symbol and apply necessary styles
1058
- this.unitSpan = this.renderer.createElement('span');
1059
- if (this.unitPosition === 'left') {
1060
- this.renderer.setAttribute(this.unitSpan, 'matPrefix', '');
1061
- this.renderer.setStyle(this.unitSpan, 'padding-right', '5px');
1062
- this.renderer.insertBefore(inputWrapper, this.unitSpan, inputWrapper.children[0]);
1063
- }
1064
- else {
1065
- this.renderer.setAttribute(this.unitSpan, 'matSuffix', '');
1066
- this.renderer.setStyle(this.unitSpan, 'padding-left', '5px');
1067
- this.renderer.appendChild(inputWrapper, this.unitSpan);
1068
- }
1069
- }
1070
- // do not display unit symbol if the unit should move along display value
1071
- if (!!this.unitSpan && this.textAlign === 'left' && this.unitPosition === 'right') {
1072
- if (NumberFormatService.valueIsSet(this.displayValue)) {
1073
- this.unitSpan.style.display = 'unset';
1074
- }
1075
- else {
1076
- this.unitSpan.style.display = 'none';
1077
- }
1078
- }
1079
- // always reset unit symbol
1080
- if (!!this.unitSpan) {
1081
- this.unitSpan.textContent = this.unit;
1082
- }
1083
- }
1084
- detachListener() {
1085
- if (this.inputChangeListener) {
1086
- this.inputChangeListener();
1087
- delete this.inputChangeListener;
1088
- }
1089
- if (this.keydownListener) {
1090
- this.keydownListener();
1091
- delete this.keydownListener;
1092
- }
1093
- if (this.keyupListener) {
1094
- this.keyupListener();
1095
- delete this.keyupListener;
1096
- }
1097
- }
1098
- roundOrTruncate(value) {
1099
- const method = this.roundValue ? 'round' : value < 0 ? 'ceil' : 'floor';
1100
- return Math[method](value * Math.pow(10, this.decimalPlaces)) / Math.pow(10, this.decimalPlaces);
1101
- }
1102
- }
1103
- NumericFieldDirective.decorators = [
1104
- { type: Directive, args: [{
1105
- selector: '[madNumericField]',
1106
- host: {
1107
- '[class.text-right]': 'textAlign === "right"',
1108
- '(change)': 'onChange(getValueForFormControl())',
1109
- '(input)': 'onChange(getValueForFormControl())',
1110
- '(blur)': 'onTouched()',
1111
- },
1112
- providers: [
1113
- {
1114
- provide: NG_VALUE_ACCESSOR,
1115
- useExisting: forwardRef(() => NumericFieldDirective),
1116
- multi: true,
1117
- },
1118
- ],
1119
- },] }
1120
- ];
1121
- NumericFieldDirective.ctorParameters = () => [
1122
- { type: Renderer2 },
1123
- { type: ElementRef },
1124
- { type: NumberFormatService }
1125
- ];
1126
- NumericFieldDirective.propDecorators = {
1127
- textAlign: [{ type: Input, args: ['textAlign',] }],
1128
- decimalPlaces: [{ type: Input, args: ['decimalPlaces',] }],
1129
- roundValue: [{ type: Input, args: ['roundDisplayValue',] }],
1130
- autofillDecimals: [{ type: Input, args: ['autofillDecimals',] }],
1131
- unit: [{ type: Input, args: ['unit',] }],
1132
- unitPosition: [{ type: Input, args: ['unitPosition',] }],
1133
- numericValueChanged: [{ type: Output, args: ['numericValueChange',] }],
1134
- numericValue: [{ type: Input, args: ['numericValue',] }]
1135
- };
1136
-
1137
- class NumericFieldModule {
1138
- static forRoot() {
1139
- return {
1140
- ngModule: NumericFieldModule,
1141
- providers: [NumberFormatService],
1142
- };
1143
- }
1144
- }
1145
- NumericFieldModule.decorators = [
1146
- { type: NgModule, args: [{
1147
- providers: [NumberFormatService],
1148
- declarations: [NumericFieldDirective],
1149
- exports: [NumericFieldDirective],
1150
- },] }
1151
- ];
1152
-
1153
- class CardComponent {
1154
- constructor() {
1155
- this.cancelDisabled = false;
1156
- this.cancelText = 'NOT SET';
1157
- this.readonly = true;
1158
- this.editText = 'NOT SET';
1159
- this.expandable = true;
1160
- this.expanded = true;
1161
- this.saveDisabled = false;
1162
- this.saveText = 'NOT SET';
1163
- this.editMode = false;
1164
- this.additionalActionText = '';
1165
- this.edit = new EventEmitter();
1166
- this.cancel = new EventEmitter();
1167
- this.save = new EventEmitter();
1168
- this.additionalAction = new EventEmitter();
1169
- }
1170
- onCancel() {
1171
- this.cancel.emit(undefined);
1172
- }
1173
- onEdit() {
1174
- this.edit.emit(undefined);
1175
- this.expanded = true;
1176
- }
1177
- onSave() {
1178
- this.save.emit(undefined);
1179
- }
1180
- toggleCollapse() {
1181
- this.expanded = !this.expanded;
1182
- }
1183
- additionalActionClicked() {
1184
- this.additionalAction.emit(undefined);
1185
- }
1186
- }
1187
- CardComponent.decorators = [
1188
- { type: Component, args: [{
1189
- selector: 'mad-card',
1190
- template: "<mat-card>\n <mat-card-header>\n <mat-card-title>\n {{ title }}\n <mad-icon-button (click)=\"toggleCollapse()\" *ngIf=\"expandable && !editMode\">\n <mat-icon [@rotateIcon]=\"!expanded\">keyboard_arrow_down</mat-icon>\n </mad-icon-button>\n </mat-card-title>\n <span>\n <mad-icon-button (click)=\"additionalActionClicked()\" *ngIf=\"additionalActionIcon\" [title]=\"additionalActionText\" type=\"button\">\n <mat-icon>{{additionalActionIcon}}</mat-icon>\n </mad-icon-button>\n <mad-icon-button [title]=\"editText\" (click)=\"onEdit()\" *ngIf=\"!readonly && !editMode\">\n <mat-icon>create</mat-icon>\n </mad-icon-button>\n </span>\n </mat-card-header>\n <mat-card-content [@collapseExpandAnimation] *ngIf=\"expanded\">\n <ng-content></ng-content>\n </mat-card-content>\n <mat-card-actions *ngIf=\"!readonly && editMode\">\n <mad-primary-button [title]=\"saveText\" [disabled]=\"saveDisabled\" (throttleClick)=\"onSave()\" madThrottleClick>\n {{ saveText }}\n </mad-primary-button>\n <mad-outline-button [title]=\"cancelText\" [disabled]=\"cancelDisabled\" (click)=\"onCancel()\">\n {{ cancelText }}\n </mad-outline-button>\n </mat-card-actions>\n</mat-card>\n",
1191
- animations: [
1192
- trigger('collapseExpandAnimation', [
1193
- transition(':enter', [
1194
- style({ opacity: 0, height: 0, overflow: 'hidden' }),
1195
- animate('100ms', style({
1196
- opacity: 1,
1197
- height: '*',
1198
- })),
1199
- ]),
1200
- transition(':leave', [
1201
- style({ opacity: 1, height: '*', overflow: 'hidden' }),
1202
- animate('100ms', style({
1203
- opacity: 0,
1204
- height: 0,
1205
- })),
1206
- ]),
1207
- ]),
1208
- trigger('rotateIcon', [
1209
- state('true', style({ transform: 'rotate(0)' })),
1210
- state('false', style({ transform: 'rotate(180deg)' })),
1211
- transition('true => false', animate('100ms ease-out')),
1212
- transition('false => true', animate('100ms ease-in')),
1213
- ]),
1214
- ],
1215
- styles: ["mat-card-header{display:flex;flex-direction:row}mat-card-header,mat-card-header mat-card-title{justify-content:space-between}mat-card-header mat-card-title:hover{background:unset!important}mat-card-header h3{float:left;font-weight:700;line-height:40px;margin:0 .25em 0 0}.mat-card-actions{margin-left:0;margin-right:0}.mat-card>.mat-card-actions:last-child{margin-bottom:0}"]
1216
- },] }
1217
- ];
1218
- CardComponent.propDecorators = {
1219
- cancelDisabled: [{ type: Input }],
1220
- cancelText: [{ type: Input }],
1221
- readonly: [{ type: Input }],
1222
- editText: [{ type: Input }],
1223
- expandable: [{ type: Input }],
1224
- expanded: [{ type: Input }],
1225
- saveDisabled: [{ type: Input }],
1226
- saveText: [{ type: Input }],
1227
- title: [{ type: Input }],
1228
- editMode: [{ type: Input }],
1229
- additionalActionIcon: [{ type: Input }],
1230
- additionalActionText: [{ type: Input }],
1231
- edit: [{ type: Output }],
1232
- cancel: [{ type: Output }],
1233
- save: [{ type: Output }],
1234
- additionalAction: [{ type: Output }]
1235
- };
1236
-
1237
- class ThrottleClickDirective {
1238
- constructor() {
1239
- this.throttleTime = 300;
1240
- this.throttleClick = new EventEmitter();
1241
- this.clicks = new Subject();
1242
- }
1243
- clickEvent(event) {
1244
- event.preventDefault();
1245
- event.stopPropagation();
1246
- this.clicks.next(event);
1247
- }
1248
- ngOnInit() {
1249
- this.subscription = this.clicks.pipe(throttleTime(this.throttleTime)).subscribe(e => this.throttleClick.emit(e));
1250
- }
1251
- ngOnDestroy() {
1252
- this.subscription.unsubscribe();
1253
- }
1254
- }
1255
- ThrottleClickDirective.decorators = [
1256
- { type: Directive, args: [{
1257
- selector: '[madThrottleClick]',
1258
- },] }
1259
- ];
1260
- ThrottleClickDirective.propDecorators = {
1261
- throttleTime: [{ type: Input }],
1262
- throttleClick: [{ type: Output }],
1263
- clickEvent: [{ type: HostListener, args: ['click', ['$event'],] }]
1264
- };
1265
-
1266
- class ThrottleClickModule {
1267
- }
1268
- ThrottleClickModule.decorators = [
1269
- { type: NgModule, args: [{
1270
- declarations: [ThrottleClickDirective],
1271
- imports: [CommonModule],
1272
- exports: [ThrottleClickDirective],
1273
- },] }
1274
- ];
1275
-
1276
- class CardModule {
1277
- }
1278
- CardModule.decorators = [
1279
- { type: NgModule, args: [{
1280
- declarations: [CardComponent],
1281
- imports: [CommonModule, MatCardModule, MatIconModule, ButtonModule, MatButtonModule, ThrottleClickModule],
1282
- exports: [CardComponent],
1283
- },] }
1284
- ];
1285
-
1286
- class BaseQuickListComponent {
1287
- constructor(changeDetectorRef) {
1288
- this.changeDetectorRef = changeDetectorRef;
1289
- this.allItems = [];
1290
- this.addLabel = 'NOT SET';
1291
- this.addPossible = true;
1292
- this.removePossible = true;
1293
- this.blankItem = {};
1294
- this.added = new EventEmitter();
1295
- this.removed = new EventEmitter();
1296
- }
1297
- ngOnInit() {
1298
- this.addEventFunction = this.addItem.bind(this);
1299
- if (this.minItems) {
1300
- for (let n = this.allItems.length; n < this.minItems; n++) {
1301
- this.interalAddItem();
1302
- }
1303
- }
1304
- }
1305
- ngAfterViewInit() {
1306
- setTimeout(() => this.setFocusOnAdd(), 1);
1307
- }
1308
- addItem() {
1309
- const newItem = this.interalAddItem();
1310
- if (!!newItem) {
1311
- this.added.emit(newItem);
1312
- }
1313
- }
1314
- removeItem(item) {
1315
- if (this.isDeleteAllowed()) {
1316
- this.allItems.splice(this.allItems.indexOf(item), 1);
1317
- this.removed.emit(item);
1318
- }
1319
- }
1320
- setFocusOnAdd() {
1321
- this.rowCountFocus = this.itemRows.length;
1322
- this.itemRows.changes.subscribe((els) => {
1323
- if (els.length > this.rowCountFocus && !!els.last) {
1324
- const firstFocusable = els.last.nativeElement.querySelector("button, a, input, select, textarea, [tabindex]:not([tabindex='-1'])");
1325
- if (firstFocusable) {
1326
- firstFocusable.focus();
1327
- }
1328
- }
1329
- this.rowCountFocus = els.length;
1330
- });
1331
- }
1332
- isAddAllowed() {
1333
- return this.addPossible && (!this.maxItems || this.allItems.length < this.maxItems);
1334
- }
1335
- isDeleteAllowed() {
1336
- return this.removePossible && (!this.minItems || this.allItems.length > this.minItems);
1337
- }
1338
- interalAddItem() {
1339
- if (this.isAddAllowed()) {
1340
- const newItem = Object.assign({}, this.blankItem);
1341
- // creates ids in the form of "n5kdz1pljl8"
1342
- newItem.id = Math.random()
1343
- .toString(36)
1344
- .substring(2);
1345
- this.allItems.push(newItem);
1346
- this.changeDetectorRef.detectChanges();
1347
- return newItem;
1348
- }
1349
- return null;
1350
- }
1351
- }
1352
- BaseQuickListComponent.decorators = [
1353
- { type: Component, args: [{
1354
- selector: 'mad-base-quick-list',
1355
- template: ''
1356
- },] }
1357
- ];
1358
- BaseQuickListComponent.ctorParameters = () => [
1359
- { type: ChangeDetectorRef }
1360
- ];
1361
- BaseQuickListComponent.propDecorators = {
1362
- allItems: [{ type: Input }],
1363
- addLabel: [{ type: Input }],
1364
- addPossible: [{ type: Input }],
1365
- removePossible: [{ type: Input }],
1366
- blankItem: [{ type: Input }],
1367
- readonly: [{ type: Input }],
1368
- maxItems: [{ type: Input }],
1369
- minItems: [{ type: Input }],
1370
- added: [{ type: Output }],
1371
- removed: [{ type: Output }],
1372
- itemTemplate: [{ type: ContentChild, args: [TemplateRef,] }],
1373
- itemRows: [{ type: ViewChildren, args: ['row',] }]
1374
- };
1375
-
1376
- // Based on https://github.com/porscheinformatik/clarity-addons/blob/master/src/clr-addons/generic-quick-list/generic-quick-list.ts
1377
- class QuickListComponent extends BaseQuickListComponent {
1378
- constructor(changeDetectorRef) {
1379
- super(changeDetectorRef);
1380
- this.changeDetectorRef = changeDetectorRef;
1381
- }
1382
- }
1383
- QuickListComponent.decorators = [
1384
- { type: Component, args: [{
1385
- selector: 'mad-quick-list',
1386
- template: "<h3>\n <ng-content select=\"label\"></ng-content>\n</h3>\n<ng-container *ngFor=\"let item of allItems\">\n <div *ngIf=\"itemTemplate\" #row>\n <ng-container *ngTemplateOutlet=\"itemTemplate; context: { $implicit: item }\"></ng-container>\n <mad-icon-button *ngIf=\"!readonly && isDeleteAllowed()\" (click)=\"removeItem(item)\">\n <mat-icon>delete</mat-icon>\n </mad-icon-button>\n </div>\n</ng-container>\n<mad-link-button *ngIf=\"!readonly\" (click)=\"addItem()\"\n [disabled]=\"!addPossible || !isAddAllowed()\">\n {{ addLabel }}\n</mad-link-button>\n"
1387
- },] }
1388
- ];
1389
- QuickListComponent.ctorParameters = () => [
1390
- { type: ChangeDetectorRef }
1391
- ];
1392
-
1393
- class QuickListCompactComponent extends BaseQuickListComponent {
1394
- constructor(changeDetectorRef) {
1395
- super(changeDetectorRef);
1396
- this.changeDetectorRef = changeDetectorRef;
1397
- }
1398
- }
1399
- QuickListCompactComponent.decorators = [
1400
- { type: Component, args: [{
1401
- selector: 'mad-quick-list-compact',
1402
- template: "<h3>\n <ng-content select=\"label\"></ng-content>\n</h3>\n<ng-container *ngFor=\"let item of allItems; let isLast = last;\">\n <div class=\"flex-container\" *ngIf=\"itemTemplate\" #row>\n <ng-container *ngTemplateOutlet=\"itemTemplate; context: { $implicit: item }\"></ng-container>\n <mad-icon-button *ngIf=\"!readonly && isDeleteAllowed()\" (click)=\"removeItem(item)\">\n <mat-icon>delete</mat-icon>\n </mad-icon-button>\n <mad-icon-button *ngIf=\"!readonly && isLast\" [disabled]=\"!isAddAllowed()\" (click)=\"addItem()\">\n <mat-icon>add_circle_outline</mat-icon>\n </mad-icon-button>\n </div>\n</ng-container>\n<mad-link-button *ngIf=\"!readonly && !this.allItems.length\"\n (click)=\"addItem()\"\n [disabled]=\"!isAddAllowed()\">\n {{ addLabel }}\n</mad-link-button>\n"
1403
- },] }
1404
- ];
1405
- QuickListCompactComponent.ctorParameters = () => [
1406
- { type: ChangeDetectorRef }
1407
- ];
1408
-
1409
- class QuickListModule {
1410
- }
1411
- QuickListModule.decorators = [
1412
- { type: NgModule, args: [{
1413
- declarations: [QuickListComponent, BaseQuickListComponent, QuickListCompactComponent],
1414
- imports: [CommonModule, MatButtonModule, MatIconModule, ButtonModule],
1415
- exports: [QuickListComponent, QuickListCompactComponent, BaseQuickListComponent],
1416
- },] }
1417
- ];
1418
-
1419
- class TableComponent {
1420
- constructor() {
1421
- var _a;
1422
- this.columns = [];
1423
- this.filterLabel = 'NOT SET';
1424
- this.filterPlaceholder = 'NOT SET';
1425
- this.pageSizeOptions = [5, 10, 15];
1426
- this.defaultPageSize = ((_a = this.pageSizeOptions) === null || _a === void 0 ? void 0 : _a[0]) || 10;
1427
- this.rowActions = [];
1428
- this.tableActions = [];
1429
- this.tableAction = new EventEmitter();
1430
- this.rowAction = new EventEmitter();
1431
- this.sortEvent = new EventEmitter();
1432
- this.ACTION_COLUMN_NAME = '__action__';
1433
- this.isFilterEnabled = false;
1434
- this.isPaginationEnabled = false;
1435
- }
1436
- set displayedData(data) {
1437
- if (!this.dataSource) {
1438
- this.dataSource = new MatTableDataSource(data);
1439
- }
1440
- else {
1441
- this.dataSource.data = data;
1442
- }
1443
- }
1444
- set paginationEnabled(isPaginationEnabled) {
1445
- this.isPaginationEnabled = isPaginationEnabled;
1446
- // eslint-disable-next-line
1447
- const pageSize = this.isPaginationEnabled ? this.defaultPageSize : Number.MAX_VALUE;
1448
- if (this.dataSource.paginator) {
1449
- this.dataSource.paginator._changePageSize(pageSize);
1450
- }
1451
- }
1452
- set filterEnabled(isFilterEnabled) {
1453
- this.isFilterEnabled = isFilterEnabled;
1454
- this.setFilterValue(undefined);
1455
- }
1456
- ngOnInit() {
1457
- this.columnNames = this.columns.map(column => column.label);
1458
- this.isRowClickable = this.rowActions.length > 0;
1459
- if (this.isRowClickable) {
1460
- this.columnNames.unshift(this.ACTION_COLUMN_NAME);
1461
- this.defaultAction = this.rowActions[0];
1462
- }
1463
- }
1464
- ngAfterViewInit() {
1465
- this.dataSource.paginator = this.paginator;
1466
- this.dataSource.sort = this.sort;
1467
- // set custom filter predicate to enable search for multiple search strings:
1468
- // e.g. "one two three"
1469
- this.dataSource.filterPredicate = (data, filter) => !filter || filter.split(/\s+/).every(term => !!Object.keys(data).find(key => data[key].includes(term)));
1470
- }
1471
- onFilter(value) {
1472
- this.setFilterValue(value);
1473
- }
1474
- onRowEvent(event, row, action = this.defaultAction) {
1475
- if (!!action && !this.isClickOnRowMenuIcon(event)) {
1476
- this.rowAction.emit(Object.assign(Object.assign({}, action), { outputRow: row }));
1477
- }
1478
- }
1479
- onSortingEvent(sortingParams) {
1480
- this.sortEvent.emit(sortingParams);
1481
- }
1482
- onTableAction(tableAction) {
1483
- if (!!tableAction) {
1484
- this.tableAction.emit(tableAction);
1485
- }
1486
- }
1487
- setFilterValue(value) {
1488
- this.dataSource.filter = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
1489
- }
1490
- isClickOnRowMenuIcon(event) {
1491
- var _a;
1492
- return (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.classList.contains('mat-icon');
1493
- }
1494
- }
1495
- TableComponent.decorators = [
1496
- { type: Component, args: [{
1497
- selector: 'mad-table',
1498
- template: "<!-- Table actions -->\n<div *ngIf=\"tableActions?.length\">\n <mad-primary-button class=\"table-action\" *ngFor=\"let tableAction of tableActions\" (click)=\"onTableAction(tableAction)\">\n {{ tableAction.label }}\n </mad-primary-button>\n</div>\n\n<!-- Row action buttons -->\n<mat-menu #menu=\"matMenu\">\n <ng-template matMenuContent let-element=\"element\">\n <button *ngFor=\"let rowAction of rowActions\" mat-menu-item class=\"row-action\" (click)=\"onRowEvent($event, element, rowAction)\">\n {{ rowAction.label }}\n </button>\n </ng-template>\n</mat-menu>\n\n<!-- Table filter -->\n<mat-form-field *ngIf=\"isFilterEnabled\">\n <mat-label>{{ filterLabel }}</mat-label>\n <input matInput (keyup)=\"onFilter($event?.target?.value)\" placeholder=\"{{ filterPlaceholder }}\" />\n</mat-form-field>\n\n<!-- Table -->\n<div *ngIf=\"dataSource?.data?.length > 0; else noData\" class=\"mad-table\">\n <table mat-table [dataSource]=\"dataSource\" matSort (matSortChange)=\"onSortingEvent($event)\">\n <!-- Row actions column -->\n <ng-container [matColumnDef]=\"ACTION_COLUMN_NAME\" *ngIf=\"rowActions?.length\" sticky>\n <th mat-header-cell *matHeaderCellDef class=\"row-action-button\"></th>\n <td mat-cell *matCellDef=\"let element\" class=\"row-action-button\">\n <mad-icon-button [matMenuTriggerData]=\"{ element: element }\" [matMenuTriggerFor]=\"menu\">\n <mat-icon>more_vert</mat-icon>\n </mad-icon-button>\n </td>\n </ng-container>\n <!-- Columns with data -->\n <ng-container *ngFor=\"let column of columns\" [matColumnDef]=\"column.label\" [sticky]=\"column.isSticky\">\n <ng-container *ngIf=\"column.isSortable; else noSort\">\n <th\n mat-header-cell\n *matHeaderCellDef\n mat-sort-header=\"{{ column.label }}\"\n [arrowPosition]=\"column.isRightAligned ? 'before' : 'after'\"\n [class.text-right]=\"column.isRightAligned\"\n >\n {{ column.label }}\n </th>\n </ng-container>\n <ng-template #noSort>\n <th mat-header-cell *matHeaderCellDef [class.text-right]=\"column.isRightAligned\">\n {{ column.label }}\n </th>\n </ng-template>\n <td mat-cell *matCellDef=\"let element\" [class.text-right]=\"column.isRightAligned\">\n {{ element[column.dataPropertyName] }}\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"columnNames\"></tr>\n <tr\n mat-row\n [class.clickable-table-row]=\"isRowClickable\"\n (click)=\"onRowEvent($event, row)\"\n *matRowDef=\"let row; columns: columnNames\"\n ></tr>\n </table>\n</div>\n<!-- Pagination -->\n<mat-paginator\n [style.display]=\"isPaginationEnabled ? 'block' : 'none'\"\n [pageSize]=\"defaultPageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n showFirstLastButtons\n>\n</mat-paginator>\n\n<!-- No data alert -->\n<ng-template #noData>\n <div class=\"noDataText\">\n {{ noDataText }}\n </div>\n</ng-template>\n",
1499
- styles: [".text-right{text-align:right!important}.table-action{margin-bottom:.5em;margin-right:.5em}.row-action-button{width:10px}.noDataText{text-align:center;width:100%}.mad-table{overflow-x:auto;width:100%}"]
1500
- },] }
1501
- ];
1502
- TableComponent.propDecorators = {
1503
- columns: [{ type: Input }],
1504
- filterLabel: [{ type: Input }],
1505
- filterPlaceholder: [{ type: Input }],
1506
- noDataText: [{ type: Input }],
1507
- pageSizeOptions: [{ type: Input }],
1508
- defaultPageSize: [{ type: Input }],
1509
- rowActions: [{ type: Input }],
1510
- tableActions: [{ type: Input }],
1511
- tableAction: [{ type: Output }],
1512
- rowAction: [{ type: Output }],
1513
- sortEvent: [{ type: Output }],
1514
- paginator: [{ type: ViewChild, args: [MatPaginator, { static: false },] }],
1515
- sort: [{ type: ViewChild, args: [MatSort, { static: true },] }],
1516
- displayedData: [{ type: Input }],
1517
- paginationEnabled: [{ type: Input }],
1518
- filterEnabled: [{ type: Input }]
1519
- };
1520
-
1521
- class TableModule {
1522
- }
1523
- TableModule.decorators = [
1524
- { type: NgModule, args: [{
1525
- declarations: [TableComponent],
1526
- imports: [
1527
- CommonModule,
1528
- MatButtonModule,
1529
- MatIconModule,
1530
- MatFormFieldModule,
1531
- MatInputModule,
1532
- MatMenuModule,
1533
- MatPaginatorModule,
1534
- MatSortModule,
1535
- MatTableModule,
1536
- ButtonModule,
1537
- ],
1538
- exports: [TableComponent],
1539
- },] }
1540
- ];
1541
-
1542
- class DataTableActionType {
1543
- }
1544
- DataTableActionType.SINGLE = 'SINGLE';
1545
- DataTableActionType.BATCH = 'BATCH';
1546
- DataTableActionType.NONE = 'NONE';
1547
-
1548
- class DataTableColumnsModalComponent {
1549
- constructor(dialogRef, data) {
1550
- this.dialogRef = dialogRef;
1551
- this.data = data;
1552
- this.selectedColumns = [];
1553
- this.availableColumns = [];
1554
- this.filteredAvailableColumns = [];
1555
- }
1556
- ngOnInit() {
1557
- this.definition = this.data.definition;
1558
- for (const column of this.data.allColumns) {
1559
- const columnId = column.id;
1560
- const selectedColumnIds = this.definition.displayedColumns.map(col => col.id);
1561
- if (selectedColumnIds.includes(columnId)) {
1562
- this.selectedColumns.push(column);
1563
- }
1564
- else {
1565
- this.availableColumns.push(column);
1566
- }
1567
- }
1568
- this.clearFilterValue();
1569
- }
1570
- onDrop(event) {
1571
- if (event.previousContainer === event.container) {
1572
- moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
1573
- }
1574
- else {
1575
- const itemIndex = this.findMatchingItemIndex(event.previousContainer, event.item);
1576
- transferArrayItem(event.previousContainer.data, event.container.data, itemIndex, event.currentIndex);
1577
- this.clearFilterValue();
1578
- this.availableColumns.sort((a, b) => a.label.localeCompare(b.label));
1579
- }
1580
- }
1581
- onSave() {
1582
- this.definition.displayedColumns = this.selectedColumns;
1583
- const saveChange = {
1584
- action: 'SAVE',
1585
- definition: this.definition,
1586
- };
1587
- this.dialogRef.close(saveChange);
1588
- }
1589
- onDelete() {
1590
- const deleteChange = {
1591
- action: 'DELETE',
1592
- definition: this.definition,
1593
- };
1594
- this.dialogRef.close(deleteChange);
1595
- }
1596
- onCancel() {
1597
- this.dialogRef.close();
1598
- }
1599
- updateFilterValue() {
1600
- var _a;
1601
- if (((_a = this.searchFilter) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1602
- this.filteredAvailableColumns = this.availableColumns.filter(c => c.label.toLowerCase().includes(this.searchFilter.toLowerCase()));
1603
- }
1604
- else {
1605
- this.filteredAvailableColumns = [...this.availableColumns];
1606
- }
1607
- }
1608
- findMatchingItemIndex(previousContainer, item) {
1609
- const itemId = item.element.nativeElement.id;
1610
- const previousContainerItems = [...previousContainer.data];
1611
- if ((previousContainerItems === null || previousContainerItems === void 0 ? void 0 : previousContainerItems.length) < 1) {
1612
- return 0;
1613
- }
1614
- for (let itemIndex = 0; itemIndex < previousContainerItems.length; itemIndex++) {
1615
- if (previousContainerItems[itemIndex].id === itemId) {
1616
- return itemIndex;
1617
- }
1618
- }
1619
- return 0;
1620
- }
1621
- clearFilterValue() {
1622
- this.searchFilter = '';
1623
- this.filteredAvailableColumns = [...this.availableColumns];
1624
- }
1625
- }
1626
- DataTableColumnsModalComponent.decorators = [
1627
- { type: Component, args: [{
1628
- selector: 'mad-data-table-columns-modal.component',
1629
- template: "<h1 mat-dialog-title>{{ data?.titleLabel | translate }}</h1>\n<div mat-dialog-content>\n <div class=\"column-drag-main-content\">\n <div class=\"column-drag-container\">\n <div class=\"column-drag-info-area\">{{ data?.infoTextLabel | translate }}</div>\n <div class=\"column-drag-container-header\">{{ data?.selectedLabel | translate }}</div>\n <div\n cdkDropList\n #selectedList=\"cdkDropList\"\n [cdkDropListData]=\"selectedColumns\"\n [cdkDropListConnectedTo]=\"[availableList]\"\n class=\"column-drag-list selected-drag-list\"\n (cdkDropListDropped)=\"onDrop($event)\">\n <div class=\"column-drag-box\"\n *ngFor=\"let selectedColumn of selectedColumns; let i = index\"\n cdkDrag\n [id]=\"selectedColumn.id\"\n >\n {{i + 1}}. {{selectedColumn.label | translate }}\n </div>\n </div>\n </div>\n\n <div class=\"column-drag-container\">\n <div class=\"column-drag-info-area\">\n <!-- Table filter -->\n <mat-form-field>\n <mat-label>{{ data?.filterColumnsLabel | translate }}</mat-label>\n <input matInput autocomplete=\"off\" (keyup)=\"updateFilterValue()\"\n placeholder=\"{{ data?.filterColumnsPlaceHolder | translate }}\" [(ngModel)]=\"searchFilter\"/>\n <button *ngIf=\"searchFilter\" matSuffix mat-icon-button aria-label=\"Clear\" (click)=\"clearFilterValue()\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n </div>\n <div class=\"column-drag-container-header\">{{ data?.availableLabel | translate }}</div>\n <div\n cdkDropList\n cdkDropListSortingDisabled\n #availableList=\"cdkDropList\"\n [cdkDropListData]=\"availableColumns\"\n [cdkDropListConnectedTo]=\"[selectedList]\"\n class=\"column-drag-list\"\n (cdkDropListDropped)=\"onDrop($event)\">\n <div *ngFor=\"let availableColumn of filteredAvailableColumns\" class=\"column-drag-box\" cdkDrag [id]=\"availableColumn.id\">\n {{availableColumn.label}}\n </div>\n </div>\n </div>\n </div>\n\n</div>\n<div mat-dialog-actions [align]=\"'end'\">\n <mad-outline-button (click)=\"onCancel()\">\n {{ data?.cancelLabel | translate }}\n </mad-outline-button>\n <mad-danger-button *ngIf=\"data?.deleteDefinitionAllowed\" (click)=\"onDelete()\">\n {{ data?.deleteLabel | translate }}\n </mad-danger-button>\n <mad-primary-button (click)=\"onSave()\" [disabled]=\"!(this.selectedColumns?.length > 0)\">\n {{ data?.saveLabel | translate }}\n </mad-primary-button>\n</div>\n",
1630
- styles: [".column-drag-main-content{border-bottom:1px solid #f5f5f5;display:flex;flex-direction:row;justify-content:space-between;margin-bottom:16px;padding:8px 8px 16px;width:544px}.column-drag-container{display:inline-block;font-size:small;max-width:100%;vertical-align:top;width:256px}.info-box{margin-bottom:16px}.column-drag-info-area,.info-box{color:rgba(0,0,0,.66);font-size:small;width:100%}.column-drag-info-area{align-items:stretch;display:flex;flex-direction:column;height:36px;justify-content:right;margin-bottom:32px}.column-drag-list{background:#fff;border:1px solid #ccc;border-radius:4px;box-sizing:border-box;display:block;height:200px;overflow:auto}.column-drag-container-header{font-weight:700;margin-bottom:4px}.column-drag-box{align-items:center;background:#fff;border-bottom:1px solid #ccc;box-sizing:border-box;color:rgba(0,0,0,.87);cursor:move;display:flex;flex-direction:row;font-size:14px;height:40px;justify-content:space-between;padding:12px 10px}.cdk-drag-preview{border-radius:4px;box-shadow:0 5px 5px -3px rgba(0,0,0,.2),0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12);box-sizing:border-box}.cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.column-drag-box:last-child{border:none}.column-drag-list.cdk-drop-list-dragging .column-drag-box:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}"]
1631
- },] }
1632
- ];
1633
- DataTableColumnsModalComponent.ctorParameters = () => [
1634
- { type: MatDialogRef },
1635
- { type: undefined, decorators: [{ type: Inject, args: [MAT_DIALOG_DATA,] }] }
1636
- ];
1637
-
1638
- class DataTableComponent {
1639
- constructor(matDialog) {
1640
- this.matDialog = matDialog;
1641
- // Translations
1642
- this.filterLabel = 'Filter';
1643
- this.filterPlaceholder = '';
1644
- this.filterColumnsLabel = 'Filter';
1645
- this.filterColumnsPlaceHolder = 'Filter available columns';
1646
- this.noDataText = 'No matching data found';
1647
- this.columnSettingsModalTitleLabel = 'Column settings';
1648
- this.selectedLabel = 'Selected columns';
1649
- this.availableLabel = 'Available columns';
1650
- this.saveLabel = 'Save';
1651
- this.deleteLabel = 'Delete';
1652
- this.cancelLabel = 'Cancel';
1653
- this.infoTextLabel = 'Drag and drop a column to select or reorder it.';
1654
- this.pageSizeOptions = [5, 10, 15];
1655
- this.actions = [];
1656
- this.deleteDefinitionAllowed = false;
1657
- this.useAsync = false;
1658
- this.sortEvent = new EventEmitter();
1659
- this.actionEvent = new EventEmitter();
1660
- this.pageEvent = new EventEmitter();
1661
- this.allColumnsEvent = new EventEmitter();
1662
- this.columnDefinitionChangeEvent = new EventEmitter();
1663
- this.viewDefinitionChangeEvent = new EventEmitter();
1664
- this.ACTION_COLUMN_NAME = '__action__';
1665
- this.SINGLE = DataTableActionType.SINGLE;
1666
- this.BATCH = DataTableActionType.BATCH;
1667
- this.NONE = DataTableActionType.NONE;
1668
- this.tableActions = [];
1669
- this.rowActions = [];
1670
- this.columns = [];
1671
- this.allSelected = false;
1672
- this.displayedDataMap = new Map();
1673
- this.actualDataMap = new Map();
1674
- this.selectionModel = new SelectionModel(true);
1675
- this.allColumnDefinitions = [];
1676
- this.isFilterEnabled = false;
1677
- this.isPaginationEnabled = false;
1678
- this.mode = this.NONE;
1679
- this.isRowClickable = false;
1680
- this.showColumnModal = false;
1681
- this.isLoading = false;
1682
- this.paginatorLength = 0;
1683
- this.paginatorPageIndex = 0;
1684
- this.paginatorPageSize = 50;
1685
- }
1686
- set displayedColumns(cols) {
1687
- if (!this.displayedColumnDefinition) {
1688
- this.columns = cols ? [...cols] : [];
1689
- this.columnIds = this.columns.map(column => column.id);
1690
- this.columnIds.unshift(this.ACTION_COLUMN_NAME);
1691
- }
1692
- }
1693
- set displayedColumnDefinition(def) {
1694
- this.selectedColumnDefinion = def;
1695
- this.columns = def.displayedColumns;
1696
- this.columnIds = this.columns.map(column => column.id);
1697
- this.columnIds.unshift(this.ACTION_COLUMN_NAME);
1698
- }
1699
- set tableData(data) {
1700
- if (!this.dataSource) {
1701
- this.dataSource = new MatTableDataSource(data);
1702
- }
1703
- this.createDataMapsAndSetDisplayedDataSourceData(data);
1704
- }
1705
- set page(page) {
1706
- this.paginatorPageIndex = page.pageIndex;
1707
- this.paginatorPageSize = page.pageSize;
1708
- this.paginatorLength = page.length;
1709
- }
1710
- set columnDefinitions(definitions) {
1711
- var _a;
1712
- this.editableColumnDefinitions = [];
1713
- this.viewableColumnDefinitions = [];
1714
- this.allColumnDefinitions = [...definitions];
1715
- for (const definition of definitions) {
1716
- if (definition.editable) {
1717
- this.editableColumnDefinitions.push(definition);
1718
- }
1719
- if (((_a = definition.displayedColumns) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1720
- this.viewableColumnDefinitions.push(definition);
1721
- }
1722
- }
1723
- }
1724
- set loading(isLoading) {
1725
- this.isLoading = isLoading;
1726
- }
1727
- set defaultPageSize(defaultSize) {
1728
- this.paginatorPageSize = defaultSize;
1729
- }
1730
- set externalPaginator(paginator) {
1731
- this.extPaginator = paginator;
1732
- }
1733
- set paginationEnabled(isPaginationEnabled) {
1734
- this.isPaginationEnabled = isPaginationEnabled;
1735
- this.unsetPageSizeIfNecessary();
1736
- }
1737
- set allColumns(allColumns) {
1738
- this.allAvailableColumns = allColumns;
1739
- if (allColumns && this.showColumnModal) {
1740
- this.openColumnModal();
1741
- }
1742
- }
1743
- set filterEnabled(isFilterEnabled) {
1744
- this.isFilterEnabled = !this.useAsync ? isFilterEnabled : false;
1745
- this.setFilterValue(undefined);
1746
- }
1747
- set forceMode(mode) {
1748
- if (mode === this.SINGLE || mode === this.BATCH || mode === this.NONE) {
1749
- this._forceMode = mode;
1750
- this.mode = mode;
1751
- this.setActions();
1752
- }
1753
- }
1754
- static compare(a, b, sort) {
1755
- const x = a[sort.active];
1756
- const y = b[sort.active];
1757
- const ascending = sort.direction === 'asc';
1758
- switch (typeof x) {
1759
- case 'number':
1760
- return DataTableComponent.compareNumber(x, y, ascending);
1761
- case 'string':
1762
- return DataTableComponent.compareString(x, y, ascending);
1763
- case 'boolean':
1764
- return DataTableComponent.compareBoolean(x, y, ascending);
1765
- default:
1766
- // cannot compare -> return equal
1767
- return 0;
1768
- }
1769
- }
1770
- static compareNumber(x, y, ascending) {
1771
- return ascending ? x - y : y - x;
1772
- }
1773
- static compareString(x, y, ascending) {
1774
- return ascending ? x.localeCompare(y) : y.localeCompare(x);
1775
- }
1776
- static compareBoolean(x, y, ascending) {
1777
- if (x === y) {
1778
- return 0;
1779
- }
1780
- if (ascending) {
1781
- // true first
1782
- return x ? -1 : 1;
1783
- }
1784
- else {
1785
- // false first
1786
- return x ? 1 : -1;
1787
- }
1788
- }
1789
- static transformData(value, transformer, transformerParams) {
1790
- if (!transformer || !(transformer instanceof Function)) {
1791
- return value;
1792
- }
1793
- return transformer(value, transformerParams);
1794
- }
1795
- static generateRowId() {
1796
- return v4();
1797
- }
1798
- static isClickOnRowMenuIcon(event) {
1799
- var _a;
1800
- return (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.classList.contains('mat-icon');
1801
- }
1802
- ngOnInit() {
1803
- this.mode = this.getTableMode();
1804
- this.setActions();
1805
- if (this.mode !== this.NONE) {
1806
- this.isRowClickable = true;
1807
- this.defaultAction = this.rowActions[0];
1808
- }
1809
- }
1810
- ngAfterViewInit() {
1811
- this.dataSource.paginator = this.paginator;
1812
- this.dataSource.sort = this.sort;
1813
- }
1814
- onColumnSettings(definition) {
1815
- this.showColumnModal = true;
1816
- this.selectedDefinition = definition ? definition : this.allColumnDefinitions[0];
1817
- if (this.allAvailableColumns) {
1818
- this.openColumnModal();
1819
- }
1820
- else {
1821
- // if no complete definitions have been loaded yet send an event so the app can load it
1822
- this.allColumnsEvent.emit();
1823
- }
1824
- }
1825
- onViewDefinition(definition) {
1826
- this.selectedDefinition = definition;
1827
- this.viewDefinitionChangeEvent.emit(definition);
1828
- }
1829
- isCurrentDefinition(definition) {
1830
- return this.selectedDefinition && this.selectedDefinition.id === definition.id;
1831
- }
1832
- get selectedCount() {
1833
- var _a;
1834
- return ((_a = this.selectionModel) === null || _a === void 0 ? void 0 : _a.selected) ? this.selectionModel.selected.length : 0;
1835
- }
1836
- get rowCount() {
1837
- return this.getAllDataSourceRowsOfCurrentPage() ? this.getAllDataSourceRowsOfCurrentPage().length : 0;
1838
- }
1839
- getAllDataSourceRowsOfCurrentPage() {
1840
- var _a;
1841
- return (_a = this.dataSource) === null || _a === void 0 ? void 0 : _a._pageData(this.dataSource.data);
1842
- }
1843
- getSelectedCount(actionType) {
1844
- const count = this.selectedCount;
1845
- if (actionType !== this.BATCH || count < 2) {
1846
- return '';
1847
- }
1848
- return ' (' + count + ')';
1849
- }
1850
- isDisabled(actionType) {
1851
- switch (actionType) {
1852
- case this.SINGLE:
1853
- return this.selectedCount !== 1;
1854
- case this.BATCH:
1855
- return this.selectedCount < 1;
1856
- default:
1857
- return false;
1858
- }
1859
- }
1860
- onToggleSelectAll() {
1861
- // clear all selection first
1862
- this.selectionModel.clear();
1863
- // toggle all checkbox
1864
- this.allSelected = !this.allSelected;
1865
- if (this.allSelected) {
1866
- // select all rows of the current page
1867
- this.getAllDataSourceRowsOfCurrentPage().forEach(row => {
1868
- this.selectionModel.select('' + row.rowId);
1869
- });
1870
- }
1871
- }
1872
- isSelected(rowId) {
1873
- return this.selectionModel.isSelected(rowId);
1874
- }
1875
- setFilterValue(value) {
1876
- this.dataSource.filter = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
1877
- }
1878
- onRowCheckbox(event, row) {
1879
- event.stopPropagation(); // no click event on row
1880
- this.selectionModel.toggle(row.rowId);
1881
- }
1882
- onRowEvent(event, row, action = this.defaultAction) {
1883
- switch (this.mode) {
1884
- case this.BATCH:
1885
- this.onRowCheckbox(event, row);
1886
- break;
1887
- case this.SINGLE:
1888
- // emit the default action if the row (not the icon!) was clicked
1889
- if (!!action && !DataTableComponent.isClickOnRowMenuIcon(event)) {
1890
- const selected = [];
1891
- // if ID-generator is provided, return the ID, else return the ACTUAL data
1892
- selected.push(this.idGenerator ? row.rowId : this.actualDataMap.get(row.rowId));
1893
- this.emitTableAction(action, selected);
1894
- }
1895
- break;
1896
- default:
1897
- // do nothing if mode is NONE (or null)
1898
- return;
1899
- }
1900
- }
1901
- onSortingEvent(sort) {
1902
- if (this.useAsync) {
1903
- this.sortEvent.emit(sort);
1904
- }
1905
- else {
1906
- this.internalSort(sort);
1907
- }
1908
- }
1909
- onPageEvent(event) {
1910
- if (this.useAsync) {
1911
- this.pageEvent.emit(event);
1912
- }
1913
- }
1914
- onTableAction(tableAction) {
1915
- if (!!tableAction) {
1916
- const selection = [];
1917
- for (const selected of this.selectionModel.selected) {
1918
- selection.push(this.idGenerator ? selected : this.actualDataMap.get(selected));
1919
- }
1920
- tableAction.selected = selection;
1921
- this.actionEvent.emit(tableAction);
1922
- }
1923
- }
1924
- emitTableAction(action, selected) {
1925
- const emitAction = Object.assign({}, action);
1926
- if (action.type !== this.NONE) {
1927
- emitAction.selected = [...selected];
1928
- }
1929
- this.actionEvent.emit(emitAction);
1930
- }
1931
- generateDisplayedDataElement(rowId, actualDataElement) {
1932
- const displayedDataElement = {};
1933
- displayedDataElement.rowId = rowId;
1934
- for (const column of this.columns) {
1935
- const actualValue = actualDataElement[column.dataPropertyName];
1936
- displayedDataElement[column.dataPropertyName] = DataTableComponent.transformData(actualValue, column.transformer, column.transformerParams);
1937
- }
1938
- return displayedDataElement;
1939
- }
1940
- internalSort(sort) {
1941
- const sortedData = [...this.dataSource.data].sort((a, b) => DataTableComponent.compare(a, b, sort));
1942
- this.dataSource.data = [...sortedData];
1943
- }
1944
- setActions() {
1945
- this.rowActions = [];
1946
- this.tableActions = [];
1947
- for (const action of this.actions) {
1948
- if (this.mode !== action.hiddenInMode) {
1949
- switch (action.type) {
1950
- case this.SINGLE:
1951
- if (this.mode === this.SINGLE) {
1952
- this.rowActions.push(action);
1953
- }
1954
- else {
1955
- this.tableActions.push(action);
1956
- }
1957
- break;
1958
- case this.BATCH:
1959
- if (this.mode !== this.SINGLE) {
1960
- this.tableActions.push(action);
1961
- }
1962
- break;
1963
- default:
1964
- this.tableActions.push(action);
1965
- }
1966
- }
1967
- }
1968
- }
1969
- createDataMapsAndSetDisplayedDataSourceData(data) {
1970
- const displayedDataList = [];
1971
- this.actualDataMap.clear();
1972
- this.displayedDataMap.clear();
1973
- if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
1974
- for (const dataEntry of data) {
1975
- const rowId = this.idGenerator ? this.idGenerator(dataEntry) : DataTableComponent.generateRowId();
1976
- this.actualDataMap.set(rowId, dataEntry);
1977
- const displayedDataElement = this.generateDisplayedDataElement(rowId, dataEntry);
1978
- this.displayedDataMap.set(rowId, displayedDataElement);
1979
- displayedDataList.push(displayedDataElement);
1980
- }
1981
- }
1982
- this.dataSource.data = displayedDataList;
1983
- this.unsetPageSizeIfNecessary();
1984
- }
1985
- openColumnModal() {
1986
- const dialogData = {
1987
- allColumns: this.allAvailableColumns,
1988
- definition: this.selectedDefinition,
1989
- deleteDefinitionAllowed: this.deleteDefinitionAllowed,
1990
- filterColumnsLabel: this.filterColumnsLabel,
1991
- filterColumnsPlaceHolder: this.filterColumnsPlaceHolder,
1992
- noDataText: this.noDataText,
1993
- titleLabel: this.columnSettingsModalTitleLabel,
1994
- selectedLabel: this.selectedLabel,
1995
- availableLabel: this.availableLabel,
1996
- saveLabel: this.saveLabel,
1997
- deleteLabel: this.deleteLabel,
1998
- cancelLabel: this.cancelLabel,
1999
- infoTextLabel: this.infoTextLabel,
2000
- };
2001
- const dialog = this.matDialog.open(DataTableColumnsModalComponent, { data: dialogData });
2002
- dialog.afterClosed().subscribe(result => {
2003
- // no event on CANCEL
2004
- if (result) {
2005
- this.columnDefinitionChangeEvent.emit(result);
2006
- }
2007
- });
2008
- }
2009
- getTableMode() {
2010
- if (this._forceMode) {
2011
- return this._forceMode;
2012
- }
2013
- if (!this.actions) {
2014
- return this.NONE;
2015
- }
2016
- const distinctActionTypes = new Set();
2017
- for (const rowAction of this.actions) {
2018
- distinctActionTypes.add(rowAction.type);
2019
- }
2020
- if (distinctActionTypes.has(this.BATCH)) {
2021
- return this.BATCH;
2022
- }
2023
- if (distinctActionTypes.has(this.SINGLE)) {
2024
- return this.SINGLE;
2025
- }
2026
- return this.NONE;
2027
- }
2028
- unsetPageSizeIfNecessary() {
2029
- if (!this.useAsync && !this.isPaginationEnabled) {
2030
- const dataCount = this.dataSource.data ? this.dataSource.data.length : 0;
2031
- this.paginatorPageSize = dataCount;
2032
- this.paginatorLength = dataCount;
2033
- }
2034
- }
2035
- }
2036
- DataTableComponent.decorators = [
2037
- { type: Component, args: [{
2038
- selector: 'mad-data-table',
2039
- template: "<div class=\"mad-datatable-action-bar\">\n <!-- Table actions: displayed before the table -->\n <div *ngIf=\"tableActions?.length\">\n <mad-outline-button\n [disabled]=\"isDisabled(tableAction.type)\"\n class=\"table-action\"\n *ngFor=\"let tableAction of tableActions\"\n (click)=\"onTableAction(tableAction)\">\n {{ tableAction.label | translate }} {{ getSelectedCount(tableAction.type) }}\n </mad-outline-button>\n </div>\n <!-- Table filter -->\n <mat-form-field *ngIf=\"isFilterEnabled\">\n <mat-label>{{ filterLabel | translate }}</mat-label>\n <input matInput autocomplete=\"off\" (keyup)=\"setFilterValue($event?.target?.value)\"\n placeholder=\"{{ filterPlaceholder }}\" />\n </mat-form-field>\n</div>\n\n\n<!-- Row action menu -->\n<mat-menu #rowActionMenu=\"matMenu\">\n <ng-template matMenuContent let-element=\"element\">\n <button *ngFor=\"let rowAction of rowActions\" mat-menu-item class=\"row-action\"\n (click)=\"onRowEvent($event, element, rowAction)\">\n {{ rowAction.label | translate }}\n </button>\n </ng-template>\n</mat-menu>\n\n<!-- editable definition menu -->\n<mat-menu #editableDefinitionMenu=\"matMenu\">\n <ng-template matMenuContent>\n <button *ngFor=\"let definition of editableColumnDefinitions\"\n mat-menu-item\n class=\"row-action\"\n (click)=\"onColumnSettings(definition)\"\n [ngClass]=\"{'active-column-definition': isCurrentDefinition(definition)}\"\n >\n {{ definition.label | translate }}\n </button>\n </ng-template>\n</mat-menu>\n\n<!-- viewable definition menu -->\n<mat-menu #viewableDefinitionMenu=\"matMenu\">\n <ng-template matMenuContent>\n <button *ngFor=\"let definition of viewableColumnDefinitions\"\n mat-menu-item\n class=\"row-action\"\n (click)=\"onViewDefinition(definition)\"\n [ngClass]=\"{'active-column-definition': isCurrentDefinition(definition)}\"\n >\n {{ definition.label | translate }}\n </button>\n </ng-template>\n</mat-menu>\n\n<!-- Table -->\n<div *ngIf=\"rowCount > 0; else noData\" class=\"datatable\" [class]=\"tableClass\">\n <div class=\"mad-datatable-spinner-wrapper\" *ngIf=\"isLoading\">\n <mat-spinner [diameter]=\"50\" [strokeWidth]=\"3\"></mat-spinner>\n </div>\n\n <table mat-table [dataSource]=\"dataSource\" matSort (matSortChange)=\"onSortingEvent($event)\">\n <!-- Row actions column-->\n <ng-container [matColumnDef]=\"ACTION_COLUMN_NAME\">\n <th scope=\"col\" mat-header-cell *matHeaderCellDef class=\"row-action-button\">\n <!-- BATCH: master checkbox -->\n <div *ngIf=\"mode === BATCH\" class=\"mad-datatable-checkbox-container\">\n <mat-checkbox\n (change)=\"onToggleSelectAll()\"\n [checked]=\"allSelected\"\n >\n </mat-checkbox>\n </div>\n <!-- SINGLE / NONE: nothing in header row -->\n </th>\n <td mat-cell *matCellDef=\"let element\" class=\"row-action-button\">\n <!-- BATCH: row checkbox -->\n <div *ngIf=\"mode === BATCH\" class=\"mad-datatable-checkbox-container\">\n <mat-checkbox\n (click)=\"onRowCheckbox($event, element.rowId)\"\n [checked]=\"isSelected(element.rowId)\"\n >\n </mat-checkbox>\n </div>\n <!-- SINGLE: row action menu icon -->\n <mad-icon-button\n *ngIf=\"mode === SINGLE\"\n [matMenuTriggerData]=\"{ element: element }\" [matMenuTriggerFor]=\"rowActionMenu\"\n >\n <mat-icon>more_vert</mat-icon>\n </mad-icon-button>\n <!-- NONE: nothing -->\n </td>\n </ng-container>\n <!-- Columns with data -->\n <ng-container *ngFor=\"let column of columns\" [matColumnDef]=\"column.id\">\n <ng-container *ngIf=\"column.isSortable; else noSort\">\n <th\n scope=\"col\"\n mat-header-cell\n *matHeaderCellDef\n mat-sort-header=\"{{ column.orderByName? column.orderByName : column.dataPropertyName }}\"\n [arrowPosition]=\"column.isRightAligned ? 'before' : 'after'\"\n [class.text-right]=\"column.isRightAligned\"\n >\n {{ column.label | translate }}\n </th>\n </ng-container>\n <ng-template #noSort>\n <th scope=\"col\" mat-header-cell *matHeaderCellDef [class.text-right]=\"column.isRightAligned\">\n {{ column.label | translate }}\n </th>\n </ng-template>\n <td mat-cell *matCellDef=\"let element\" [class.text-right]=\"column.isRightAligned\" [ngSwitch]=\"column.transformer\">\n <span>\n {{ element[column.dataPropertyName] }}\n </span>\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"columnIds\"></tr>\n <tr\n mat-row\n [class.clickable-table-row]=\"isRowClickable\"\n (click)=\"onRowEvent($event, row)\"\n *matRowDef=\"let row; columns: columnIds\"\n ></tr>\n </table>\n</div>\n<div class=\"mad-data-table-bottom-area\">\n <div class=\"mad-data-table-bottom-info-area\">\n <!-- column settings: 1 definition -->\n <mad-icon-button\n *ngIf=\"this.editableColumnDefinitions?.length == 1\"\n (click)=\"onColumnSettings()\"\n >\n <mat-icon class=\"material-icons-outlined\">view_column</mat-icon>\n </mad-icon-button>\n <!-- column settings: multiple definitions -->\n <mad-icon-button\n *ngIf=\"this.editableColumnDefinitions?.length > 0\" [matMenuTriggerFor]=\"editableDefinitionMenu\"\n >\n <mat-icon>view_column</mat-icon>\n </mad-icon-button>\n <!-- column view: multiple definitions -->\n <mad-icon-button\n *ngIf=\"this.viewableColumnDefinitions?.length > 0\" [matMenuTriggerFor]=\"viewableDefinitionMenu\"\n >\n <mat-icon>preview</mat-icon>\n </mad-icon-button>\n </div>\n\n <!-- Pagination -->\n <mat-paginator\n [style.display]=\"isPaginationEnabled ? 'block' : 'none'\"\n [length]=\"paginatorLength\"\n [pageIndex]=\"paginatorPageIndex\"\n [pageSize]=\"paginatorPageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n (page)=\"onPageEvent($event)\"\n showFirstLastButtons\n >\n </mat-paginator>\n</div>\n\n<!-- No data alert -->\n<ng-template #noData>\n <div class=\"noDataText\">\n <div class=\"mad-datatable-spinner-wrapper\" *ngIf=\"isLoading\">\n <mat-spinner [diameter]=\"50\" [strokeWidth]=\"3\"></mat-spinner>\n </div>\n {{ noDataText }}\n </div>\n</ng-template>\n",
2040
- styles: [":host{background-color:#fff;display:flex;flex:1 1 auto;flex-direction:column;min-height:112px}.datatable-vertical-stretch-to-parent{display:flex;flex:1;flex-direction:column;max-height:100%;width:100%}.datatable-max-height-500{max-height:500px}.datatable-max-height-300{max-height:300px}.datatable-max-height,.datatable-max-height-300,.datatable-max-height-500{display:flex;flex:1;flex-direction:column;width:100%}.datatable{flex:1 1 auto;height:100%;overflow:auto;position:relative;width:100%}.datatable table{max-height:100%;width:100%}.datatable td,.datatable th{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:auto}.text-right{padding-right:24px!important;text-align:right!important}.table-action{margin-bottom:.5em;margin-right:.5em}.row-action-button{width:10px}.noDataText{position:relative;text-align:center;width:100%}.mad-datatable-action-bar{align-items:baseline;display:flex;justify-content:space-between}.mad-datatable-checkbox-container{margin-right:16px}.mad-datatable-spinner-wrapper{align-items:center;background-color:#fff;display:flex;height:100%;justify-content:center;left:0;opacity:.8;pointer-events:unset;position:absolute;top:0;width:100%;z-index:99999}.mad-data-table-bottom-area{display:flex;flex-direction:row}.mad-data-table-bottom-area .mad-data-table-bottom-info-area{display:flex;flex:1}.mat-header-row th{background-color:#fff;position:-webkit-sticky;position:sticky;top:0;z-index:1}.active-column-definition{background-color:#f5f5f5;color:#000}"]
2041
- },] }
2042
- ];
2043
- DataTableComponent.ctorParameters = () => [
2044
- { type: MatDialog }
2045
- ];
2046
- DataTableComponent.propDecorators = {
2047
- filterLabel: [{ type: Input }],
2048
- filterPlaceholder: [{ type: Input }],
2049
- filterColumnsLabel: [{ type: Input }],
2050
- filterColumnsPlaceHolder: [{ type: Input }],
2051
- noDataText: [{ type: Input }],
2052
- columnSettingsModalTitleLabel: [{ type: Input }],
2053
- selectedLabel: [{ type: Input }],
2054
- availableLabel: [{ type: Input }],
2055
- saveLabel: [{ type: Input }],
2056
- deleteLabel: [{ type: Input }],
2057
- cancelLabel: [{ type: Input }],
2058
- infoTextLabel: [{ type: Input }],
2059
- tableClass: [{ type: Input }],
2060
- pageSizeOptions: [{ type: Input }],
2061
- externalFilter: [{ type: Input }],
2062
- actions: [{ type: Input }],
2063
- idGenerator: [{ type: Input }],
2064
- deleteDefinitionAllowed: [{ type: Input }],
2065
- useAsync: [{ type: Input }],
2066
- displayedColumns: [{ type: Input }],
2067
- displayedColumnDefinition: [{ type: Input }],
2068
- tableData: [{ type: Input }],
2069
- page: [{ type: Input }],
2070
- columnDefinitions: [{ type: Input }],
2071
- loading: [{ type: Input }],
2072
- defaultPageSize: [{ type: Input }],
2073
- externalPaginator: [{ type: Input }],
2074
- paginationEnabled: [{ type: Input }],
2075
- allColumns: [{ type: Input }],
2076
- filterEnabled: [{ type: Input }],
2077
- forceMode: [{ type: Input }],
2078
- sortEvent: [{ type: Output }],
2079
- actionEvent: [{ type: Output }],
2080
- pageEvent: [{ type: Output }],
2081
- allColumnsEvent: [{ type: Output }],
2082
- columnDefinitionChangeEvent: [{ type: Output }],
2083
- viewDefinitionChangeEvent: [{ type: Output }],
2084
- paginator: [{ type: ViewChild, args: [MatPaginator, { static: false },] }],
2085
- sort: [{ type: ViewChild, args: [MatSort, { static: true },] }]
2086
- };
2087
-
2088
- class DataTableModule {
2089
- }
2090
- DataTableModule.decorators = [
2091
- { type: NgModule, args: [{
2092
- declarations: [DataTableComponent, DataTableColumnsModalComponent],
2093
- imports: [
2094
- CommonModule,
2095
- MatButtonModule,
2096
- MatIconModule,
2097
- MatFormFieldModule,
2098
- MatInputModule,
2099
- MatMenuModule,
2100
- MatPaginatorModule,
2101
- MatSortModule,
2102
- MatTableModule,
2103
- MatProgressSpinnerModule,
2104
- ButtonModule,
2105
- TranslateModule,
2106
- MatCheckboxModule,
2107
- MatBadgeModule,
2108
- DragDropModule,
2109
- FormsModule,
2110
- ],
2111
- exports: [DataTableComponent, DataTableColumnsModalComponent],
2112
- },] }
2113
- ];
2114
-
2115
- class StepHeaderComponent extends CdkStepHeader {
2116
- constructor(_focusMonitor, _elementRef) {
2117
- super(_elementRef);
2118
- this._focusMonitor = _focusMonitor;
2119
- }
2120
- ngAfterViewInit() {
2121
- this._focusMonitor.monitor(this._elementRef, true);
2122
- }
2123
- ngOnDestroy() {
2124
- this._focusMonitor.stopMonitoring(this._elementRef);
2125
- }
2126
- /** Focuses the step header. */
2127
- focus(origin, options) {
2128
- if (origin) {
2129
- this._focusMonitor.focusVia(this._elementRef, origin, options);
2130
- }
2131
- else {
2132
- this._elementRef.nativeElement.focus(options);
2133
- }
2134
- }
2135
- getCssForState() {
2136
- if (this.state === STEP_STATE.NUMBER && !this.completed && !this.hasError) {
2137
- return 'step-state-neutral'; //initiale state is 'number'
2138
- }
2139
- else if (this.completed) {
2140
- return 'step-state-complete';
2141
- }
2142
- else if (this.hasError) {
2143
- return 'step-state-error';
2144
- }
2145
- }
2146
- getIcon() {
2147
- if (this.completed) {
2148
- return 'check_circle_outline';
2149
- }
2150
- else if (this.hasError) {
2151
- return 'error_outline';
2152
- }
2153
- return '';
2154
- }
2155
- }
2156
- StepHeaderComponent.decorators = [
2157
- { type: Component, args: [{
2158
- selector: 'mad-step-header',
2159
- template: "<div\n class=\"header\"\n fxLayout=\"row\"\n fxLayoutGap=\"1em\"\n [style.background]=\"this.selected && !this.closed ? '#d8e2e9' : '#ffffff'\"\n [ngClass]=\"this.hasError ? 'error-border' : 'check-border'\"\n>\n <div [ngClass]=\"this.getCssForState()\"></div>\n <div class=\"header-label\">\n <mat-icon class=\"material-icons-outlined\">\n {{ this.selected && !this.closed ? 'keyboard_arrow_down' : 'keyboard_arrow_right' }}\n </mat-icon>\n </div>\n <div *ngIf=\"this.completed || this.hasError\" class=\"header-label\">\n <mat-icon [ngClass]=\"this.completed ? 'green-check' : 'red-error'\">\n {{ getIcon() }}\n </mat-icon>\n </div>\n <span *ngIf=\"!this.hasError && !this.completed\" class=\"header-label\">{{ this.index + 1 + '.' }}</span>\n <div class=\"header-label\">{{ this.label }}</div>\n</div>\n",
2160
- inputs: ['color'],
2161
- host: {
2162
- class: 'mad-step-header',
2163
- role: 'tab',
2164
- },
2165
- encapsulation: ViewEncapsulation.None,
2166
- changeDetection: ChangeDetectionStrategy.OnPush,
2167
- styles: [".header{-webkit-tap-highlight-color:transparent;border:1px solid #d3d3d3;box-sizing:content-box;cursor:pointer;height:62px;outline:var(--warn-color);overflow:hidden;width:100%}.header-label{align-items:center;display:flex}.step-state-complete{background:green;width:5px}.step-state-error{background:var(--warn-color);width:5px}.step-state-neutral{background:#d3d3d3;width:5px}.green-check{color:green}.red-error{color:var(--warn-color)}.check-border{border-color:#d3d3d3}.error-border{border-color:var(--warn-color)}"]
2168
- },] }
2169
- ];
2170
- StepHeaderComponent.ctorParameters = () => [
2171
- { type: FocusMonitor },
2172
- { type: ElementRef }
2173
- ];
2174
- StepHeaderComponent.propDecorators = {
2175
- index: [{ type: Input }],
2176
- label: [{ type: Input }],
2177
- state: [{ type: Input }],
2178
- errorMessage: [{ type: Input }],
2179
- selected: [{ type: Input }],
2180
- active: [{ type: Input }],
2181
- optional: [{ type: Input }],
2182
- hasError: [{ type: Input }],
2183
- completed: [{ type: Input }],
2184
- closed: [{ type: Input }]
2185
- };
2186
-
2187
- /**
2188
- * Animations used by the MAD stepper.
2189
- */
2190
- const madStepperAnimations = {
2191
- verticalStepTransition: trigger('stepTransition', [
2192
- state('previous', style({ height: '0px', visibility: 'hidden' })),
2193
- state('next', style({ height: '0px', visibility: 'hidden' })),
2194
- state('current', style({ height: '*', visibility: 'visible' })),
2195
- transition('* <=> current', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
2196
- ]),
2197
- };
2198
-
2199
- class StepComponent extends CdkStep {
2200
- constructor(stepper, _viewContainerRef) {
2201
- super(stepper);
2202
- this.stepper = stepper;
2203
- this._viewContainerRef = _viewContainerRef;
2204
- /** Action event for the next button. If not set the StepComponent will handle the step navigation */
2205
- this.onNext = new EventEmitter();
2206
- /** Action event for the done button. If not set the StepComponent will handle the step navigation */
2207
- this.onDone = new EventEmitter();
2208
- /*** Action event when the header is clicked. If not set the StepComponent will handle the step navigation*/
2209
- this.onHeaderClick = new EventEmitter();
2210
- this.stepClosed = false;
2211
- this._isSelected = Subscription.EMPTY;
2212
- }
2213
- ngAfterContentInit() {
2214
- this._isSelected = this._stepper.steps.changes
2215
- .pipe(switchMap(() => this._stepper.selectionChange.pipe(map(event => event.selectedStep === this), tap(() => (this.stepClosed = false)), startWith(this._stepper.selected === this))))
2216
- .subscribe();
2217
- }
2218
- ngOnDestroy() {
2219
- this._isSelected.unsubscribe();
2220
- }
2221
- next(markFormAsTouched = true) {
2222
- this.stepValidation(markFormAsTouched);
2223
- if (this.onNext.observers.length <= 0) {
2224
- this.stepper.next();
2225
- }
2226
- this.onNext.emit();
2227
- }
2228
- selectAndMarkAsTouched(index) {
2229
- var _a, _b;
2230
- //Mark current selected step as touched before selecting to display errors in the from
2231
- (_b = (_a = this._stepper.selected) === null || _a === void 0 ? void 0 : _a.stepControl) === null || _b === void 0 ? void 0 : _b.markAllAsTouched();
2232
- this.stepClosed = false;
2233
- if (this.onHeaderClick.observers.length <= 0) {
2234
- this.select();
2235
- }
2236
- this.onHeaderClick.emit(index);
2237
- }
2238
- completeLast() {
2239
- this.stepValidation(true);
2240
- this.stepClosed = true;
2241
- if (this.onDone.observers.length <= 0) {
2242
- this.stepper.next();
2243
- }
2244
- this.onDone.emit();
2245
- }
2246
- resetValidations() {
2247
- this.hasError = false;
2248
- this.completed = true;
2249
- this.state = STEP_STATE.DONE;
2250
- }
2251
- stepValidation(markFormAsTouched) {
2252
- var _a, _b;
2253
- if (markFormAsTouched) {
2254
- (_a = this.stepControl) === null || _a === void 0 ? void 0 : _a.markAllAsTouched();
2255
- }
2256
- if ((_b = this.stepControl) === null || _b === void 0 ? void 0 : _b.valid) {
2257
- this.hasError = false;
2258
- this.completed = true;
2259
- this.state = STEP_STATE.DONE;
2260
- }
2261
- else {
2262
- this.completed = false;
2263
- this.hasError = true;
2264
- this.state = STEP_STATE.ERROR;
2265
- }
2266
- }
2267
- }
2268
- StepComponent.decorators = [
2269
- { type: Component, args: [{
2270
- selector: 'mad-step',
2271
- template: "<ng-template let-last=\"last\" let-nextBtnLbl=\"nextBtnLbl\" let-doneBtnLbl=\"doneBtnLbl\">\n <div class=\"step-container\" fxLayout=\"column\">\n <div class=\"step-content\">\n <ng-content></ng-content>\n </div>\n <div class=\"step-buttons\">\n <div *ngIf=\"!last\">\n <button mat-stroked-button color=\"primary\" (click)=\"next()\">{{nextBtnLbl}}</button>\n </div>\n <div *ngIf=\"last\">\n <button mat-stroked-button color=\"primary\" (click)=\"completeLast()\">{{doneBtnLbl}}</button>\n </div>\n </div>\n </div>\n</ng-template>\n",
2272
- providers: [{ provide: CdkStep, useExisting: StepComponent }],
2273
- encapsulation: ViewEncapsulation.None,
2274
- changeDetection: ChangeDetectionStrategy.OnPush,
2275
- styles: [".stepper-vertical{display:block}.mat-vertical-stepper-header{align-items:center;border:none!important;display:flex;height:10px}.mat-vertical-stepper-header .mat-step-icon{margin-right:12px}.vertical-content-container{border:none}[dir=rtl] .vertical-content-container{margin-left:0;margin-right:36px}.vertical-stepper-content{outline:0;overflow:hidden}.vertical-content{padding:0 24px}.step-container{border-bottom:1px solid #d3d3d3;border-left:1px solid #d3d3d3;border-right:1px solid #d3d3d3}.step-buttons,.step-content{padding:2em}"]
2276
- },] }
2277
- ];
2278
- StepComponent.ctorParameters = () => [
2279
- { type: StepperComponent, decorators: [{ type: Inject, args: [forwardRef(() => StepperComponent),] }] },
2280
- { type: ViewContainerRef }
2281
- ];
2282
- StepComponent.propDecorators = {
2283
- onNext: [{ type: Output }],
2284
- onDone: [{ type: Output }],
2285
- onHeaderClick: [{ type: Output }]
2286
- };
2287
- class StepperComponent extends CdkStepper {
2288
- constructor(dir, changeDetectorRef, elementRef, _document) {
2289
- super(dir, changeDetectorRef, elementRef, _document);
2290
- /** Event emitted when the current step is done transitioning in. */
2291
- this.animationDone = new EventEmitter();
2292
- /** Steps that belong to the current stepper, excluding ones from nested steppers. */
2293
- this.steps = new QueryList();
2294
- this._animationDone = new Subject();
2295
- this._orientation = 'vertical';
2296
- }
2297
- ngOnInit() {
2298
- // Only linear stepper implementation is supported
2299
- super.linear = true;
2300
- }
2301
- ngAfterContentInit() {
2302
- super.ngAfterContentInit();
2303
- this.steps.changes.pipe(takeUntil(this._destroyed)).subscribe(() => {
2304
- this._stateChanged();
2305
- });
2306
- this._animationDone
2307
- .pipe(distinctUntilChanged((x, y) => x.fromState === y.fromState && x.toState === y.toState), takeUntil(this._destroyed))
2308
- .subscribe(event => {
2309
- if (event.toState === 'current') {
2310
- this.animationDone.emit();
2311
- }
2312
- });
2313
- }
2314
- /**
2315
- * Method patched to enable the closing of the last step.
2316
- */
2317
- _getAnimationDirection(index) {
2318
- var _a, _b;
2319
- const closeLastStep = this.selectedIndex === this.steps.length - 1 && ((_a = this._steps.last) === null || _a === void 0 ? void 0 : _a.completed) && ((_b = this._steps.last) === null || _b === void 0 ? void 0 : _b.stepClosed);
2320
- if (closeLastStep) {
2321
- return 'next';
2322
- }
2323
- return super._getAnimationDirection(index);
2324
- }
2325
- _stepIsNavigable(index, step) {
2326
- return step.completed || this.selectedIndex === index || !this.linear;
2327
- }
2328
- }
2329
- StepperComponent.decorators = [
2330
- { type: Component, args: [{
2331
- selector: 'mad-stepper',
2332
- template: "<!-- Vertical stepper -->\n<ng-container>\n <div *ngFor=\"let step of steps; let i = index; let isLast = last; let isFirst = first\">\n <ng-container\n [ngTemplateOutlet]=\"stepTemplate\"\n [ngTemplateOutletContext]=\"{step: step, i: i}\"></ng-container>\n <div class=\"vertical-content-container\" [class.mat-stepper-vertical-line]=\"!isLast\">\n <div class=\"vertical-stepper-content\" role=\"tabpanel\"\n [@stepTransition]=\"_getAnimationDirection(i)\"\n (@stepTransition.done)=\"_animationDone.next($event)\"\n [id]=\"_getStepContentId(i)\"\n [attr.aria-labelledby]=\"_getStepLabelId(i)\"\n [attr.aria-expanded]=\"selectedIndex === i\">\n <div class=\"vertical-content\">\n <ng-container [ngTemplateOutlet]=\"step.content\"\n [ngTemplateOutletContext]=\"{step: step, i: i, last: isLast, first: isFirst, nextBtnLbl: this.nextButtonLabel, doneBtnLbl: this.doneButtonLabel}\"></ng-container>\n </div>\n </div>\n </div>\n </div>\n</ng-container>\n\n<ng-template let-step=\"step\" let-i=\"i\" #stepTemplate>\n <mad-step-header\n class=\"mat-vertical-stepper-header\"\n (click)=\"step.selectAndMarkAsTouched(i)\"\n (keydown)=\"_onKeydown($event)\"\n [tabIndex]=\"_getFocusIndex() === i ? 0 : -1\"\n [id]=\"_getStepLabelId(i)\"\n [attr.aria-posinset]=\"i + 1\"\n [attr.aria-setsize]=\"steps.length\"\n [attr.aria-controls]=\"_getStepContentId(i)\"\n [attr.aria-selected]=\"selectedIndex == i\"\n [attr.aria-label]=\"step.ariaLabel || null\"\n [attr.aria-labelledby]=\"(!step.ariaLabel && step.ariaLabelledby) ? step.ariaLabelledby : null\"\n [attr.aria-disabled]=\"_stepIsNavigable(i, step) ? null : true\"\n [index]=\"i\"\n [completed]=\"step.completed\"\n [hasError]=\"step.hasError\"\n [state]=\"_getIndicatorType(i, step.state)\"\n [label]=\"step.stepLabel || step.label\"\n [selected]=\"selectedIndex === i\"\n [active]=\"_stepIsNavigable(i, step)\"\n [optional]=\"step.optional\"\n [closed]=\"step.stepClosed\"\n [errorMessage]=\"step.errorMessage\"></mad-step-header>\n</ng-template>\n",
2333
- host: {
2334
- '[class.stepper-vertical]': 'true',
2335
- '[attr.aria-orientation]': '"vertical"',
2336
- role: 'tablist',
2337
- },
2338
- animations: [madStepperAnimations.verticalStepTransition],
2339
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
2340
- providers: [{ provide: CdkStepper, useExisting: StepperComponent }],
2341
- encapsulation: ViewEncapsulation.None,
2342
- changeDetection: ChangeDetectionStrategy.OnPush,
2343
- styles: [".stepper-vertical{display:block}.mat-vertical-stepper-header{align-items:center;border:none!important;display:flex;height:10px}.mat-vertical-stepper-header .mat-step-icon{margin-right:12px}.vertical-content-container{border:none}[dir=rtl] .vertical-content-container{margin-left:0;margin-right:36px}.vertical-stepper-content{outline:0;overflow:hidden}.vertical-content{padding:0 24px}.step-container{border-bottom:1px solid #d3d3d3;border-left:1px solid #d3d3d3;border-right:1px solid #d3d3d3}.step-buttons,.step-content{padding:2em}"]
2344
- },] }
2345
- ];
2346
- StepperComponent.ctorParameters = () => [
2347
- { type: Directionality, decorators: [{ type: Optional }] },
2348
- { type: ChangeDetectorRef },
2349
- { type: ElementRef },
2350
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2351
- ];
2352
- StepperComponent.propDecorators = {
2353
- animationDone: [{ type: Output }],
2354
- nextButtonLabel: [{ type: Input }],
2355
- doneButtonLabel: [{ type: Input }],
2356
- _stepHeader: [{ type: ViewChildren, args: [StepHeaderComponent,] }],
2357
- _steps: [{ type: ContentChildren, args: [StepComponent, { descendants: true },] }]
2358
- };
2359
-
2360
- class StepperModule {
2361
- }
2362
- StepperModule.decorators = [
2363
- { type: NgModule, args: [{
2364
- declarations: [StepperComponent, StepHeaderComponent, StepComponent],
2365
- imports: [CommonModule, MatButtonModule, MatIconModule, CdkStepperModule, FlexModule],
2366
- exports: [StepperComponent, StepHeaderComponent, StepComponent],
2367
- },] }
2368
- ];
2369
-
2370
- class ContentHeaderComponent {
2371
- }
2372
- ContentHeaderComponent.decorators = [
2373
- { type: Component, args: [{
2374
- selector: 'mad-content-header',
2375
- template: "<div class=\"content-header\">\n <ng-content></ng-content>\n</div>\n",
2376
- styles: [".content-header{padding-right:.5rem}"]
2377
- },] }
2378
- ];
2379
-
2380
- class ContentPanelContainerComponent {
2381
- }
2382
- ContentPanelContainerComponent.decorators = [
2383
- { type: Component, args: [{
2384
- selector: 'mad-content-panel-container',
2385
- template: "<div class=\"content-panel-outer-wrapper\">\n <ng-content select=\"mad-content-panel-container-content\"></ng-content>\n <ng-content select=\"mad-content-panel-container-footer\"></ng-content>\n</div>\n",
2386
- styles: [":host{display:flex;flex:1 1 auto;min-height:.05rem;overflow:hidden;position:relative}.content-panel-outer-wrapper{display:flex;flex:1 1 auto;flex-direction:column}"]
2387
- },] }
2388
- ];
2389
-
2390
- class ContentPanelContainerContentComponent {
2391
- }
2392
- ContentPanelContainerContentComponent.decorators = [
2393
- { type: Component, args: [{
2394
- selector: 'mad-content-panel-container-content',
2395
- template: "<ng-content></ng-content>",
2396
- styles: [":host{border-top:.05rem solid #ccc;flex:1 1 auto;height:1rem;overflow-y:auto;padding:1rem}"]
2397
- },] }
2398
- ];
2399
-
2400
- class ContentPanelContainerFooterComponent {
2401
- }
2402
- ContentPanelContainerFooterComponent.decorators = [
2403
- { type: Component, args: [{
2404
- selector: 'mad-content-panel-container-footer',
2405
- template: "<ng-content></ng-content>",
2406
- styles: [":host{align-items:center;border-top:.05rem solid #ccc;display:flex;flex:0 0 auto;min-height:2rem;padding:.25rem 1rem}"]
2407
- },] }
2408
- ];
2409
-
2410
- class MainContainerComponent {
2411
- }
2412
- MainContainerComponent.decorators = [
2413
- { type: Component, args: [{
2414
- selector: 'mad-main-container',
2415
- template: "<div class=\"main-container\">\n <ng-content select=\"mad-content-header\"></ng-content>\n <ng-content select=\"mad-flowbar\"></ng-content>\n <ng-content select=\"mad-content-panel-container\"></ng-content>\n</div>\n",
2416
- styles: [".main-container{display:flex;flex-direction:column;height:100%}"]
2417
- },] }
2418
- ];
2419
-
2420
- class ContentPanelModule {
2421
- }
2422
- ContentPanelModule.decorators = [
2423
- { type: NgModule, args: [{
2424
- declarations: [
2425
- ContentHeaderComponent,
2426
- ContentPanelContainerComponent,
2427
- ContentPanelContainerContentComponent,
2428
- ContentPanelContainerFooterComponent,
2429
- MainContainerComponent,
2430
- ],
2431
- imports: [CommonModule],
2432
- exports: [
2433
- ContentHeaderComponent,
2434
- ContentPanelContainerComponent,
2435
- ContentPanelContainerContentComponent,
2436
- ContentPanelContainerFooterComponent,
2437
- MainContainerComponent,
2438
- ],
2439
- },] }
2440
- ];
2441
-
2442
- class FlowbarComponent {
2443
- constructor() {
2444
- this._steps = [];
2445
- this._activeStepChange = new EventEmitter(true);
2446
- /**
2447
- * Event emitted when a step header is clicked.
2448
- * When defined header navigation has to be implemented programmatically.
2449
- * e.g. {@see changeActiveStepOnHeader}
2450
- */
2451
- this._headerClick = new EventEmitter(true);
2452
- }
2453
- get currentStepLabel() {
2454
- return this._activeStep.label;
2455
- }
2456
- get currentSubStepLabel() {
2457
- var _a;
2458
- return (_a = this._activeStep.activeSubStep) === null || _a === void 0 ? void 0 : _a.label;
2459
- }
2460
- ngOnInit() {
2461
- // If no active step is set as input or the active step is not enabled, select the first enabled step
2462
- if (!this._activeStep || !this._activeStep.enabled) {
2463
- this._activeStep = this._steps.find(step => step.enabled);
2464
- if (this._activeStep) {
2465
- // If sub steps exist then set the first non disabled sub step per default
2466
- if (this.activeTabHasSubSteps()) {
2467
- this._activeStep.activeSubStep = this._activeStep.subSteps.find(step => step.enabled);
2468
- }
2469
- this._activeStepChange.emit(this._activeStep);
2470
- }
2471
- }
2472
- }
2473
- ngAfterViewInit() {
2474
- this.stepper._getIndicatorType = () => 'number';
2475
- }
2476
- getIndexForActiveStep() {
2477
- const selectedIndex = this._steps.indexOf(this._activeStep);
2478
- return selectedIndex === -1 ? 0 : selectedIndex;
2479
- }
2480
- changeActiveStep(step) {
2481
- const previousIndex = this._steps.indexOf(this._activeStep);
2482
- this._activeStep = step;
2483
- if (this.activeTabHasSubSteps()) {
2484
- if (previousIndex < this._steps.indexOf(this._activeStep)) {
2485
- this._activeStep.activeSubStep = this._activeStep.subSteps[0];
2486
- }
2487
- else {
2488
- this._activeStep.activeSubStep = this._activeStep.subSteps[this._activeStep.subSteps.length - 1];
2489
- }
2490
- }
2491
- this._activeStepChange.emit(this._activeStep);
2492
- }
2493
- changeActiveStepOnHeader(step) {
2494
- const stepIndex = this._steps.indexOf(step);
2495
- this._activeStep = step;
2496
- this.stepper.selected = this.stepper._steps.find((_, i) => i === stepIndex);
2497
- }
2498
- changeActiveSubStep(subStep) {
2499
- this._activeStep.activeSubStep = subStep;
2500
- }
2501
- previous() {
2502
- if (this.isPreviousAvailable()) {
2503
- // If active step has no sub steps or first sub step is selected -> go to previous main step
2504
- if (!this.activeTabHasSubSteps() || this.isFirstSubStep()) {
2505
- const previousEnabledStep = this.findPreviousEnabledStep();
2506
- this.changeActiveStep(previousEnabledStep);
2507
- this.stepper.selectedIndex = this._steps.indexOf(previousEnabledStep);
2508
- }
2509
- else {
2510
- const subStepIndex = this._activeStep.subSteps.indexOf(this._activeStep.activeSubStep);
2511
- this._activeStep.activeSubStep = this._activeStep.subSteps[subStepIndex - 1];
2512
- }
2513
- }
2514
- }
2515
- next() {
2516
- if (this.isNextAvailable()) {
2517
- // If active step has no sub steps or last sub step is selected -> go to next main step
2518
- if (!this.activeTabHasSubSteps() || this.isLastSubStep()) {
2519
- const nextEnabledStep = this.findNextEnabledStep();
2520
- this.changeActiveStep(nextEnabledStep);
2521
- this.stepper.selectedIndex = this._steps.indexOf(nextEnabledStep);
2522
- }
2523
- else {
2524
- const subStepIndex = this._activeStep.subSteps.indexOf(this._activeStep.activeSubStep);
2525
- this._activeStep.activeSubStep = this._activeStep.subSteps[subStepIndex + 1];
2526
- }
2527
- }
2528
- }
2529
- isPreviousAvailable() {
2530
- if (this._activeStep) {
2531
- if (!this.activeTabHasSubSteps() || this.isFirstSubStep()) {
2532
- const index = this.getCurrentIndex();
2533
- return index > 0 && this.isAnyPreviousStepEnabled(index);
2534
- }
2535
- else {
2536
- return true;
2537
- }
2538
- }
2539
- return false;
2540
- }
2541
- isNextAvailable() {
2542
- if (this._activeStep) {
2543
- if (!this.activeTabHasSubSteps() || this.isLastSubStep()) {
2544
- const index = this.getCurrentIndex();
2545
- return index < this._steps.length - 1 && this.isAnyFollowingStepEnabled(index);
2546
- }
2547
- else {
2548
- return true;
2549
- }
2550
- }
2551
- return false;
2552
- }
2553
- isLastStep() {
2554
- if (this.getCurrentIndex() === this._steps.length - 1) {
2555
- if (this.activeTabHasSubSteps()) {
2556
- return this.isLastSubStep();
2557
- }
2558
- else {
2559
- return true;
2560
- }
2561
- }
2562
- return false;
2563
- }
2564
- getCurrentIndex() {
2565
- return this._steps.findIndex(value => value === this._activeStep);
2566
- }
2567
- getCurrentSubStepIndex() {
2568
- return this._activeStep.subSteps.findIndex(value => value === this._activeStep.activeSubStep);
2569
- }
2570
- triggerClick() {
2571
- const selectedStep = this._steps[this.stepper.selectedIndex];
2572
- this.changeActiveStep(selectedStep);
2573
- }
2574
- headerClick(event, step) {
2575
- event.stopPropagation(); //stop processing current header click event
2576
- this._headerClick.emit(step);
2577
- }
2578
- activeTabHasSubSteps() {
2579
- return this._activeStep.subSteps && this._activeStep.subSteps.length > 0;
2580
- }
2581
- isFirstSubStep() {
2582
- return this._activeStep.activeSubStep === this._activeStep.subSteps[0];
2583
- }
2584
- isLastSubStep() {
2585
- return this._activeStep.activeSubStep === this._activeStep.subSteps[this._activeStep.subSteps.length - 1];
2586
- }
2587
- isAnyPreviousStepEnabled(index) {
2588
- // eslint-disable-next-line id-blacklist
2589
- return this._steps.slice(0, index).find(step => step.enabled) !== undefined;
2590
- }
2591
- isAnyFollowingStepEnabled(index) {
2592
- // eslint-disable-next-line id-blacklist
2593
- return this._steps.slice(index + 1, this._steps.length).find(step => step.enabled) !== undefined;
2594
- }
2595
- findPreviousEnabledStep() {
2596
- const index = this.getCurrentIndex();
2597
- return this._steps
2598
- .slice(0, index)
2599
- .reverse()
2600
- .find(step => step.enabled);
2601
- }
2602
- findNextEnabledStep() {
2603
- const index = this.getCurrentIndex();
2604
- return this._steps.slice(index + 1, this._steps.length).find(step => step.enabled);
2605
- }
2606
- }
2607
- FlowbarComponent.decorators = [
2608
- { type: Component, args: [{
2609
- selector: 'mad-flowbar',
2610
- template: "<div class=\"stepper-container\">\n <mat-horizontal-stepper #stepper [selectedIndex]=\"this.getIndexForActiveStep()\" (click)=\"triggerClick()\">\n <mat-step *ngFor=\"let step of _steps\" [aria-labelledby]=\"!step.enabled ? 'disabled' : null\">\n <ng-template matStepLabel>\n <div class=\"step-header-overlay\" *ngIf=\"this._headerClick.observers.length > 0\" (click)=\"headerClick($event, step)\"></div>\n <span>{{step.label}}</span>\n </ng-template>\n </mat-step>\n </mat-horizontal-stepper>\n</div>\n",
2611
- styles: [".stepper-container{display:flex;padding:0 1rem}::ng-deep .mat-stepper-horizontal .mat-horizontal-stepper-header{height:auto;padding:0}::ng-deep .mat-step-header[aria-labelledby=disabled]{cursor:not-allowed;pointer-events:none!important}::ng-deep .mat-stepper-horizontal .mat-horizontal-content-container{padding:0 0 10px}::ng-deep .mat-stepper-horizontal .mat-stepper-horizontal-line{border-top-width:4px;margin:0 5px}.step-header-overlay{height:100%;position:absolute;right:0;top:0;width:100%}"]
2612
- },] }
2613
- ];
2614
- FlowbarComponent.propDecorators = {
2615
- _steps: [{ type: Input, args: ['steps',] }],
2616
- _activeStep: [{ type: Input, args: ['activeStep',] }],
2617
- _activeStepChange: [{ type: Output, args: ['activeStepChange',] }],
2618
- _headerClick: [{ type: Output, args: ['headerClick',] }],
2619
- stepper: [{ type: ViewChild, args: ['stepper',] }]
2620
- };
2621
-
2622
- class FlowbarModule {
2623
- }
2624
- FlowbarModule.decorators = [
2625
- { type: NgModule, args: [{
2626
- declarations: [FlowbarComponent],
2627
- imports: [CommonModule, MatStepperModule],
2628
- exports: [FlowbarComponent],
2629
- },] }
2630
- ];
2631
-
2632
- class MaterialAddonsModule {
2633
- }
2634
- MaterialAddonsModule.decorators = [
2635
- { type: NgModule, args: [{
2636
- exports: [
2637
- ReadOnlyFormFieldModule,
2638
- ButtonModule,
2639
- ToolbarModule,
2640
- MaterialActionButtonModule,
2641
- NumericFieldModule,
2642
- CardModule,
2643
- QuickListModule,
2644
- ThrottleClickModule,
2645
- ],
2646
- },] }
2647
- ];
2648
-
2649
- /*
2650
- * Public API Surface of material-addons
2651
- */
2652
-
2653
- /**
2654
- * Generated bundle index. Do not edit.
2655
- */
2656
-
2657
- export { ButtonModule, CardModule, ContentHeaderComponent, ContentPanelContainerComponent, ContentPanelContainerContentComponent, ContentPanelContainerFooterComponent, ContentPanelModule, DataTableModule, FlowbarComponent, FlowbarModule, MainContainerComponent, MaterialActionButtonComponent, MaterialActionButtonModule, MaterialAddonsModule, NumberFormatService, NumericFieldModule, QuickListModule, ReadOnlyFormFieldComponent, ReadOnlyFormFieldModule, ReadOnlyFormFieldWrapperComponent, StepComponent, StepHeaderComponent, StepperComponent, StepperModule, TableModule, ThrottleClickDirective, ThrottleClickModule, ToolbarComponent, ToolbarModule, ToolbarService, madStepperAnimations, PrimaryButtonComponent as ɵb, MadBasicButton as ɵc, OutlineButtonComponent as ɵd, LinkButtonComponent as ɵe, DangerButtonComponent as ɵf, IconButtonComponent as ɵg, NumericFieldDirective as ɵh, CardComponent as ɵi, QuickListComponent as ɵj, BaseQuickListComponent as ɵk, QuickListCompactComponent as ɵl, TableComponent as ɵm, DataTableComponent as ɵn, DataTableColumnsModalComponent as ɵo };
2658
- //# sourceMappingURL=porscheinformatik-material-addons.js.map