turbogui-angular 15.3.0 → 16.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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Directive, Output, HostListener, NgModule, inject, Injectable, Component, Inject, HostBinding, ViewContainerRef, Input, ViewChild } from '@angular/core';
2
+ import { EventEmitter, Directive, Output, HostListener, NgModule, inject, Injectable, Component, Inject, HostBinding, Input } from '@angular/core';
3
3
  import { Subject } from 'rxjs';
4
4
  import { ArrayUtils, NumericUtils, HTTPManager, StringUtils, HTTPManagerGetRequest, HTTPManagerPostRequest, BrowserManager, ConversionUtils } from 'turbocommons-ts';
5
5
  import * as i1 from '@angular/material/dialog';
@@ -8,7 +8,6 @@ import * as i3 from '@angular/material/button';
8
8
  import { MatButtonModule } from '@angular/material/button';
9
9
  import * as i2 from '@angular/common';
10
10
  import { CommonModule } from '@angular/common';
11
- import * as i1$2 from '@angular/animations';
12
11
  import { style, animate, transition, trigger } from '@angular/animations';
13
12
  import { ComponentPortal, DomPortalOutlet } from '@angular/cdk/portal';
14
13
  import * as i2$1 from '@angular/material/datepicker';
@@ -476,6 +475,8 @@ class LocalesService extends SingletoneStrictClass {
476
475
  }
477
476
  /**
478
477
  * Initializes the translation system by loading and parsing bundle files from the specified translations path.
478
+ * After the promise finishes, the class will contain all the translation data and will be ready to translate any
479
+ * provided key.
479
480
  *
480
481
  * @param translationsPath - Url where the translations Json structure of libraries/bundles/locales/keys is available.
481
482
  * @param locales An array of locale codes (e.g., ['en_US', 'es_ES', 'fr_FR']) to load. These will be added to the translation
@@ -573,8 +574,8 @@ class LocalesService extends SingletoneStrictClass {
573
574
  * @param string key The key we want to read from the specified resource bundle
574
575
  * @param string bundlePath A string with the format 'library_name/bundle_name' that is used to locate the bundle were the key to translate is found
575
576
  * @param array replaceWildcards A list of values that will replace wildcards that may be found on the translated text. Each wildcard
576
- * will be replaced with the element whose index on toReplace matches it. Check the documentation for this.wildCardsFormat
577
- * property to know more about how to setup wildcards.
577
+ * will be replaced with the element whose index on replaceWildcards matches it. Check the documentation for this.wildCardsFormat
578
+ * property to know more about how to setup wildcards on your translations.
578
579
  *
579
580
  * @see setWildCardsFormat()
580
581
  *
@@ -1273,8 +1274,9 @@ class DialogService extends SingletoneStrictClass {
1273
1274
  * - modal: True (default) if selecting an option is mandatory to close the dialog, false if the dialog can be closed
1274
1275
  * by the user clicking outside it
1275
1276
  * - texts: A list with strings containing the dialog texts, sorted by importance. When dialog has a title, this should
1276
- * be placed first, subtitle second and so (Each dialog may accept different number of texts).
1277
+ * be placed first, subtitle second and so (Each dialog may accept a different custom number of texts).
1277
1278
  * - options: A list of strings that will be used as button captions for each one of the accepted dialog options
1279
+ * - data: An object that we can use to pass any extra data that we want to the dialog
1278
1280
  * - viewContainerRef: This is important if we want to propagate providers from a parent component to this dialog. We must specify
1279
1281
  * this reference to make sure the same services injected on the parent are available too at the child dialog
1280
1282
  *
@@ -1289,6 +1291,7 @@ class DialogService extends SingletoneStrictClass {
1289
1291
  properties.modal = properties.modal ?? true;
1290
1292
  properties.texts = properties.texts ?? [];
1291
1293
  properties.options = properties.options ?? [];
1294
+ properties.data = properties.data ?? {};
1292
1295
  // Generate a string to uniquely identify this dialog on the list of active dialogs
1293
1296
  // A dialog is considered as unique if the dialog id and texts are exactly the same. We do not take options into consideration
1294
1297
  // as there may be dialogs with a big amount of options available.
@@ -1308,7 +1311,7 @@ class DialogService extends SingletoneStrictClass {
1308
1311
  autoFocus: false,
1309
1312
  closeOnNavigation: !properties.modal,
1310
1313
  viewContainerRef: properties.viewContainerRef,
1311
- data: { texts: properties.texts, options: properties.options }
1314
+ data: { texts: properties.texts, options: properties.options, data: properties.data }
1312
1315
  });
1313
1316
  // Assign the dialog ID only if specifically set on properties
1314
1317
  if (properties.id && properties.id !== undefined) {
@@ -1604,6 +1607,10 @@ class TurboApiCallerService extends SingletoneStrictClass {
1604
1607
  * URI Path to the web service that performs the user login
1605
1608
  */
