turbogui-angular 9.0.0 → 11.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 (70) hide show
  1. package/{esm2020 → esm2022}/main/controller/browser.service.mjs +4 -4
  2. package/{esm2020 → esm2022}/main/controller/dialog.service.mjs +7 -7
  3. package/{esm2020 → esm2022}/main/controller/globalerror.service.mjs +4 -4
  4. package/esm2022/main/controller/http.service.mjs +70 -0
  5. package/{esm2020 → esm2022}/main/controller/localization.service.mjs +4 -4
  6. package/{esm2020 → esm2022}/main/controller/notification.service.mjs +4 -4
  7. package/{esm2020 → esm2022}/main/controller/user.service.mjs +4 -4
  8. package/{esm2020 → esm2022}/main/controller/views.service.mjs +4 -4
  9. package/esm2022/main/model/modules/turbogui-angular.module.mjs +140 -0
  10. package/{esm2020 → esm2022}/main/view/animations/fade.animation.mjs +4 -4
  11. package/{esm2020 → esm2022}/main/view/components/busy-state-base/busy-state-base.component.mjs +4 -4
  12. package/{esm2020 → esm2022}/main/view/components/button-base/button-base.component.mjs +4 -4
  13. package/{esm2020 → esm2022}/main/view/components/button-container/button-container.component.mjs +4 -4
  14. package/{esm2020 → esm2022}/main/view/components/button-image/button-image.component.mjs +4 -4
  15. package/esm2022/main/view/components/dialog-error/dialog-error.component.mjs +41 -0
  16. package/esm2022/main/view/components/dialog-multiple-option/dialog-multiple-option.component.mjs +38 -0
  17. package/esm2022/main/view/components/dialog-single-option/dialog-single-option.component.mjs +41 -0
  18. package/esm2022/main/view/components/dialog-single-selection-list/dialog-single-selection-list.component.mjs +112 -0
  19. package/esm2022/main/view/components/dialog-two-option/dialog-two-option.component.mjs +42 -0
  20. package/{esm2020 → esm2022}/main/view/components/views-container/views-container.component.mjs +4 -4
  21. package/{esm2020 → esm2022}/main/view/directives/AutoFocusOnDisplayDirective.mjs +4 -4
  22. package/{esm2020 → esm2022}/main/view/directives/AutoSelectTextOnFocusDirective.mjs +4 -4
  23. package/{esm2020 → esm2022}/main/view/directives/ElementCreatedDirective.mjs +4 -4
  24. package/{esm2020 → esm2022}/main/view/directives/ElementDestroyedDirective.mjs +4 -4
  25. package/{fesm2020 → fesm2022}/turbogui-angular.mjs +151 -151
  26. package/fesm2022/turbogui-angular.mjs.map +1 -0
  27. package/main/controller/dialog.service.d.ts +2 -2
  28. package/main/controller/dialog.service.d.ts.map +1 -1
  29. package/main/model/modules/turbogui-angular.module.d.ts +6 -6
  30. package/main/view/components/busy-state-base/busy-state-base.component.d.ts +1 -1
  31. package/main/view/components/button-base/button-base.component.d.ts +1 -1
  32. package/main/view/components/button-container/button-container.component.d.ts +1 -1
  33. package/main/view/components/button-image/button-image.component.d.ts +1 -1
  34. package/main/view/components/dialog-error/dialog-error.component.d.ts +2 -2
  35. package/main/view/components/dialog-error/dialog-error.component.d.ts.map +1 -1
  36. package/main/view/components/dialog-multiple-option/dialog-multiple-option.component.d.ts +2 -2
  37. package/main/view/components/dialog-multiple-option/dialog-multiple-option.component.d.ts.map +1 -1
  38. package/main/view/components/dialog-single-option/dialog-single-option.component.d.ts +2 -2
  39. package/main/view/components/dialog-single-option/dialog-single-option.component.d.ts.map +1 -1
  40. package/main/view/components/dialog-single-selection-list/dialog-single-selection-list.component.d.ts +2 -2
  41. package/main/view/components/dialog-single-selection-list/dialog-single-selection-list.component.d.ts.map +1 -1
  42. package/main/view/components/dialog-two-option/dialog-two-option.component.d.ts +2 -2
  43. package/main/view/components/dialog-two-option/dialog-two-option.component.d.ts.map +1 -1
  44. package/main/view/components/views-container/views-container.component.d.ts +1 -1
  45. package/main/view/directives/AutoFocusOnDisplayDirective.d.ts +1 -1
  46. package/main/view/directives/AutoSelectTextOnFocusDirective.d.ts +1 -1
  47. package/main/view/directives/ElementCreatedDirective.d.ts +1 -1
  48. package/main/view/directives/ElementDestroyedDirective.d.ts +1 -1
  49. package/package.json +12 -18
  50. package/esm2020/main/controller/http.service.mjs +0 -70
  51. package/esm2020/main/model/modules/turbogui-angular.module.mjs +0 -140
  52. package/esm2020/main/view/components/dialog-error/dialog-error.component.mjs +0 -41
  53. package/esm2020/main/view/components/dialog-multiple-option/dialog-multiple-option.component.mjs +0 -38
  54. package/esm2020/main/view/components/dialog-single-option/dialog-single-option.component.mjs +0 -41
  55. package/esm2020/main/view/components/dialog-single-selection-list/dialog-single-selection-list.component.mjs +0 -112
  56. package/esm2020/main/view/components/dialog-two-option/dialog-two-option.component.mjs +0 -42
  57. package/fesm2015/turbogui-angular.mjs +0 -1951
  58. package/fesm2015/turbogui-angular.mjs.map +0 -1
  59. package/fesm2020/turbogui-angular.mjs.map +0 -1
  60. /package/{esm2020 → esm2022}/main/controller/httpservice/HTTPServiceGetRequest.mjs +0 -0
  61. /package/{esm2020 → esm2022}/main/controller/httpservice/HTTPServicePostRequest.mjs +0 -0
  62. /package/{esm2020 → esm2022}/main/managers/DelayedMethodCallManager.mjs +0 -0
  63. /package/{esm2020 → esm2022}/main/model/classes/GUINotification.mjs +0 -0
  64. /package/{esm2020 → esm2022}/main/model/classes/View.mjs +0 -0
  65. /package/{esm2020 → esm2022}/main/model/classes/ViewModel.mjs +0 -0
  66. /package/{esm2020 → esm2022}/main/model/classes/ViewService.mjs +0 -0
  67. /package/{esm2020 → esm2022}/main/view/components/dialog-base/dialog-base.component.mjs +0 -0
  68. /package/{esm2020 → esm2022}/main/view/components/dialog-options-base/dialog-options-base.component.mjs +0 -0
  69. /package/{esm2020 → esm2022}/public_api.mjs +0 -0
  70. /package/{esm2020 → esm2022}/turbogui-angular.mjs +0 -0