1606
1609
  this.loginServiceURI = 'users/login';
1610
+ /**
1611
+ * URI Path to the web service that allows us to create extra user tokens
1612
+ */
1613
+ this.tokenCreationServiceURI = 'users/user-token-create';
1607
1614
  /**
1608
1615
  * URI Path to the web service that performs the user log out
1609
1616
  */
@@ -1796,6 +1803,18 @@ class TurboApiCallerService extends SingletoneStrictClass {
1796
1803
  this.httpManager.execute(request);
1797
1804
  });
1798
1805
  }
1806
+ /**
1807
+ * Perform a request to the API service to create a new token for the user that is currently logged in.
1808
+ *
1809
+ * @param options The parameters that will affect the token behaviour. To learn more about each option, please
1810
+ * refer to the turbodepot UsersManager class createToken method documentation
1811
+ *
1812
+ * @returns A promise that resolves with the created token string if the request is successful, or rejects
1813
+ * with an error (containing all the error response details) if the request fails.
1814
+ */
1815
+ createUserToken(options) {
1816
+ return this.call(this.tokenCreationServiceURI, { options: options }, { resultFormat: 'STRING' });
1817
+ }
1799
1818
  /**
1800
1819
  * Checks if the user and password credentials are filled and not empty.
1801
1820
  * If any of the two values is empty, false will be returned
@@ -2001,149 +2020,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImpor
2001
2020
  }]
2002
2021
  }], ctorParameters: () => [{ type: DialogService }, { type: BrowserService }] });
2003
2022
 
2004
- /**
2005
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
2006
- *
2007
- * Website : -> http://www.turbogui.org
2008
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
2009
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
2010
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
2011
- */
2012
- /**
2013
- * Manages adding, removing and manipulating the application views
2014
- */
2015
- class ViewsService extends SingletoneStrictClass {
2016
- constructor(animationBuilder) {
2017
- super(ViewsService);
2018
- this.animationBuilder = animationBuilder;
2019
- /**
2020
- * See getter method for docs
2021
- */
2022
- this._loadedViewClass = null;
2023
- /**
2024
- * See setter method for docs
2025
- */
2026
- this._viewContainerRef = null;
2027
- /**
2028
- * Contains the reference to the currently loaded view component
2029
- */
2030
- this._currentComponentRef = null;
2031
- /**
2032
- * Flag that stores if any view is in the process of being loaded
2033
- */
2034
- this._isLoadingView = false;
2035
- }
2036
- /**
2037
- * Tells if there's any view currently loaded on the application views container
2038
- */
2039
- get isViewLoaded() {
2040
- return this._loadedViewClass !== null;
2041
- }
2042
- /**
2043
- * Stores a reference to the visual element that will be used as the container for all the views.
2044
- * This is automatically assigned by the tg-views-container component once it is created.
2045
- *
2046
- * @see ViewsContainerComponent for more information
2047
- */
2048
- set viewContainerRef(ref) {
2049
- if (ref !== null && this._viewContainerRef !== null) {
2050
- throw new Error('Views container already defined. Only one views container element can exist on an application');
2051
- }
2052
- this._viewContainerRef = ref;
2053
- }
2054
- /**
2055
- * Create a new view instance with the specified type and add it to the current application views container. Any currently loaded
2056
- * view will be removed.
2057
- *
2058
- * If we push a view while another one is in the process of being loaded, the new push will be ignored.
2059
- *
2060
- * Make sure this method is called when all the visual components of the application have been created (ngAfterViewInit)
2061
- *
2062
- * @param view The classname for the view that we want to create (must extend View base class). A new angular object
2063
- * will be instantiated and loaded into the views container.
2064
- */
2065
- async pushView(view) {
2066
- // If the loaded view is the same as the specified one, we will do nothing
2067
- if (this._loadedViewClass === view) {
2068
- return;
2069
- }
2070
- // If a view is already being loaded, nothing to do
2071
- if (this._isLoadingView) {
2072
- return;
2073
- }
2074
- this._isLoadingView = true;
2075
- // If a view is already loaded, we will unload it first
2076
- if (this._loadedViewClass !== null) {
2077
- await this.removeCurrentView();
2078
- }
2079
- // Create the new view
2080
- const newComponentRef = this._viewContainerRef.createComponent(view);
2081
- newComponentRef.changeDetectorRef.detectChanges();
2082
- // Set initial opacity to 0
2083
- newComponentRef.location.nativeElement.style.opacity = '0';
2084
- // Fade in the new view
2085
- const fadeInPlayer = this.animationBuilder.build([
2086
- style({ opacity: 0 }),
2087
- animate('300ms ease', style({ opacity: 1 }))
2088
- ]).create(newComponentRef.location.nativeElement);
2089
- await new Promise((resolve) => {
2090
- fadeInPlayer.onDone(() => {
2091
- this._currentComponentRef = newComponentRef;
2092
- this._loadedViewClass = view;
2093
- this._isLoadingView = false;
2094
- resolve();
2095
- });
2096
- fadeInPlayer.play();
2097
- });
2098
- }
2099
- /**
2100
- * Delete the currently loaded view from the views container, and leave it empty.
2101
- * If no view is currently loaded, this method will do nothing
2102
- */
2103
- async popView() {
2104
- if (this._loadedViewClass !== null && this._currentComponentRef) {
2105
- await this.removeCurrentView();
2106
- }
2107
- }
2108
- /**
2109
- * Aux method to remove the currently loaded view from the views container using a promise
2110
- */
2111
- removeCurrentView() {
2112
- if (this._viewContainerRef === null) {
2113
- throw new Error('Views container not defined. Please declare a <views-container> element in your application');
2114
- }
2115
- return new Promise((resolve) => {
2116
- if (this._currentComponentRef) {
2117
- const element = this._currentComponentRef.location.nativeElement;
2118
- const fadeOutPlayer = this.animationBuilder.build([
2119
- style({ opacity: 1 }),
2120
- animate('300ms ease', style({ opacity: 0 }))
2121
- ]).create(element);
2122
- fadeOutPlayer.onDone(() => {
2123
- if (this._viewContainerRef !== null) {
2124
- this._viewContainerRef.clear();
2125
- }
2126
- this._currentComponentRef = null;
2127
- this._loadedViewClass = null;
2128
- resolve();
2129
- });
2130
- fadeOutPlayer.play();
2131
- }
2132
- else {
2133
- resolve();
2134
- }
2135
- });
2136
- }
2137
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ViewsService, deps: [{ token: i1$2.AnimationBuilder }], target: i0.ɵɵFactoryTarget.Injectable }); }
2138
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ViewsService, providedIn: 'root' }); }
2139
- }
2140
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ViewsService, decorators: [{
2141
- type: Injectable,
2142
- args: [{
2143
- providedIn: 'root',
2144
- }]
2145
- }], ctorParameters: () => [{ type: i1$2.AnimationBuilder }] });
2146
-
2147
2023
  /**
2148
2024
  * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
2149
2025
  *
@@ -2439,73 +2315,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImpor
2439
2315
  args: [MAT_DIALOG_DATA]
2440
2316
  }] }] });
2441
2317
 
2442
- /**
2443
- * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
2444
- *
2445
- * Website : -> http://www.turbogui.org
2446
- * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
2447
- * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
2448
- * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
2449
- */
2450
- /**
2451
- * Component that is used as a container for application views.
2452
- * We must create only one views container in our application and pass to it a reference to our main
2453
- * viewsService instance. For example:
2454
- *
2455
- * <tg-views-container [viewsService]="viewsService" [initialView]="HomeViewComponent"></tg-views-container>
2456
- */
2457
- class ViewsContainerComponent {
2458
- constructor() {
2459
- /**
2460
- * If we want to load a view by default when this component is loaded for the first time, we can
2461
- * set here the respective class view and it will be automatically added.
2462
- */
2463
- this.initialView = null;
2464
- /**
2465
- * A reference to the views service that is used to operate with this views container.
2466
- * This must be specified when this component is added to the application
2467
- */
2468
- this.viewsService = null;
2469
- }
2470
- /**
2471
- * Check that the service reference has been correctly passed
2472
- */
2473
- ngOnInit() {
2474
- if (!(this.viewsService instanceof ViewsService)) {
2475
- throw new Error('ViewService instance must be referenced on a views container');
2476
- }
2477
- else {
2478
- this.viewsService.viewContainerRef = this.viewContainerRef;
2479
- }
2480
- // Set the initial view if defined
2481
- if (this.initialView !== null) {
2482
- this.viewsService.pushView(this.initialView);
2483
- }
2484
- }
2485
- /**
2486
- * Clear the current view from the service when this component is deleted
2487
- */
2488
- ngOnDestroy() {
2489
- if (this.viewsService instanceof ViewsService) {
2490
- this.viewsService.popView();
2491
- this.viewsService.viewContainerRef = null;
2492
- }
2493
- }
2494
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ViewsContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2495
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: ViewsContainerComponent, isStandalone: true, selector: "tg-views-container", inputs: { initialView: "initialView", viewsService: "viewsService" }, providers: [], 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: [""] }); }
2496
- }
2497
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ViewsContainerComponent, decorators: [{
2498
- type: Component,
2499
- args: [{ selector: 'tg-views-container', standalone: true, imports: [], providers: [], 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>" }]
2500
- }], propDecorators: { initialView: [{
2501
- type: Input
2502
- }], viewsService: [{
2503
- type: Input
2504
- }], viewContainerRef: [{
2505
- type: ViewChild,
2506
- args: ['viewContainerRef', { read: ViewContainerRef, static: true }]
2507
- }] } });
2508
-
2509
2318
  /**
2510
2319
  * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
2511
2320
  *
@@ -2799,14 +2608,21 @@ class GUINotification {
2799
2608
  */
2800
2609
  /**
2801
2610
  * Defines an application view.
2802
- * Our View components must extend this class so they can be manipulated via ViewsService and be correctly linked to a views-container.
2611
+ * This is a base class that helps managing our application views. We should extend this class to create our views, as it forces us
2612
+ * to set the viewContainerRef and the viewService, which are both used when working with views.
2613
+ *
2614
+ * When using view services, it is important to specify the view service as a provider for the view component to ensure that it will
2615
+ * be created and destroyed when the view is created and destroyed.
2803
2616
  */
2804
2617
  class View {
2805
2618
  /**
2806
2619
  * This constructor is specifically designed to force the view to set the viewContainerRef which will be automatically assigned
2807
- * to the respective view service. If the view has no service, we can set it to null.
2620
+ * to the respective view service. If the view has no service, we can set it to null, but it is recommended to always use a service with a view,
2621
+ * to store the view state and global methods that can be used by other components loaded in the view.
2808
2622
  */
2809
2623
  constructor(viewContainerRef, viewService) {
2624
+ this.viewContainerRef = viewContainerRef;
2625
+ this.viewService = viewService;
2810
2626
  if (viewService !== null) {
2811
2627
  viewService.viewContainerRef = viewContainerRef;
2812
2628
  }
@@ -2943,5 +2759,5 @@ class ValidatorsPlus extends Validators {
2943
2759
  * Generated bundle index. Do not edit.
2944
2760
  */
2945
2761
 
2946
- export { AutoFocusOnDisplayDirective, AutoSelectTextOnFocusDirective, BrowserService, BusyStateBaseComponent, ButtonContainerComponent, ButtonImageComponent, DelayedMethodCallManager, DialogBaseComponent, DialogDateSelectionComponent, DialogErrorComponent, DialogMultipleOptionComponent, DialogService, DialogSingleInputComponent, DialogSingleOptionComponent, DialogSingleSelectionListComponent, DialogTwoOptionComponent, ElementCreatedDirective, ElementDestroyedDirective, FadeAnimationClass, GUINotification, GlobalErrorService, HTTPService, HTTPServiceGetRequest, HTTPServicePostRequest, LocalesService, NotificationService, SingletoneStrictClass, TurboApiCallerService, TurboGuiAngularModule, ValidatorsPlus, View, ViewService, ViewsContainerComponent, ViewsService };
2762
+ export { AutoFocusOnDisplayDirective, AutoSelectTextOnFocusDirective, BrowserService, BusyStateBaseComponent, ButtonContainerComponent, ButtonImageComponent, DelayedMethodCallManager, DialogBaseComponent, DialogDateSelectionComponent, DialogErrorComponent, DialogMultipleOptionComponent, DialogService, DialogSingleInputComponent, DialogSingleOptionComponent, DialogSingleSelectionListComponent, DialogTwoOptionComponent, ElementCreatedDirective, ElementDestroyedDirective, FadeAnimationClass, GUINotification, GlobalErrorService, HTTPService, HTTPServiceGetRequest, HTTPServicePostRequest, LocalesService, NotificationService, SingletoneStrictClass, TurboApiCallerService, TurboGuiAngularModule, ValidatorsPlus, View, ViewService };
2947
2763
  //# sourceMappingURL=turbogui-angular.mjs.map