@@ -1,1951 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, Component, HostBinding, Inject, ViewContainerRef, Input, ViewChild, Directive, HostListener, EventEmitter, Output, NgModule } from '@angular/core';
3
- import * as i1$1 from '@angular/material/dialog';
4
- import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
5
- import * as i4 from '@angular/material/input';
6
- import { MatInputModule } from '@angular/material/input';
7
- import * as i1 from '@angular/material/snack-bar';
8
- import { MatSnackBarModule } from '@angular/material/snack-bar';
9
- import * as i2 from '@angular/material/button';
10
- import { MatButtonModule } from '@angular/material/button';
11
- import * as i3$1 from '@angular/material/form-field';
12
- import { MatFormFieldModule } from '@angular/material/form-field';
13
- import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
14
- import { trigger, transition, style, animate } from '@angular/animations';
15
- import { ArrayUtils, NumericUtils, LocalizationManager, HTTPManager, StringUtils, HTTPManagerPostRequest, ConversionUtils, BrowserManager, HTTPManagerGetRequest } from 'turbocommons-ts';
16
- import { ComponentPortal, DomPortalOutlet } from '@angular/cdk/portal';
17
- import * as i3 from '@angular/common';
18
- import { Subject } from 'rxjs';
19
-
20
- /**
21
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
22
- *
23
- * Website : -> http://www.turbogui.org
24
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
25
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
26
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
27
- */
28
- /**
29
- * Fade animations
30
- */
31
- class FadeAnimationClass {
32
- /**
33
- * Get a custom trigger to create fade animations when components are added or removed from the application
34
- *
35
- * @param triggerName The name for the trigger we want to create
36
- * @param enter The time and easing that we want to use for the enter state
37
- * @param leave The time and easing that we want to use for the leave state
38
- */
39
- static getTrigger(triggerName, enter = '1s ease', leave = '0s ease') {
40
- return trigger(triggerName, [
41
- transition(':enter', [style({ opacity: 0 }), animate(enter)]),
42
- transition(':leave', [style({ opacity: 1 }), animate(leave, style({ opacity: 0 }))])
43
- ]);
44
- }
45
- }
46
- FadeAnimationClass.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FadeAnimationClass, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
47
- FadeAnimationClass.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FadeAnimationClass });
48
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FadeAnimationClass, decorators: [{
49
- type: Injectable
50
- }] });
51
-
52
- /**
53
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
54
- *
55
- * Website : -> http://www.turbogui.org
56
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
57
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
58
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
59
- */
60
- /**
61
- * This component is used by turboGUI angular library to show the busy state to the user.
62
- * It is used to block all the user input and progressively shows a busy cursor to notify that the application
63
- * is waiting for something.
64
- *
65
- * We can (should) override this component with our own one to adapt its visual appearance to our application.
66
- * We can then set dialogService.busyStateComponentClass to our component class at the application start to to
67
- * override the default one.
68
- */
69
- class BusyStateBaseComponent {
70
- constructor() {
71
- /**
72
- * This is used to attach the fade animation directly to this component so it fades in and out when created and removed from the app
73
- */
74
- this.busyStateBaseFade = true;
75
- }
76
- }
77
- BusyStateBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BusyStateBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
78
- BusyStateBaseComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: BusyStateBaseComponent, selector: "tg-busy-state-base", host: { properties: { "@busyStateBaseFade": "this.busyStateBaseFade" } }, ngImport: i0, template: "<div class=\"darkBg\">\r\n\r\n</div>\r\n\r\n<svg width=\"38\" height=\"38\" viewBox=\"0 0 38 38\" xmlns=\"http://www.w3.org/2000/svg\" stroke=\"#fff\">\r\n <g fill=\"none\" fill-rule=\"evenodd\">\r\n <g transform=\"translate(1 1)\" stroke-width=\"1\">\r\n <circle stroke-opacity=\".2\" cx=\"18\" cy=\"18\" r=\"18\"/>\r\n <path d=\"M36 18c0-9.94-8.06-18-18-18\">\r\n <animateTransform\r\n attributeName=\"transform\"\r\n type=\"rotate\"\r\n from=\"0 18 18\"\r\n to=\"360 18 18\"\r\n dur=\"1s\"\r\n repeatCount=\"indefinite\"/>\r\n </path>\r\n </g>\r\n </g>\r\n</svg>\r\n", styles: [":host{position:fixed;inset:0;display:flex;justify-content:center;align-items:center;z-index:999999999}.darkBg{position:absolute;cursor:progress;width:100%;height:100%;display:flex;justify-content:center;align-items:center;background-color:#00000096;animation-name:bgfadein;animation-duration:30s;animation-timing-function:ease}svg{z-index:5000;width:40%;height:40%;max-width:130px;max-height:130px;animation-name:loadingfadein;animation-duration:3s;animation-timing-function:ease-in}@keyframes loadingfadein{0%{opacity:0}25%{opacity:0}to{opacity:1}}@keyframes bgfadein{0%{opacity:0}4%{opacity:0}14%{opacity:.2}35%{opacity:.5}to{opacity:1}}\n"], animations: [FadeAnimationClass.getTrigger('busyStateBaseFade', '1s ease', '400ms ease')] });
79
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BusyStateBaseComponent, decorators: [{
80
- type: Component,
81
- args: [{ selector: 'tg-busy-state-base', animations: [FadeAnimationClass.getTrigger('busyStateBaseFade', '1s ease', '400ms ease')], template: "<div class=\"darkBg\">\r\n\r\n</div>\r\n\r\n<svg width=\"38\" height=\"38\" viewBox=\"0 0 38 38\" xmlns=\"http://www.w3.org/2000/svg\" stroke=\"#fff\">\r\n <g fill=\"none\" fill-rule=\"evenodd\">\r\n <g transform=\"translate(1 1)\" stroke-width=\"1\">\r\n <circle stroke-opacity=\".2\" cx=\"18\" cy=\"18\" r=\"18\"/>\r\n <path d=\"M36 18c0-9.94-8.06-18-18-18\">\r\n <animateTransform\r\n attributeName=\"transform\"\r\n type=\"rotate\"\r\n from=\"0 18 18\"\r\n to=\"360 18 18\"\r\n dur=\"1s\"\r\n repeatCount=\"indefinite\"/>\r\n </path>\r\n </g>\r\n </g>\r\n</svg>\r\n", styles: [":host{position:fixed;inset:0;display:flex;justify-content:center;align-items:center;z-index:999999999}.darkBg{position:absolute;cursor:progress;width:100%;height:100%;display:flex;justify-content:center;align-items:center;background-color:#00000096;animation-name:bgfadein;animation-duration:30s;animation-timing-function:ease}svg{z-index:5000;width:40%;height:40%;max-width:130px;max-height:130px;animation-name:loadingfadein;animation-duration:3s;animation-timing-function:ease-in}@keyframes loadingfadein{0%{opacity:0}25%{opacity:0}to{opacity:1}}@keyframes bgfadein{0%{opacity:0}4%{opacity:0}14%{opacity:.2}35%{opacity:.5}to{opacity:1}}\n"] }]
82
- }], propDecorators: { busyStateBaseFade: [{
83
- type: HostBinding,
84
- args: ['@busyStateBaseFade']
85
- }] } });
86
-
87
- /**
88
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
89
- *
90
- * Website : -> http://www.turbogui.org
91
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
92
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
93
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
94
- */
95
- /**
96
- * Manages the application modal and non modal floating elements
97
- */
98
- class DialogService {
99
- constructor(rendererFactory, matSnackBar, matDialog, injector, applicationRef, componentFactoryResolver) {
100
- this.matSnackBar = matSnackBar;
101
- this.matDialog = matDialog;
102
- this.injector = injector;
103
- this.applicationRef = applicationRef;
104
- this.componentFactoryResolver = componentFactoryResolver;
105
- /**
106
- * Used to modify the busy state component that is shown by default by the addModalBusyState() method.
107
- *
108
- * @see this.addModalBusyState()
109
- */
110
- this.customBusyStateComponentClass = BusyStateBaseComponent;
111
- /**
112
- * Check public getter for docs
113
- */
114
- this._isEnabled = true;
115
- /**
116
- * Tells if the main application is currently showing a busy state that blocks all user interaction
117
- */
118
- this._isShowingBusyState = false;
119
- /**
120
- * A reference to the modal busy state component that is initialized only the first time it is called.
121
- *
122
- * (To append the busy state dynamically, we use the Portal concept from the angular material library)
123
- */
124
- this._componentPortal = null;
125
- /**
126
- * A reference to the modal busy state container where the component will be added
127
- */
128
- this._modalBusyStateHost = null;
129
- /**
130
- * Tells if the manager is currently showing a snackbar element or not
131
- */
132
- this._isShowingSnackBar = false;
133
- /**
134
- * Contains a list of the dialogs that are currently visible to the user.
135
- * Each item in this list is a hash that is computed when dialog is created to uniquely identify it.
136
- *
137
- * Empty list means no dialogs are currently visible
138
- */
139
- this._activeDialogs = [];
140
- /**
141
- * Contains a list with all the MatDialog instances that are currently visible to the user.
142
- * The list uses the same order as the list of _activeDialogs hash values
143
- */
144
- this._activeDialogInstances = [];
145
- /**
146
- * Method that is used to delete the window beforeunload event listener once not used anymore
147
- */
148
- this._windowBeforeUnloadUnListen = null;
149
- /**
150
- * Method that is used to delete the document keydown event listener once not used anymore
151
- */
152
- this._documentKeydownUnlisten = null;
153
- /**
154
- * Method that is used to delete the document mousedown event listener once not used anymore
155
- */
156
- this._documentMousedownUnlisten = null;
157
- /**
158
- * Method that is used to delete the document pointerdown event listener once not used anymore
159
- */
160
- this._documentPointerdownUnlisten = null;
161
- this._renderer = rendererFactory.createRenderer(null, null);
162
- }
163
- /**
164
- * Tells if this dialog service is enabled or not. If dialog service is disabled, none of it's features will work
165
- * This is used to block all dialog features normally when shutting down the application
166
- *
167
- * Use with caution. When this is set to false, dialog service stops working.
168
- */
169
- set isEnabled(v) {
170
- if (v === this._isEnabled) {
171
- return;
172
- }
173
- this._isEnabled = v;
174
- }
175
- /**
176
- * Enables a warning that will be shown to the user when he/she tries to close the application.
177
- * This warning will prompt the user to continue with the exit process or cancel it.
178
- * The specific texts of this message are a generic ones and cannot be changed.
179
- *
180
- * IMPORTANT: This method must be called after the main application has been initialized in order to work,
181
- * otherwise it will do nothing.
182
- */
183
- addCloseApplicationWarning() {
184
- if (this._windowBeforeUnloadUnListen === null) {
185
- this._windowBeforeUnloadUnListen = this._renderer.listen('window', 'beforeunload', (event) => event.returnValue = true);
186
- }
187
- }
188
- /**
189
- * Remove the close application warning message if previously assigned
190
- */
191
- removeCloseApplicationWarning() {
192
- if (this._windowBeforeUnloadUnListen !== null) {
193
- this._windowBeforeUnloadUnListen();
194
- this._windowBeforeUnloadUnListen = null;
195
- }
196
- }
197
- /**
198
- * Change the application visual appearance so the user perceives that the application is
199
- * currently busy. While modal busy state is enabled, no user input is possible neither via
200
- * keyboard, mouse or touch. Use this state when performing server requests or operations that
201
- * must block the user interaction with the application.
202
- *
203
- * Note: We can modify the busy state component that is shown by this method. To do it, we must
204
- * set this.customBusyStateComponentClass property with our own custom busy state component class. (We can do it at
205
- * our main application component constructor for example). Our custom component must extend the
206
- * BusyStateBaseComponent one to add its own visual appearance.
207
- *
208
- * @see this.customBusyStateComponentClass
209
- */
210
- addModalBusyState() {
211
- if (!this._isEnabled || this._isShowingBusyState) {
212
- return;
213
- }
214
- this._disableUserInteraction();
215
- // Dynamically create the busy state component reference if this is the first time
216
- if (this._componentPortal === null) {
217
- this._componentPortal = new ComponentPortal(this.customBusyStateComponentClass);
218
- // Create a PortalHost with document.body as its anchor element
219
- this._modalBusyStateHost = new DomPortalOutlet(document.body, this.componentFactoryResolver, this.applicationRef, this.injector);
220
- }
221
- this._modalBusyStateHost.attach(this._componentPortal);
222
- this._isShowingBusyState = true;
223
- }
224
- /**
225
- * Tells if the application is currently locked in a modal busy state (caused by an addModalBusyState() call)
226
- */
227
- get isShowingBusyState() {
228
- return this._isShowingBusyState;
229
- }
230
- /**
231
- * Remove the application busy state and restore it back to normal user interaction
232
- */
233
- removeModalBusyState() {
234
- if (!this._isEnabled || !this._isShowingBusyState) {
235
- return;
236
- }
237
- if (this._componentPortal !== null) {
238
- this._modalBusyStateHost.detach();
239
- }
240
- this._enableUserInteraction();
241
- this._isShowingBusyState = false;
242
- }
243
- /**
244
- * TODO - adapt from TS version
245
- */
246
- addToolTip() {
247
- // TODO - adapt from TS version
248
- }
249
- /**
250
- * Show a non modal snackbar notification to the user (Only one snack-bar can ever be opened at the same time).
251
- *
252
- * Snackbars inform users of a process that an app has performed or will perform. They appear temporarily, towards the bottom or top of the screen.
253
- * They shouldn’t interrupt the user experience, and they don’t require user input to disappear.
254
- *
255
- * @param config A MatSnackBarConfig instance with the customizations we want for this snackbar
256
- * @param message The message to show on the snackbar
257
- * @param action If not empty, the text to place on the snackbar confirmation button
258
- * @param actionCallback A method to execute once the user clicks into the action button.
259
- *
260
- * @return void
261
- */
262
- addSnackBar(config, message, action = '', actionCallback = null) {
263
- if (!this._isEnabled) {
264
- return;
265
- }
266
- if (this._isShowingSnackBar) {
267
- throw new Error('Trying to show a snackbar while another one is still visible');
268
- }
269
- this._isShowingSnackBar = true;
270
- const snackBarRef = this.matSnackBar.open(message, action === '' ? undefined : action, config);
271
- if (actionCallback !== null) {
272
- snackBarRef.onAction().subscribe(() => {
273
- actionCallback();
274
- });
275
- }
276
- }
277
- /**
278
- * Tells if the application is currently showing a snackbar or not
279
- */
280
- get isShowingSnackBar() {
281
- return this._isShowingSnackBar;
282
- }
283
- /**
284
- * Force the removal of the snack bar dialog if it exists.
285
- *
286
- * If no snackbar is currently visible, this method will do nothing
287
- */
288
- removeSnackBar() {
289
- if (!this._isEnabled || !this._isShowingSnackBar) {
290
- return;
291
- }
292
- this.matSnackBar.dismiss();
293
- this._isShowingSnackBar = false;
294
- }
295
- /**
296
- * Show a dialog with one or more options that can be used to close it. We can use any of the predefined dialog types that are bundled with
297
- * this library or extend DialogOptionsBaseComponent to create our own custom ones.
298
- *
299
- * @param width Specify the css value for the maximum width the dialog will have. As the dialog is responsive, the value will be automatically
300
- reduced if the available screen is not enough, and will reach the desired value otherwise. Note that height will be adapted to the contents
301
- of the dialog and cannot be specified here. We can set a pixels, % or any other css accepted value. For example: '400px', '50%', etc.
302
- * @param texts A list with strings containing the dialog texts, sorted by importance. When dialog has a title, this should
303
- * be placed first, subtitle second and so (Each dialog may accept different kind of texts).
304
- * @param options A list of strings that will be used as button captions for each one of the accepted dialog options
305
- * @param dialogComponentClass A class for a component that extends DialogOptionsBaseComponent, which will be the
306
- * dialog visual element that is shown to the user.
307
- * @param callback A function that will be called after the dialog is closed and will receive an object with the numeric index and value for
308
- * the option that's been selected by the user.
309
- * @param modal True (default) if selecting an option is mandatory to close the dialog, false if the dialog can be closed
310
- * by the user by clicking outside it
311
- */
312
- addDialog(width, texts, options, dialogComponentClass, callback = null, modal = true) {
313
- if (!this._isEnabled) {
314
- return;
315
- }
316
- // Generate a string to uniquely identify this dialog on the list of active dialogs
317
- const dialogHash = texts.join('') + options.join('') + dialogComponentClass.name;
318
- // identical dialogs won't be allowed at the same time
319
- if (this._activeDialogs.includes(dialogHash)) {
320
- return;
321
- }
322
- const dialogRef = this.matDialog.open(dialogComponentClass, {
323
- width: width,
324
- disableClose: modal,
325
- autoFocus: false,
326
- closeOnNavigation: !modal,
327
- data: { texts: texts, options: options }
328
- });
329
- this._activeDialogs.push(dialogHash);
330
- this._activeDialogInstances.push(dialogRef);
331
- dialogRef.beforeClosed().subscribe((selectedOptionIndex) => {
332
- this._activeDialogs = ArrayUtils.removeElement(this._activeDialogs, dialogHash);
333
- this._activeDialogInstances = ArrayUtils.removeElement(this._activeDialogInstances, dialogRef);
334
- if (!NumericUtils.isInteger(selectedOptionIndex)) {
335
- if (modal) {
336
- throw new Error(`dialogRef.close() expects int value`);
337
- }
338
- else {
339
- selectedOptionIndex = -1;
340
- }
341
- }
342
- if (callback !== null) {
343
- let selectedOption = { index: selectedOptionIndex, value: '' };
344
- if (selectedOptionIndex >= 0) {
345
- selectedOption.value = options[selectedOptionIndex];
346
- }
347
- callback(selectedOption);
348
- }
349
- });
350
- }
351
- /**
352
- * Force the removal of all the dialogs that are currently visible.
353
- *
354
- * If no dialogs are currently visible, this method will do nothing
355
- */
356
- removeAllDialogs() {
357
- if (!this._isEnabled) {
358
- return;
359
- }
360
- for (const dialogRef of this._activeDialogInstances) {
361
- dialogRef.close(-1);
362
- }
363
- this._activeDialogs = [];
364
- this._activeDialogInstances = [];
365
- }
366
- /**
367
- * Block all the user interactions with the application (keyboard, touch, mouse, ...)
368
- */
369
- _disableUserInteraction() {
370
- if (this._documentKeydownUnlisten === null) {
371
- this._documentKeydownUnlisten = this._renderer.listen('document', 'keydown', (event) => event.preventDefault());
372
- }
373
- if (this._documentMousedownUnlisten === null) {
374
- this._documentMousedownUnlisten = this._renderer.listen('document', 'mousedown', (event) => event.preventDefault());
375
- }
376
- if (this._documentPointerdownUnlisten === null) {
377
- this._documentPointerdownUnlisten = this._renderer.listen('document', 'pointerdown', (event) => event.preventDefault());
378
- }
379
- }
380
- /**
381
- * Restore the user interactions that were previously disabled with _disableUserInteraction method
382
- */
383
- _enableUserInteraction() {
384
- if (this._documentKeydownUnlisten !== null) {
385
- this._documentKeydownUnlisten();
386
- this._documentKeydownUnlisten = null;
387
- }
388
- if (this._documentMousedownUnlisten !== null) {
389
- this._documentMousedownUnlisten();
390
- this._documentMousedownUnlisten = null;
391
- }
392
- if (this._documentPointerdownUnlisten !== null) {
393
- this._documentPointerdownUnlisten();
394
- this._documentMousedownUnlisten = null;
395
- }
396
- }
397
- }
398
- DialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogService, deps: [{ token: i0.RendererFactory2 }, { token: i1.MatSnackBar }, { token: i1$1.MatDialog }, { token: i0.Injector }, { token: i0.ApplicationRef }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Injectable });
399
- DialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogService });
400
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogService, decorators: [{
401
- type: Injectable
402
- }], ctorParameters: function () { return [{ type: i0.RendererFactory2 }, { type: i1.MatSnackBar }, { type: i1$1.MatDialog }, { type: i0.Injector }, { type: i0.ApplicationRef }, { type: i0.ComponentFactoryResolver }]; } });
403
-
404
- /**
405
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
406
- *
407
- * Website : -> http://www.turbogui.org
408
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
409
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
410
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
411
- */
412
- /**
413
- * Manages application text translations and languages
414
- */
415
- class LocalizationService extends LocalizationManager {
416
- }
417
- LocalizationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LocalizationService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
418
- LocalizationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LocalizationService });
419
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LocalizationService, decorators: [{
420
- type: Injectable
421
- }] });
422
-
423
- /**
424
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
425
- *
426
- * Website : -> http://www.turbogui.org
427
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
428
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
429
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
430
- */
431
- /**
432
- * This is the base class for all the dialog components that can be loaded by the dialog service class
433
- */
434
- class DialogBaseComponent {
435
- }
436
-
437
- /**
438
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
439
- *
440
- * Website : -> http://www.turbogui.org
441
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
442
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
443
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
444
- */
445
- /**
446
- * This is the base class for all the dialog components that show one or more options for the user to select
447
- */
448
- class DialogOptionsBaseComponent extends DialogBaseComponent {
449
- }
450
-
451
- /**
452
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
453
- *
454
- * Website : -> http://www.turbogui.org
455
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
456
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
457
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
458
- */
459
- /**
460
- * A dialog component with a single option button, to be used for error notifications
461
- */
462
- class DialogErrorComponent extends DialogOptionsBaseComponent {
463
- constructor(dialogRef, data) {
464
- super();
465
- this.dialogRef = dialogRef;
466
- this.data = data;
467
- if (data.texts.length < 1) {
468
- throw new Error('DialogErrorComponent expects 2 texts: The title and optionally a description');
469
- }
470
- if (data.options.length !== 1) {
471
- throw new Error('DialogErrorComponent expects only one option');
472
- }
473
- }
474
- }
475
- DialogErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogErrorComponent, deps: [{ token: i1$1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
476
- DialogErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DialogErrorComponent, selector: "tg-dialog-error", usesInheritance: true, ngImport: i0, template: "<div class=\"titleAndIconContainer\">\r\n <h3>\r\n {{data.texts[0]}}\r\n </h3>\r\n \r\n <!-- error icon -->\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\r\n <path d=\"M0 0h24v24H0z\" fill=\"none\"/>\r\n <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\" fill=\"#ff0000\" />\r\n </svg>\r\n \r\n</div>\r\n\r\n<p *ngIf=\"data.texts.length > 1\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<button mat-raised-button color=\"warn\"\r\n (click)=\"dialogRef.close(0)\">\r\n \r\n {{data.options[0]}}\r\n \r\n</button>", styles: [":host{position:relative;min-height:300px}.titleAndIconContainer{display:flex;flex-direction:row;align-items:center}h3{margin-top:0;margin-bottom:25px;width:82%}svg{width:18%;height:auto}p{margin-bottom:52px}button{float:right;width:50%;min-width:50px}\n"], dependencies: [{ kind: "component", type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
477
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogErrorComponent, decorators: [{
478
- type: Component,
479
- args: [{ selector: 'tg-dialog-error', template: "<div class=\"titleAndIconContainer\">\r\n <h3>\r\n {{data.texts[0]}}\r\n </h3>\r\n \r\n <!-- error icon -->\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\r\n <path d=\"M0 0h24v24H0z\" fill=\"none\"/>\r\n <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\" fill=\"#ff0000\" />\r\n </svg>\r\n \r\n</div>\r\n\r\n<p *ngIf=\"data.texts.length > 1\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<button mat-raised-button color=\"warn\"\r\n (click)=\"dialogRef.close(0)\">\r\n \r\n {{data.options[0]}}\r\n \r\n</button>", styles: [":host{position:relative;min-height:300px}.titleAndIconContainer{display:flex;flex-direction:row;align-items:center}h3{margin-top:0;margin-bottom:25px;width:82%}svg{width:18%;height:auto}p{margin-bottom:52px}button{float:right;width:50%;min-width:50px}\n"] }]
480
- }], ctorParameters: function () {
481
- return [{ type: i1$1.MatDialogRef }, { type: undefined, decorators: [{
482
- type: Inject,
483
- args: [MAT_DIALOG_DATA]
484
- }] }];
485
- } });
486
-
487
- /**
488
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
489
- *
490
- * Website : -> http://www.turbogui.org
491
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
492
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
493
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
494
- */
495
- /**
496
- * Manages application http communications
497
- */
498
- class HTTPService extends HTTPManager {
499
- constructor(dialogService) {
500
- super(true);
501
- this.dialogService = dialogService;
502
- }
503
- /**
504
- * The same method as HTTPManager.execute but with the ability to enable several options which are specific to this service:
505
- *
506
- * - HTTPService.NO_MODAL_BUSY_STATE To prevent the default behaviour of locking the UI while the request is running
507
- * - HTTPService.DISABLE_ERROR_HANDLING To prevent the default behaviour of showing a detailed error dialog when a request fails
508
- *
509
- * @see HTTPManager.execute()
510
- */
511
- execute(requests, finishedCallback = null, progressCallback = null, options = []) {
512
- if (options.indexOf(HTTPService.NO_MODAL_BUSY_STATE) < 0) {
513
- this.dialogService.addModalBusyState();
514
- }
515
- super.execute(requests, (results, anyError) => {
516
- if (options.indexOf(HTTPService.NO_MODAL_BUSY_STATE) < 0) {
517
- this.dialogService.removeModalBusyState();
518
- }
519
- if ((options.indexOf(HTTPService.DISABLE_ERROR_HANDLING) < 0) && anyError) {
520
- for (let result of results) {
521
- if (result.isError) {
522
- let errorMsg = result.errorMsg + '\n\n' + result.response;
523
- if (StringUtils.isEmpty(errorMsg)) {
524
- errorMsg = 'Unknown error. Make sure Internet connection is available';
525
- }
526
- this.dialogService.addDialog('600px', ['Error: ' + result.code, errorMsg], ['Ok'], DialogErrorComponent);
527
- }
528
- }
529
- }
530
- if (finishedCallback !== null) {
531
- finishedCallback(results, anyError);
532
- }
533
- }, progressCallback);
534
- }
535
- }
536
- /**
537
- * execute() method option that tells the service to avoid blocking the user interface with a modal busy state while the requests that are
538
- * launched by the execute method are running.
539
- */
540
- HTTPService.NO_MODAL_BUSY_STATE = 'NO_MODAL_BUSY_STATE';
541
- /**
542
- * execute() method option that tells the service to skip showing an error dialog when a request fails. We normally use this to handle the
543
- * errors by ourselves or if we want to hide the error dialog for a specific request.
544
- */
545
- HTTPService.DISABLE_ERROR_HANDLING = 'DISABLE_ERROR_HANDLING';
546
- HTTPService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HTTPService, deps: [{ token: DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
547
- HTTPService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HTTPService });
548
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HTTPService, decorators: [{
549
- type: Injectable
550
- }], ctorParameters: function () { return [{ type: DialogService }]; } });
551
-
552
- /**
553
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
554
- *
555
- * Website : -> http://www.turbogui.org
556
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
557
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
558
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
559
- */
560
- /**
561
- * This is the main application event bus.
562
- * All global events that happen on the application are broadcasted by this service, and
563
- * can be listened by any application element who previously subscribed
564
- */
565
- class NotificationService {
566
- constructor() {
567
- /**
568
- * The Observable instance that handles subscriptions and notifications
569
- */
570
- this._notifications = new Subject();
571
- }
572
- /**
573
- * used by other services or components to subscribe to all notifications that are generated by this service
574
- *
575
- * @param notificationHandler A method that will be used to receive each notification as a GUINotification instance
576
- *
577
- * @returns The new subscription object. Make sure to unsubscribe when not required anymore
578
- */
579
- subscribe(notificationHandler) {
580
- return this._notifications.subscribe(notificationHandler);
581
- }
582
- /**
583
- * Launch a notification to anyone who may be listening
584
- *
585
- * @param notification A notification instance to launch
586
- */
587
- send(notification) {
588
- this._notifications.next(notification);
589
- }
590
- /**
591
- * End a previously initiated subscription
592
- *
593
- * @param subscription A previously created subscription instance from which we want to unsubscribe
594
- */
595
- unsubscribe(subscription) {
596
- return subscription.unsubscribe();
597
- }
598
- }
599
- NotificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
600
- NotificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NotificationService });
601
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NotificationService, decorators: [{
602
- type: Injectable
603
- }] });
604
-
605
- /**
606
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
607
- *
608
- * Website : -> http://www.turbogui.org
609
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
610
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
611
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
612
- */
613
- /**
614
- * Class that defines a POST http request, to be used by HttpService
615
- */
616
- class HTTPServicePostRequest extends HTTPManagerPostRequest {
617
- }
618
-
619
- /**
620
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
621
- *
622
- * Website : -> http://www.turbogui.org
623
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
624
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
625
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
626
- */
627
- /**
628
- * Manages the users model and commands
629
- */
630
- class UserService {
631
- constructor(httpService, ls) {
632
- this.httpService = httpService;
633
- this.ls = ls;
634
- /**
635
- * Path to the web service that performs the user login
636
- */
637
- this.loginWebService = 'users/login';
638
- /**
639
- * The username that is currently defined and will be used by the login methods
640
- */
641
- this.userName = '';
642
- /**
643
- * The password for the user that is currently defined and will be used by the login methods
644
- */
645
- this.password = '';
646
- /**
647
- * Check public getter for docs
648
- */
649
- this._isLogged = false;
650
- /**
651
- * @see token() getter for more info
652
- */
653
- this._token = '';
654
- }
655
- /**
656
- * Tells if the services contains a non empty username and password specified
657
- */
658
- get isUserAndPswDefined() {
659
- return !StringUtils.isEmpty(this.userName) && !StringUtils.isEmpty(this.password);
660
- }
661
- /**
662
- * Tells if exists a user that is currently logged or not
663
- */
664
- get isLogged() {
665
- return this._isLogged;
666
- }
667
- /**
668
- * Gives the value for the currently active user authentication token or an empty string if no user logged
669
- */
670
- get token() {
671
- return this._token;
672
- }
673
- /**
674
- * Perform a user login against the configured login webservice
675
- *
676
- * @param loginOkCallback Method to be executed once the login finishes chorrectly. An object with all the service response data will be passed to this method
677
- * @param loginFailCallback Method to be executed once the login finishes incorrectly.
678
- */
679
- login(loginOkCallback = null, loginFailCallback = null) {
680
- const request = new HTTPServicePostRequest(this.loginWebService);
681
- request.ignoreGlobalPostParams = true;
682
- const encodedCredentials = ConversionUtils.stringToBase64(ConversionUtils.stringToBase64(this.userName) + ',' + ConversionUtils.stringToBase64(this.password));
683
- request.parameters = {
684
- data: encodedCredentials
685
- };
686
- request.successCallback = (response) => {
687
- if (response !== '') {
688
- response = JSON.parse(response);
689
- this._isLogged = true;
690
- this._token = response.token;
691
- this.httpService.setGlobalPostParam('token', response.token);
692
- if (loginOkCallback !== null) {
693
- loginOkCallback(response);
694
- }
695
- }
696
- else {
697
- this._clearUserAndToken();
698
- if (loginFailCallback !== null) {
699
- loginFailCallback();
700
- }
701
- }
702
- };
703
- this.httpService.execute(request);
704
- }
705
- /**
706
- * Perform the logout for the currently logged user
707
- */
708
- logout(logoutOkCallback = null) {
709
- const request = new HTTPServicePostRequest('users/logout');
710
- request.parameters = {
711
- token: this._token
712
- };
713
- request.successCallback = () => {
714
- this._clearUserAndToken();
715
- if (logoutOkCallback !== null) {
716
- logoutOkCallback();
717
- }
718
- };
719
- this.httpService.execute(request);
720
- }
721
- _clearUserAndToken() {
722
- this.userName = '';
723
- this.password = '';
724
- this._isLogged = false;
725
- this._token = '';
726
- if (this.httpService.isGlobalPostParam('token')) {
727
- this.httpService.deleteGlobalPostParam('token');
728
- }
729
- }
730
- }
731
- UserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserService, deps: [{ token: HTTPService }, { token: LocalizationService }], target: i0.ɵɵFactoryTarget.Injectable });
732
- UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserService });
733
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserService, decorators: [{
734
- type: Injectable
735
- }], ctorParameters: function () { return [{ type: HTTPService }, { type: LocalizationService }]; } });
736
-
737
- /**
738
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
739
- *
740
- * Website : -> http://www.turbogui.org
741
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
742
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
743
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
744
- */
745
- /**
746
- * Manages adding, removing and manipulating the application views
747
- */
748
- class ViewsService {
749
- constructor(componentFactoryResolver) {
750
- this.componentFactoryResolver = componentFactoryResolver;
751
- /**
752
- * See getter method for docs
753
- */
754
- this._loadedViewClass = null;
755
- /**
756
- * An instance of the model that is assigned to the currently loaded view
757
- */
758
- this._loadedViewModel = null;
759
- /**
760
- * See setter method for docs
761
- */
762
- this._viewContainerRef = null;
763
- }
764
- /**
765
- * Tells if there's any view currently loaded on the application views container
766
- */
767
- get isViewLoaded() {
768
- return this._loadedViewClass !== null;
769
- }
770
- /**
771
- * Stores a reference to the visual element that will be used as the container for all the views.
772
- * This is automatically assigned by the tg-views-container component once it is created.
773
- *
774
- * @see ViewsContainerComponent for more information
775
- */
776
- set viewContainerRef(ref) {
777
- if (ref !== null && this._viewContainerRef !== null) {
778
- throw new Error('Views container already defined. Only one views container element can exist on an application');
779
- }
780
- this._viewContainerRef = ref;
781
- }
782
- /**
783
- * Create a new view instance with the specified type and add it to the current application views container. Any currently loaded
784
- * view will be removed
785
- *
786
- * Make sure this method is called when all the visual components of the application have been created (ngAfterViewInit)
787
- *
788
- * @param view The classname for the view that we want to create and add to the views container (must extend View base class).
789
- *
790
- * @return The instance of the newly added and created view.
791
- */
792
- pushView(view) {
793
- // If a view is already loaded, we will unload it first
794
- if (this._loadedViewClass !== null) {
795
- // If the loaded view is the same as the specified one, we will do nothing
796
- if (this._loadedViewClass === view) {
797
- return;
798
- }
799
- this.popView();
800
- }
801
- this.verifyViewsContainerExist();
802
- const factory = this.componentFactoryResolver.resolveComponentFactory(view);
803
- const componentRef = this._viewContainerRef.createComponent(factory);
804
- this._loadedViewModel = componentRef.instance.modelClass !== null ? new componentRef.instance.modelClass() : null;
805
- componentRef.changeDetectorRef.detectChanges();
806
- this._loadedViewClass = view;
807
- return componentRef;
808
- }
809
- /**
810
- * Get the model that is instantiated for the currently active view. (A view model only lives while its view is active)
811
- * If no view model is assigned to the current view or no view is loaded, an exception will be thrown.
812
- *
813
- * @return The current view model instance, which must be casted to the appropiate ViewModel extended class
814
- */
815
- get model() {
816
- if (this._loadedViewModel === null) {
817
- throw new Error('No active model. Make sure a view is loaded with an assigned model. Do not access the model until view is initialized (for example on ngAfterViewInit)');
818
- }
819
- return this._loadedViewModel;
820
- }
821
- /**
822
- * Delete the currently loaded view from the views container, and leave it empty.
823
- * If no view is currently loaded, this method will do nothing
824
- */
825
- popView() {
826
- this.verifyViewsContainerExist();
827
- if (this._loadedViewClass !== null) {
828
- this._viewContainerRef.clear();
829
- }
830
- this._loadedViewClass = null;
831
- this._loadedViewModel = null;
832
- }
833
- /**
834
- * Auxiliary method to test if the views container instance is available on the application
835
- */
836
- verifyViewsContainerExist() {
837
- if (this._viewContainerRef === null) {
838
- throw new Error('Views container not defined. Please declare a <views-container> element in your application');
839
- }
840
- }
841
- }
842
- ViewsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ViewsService, deps: [{ token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Injectable });
843
- ViewsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ViewsService });
844
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ViewsService, decorators: [{
845
- type: Injectable
846
- }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }]; } });
847
-
848
- /**
849
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
850
- *
851
- * Website : -> http://www.turbogui.org
852
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
853
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
854
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
855
- */
856
- /**
857
- * Component that is used as a container for application views.
858
- * We must create only one views container in our application and pass to it a reference to our main
859
- * viewsService instance. For example:
860
- *
861
- * <tg-views-container [viewsService]="viewsService" [initialView]="HomeViewComponent"></tg-views-container>
862
- */
863
- class ViewsContainerComponent {
864
- constructor() {
865
- /**
866
- * If we want to load a view by default when this component is loaded for the first time, we can
867
- * set here the respective class view and it will be automatically added.
868
- */
869
- this.initialView = null;
870
- /**
871
- * A reference to the views service that is used to operate with this views container.
872
- * This must be specified when this component is added to the application
873
- */
874
- this.viewsService = null;
875
- }
876
- /**
877
- * Check that the service reference has been correctly passed
878
- */
879
- ngOnInit() {
880
- if (!(this.viewsService instanceof ViewsService)) {
881
- throw new Error('ViewService instance must be referenced on a views container');
882
- }
883
- else {
884
- this.viewsService.viewContainerRef = this.viewContainerRef;
885
- }
886
- // Set the initial view if defined
887
- if (this.initialView !== null) {
888
- this.viewsService.pushView(this.initialView);
889
- }
890
- }
891
- /**
892
- * Clear the current view from the service when this component is deleted
893
- */
894
- ngOnDestroy() {
895
- if (this.viewsService instanceof ViewsService) {
896
- this.viewsService.popView();
897
- this.viewsService.viewContainerRef = null;
898
- }
899
- }
900
- }
901
- ViewsContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ViewsContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
902
- ViewsContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ViewsContainerComponent, selector: "tg-views-container", inputs: { initialView: "initialView", viewsService: "viewsService" }, viewQueries: [{ propertyName: "viewContainerRef", first: true, predicate: ["viewContainerRef"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<!--\r\n This is a dummy template component that will be used as the anchor point where the views will be loaded\r\n-->\r\n<ng-template #viewContainerRef></ng-template>", styles: [""] });
903
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ViewsContainerComponent, decorators: [{
904
- type: Component,
905
- args: [{ selector: 'tg-views-container', template: "<!--\r\n This is a dummy template component that will be used as the anchor point where the views will be loaded\r\n-->\r\n<ng-template #viewContainerRef></ng-template>" }]
906
- }], propDecorators: { initialView: [{
907
- type: Input
908
- }], viewsService: [{
909
- type: Input
910
- }], viewContainerRef: [{
911
- type: ViewChild,
912
- args: ['viewContainerRef', { read: ViewContainerRef, static: true }]
913
- }] } });
914
-
915
- /**
916
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
917
- *
918
- * Website : -> http://www.turbogui.org
919
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
920
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
921
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
922
- */
923
- /**
924
- * This is the base class for all button components
925
- */
926
- class ButtonBaseComponent {
927
- constructor() {
928
- /**
929
- * Defines the actual opacity that is binded on the html part
930
- */
931
- this.currentOpacity = .7;
932
- /**
933
- * Defines the actual scale that is binded on the html part
934
- */
935
- this.currentScale = 'scale(1)';
936
- /**
937
- * Defines if the button can be clicked or not
938
- */
939
- this.pointerEvents = 'initial';
940
- /**
941
- * Specifies if the button animations must rollback when the user releases the mouse or pointer after pressing it
942
- */
943
- this.releaseOnMouseUp = true;
944
- /**
945
- * Specifies the amount of milliseconds that the button will vibrate when it gets clicked (only on compatible devices and browsers)
946
- * Set it to 0 to disable click vibration
947
- */
948
- this.vibrateOnClick = 25;
949
- /**
950
- * Defines the button opacity when it is not clicked
951
- */
952
- this.defaultOpacity = .7;
953
- /**
954
- * Defines the image scale when it is not clicked
955
- */
956
- this.defaultScale = 1;
957
- /**
958
- * Defines the button opacity when it is hovered
959
- */
960
- this.hoverOpacity = .8;
961
- /**
962
- * Defines the image scale when it is hovered
963
- */
964
- this.hoverScale = 1;
965
- /**
966
- * Defines the button opacity when it is clicked
967
- */
968
- this.clickOpacity = 1;
969
- /**
970
- * Defines the image scale when it is clicked
971
- */
972
- this.clickScale = 1;
973
- /**
974
- * Defines the button opacity when it is disabled
975
- */
976
- this.disabledOpacity = .2;
977
- /**
978
- * Stores the value that tells if the button is enabled or disabled
979
- */
980
- this._enabled = true;
981
- }
982
- /**
983
- * Specifies if the button is enabled or disabled
984
- */
985
- set enabled(v) {
986
- this._enabled = v;
987
- this.currentOpacity = v ? this.defaultOpacity : this.disabledOpacity;
988
- this.pointerEvents = v ? 'initial' : 'none';
989
- }
990
- ;
991
- /**
992
- * Set button default values
993
- */
994
- ngOnInit() {
995
- this.currentOpacity = this._enabled ? this.defaultOpacity : this.disabledOpacity;
996
- this.currentScale = 'scale(1)';
997
- }
998
- /**
999
- * Listens for the mouse over the button component
1000
- */
1001
- onMouseOver() {
1002
- if (this._enabled) {
1003
- this.currentOpacity = this.hoverOpacity;
1004
- this.currentScale = 'scale(' + this.hoverScale + ')';
1005
- }
1006
- }
1007
- /**
1008
- * Listens for the mouse out of the button component
1009
- */
1010
- onMouseOut() {
1011
- if (this._enabled) {
1012
- this.currentOpacity = this.defaultOpacity;
1013
- this.currentScale = 'scale(' + this.defaultScale + ')';
1014
- }
1015
- }
1016
- /**
1017
- * Listens for the mouse down on the button component
1018
- */
1019
- onMouseDown() {
1020
- if (this._enabled) {
1021
- this.currentOpacity = this.clickOpacity;
1022
- this.currentScale = 'scale(' + this.clickScale + ')';
1023
- }
1024
- }
1025
- /**
1026
- * Listens for the mouse up of the button component
1027
- */
1028
- onMouseUp() {
1029
- if (this._enabled) {
1030
- if (this.vibrateOnClick > 0 && window.navigator && window.navigator.vibrate) {
1031
- window.navigator.vibrate(this.vibrateOnClick);
1032
- }
1033
- if (this.releaseOnMouseUp) {
1034
- this.currentOpacity = this.defaultOpacity;
1035
- this.currentScale = 'scale(' + this.defaultScale + ')';
1036
- }
1037
- }
1038
- }
1039
- }
1040
- ButtonBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ButtonBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1041
- ButtonBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: ButtonBaseComponent, inputs: { releaseOnMouseUp: "releaseOnMouseUp", vibrateOnClick: "vibrateOnClick", defaultOpacity: "defaultOpacity", defaultScale: "defaultScale", hoverOpacity: "hoverOpacity", hoverScale: "hoverScale", clickOpacity: "clickOpacity", clickScale: "clickScale", disabledOpacity: "disabledOpacity", enabled: "enabled" }, host: { listeners: { "mouseover": "onMouseOver()", "mouseout": "onMouseOut()", "pointerout": "onMouseOut()", "pointerleave": "onMouseOut()", "pointerdown": "onMouseDown()", "pointerup": "onMouseUp()" }, properties: { "style.opacity": "this.currentOpacity", "style.transform": "this.currentScale", "style.pointer-events": "this.pointerEvents" } }, ngImport: i0 });
1042
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ButtonBaseComponent, decorators: [{
1043
- type: Directive
1044
- }], propDecorators: { currentOpacity: [{
1045
- type: HostBinding,
1046
- args: ['style.opacity']
1047
- }], currentScale: [{
1048
- type: HostBinding,
1049
- args: ['style.transform']
1050
- }], pointerEvents: [{
1051
- type: HostBinding,
1052
- args: ['style.pointer-events']
1053
- }], releaseOnMouseUp: [{
1054
- type: Input
1055
- }], vibrateOnClick: [{
1056
- type: Input
1057
- }], defaultOpacity: [{
1058
- type: Input
1059
- }], defaultScale: [{
1060
- type: Input
1061
- }], hoverOpacity: [{
1062
- type: Input
1063
- }], hoverScale: [{
1064
- type: Input
1065
- }], clickOpacity: [{
1066
- type: Input
1067
- }], clickScale: [{
1068
- type: Input
1069
- }], disabledOpacity: [{
1070
- type: Input
1071
- }], enabled: [{
1072
- type: Input
1073
- }], onMouseOver: [{
1074
- type: HostListener,
1075
- args: ['mouseover']
1076
- }], onMouseOut: [{
1077
- type: HostListener,
1078
- args: ['mouseout']
1079
- }, {
1080
- type: HostListener,
1081
- args: ['pointerout']
1082
- }, {
1083
- type: HostListener,
1084
- args: ['pointerleave']
1085
- }], onMouseDown: [{
1086
- type: HostListener,
1087
- args: ['pointerdown']
1088
- }], onMouseUp: [{
1089
- type: HostListener,
1090
- args: ['pointerup']
1091
- }] } });
1092
-
1093
- /**
1094
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1095
- *
1096
- * Website : -> http://www.turbogui.org
1097
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1098
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1099
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1100
- */
1101
- /**
1102
- * This component is a basic button that uses an image as its visual appearance
1103
- */
1104
- class ButtonImageComponent extends ButtonBaseComponent {
1105
- constructor() {
1106
- super(...arguments);
1107
- /**
1108
- * This is used to attach the fade animation directly to this component so it fades in and out when created and removed from the app
1109
- */
1110
- this.buttonFade = true;
1111
- /**
1112
- * Defines the path to the image that is shown by this button
1113
- */
1114
- this.src = '';
1115
- /**
1116
- * Defines the percentual size of the image based on the button size. 100 means the image will fill the whole button,
1117
- * 50 only half, etc..
1118
- */
1119
- this.percentSize = 100;
1120
- }
1121
- }
1122
- ButtonImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ButtonImageComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1123
- ButtonImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ButtonImageComponent, selector: "tg-button-image", inputs: { src: "src", percentSize: "percentSize" }, host: { properties: { "@buttonFade": "this.buttonFade" } }, usesInheritance: true, ngImport: i0, template: "<img src=\"{{src}}\"\r\n [style.width]=\"percentSize + '%'\"\r\n [style.height]=\"percentSize + '%'\" />", styles: [":host{-webkit-user-select:none;-moz-user-select:none;user-select:none;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:opacity .3s ease,transform .2s cubic-bezier(.04,.62,.58,1);display:flex;justify-content:center;align-items:center}img{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}\n"], animations: [FadeAnimationClass.getTrigger('buttonFade', '300ms ease', '300ms ease')] });
1124
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ButtonImageComponent, decorators: [{
1125
- type: Component,
1126
- args: [{ selector: 'tg-button-image', animations: [FadeAnimationClass.getTrigger('buttonFade', '300ms ease', '300ms ease')], template: "<img src=\"{{src}}\"\r\n [style.width]=\"percentSize + '%'\"\r\n [style.height]=\"percentSize + '%'\" />", styles: [":host{-webkit-user-select:none;-moz-user-select:none;user-select:none;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:opacity .3s ease,transform .2s cubic-bezier(.04,.62,.58,1);display:flex;justify-content:center;align-items:center}img{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}\n"] }]
1127
- }], propDecorators: { buttonFade: [{
1128
- type: HostBinding,
1129
- args: ['@buttonFade']
1130
- }], src: [{
1131
- type: Input
1132
- }], percentSize: [{
1133
- type: Input
1134
- }] } });
1135
-
1136
- /**
1137
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1138
- *
1139
- * Website : -> http://www.turbogui.org
1140
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1141
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1142
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1143
- */
1144
- /**
1145
- * This component is a basic button without visual appearance, that is used as a container to load any content.
1146
- */
1147
- class ButtonContainerComponent extends ButtonBaseComponent {
1148
- constructor() {
1149
- super(...arguments);
1150
- /**
1151
- * This is used to attach the fade animation directly to this component so it fades in and out when created and removed from the app
1152
- */
1153
- this.buttonFade = true;
1154
- }
1155
- }
1156
- ButtonContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ButtonContainerComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1157
- ButtonContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ButtonContainerComponent, selector: "tg-button-container", host: { properties: { "@buttonFade": "this.buttonFade" } }, usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>", styles: [":host{-webkit-user-select:none;-moz-user-select:none;user-select:none;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:opacity .3s ease,transform .2s cubic-bezier(.04,.62,.58,1);display:flex;justify-content:center;align-items:center}\n"], animations: [FadeAnimationClass.getTrigger('buttonFade', '300ms ease', '300ms ease')] });
1158
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ButtonContainerComponent, decorators: [{
1159
- type: Component,
1160
- args: [{ selector: 'tg-button-container', animations: [FadeAnimationClass.getTrigger('buttonFade', '300ms ease', '300ms ease')], template: "<ng-content></ng-content>", styles: [":host{-webkit-user-select:none;-moz-user-select:none;user-select:none;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:opacity .3s ease,transform .2s cubic-bezier(.04,.62,.58,1);display:flex;justify-content:center;align-items:center}\n"] }]
1161
- }], propDecorators: { buttonFade: [{
1162
- type: HostBinding,
1163
- args: ['@buttonFade']
1164
- }] } });
1165
-
1166
- /**
1167
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1168
- *
1169
- * Website : -> http://www.turbogui.org
1170
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1171
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1172
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1173
- */
1174
- /**
1175
- * A dialog component with a single option button, to be used with dialog service
1176
- */
1177
- class DialogSingleOptionComponent extends DialogOptionsBaseComponent {
1178
- constructor(dialogRef, data) {
1179
- super();
1180
- this.dialogRef = dialogRef;
1181
- this.data = data;
1182
- if (data.texts.length < 1) {
1183
- throw new Error('DialogSingleOptionComponent expects 2 texts: The title and optionally a description');
1184
- }
1185
- if (data.options.length !== 1) {
1186
- throw new Error('DialogSingleOptionComponent expects only one option');
1187
- }
1188
- }
1189
- }
1190
- DialogSingleOptionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogSingleOptionComponent, deps: [{ token: i1$1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
1191
- DialogSingleOptionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DialogSingleOptionComponent, selector: "tg-dialog-single-option", usesInheritance: true, ngImport: i0, template: "<h3>\r\n {{data.texts[0]}}\r\n</h3>\r\n\r\n<p *ngIf=\"data.texts.length > 1\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<button mat-raised-button color=\"primary\"\r\n (click)=\"dialogRef.close(0)\">\r\n \r\n {{data.options[0]}}\r\n \r\n</button>", styles: [":host{min-height:300px}h3{margin-bottom:25px}p{margin-bottom:52px}button{float:right}\n"], dependencies: [{ kind: "component", type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1192
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogSingleOptionComponent, decorators: [{
1193
- type: Component,
1194
- args: [{ selector: 'tg-dialog-single-option', template: "<h3>\r\n {{data.texts[0]}}\r\n</h3>\r\n\r\n<p *ngIf=\"data.texts.length > 1\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<button mat-raised-button color=\"primary\"\r\n (click)=\"dialogRef.close(0)\">\r\n \r\n {{data.options[0]}}\r\n \r\n</button>", styles: [":host{min-height:300px}h3{margin-bottom:25px}p{margin-bottom:52px}button{float:right}\n"] }]
1195
- }], ctorParameters: function () {
1196
- return [{ type: i1$1.MatDialogRef }, { type: undefined, decorators: [{
1197
- type: Inject,
1198
- args: [MAT_DIALOG_DATA]
1199
- }] }];
1200
- } });
1201
-
1202
- /**
1203
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1204
- *
1205
- * Website : -> http://www.turbogui.org
1206
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1207
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1208
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1209
- */
1210
- /**
1211
- * A dialog component with two option buttons, to be used with dialog service.
1212
- * The first of the options is considered to be the primary one and will therefore have more visual accent
1213
- */
1214
- class DialogTwoOptionComponent extends DialogOptionsBaseComponent {
1215
- constructor(dialogRef, data) {
1216
- super();
1217
- this.dialogRef = dialogRef;
1218
- this.data = data;
1219
- if (data.texts.length < 1) {
1220
- throw new Error('DialogTwoOptionComponent expects 2 texts: The title and optionally a description');
1221
- }
1222
- if (data.options.length !== 2) {
1223
- throw new Error('DialogTwoOptionComponent expects only two options');
1224
- }
1225
- }
1226
- }
1227
- DialogTwoOptionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogTwoOptionComponent, deps: [{ token: i1$1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
1228
- DialogTwoOptionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DialogTwoOptionComponent, selector: "tg-dialog-two-option", usesInheritance: true, ngImport: i0, template: "<h3>\r\n {{data.texts[0]}}\r\n</h3>\r\n\r\n<p *ngIf=\"data.texts.length > 1\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<div class=\"buttonsContainer\">\r\n\r\n <button mat-raised-button color=\"primary\" class=\"primaryButton\"\r\n (click)=\"dialogRef.close(0)\">\r\n \r\n {{data.options[0]}}\r\n \r\n </button>\r\n \r\n <button mat-button\r\n (click)=\"dialogRef.close(1)\">\r\n \r\n {{data.options[1]}}\r\n \r\n </button>\r\n \r\n</div>\r\n", styles: [":host{min-height:300px}h3{margin-bottom:25px}p{margin-bottom:52px}.buttonsContainer{width:100%;max-width:530px;display:flex;flex-direction:row-reverse;float:right}button{width:50%;padding:0}.primaryButton{margin-left:2%}\n"], dependencies: [{ kind: "component", type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1229
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogTwoOptionComponent, decorators: [{
1230
- type: Component,
1231
- args: [{ selector: 'tg-dialog-two-option', template: "<h3>\r\n {{data.texts[0]}}\r\n</h3>\r\n\r\n<p *ngIf=\"data.texts.length > 1\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<div class=\"buttonsContainer\">\r\n\r\n <button mat-raised-button color=\"primary\" class=\"primaryButton\"\r\n (click)=\"dialogRef.close(0)\">\r\n \r\n {{data.options[0]}}\r\n \r\n </button>\r\n \r\n <button mat-button\r\n (click)=\"dialogRef.close(1)\">\r\n \r\n {{data.options[1]}}\r\n \r\n </button>\r\n \r\n</div>\r\n", styles: [":host{min-height:300px}h3{margin-bottom:25px}p{margin-bottom:52px}.buttonsContainer{width:100%;max-width:530px;display:flex;flex-direction:row-reverse;float:right}button{width:50%;padding:0}.primaryButton{margin-left:2%}\n"] }]
1232
- }], ctorParameters: function () {
1233
- return [{ type: i1$1.MatDialogRef }, { type: undefined, decorators: [{
1234
- type: Inject,
1235
- args: [MAT_DIALOG_DATA]
1236
- }] }];
1237
- } });
1238
-
1239
- /**
1240
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1241
- *
1242
- * Website : -> http://www.turbogui.org
1243
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1244
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1245
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1246
- */
1247
- /**
1248
- * An abstraction of the browser entity an all its related operations and properties
1249
- */
1250
- class BrowserService extends BrowserManager {
1251
- constructor(location) {
1252
- super();
1253
- this.location = location;
1254
- }
1255
- /**
1256
- * Modify the current browser URI without reloading the current page document
1257
- *
1258
- * @param path The uri value we want to set
1259
- * @param query The query url parameters part we want to specify if any
1260
- *
1261
- * @returns void
1262
- */
1263
- setURI(path, query) {
1264
- this.location.go(path, query);
1265
- }
1266
- /**
1267
- * Obtain a subscription to get notified on any changes at the browser url
1268
- *
1269
- * @param onNext A method to be executed every time the url changes on the browser. The url will be available inside the value parameter
1270
- *
1271
- * @returns Subscribed events. Make sure to unsubscribe when not needed
1272
- */
1273
- subscribeToUrlChange(onNext) {
1274
- return this.location.subscribe(onNext);
1275
- }
1276
- }
1277
- BrowserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BrowserService, deps: [{ token: i3.Location }], target: i0.ɵɵFactoryTarget.Injectable });
1278
- BrowserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BrowserService });
1279
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BrowserService, decorators: [{
1280
- type: Injectable
1281
- }], ctorParameters: function () { return [{ type: i3.Location }]; } });
1282
-
1283
- /**
1284
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1285
- *
1286
- * Website : -> http://www.turbogui.org
1287
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1288
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1289
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1290
- */
1291
- /** This directive is used to perform an autofocus on an element every time it is displayed */
1292
- /**
1293
- * This directive is used to perform an autofocus on an element every time it is displayed
1294
- * If we set the autoFocusOnDisplay tag to the html element, it will be automatically focused after it is shown.
1295
- */
1296
- class AutoFocusOnDisplayDirective {
1297
- constructor(el, zone, renderer) {
1298
- this.el = el;
1299
- this.zone = zone;
1300
- this.renderer = renderer;
1301
- if (!el.nativeElement['focus']) {
1302
- throw new Error('Element does not accept focus');
1303
- }
1304
- }
1305
- ngAfterContentInit() {
1306
- this.zone.runOutsideAngular(() => setTimeout(() => {
1307
- this.renderer.selectRootElement(this.el.nativeElement).focus();
1308
- }, 0));
1309
- }
1310
- }
1311
- AutoFocusOnDisplayDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AutoFocusOnDisplayDirective, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
1312
- AutoFocusOnDisplayDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: AutoFocusOnDisplayDirective, selector: "[autoFocusOnDisplay]", ngImport: i0 });
1313
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AutoFocusOnDisplayDirective, decorators: [{
1314
- type: Directive,
1315
- args: [{
1316
- selector: '[autoFocusOnDisplay]'
1317
- }]
1318
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.Renderer2 }]; } });
1319
-
1320
- /**
1321
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1322
- *
1323
- * Website : -> http://www.turbogui.org
1324
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1325
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1326
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1327
- */
1328
- /**
1329
- * A dialog component which allows us to select one single item from a list. The elements on that list are displayed on a table
1330
- * which may show a scroll if necessary when there are many elements on the list.
1331
- *
1332
- * It also allows us to filter inside the list with a custom text that we can type into a search input, which is optional.
1333
- *
1334
- * texts parameter must contain the title, the description (optional), the filter input title (optional), and the submit button caption.
1335
- * If that caption is not provided, the selection will be automatically performed once user clicks on an element on the list. Otherwise,
1336
- * the element will be selected on the list and the selection will be performed once the user clicks on the submit button.
1337
- *
1338
- * options parameter must contain the list of elements that will be displayed to the user
1339
- */
1340
- class DialogSingleSelectionListComponent extends DialogOptionsBaseComponent {
1341
- constructor(dialogRef, browserService, data) {
1342
- super();
1343
- this.dialogRef = dialogRef;
1344
- this.browserService = browserService;
1345
- this.data = data;
1346
- /**
1347
- * Declare a reference to the string utils class so it can be used on the html part
1348
- */
1349
- this.stringUtils = StringUtils;
1350
- /**
1351
- * Contains the list of elements that will be directly shown to the user at the component list.
1352
- * It may be filtered or not depending on this component setup and the user input
1353
- */
1354
- this.filteredOptions = [];
1355
- /**
1356
- * Contains the original list of elements that are provided to be listed on this component before
1357
- * being possibly filtered. It is only used as a backup, not shown to the user
1358
- */
1359
- this.originalOptions = [];
1360
- /**
1361
- * The same list as the originally provided but processed for a better text search.
1362
- * It will be used to perform the search, but not shown to the user.
1363
- */
1364
- this.originalOptionsFullTextSearch = [];
1365
- /**
1366
- * Stores the index for the element that's been selected by the user
1367
- */
1368
- this.selectedItemIndex = -1;
1369
- /**
1370
- * This method is used to greatly improve ngFor performance with arrays of primitive values. It tells the refresh
1371
- * function to work by index instead of by value. The change in performance when refreshing the list is massive.
1372
- */
1373
- this.trackByFn = (index, _value) => index;
1374
- if (data.texts.length < 1) {
1375
- throw new Error('DialogSingleSelectionListComponent expects 4 texts: The title, the description (optional), the filter input title (optional), and the submit button caption');
1376
- }
1377
- if (data.options.length < 1) {
1378
- throw new Error('DialogSingleSelectionListComponent expects one or more options');
1379
- }
1380
- this.originalOptions = data.options;
1381
- for (let option of this.originalOptions) {
1382
- this.filteredOptions.push(option);
1383
- this.originalOptionsFullTextSearch.push(StringUtils.formatForFullTextSearch(option));
1384
- }
1385
- }
1386
- /**
1387
- * Method to calculate the max possible height that the list items container is allowed to have
1388
- */
1389
- getListItemsContainerMaxheight() {
1390
- return (this.browserService.getWindowHeight() * 0.6) + 'px';
1391
- }
1392
- /**
1393
- * When the user types a value on the input element to filter the list, this method will perform
1394
- * that filtering and refresh the list
1395
- */
1396
- onSearchChange(input) {
1397
- this.selectedItemIndex = -1;
1398
- let inputValue = StringUtils.formatForFullTextSearch(input.value);
1399
- for (let i = 0; i < this.originalOptionsFullTextSearch.length; i++) {
1400
- if (inputValue === '' ||
1401
- this.originalOptionsFullTextSearch[i].indexOf(inputValue) >= 0) {
1402
- this.filteredOptions[i] = this.originalOptions[i];
1403
- }
1404
- else {
1405
- this.filteredOptions[i] = '';
1406
- }
1407
- }
1408
- }
1409
- }
1410
- DialogSingleSelectionListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogSingleSelectionListComponent, deps: [{ token: i1$1.MatDialogRef }, { token: BrowserService }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
1411
- DialogSingleSelectionListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DialogSingleSelectionListComponent, selector: "tg-dialog-single-selection-list", usesInheritance: true, ngImport: i0, template: "<h3>\r\n {{data.texts[0]}}\r\n</h3>\r\n\r\n<p *ngIf=\"data.texts.length > 1 &amp;&amp; !stringUtils.isEmpty(data.texts[1])\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<mat-form-field *ngIf=\"data.texts.length > 2 &amp;&amp; !stringUtils.isEmpty(data.texts[2])\"\r\n class=\"searchItemInputContainer\">\r\n \r\n <input matInput autoFocusOnDisplay\r\n placeholder=\"{{data.texts[2]}}\"\r\n (input)=\"onSearchChange($event.target)\">\r\n \r\n</mat-form-field>\r\n\r\n<div class=\"listItemsContainer\"\r\n [style.max-height]=\"getListItemsContainerMaxheight()\">\r\n\r\n <div class=\"listItemContainer\"\r\n [style.background-color]=\"selectedItemIndex === i ? '#90d1ffad' : (i % 2 === 0 ? 'initial' : '#00000009')\"\r\n *ngFor=\"let item of filteredOptions; let i = index; trackBy: trackByFn\"\r\n (click)=\"data.texts.length < 4 ? dialogRef.close(i) : selectedItemIndex = i\">\r\n \r\n <p *ngIf=\"item !== ''\">\r\n {{item}}\r\n </p>\r\n \r\n </div>\r\n\r\n</div>\r\n\r\n<button mat-raised-button color=\"primary\"\r\n [disabled]=\"selectedItemIndex < 0\"\r\n (click)=\"dialogRef.close(selectedItemIndex)\"\r\n *ngIf=\"data.texts.length > 3\">\r\n\r\n {{data.texts[3]}}\r\n \r\n</button>", styles: [":host{min-height:300px}h3{margin-top:0;margin-bottom:10px}p{margin-top:0;margin-bottom:5px}.searchItemInputContainer{width:100%;margin-top:0;margin-bottom:0}.listItemsContainer{overflow-y:auto;border:1px solid rgba(0,0,0,.2);border-radius:4px;margin-bottom:5px}.listItemContainer p{line-height:36px;width:calc(100% - 12px);margin:0 0 0 6px}button{float:right}\n"], dependencies: [{ kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: AutoFocusOnDisplayDirective, selector: "[autoFocusOnDisplay]" }] });
1412
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogSingleSelectionListComponent, decorators: [{
1413
- type: Component,
1414
- args: [{ selector: 'tg-dialog-single-selection-list', template: "<h3>\r\n {{data.texts[0]}}\r\n</h3>\r\n\r\n<p *ngIf=\"data.texts.length > 1 &amp;&amp; !stringUtils.isEmpty(data.texts[1])\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<mat-form-field *ngIf=\"data.texts.length > 2 &amp;&amp; !stringUtils.isEmpty(data.texts[2])\"\r\n class=\"searchItemInputContainer\">\r\n \r\n <input matInput autoFocusOnDisplay\r\n placeholder=\"{{data.texts[2]}}\"\r\n (input)=\"onSearchChange($event.target)\">\r\n \r\n</mat-form-field>\r\n\r\n<div class=\"listItemsContainer\"\r\n [style.max-height]=\"getListItemsContainerMaxheight()\">\r\n\r\n <div class=\"listItemContainer\"\r\n [style.background-color]=\"selectedItemIndex === i ? '#90d1ffad' : (i % 2 === 0 ? 'initial' : '#00000009')\"\r\n *ngFor=\"let item of filteredOptions; let i = index; trackBy: trackByFn\"\r\n (click)=\"data.texts.length < 4 ? dialogRef.close(i) : selectedItemIndex = i\">\r\n \r\n <p *ngIf=\"item !== ''\">\r\n {{item}}\r\n </p>\r\n \r\n </div>\r\n\r\n</div>\r\n\r\n<button mat-raised-button color=\"primary\"\r\n [disabled]=\"selectedItemIndex < 0\"\r\n (click)=\"dialogRef.close(selectedItemIndex)\"\r\n *ngIf=\"data.texts.length > 3\">\r\n\r\n {{data.texts[3]}}\r\n \r\n</button>", styles: [":host{min-height:300px}h3{margin-top:0;margin-bottom:10px}p{margin-top:0;margin-bottom:5px}.searchItemInputContainer{width:100%;margin-top:0;margin-bottom:0}.listItemsContainer{overflow-y:auto;border:1px solid rgba(0,0,0,.2);border-radius:4px;margin-bottom:5px}.listItemContainer p{line-height:36px;width:calc(100% - 12px);margin:0 0 0 6px}button{float:right}\n"] }]
1415
- }], ctorParameters: function () {
1416
- return [{ type: i1$1.MatDialogRef }, { type: BrowserService }, { type: undefined, decorators: [{
1417
- type: Inject,
1418
- args: [MAT_DIALOG_DATA]
1419
- }] }];
1420
- } });
1421
-
1422
- /**
1423
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1424
- *
1425
- * Website : -> http://www.turbogui.org
1426
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1427
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1428
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1429
- */
1430
- /**
1431
- * A dialog component that is designed to show more than one option buttons (usually more than two), to be used with dialog service
1432
- */
1433
- class DialogMultipleOptionComponent extends DialogOptionsBaseComponent {
1434
- constructor(dialogRef, data) {
1435
- super();
1436
- this.dialogRef = dialogRef;
1437
- this.data = data;
1438
- if (data.texts.length < 1) {
1439
- throw new Error('DialogMultipleOptionComponent expects 2 texts: The title and optionally a description');
1440
- }
1441
- }
1442
- }
1443
- DialogMultipleOptionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogMultipleOptionComponent, deps: [{ token: i1$1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
1444
- DialogMultipleOptionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DialogMultipleOptionComponent, selector: "tg-dialog-multiple-option", usesInheritance: true, ngImport: i0, template: "<h3>\r\n {{data.texts[0]}}\r\n</h3>\r\n\r\n<p *ngIf=\"data.texts.length > 1\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<button mat-raised-button color=\"primary\"\r\n *ngFor=\"let option of data.options; let i = index\"\r\n (click)=\"dialogRef.close(i)\">\r\n \r\n {{option}}\r\n \r\n</button>", styles: [":host{display:flex;flex-direction:column;min-height:193px}h3{margin-bottom:45px}button{margin-bottom:25px}\n"], dependencies: [{ kind: "component", type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1445
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogMultipleOptionComponent, decorators: [{
1446
- type: Component,
1447
- args: [{ selector: 'tg-dialog-multiple-option', template: "<h3>\r\n {{data.texts[0]}}\r\n</h3>\r\n\r\n<p *ngIf=\"data.texts.length > 1\">\r\n {{data.texts[1]}}\r\n</p>\r\n\r\n<button mat-raised-button color=\"primary\"\r\n *ngFor=\"let option of data.options; let i = index\"\r\n (click)=\"dialogRef.close(i)\">\r\n \r\n {{option}}\r\n \r\n</button>", styles: [":host{display:flex;flex-direction:column;min-height:193px}h3{margin-bottom:45px}button{margin-bottom:25px}\n"] }]
1448
- }], ctorParameters: function () {
1449
- return [{ type: i1$1.MatDialogRef }, { type: undefined, decorators: [{
1450
- type: Inject,
1451
- args: [MAT_DIALOG_DATA]
1452
- }] }];
1453
- } });
1454
-
1455
- /**
1456
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1457
- *
1458
- * Website : -> http://www.turbogui.org
1459
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1460
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1461
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1462
- */
1463
- /** This directive is used to listen for onInit events on raw html elements */
1464
- /**
1465
- * This directive is used to listen for onInit events on raw html elements
1466
- * If we place (elementCreated)="someMethod()" on the element at the html template part, when the element
1467
- * that uses this directive is visually created, someMethod() will be called.
1468
- */
1469
- class ElementCreatedDirective {
1470
- constructor() {
1471
- /**
1472
- * Event that will be dispatched once element is created
1473
- */
1474
- this.elementCreated = new EventEmitter();
1475
- }
1476
- /**
1477
- * Listen for the on init event
1478
- */
1479
- ngOnInit() {
1480
- this.elementCreated.next(this);
1481
- }
1482
- }
1483
- ElementCreatedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ElementCreatedDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1484
- ElementCreatedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: ElementCreatedDirective, selector: "[elementCreated]", outputs: { elementCreated: "elementCreated" }, ngImport: i0 });
1485
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ElementCreatedDirective, decorators: [{
1486
- type: Directive,
1487
- args: [{
1488
- selector: '[elementCreated]'
1489
- }]
1490
- }], propDecorators: { elementCreated: [{
1491
- type: Output,
1492
- args: ['elementCreated']
1493
- }] } });
1494
-
1495
- /**
1496
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1497
- *
1498
- * Website : -> http://www.turbogui.org
1499
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1500
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1501
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1502
- */
1503
- /** This directive is used to listen for onDestroy events on raw html elements */
1504
- /**
1505
- * This directive is used to listen for onDestroy events on raw html elements
1506
- * If we place (elementDestroyed)="someMethod()" on the element at the html template part, when the element
1507
- * that uses this directive is visually destroyed from the screen, someMethod() will be called.
1508
- */
1509
- class ElementDestroyedDirective {
1510
- constructor() {
1511
- /**
1512
- * Event that will be dispatched once element is destroyed
1513
- */
1514
- this.elementDestroyed = new EventEmitter();
1515
- }
1516
- /**
1517
- * Listen for the on destroy event
1518
- */
1519
- ngOnDestroy() {
1520
- this.elementDestroyed.next(this);
1521
- }
1522
- }
1523
- ElementDestroyedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ElementDestroyedDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1524
- ElementDestroyedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: ElementDestroyedDirective, selector: "[elementDestroyed]", outputs: { elementDestroyed: "elementDestroyed" }, ngImport: i0 });
1525
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ElementDestroyedDirective, decorators: [{
1526
- type: Directive,
1527
- args: [{
1528
- selector: '[elementDestroyed]'
1529
- }]
1530
- }], propDecorators: { elementDestroyed: [{
1531
- type: Output,
1532
- args: ['elementDestroyed']
1533
- }] } });
1534
-
1535
- /**
1536
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1537
- *
1538
- * Website : -> http://www.turbogui.org
1539
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1540
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1541
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1542
- */
1543
- /** This directive is used to perform an automatic select all text on an element every time it is focused */
1544
- /**
1545
- * This directive is used to perform an an automatic select all text on an element every time it is focused.
1546
- * If we set the autoSelectTextOnFocus tag to the html element, its text will be automatically selected after it gets the focus.
1547
- */
1548
- class AutoSelectTextOnFocusDirective {
1549
- constructor(el, renderer) {
1550
- this.el = el;
1551
- this.renderer = renderer;
1552
- if (!el.nativeElement['select']) {
1553
- throw new Error('Element does not accept select');
1554
- }
1555
- }
1556
- onFocus() {
1557
- this.renderer.selectRootElement(this.el.nativeElement).select();
1558
- }
1559
- }
1560
- AutoSelectTextOnFocusDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AutoSelectTextOnFocusDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
1561
- AutoSelectTextOnFocusDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: AutoSelectTextOnFocusDirective, selector: "[autoSelectTextOnFocus]", host: { listeners: { "focus": "onFocus($event)" } }, ngImport: i0 });
1562
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AutoSelectTextOnFocusDirective, decorators: [{
1563
- type: Directive,
1564
- args: [{
1565
- selector: '[autoSelectTextOnFocus]'
1566
- }]
1567
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }]; }, propDecorators: { onFocus: [{
1568
- type: HostListener,
1569
- args: ['focus', ['$event']]
1570
- }] } });
1571
-
1572
- /**
1573
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1574
- *
1575
- * Website : -> http://www.turbogui.org
1576
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1577
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1578
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1579
- */
1580
- /**
1581
- * This file contains the root module that contains all the library declarations and exports.
1582
- */
1583
- class TurboGuiAngularModule {
1584
- }
1585
- TurboGuiAngularModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TurboGuiAngularModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1586
- TurboGuiAngularModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: TurboGuiAngularModule, declarations: [BusyStateBaseComponent,
1587
- DialogErrorComponent,
1588
- DialogSingleOptionComponent,
1589
- DialogTwoOptionComponent,
1590
- DialogMultipleOptionComponent,
1591
- DialogSingleSelectionListComponent,
1592
- ViewsContainerComponent,
1593
- ButtonImageComponent,
1594
- ButtonContainerComponent,
1595
- ElementCreatedDirective,
1596
- ElementDestroyedDirective,
1597
- AutoFocusOnDisplayDirective,
1598
- AutoSelectTextOnFocusDirective], imports: [MatDialogModule,
1599
- MatSnackBarModule,
1600
- MatInputModule,
1601
- MatButtonModule,
1602
- MatFormFieldModule,
1603
- BrowserAnimationsModule], exports: [BusyStateBaseComponent,
1604
- ViewsContainerComponent,
1605
- ButtonImageComponent,
1606
- ButtonContainerComponent,
1607
- DialogErrorComponent,
1608
- DialogSingleOptionComponent,
1609
- DialogTwoOptionComponent,
1610
- DialogMultipleOptionComponent,
1611
- DialogSingleSelectionListComponent,
1612
- ElementCreatedDirective,
1613
- ElementDestroyedDirective,
1614
- AutoFocusOnDisplayDirective,
1615
- AutoSelectTextOnFocusDirective] });
1616
- TurboGuiAngularModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TurboGuiAngularModule, providers: [
1617
- DialogService,
1618
- LocalizationService,
1619
- HTTPService,
1620
- NotificationService,
1621
- UserService,
1622
- ViewsService,
1623
- BrowserService
1624
- ], imports: [MatDialogModule,
1625
- MatSnackBarModule,
1626
- MatInputModule,
1627
- MatButtonModule,
1628
- MatFormFieldModule,
1629
- BrowserAnimationsModule] });
1630
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TurboGuiAngularModule, decorators: [{
1631
- type: NgModule,
1632
- args: [{
1633
- imports: [
1634
- MatDialogModule,
1635
- MatSnackBarModule,
1636
- MatInputModule,
1637
- MatButtonModule,
1638
- MatFormFieldModule,
1639
- BrowserAnimationsModule
1640
- ],
1641
- declarations: [
1642
- BusyStateBaseComponent,
1643
- DialogErrorComponent,
1644
- DialogSingleOptionComponent,
1645
- DialogTwoOptionComponent,
1646
- DialogMultipleOptionComponent,
1647
- DialogSingleSelectionListComponent,
1648
- ViewsContainerComponent,
1649
- ButtonImageComponent,
1650
- ButtonContainerComponent,
1651
- ElementCreatedDirective,
1652
- ElementDestroyedDirective,
1653
- AutoFocusOnDisplayDirective,
1654
- AutoSelectTextOnFocusDirective
1655
- ],
1656
- // Globally available singleton services are added here
1657
- providers: [
1658
- DialogService,
1659
- LocalizationService,
1660
- HTTPService,
1661
- NotificationService,
1662
- UserService,
1663
- ViewsService,
1664
- BrowserService
1665
- ],
1666
- exports: [
1667
- BusyStateBaseComponent,
1668
- ViewsContainerComponent,
1669
- ButtonImageComponent,
1670
- ButtonContainerComponent,
1671
- DialogErrorComponent,
1672
- DialogSingleOptionComponent,
1673
- DialogTwoOptionComponent,
1674
- DialogMultipleOptionComponent,
1675
- DialogSingleSelectionListComponent,
1676
- ElementCreatedDirective,
1677
- ElementDestroyedDirective,
1678
- AutoFocusOnDisplayDirective,
1679
- AutoSelectTextOnFocusDirective
1680
- ]
1681
- }]
1682
- }] });
1683
-
1684
- /**
1685
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1686
- *
1687
- * Website : -> http://www.turbogui.org
1688
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1689
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1690
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1691
- */
1692
- /**
1693
- * Captures all the application exceptions and performs any required action.
1694
- * It also contains multiple general error management features.
1695
- *
1696
- * To define this class as your application error handler, you must add the following to your
1697
- * main app module providers:
1698
- * {
1699
- * provide: ErrorHandler,
1700
- * useClass: GlobalErrorService
1701
- * },
1702
- * GlobalErrorService
1703
- *
1704
- * You cannot access the error handler at runtime. If you need to modify any of the behaviours
1705
- * or implement your custom ones, you must extend this class and set your new one as the error
1706
- * handler provider.
1707
- */
1708
- class GlobalErrorService {
1709
- constructor() {
1710
- /**
1711
- * Enables or disables the error notification to user via an alert box
1712
- * Extend this class and override this value on your custom error handle to change it
1713
- */
1714
- this.showExceptionsToUser = true;
1715
- /**
1716
- * Enables or disables the error notification to user via an alert box
1717
- * Extend this class and override this value on your custom error handle to change it
1718
- */
1719
- this.showExceptionsOnConsole = true;
1720
- /**
1721
- * Defines the text that will be used for the alert that is shown to the user when an exception happens
1722
- * and showExceptionsToUser is true
1723
- * Extend this class and override this value on your custom error handle to change it
1724
- */
1725
- this.errorAlertMessage = 'Application exception:\n\n';
1726
- }
1727
- /**
1728
- * Show an alert with the received error detail and also log it to the js console.
1729
- *
1730
- * Angular expects at least this method to be implemented on any class that is used as a global exception handler.
1731
- *
1732
- * @param error An error instance
1733
- */
1734
- handleError(error) {
1735
- if (this.showExceptionsToUser) {
1736
- alert(this.errorAlertMessage + error);
1737
- }
1738
- if (this.showExceptionsOnConsole) {
1739
- console.log(error);
1740
- }
1741
- throw error;
1742
- }
1743
- }
1744
- GlobalErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GlobalErrorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1745
- GlobalErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GlobalErrorService });
1746
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GlobalErrorService, decorators: [{
1747
- type: Injectable
1748
- }] });
1749
-
1750
- /**
1751
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1752
- *
1753
- * Website : -> http://www.turbogui.org
1754
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1755
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1756
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1757
- */
1758
- /**
1759
- * Class that defines a GET http request, to be used by HttpService
1760
- */
1761
- class HTTPServiceGetRequest extends HTTPManagerGetRequest {
1762
- }
1763
-
1764
- /**
1765
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1766
- *
1767
- * Website : -> http://www.turbogui.org
1768
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1769
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1770
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1771
- */
1772
- /**
1773
- * Defines the data that is contained inside a GUI notification
1774
- */
1775
- class GUINotification {
1776
- constructor(name, type = '', data = null) {
1777
- /**
1778
- * The name for this notification
1779
- */
1780
- this.name = '';
1781
- /**
1782
- * An optional type to categorize this notification in case the name is not enough
1783
- * to uniquely identify it
1784
- */
1785
- this.type = '';
1786
- /**
1787
- * Additional data to send with the notification
1788
- */
1789
- this.data = null;
1790
- this.name = name;
1791
- this.type = type;
1792
- this.data = data;
1793
- }
1794
- }
1795
-
1796
- /**
1797
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1798
- *
1799
- * Website : -> http://www.turbogui.org
1800
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1801
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1802
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1803
- */
1804
- /**
1805
- * Defines an application view.
1806
- * Our View components must extend this class so they can be manipulated via ViewsService
1807
- */
1808
- class View {
1809
- /**
1810
- * In order for the views service to know which model class must be created when setting a new active view,
1811
- * each view must specify the class for the view model at the overriden constructor super() call.
1812
- * All view models must also extend ViewModel. If we do not plan to attach a model to a view, we can pass a null value to
1813
- * the constructor super() call.
1814
- *
1815
- * A new model instance will be automatically created each time the view is added to the views container, and
1816
- * destroyed when the view is removed. So the view model will only live while the view is active on the views service.
1817
- */
1818
- constructor(modelClass) {
1819
- this._modelClass = null;
1820
- this._modelClass = modelClass;
1821
- }
1822
- /**
1823
- * Obtain the class type for the model that is linked to this view, or null if the view model is not yet instantiated.
1824
- */
1825
- get modelClass() {
1826
- return this._modelClass;
1827
- }
1828
- }
1829
-
1830
- /**
1831
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1832
- *
1833
- * Website : -> http://www.turbogui.org
1834
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1835
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1836
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1837
- */
1838
- /**
1839
- * Defines the model base class for an application view
1840
- */
1841
- class ViewModel {
1842
- }
1843
-
1844
- /**
1845
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1846
- *
1847
- * Website : -> http://www.turbogui.org
1848
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1849
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1850
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1851
- */
1852
- /**
1853
- * Defines the service base class for a view service class. All services that are used by views must extend this.
1854
- * We must create the view services as an @Injectable() angular class which will be globally available at any time, but we must take
1855
- * into consideration that the view model will only be instantiated when the view is active.
1856
- */
1857
- class ViewService {
1858
- /**
1859
- * Class requires a views service instance
1860
- */
1861
- constructor(viewsService) {
1862
- this.viewsService = viewsService;
1863
- }
1864
- /**
1865
- * A reference to the currently active view model
1866
- */
1867
- get model() {
1868
- return this.viewsService.model;
1869
- }
1870
- }
1871
-
1872
- /**
1873
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
1874
- *
1875
- * Website : -> http://www.turbogui.org
1876
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
1877
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
1878
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
1879
- */
1880
- /**
1881
- * Sometimes it is necessary to apply some kind of buffer to the user input for certain operations that may be executed
1882
- * several times but we need to capture only the latest of them into a certain period of time. This class does exactly this:
1883
- * we can queue as many times as we want a specific method call and only the last one will be executed under a defined window of time.
1884
- * So for example if a user types keys on an input, we can buffer it for x seconds and perform a request only with the last of its changes.
1885
- * Lots of other UI interaction usages may be interesting with this class.
1886
- */
1887
- class DelayedMethodCallManager {
1888
- /**
1889
- * Sometimes it is necessary to apply some kind of buffer to the user input for certain operations that may be executed
1890
- * several times but we need to capture only the latest of them into a certain period of time. This class does exactly this:
1891
- * we can queue as many times as we want a specific method call and only the last one will be executed under a defined window of time.
1892
- * So for example if a user types keys on an input, we can buffer it for x seconds and perform a request only with the last of its changes.
1893
- * Lots of other UI interaction usages may be interesting with this class.
1894
- *
1895
- * @param delay Amount of time to wait before executing the operations . Defaults to 1000 miliseconds.
1896
- */
1897
- constructor(delay = 1000) {
1898
- this.delay = delay;
1899
- this._functionsToExecute = [];
1900
- this._timerIsRunning = false;
1901
- this._setTimeoutHandler = null;
1902
- }
1903
- /**
1904
- * Add a method to be called once the delay time is finished.
1905
- * Every time a new call to queue is performed, the delay timer is restarted. When the delay time finishes, only the
1906
- * last of the methods that have been pushed by call() will be executed.
1907
- *
1908
- * Use it to queue several user input operations that should be called only once in a period of time, while waiting
1909
- * for the user to finish his input.
1910
- *
1911
- * @param method The function that will be queued for execution after the delay time has passed
1912
- */
1913
- queue(method) {
1914
- this._functionsToExecute.push(method);
1915
- if (this._timerIsRunning) {
1916
- clearTimeout(this._setTimeoutHandler);
1917
- }
1918
- this._timerIsRunning = true;
1919
- this._setTimeoutHandler = setTimeout(() => { this.run(); }, this.delay);
1920
- }
1921
- /**
1922
- * Abort all methods that may have been pushed to this class and are waiting to be executed, so none of them
1923
- * is executed when the delay time finishes. Basically everything is cleared and stoped when this method is called.
1924
- */
1925
- cancel() {
1926
- if (this._setTimeoutHandler !== null) {
1927
- clearTimeout(this._setTimeoutHandler);
1928
- }
1929
- this._functionsToExecute = [];
1930
- this._timerIsRunning = false;
1931
- }
1932
- /**
1933
- * Auxiliary function that performs the call to the latest queued method
1934
- */
1935
- run() {
1936
- this._functionsToExecute.pop()();
1937
- this._functionsToExecute = [];
1938
- this._timerIsRunning = false;
1939
- }
1940
- }
1941
-
1942
- /*
1943
- * Public API Surface of turbogui-angular
1944
- */
1945
-
1946
- /**
1947
- * Generated bundle index. Do not edit.
1948
- */
1949
-
1950
- export { AutoFocusOnDisplayDirective, AutoSelectTextOnFocusDirective, BrowserService, BusyStateBaseComponent, ButtonContainerComponent, ButtonImageComponent, DelayedMethodCallManager, DialogErrorComponent, DialogMultipleOptionComponent, DialogOptionsBaseComponent, DialogService, DialogSingleOptionComponent, DialogSingleSelectionListComponent, DialogTwoOptionComponent, ElementCreatedDirective, ElementDestroyedDirective, FadeAnimationClass, GUINotification, GlobalErrorService, HTTPService, HTTPServiceGetRequest, HTTPServicePostRequest, LocalizationService, NotificationService, TurboGuiAngularModule, UserService, View, ViewModel, ViewService, ViewsContainerComponent, ViewsService };
1951
- //# sourceMappingURL=turbogui-angular.mjs.map