turbogui-angular 20.2.0 → 20.4.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.
@@ -943,19 +943,14 @@ class DialogService extends SingletoneStrictClass {
943
943
  * Show a dialog with a calendar to let the user pick a date.
944
944
  *
945
945
  * @param properties An object containing the different visual and textual options that this dialog allows:
946
- * - id: The html unique identifier that the dialog will have once created. If not specified, no id will be explicitly set
947
- * - width: Specify the css value for the default dialog width. As the dialog is responsive, the value will be automatically
948
- * reduced if the available screen is not enough, and will reach the desired value otherwise. We can set any css unit like pixels,
949
- * %, vh, vw, or any other. For example: '400px', '50%', etc.
950
- * - maxWidth: Defines the maximum width that the dialog will have regarding the viewport. We can specify it in % or vw, just like is done in
951
- * css. By default it is defined as 96vw, which will fit 96% of the viewport on small devices
952
- * - height: TODO docs
953
- * - maxHeight: TODO docs
954
- * - modal: True (default) if selecting an option is mandatory to close the dialog, false if the dialog can be closed
955
- * by the user clicking outside it
956
- * - title: An optional dialog title
957
- * - viewContainerRef: This is important to propagate providers from a parent component to this dialog. We must specify
958
- * this reference to make sure the same services injected on the parent are available too at the child dialog
946
+ * - id: see addDialog() docs
947
+ * - width: see addDialog() docs
948
+ * - maxWidth: see addDialog() docs
949
+ * - height: see addDialog() docs
950
+ * - maxHeight: see addDialog() docs
951
+ * - modal: see addDialog() docs
952
+ * - title: see addDialog() docs
953
+ * - viewContainerRef: see addDialog() docs
959
954
  *
960
955
  * @returns A Promise that resolves to a Date() object selected by the user or null if no selection was made
961
956
  */
@@ -975,6 +970,44 @@ class DialogService extends SingletoneStrictClass {
975
970
  });
976
971
  return selection.index === -1 ? null : selection.value;
977
972
  }
973
+ /**
974
+ * Show a dialog with an error message and a single option button to close it.
975
+ *
976
+ * This method is a shortcut for addDialog() method using DialogErrorComponent as the dialog component class
977
+ *
978
+ * @param properties An object containing the different visual and textual options that this dialog allows:
979
+ * - title (mandatory): The dialog title
980
+ * - option (mandatory): The text to place on the single option button
981
+ * - description: An optional description text to show below the title
982
+ * - id: see addDialog() docs
983
+ * - width: see addDialog() docs
984
+ * - maxWidth: see addDialog() docs
985
+ * - height: see addDialog() docs
986
+ * - maxHeight: see addDialog() docs
987
+ * - modal: see addDialog() docs
988
+ * - dialogErrorComponentClass: A custom component class to use instead of the default DialogErrorComponent. This custom component must extend DialogErrorComponent
989
+ *
990
+ * @returns A Promise that resolves once the user selects the button with the option caption
991
+ */
992
+ async addErrorDialog(properties) {
993
+ if (this._isEnabled) {
994
+ let texts = [properties.title];
995
+ if (properties.description && properties.description !== undefined) {
996
+ texts.push(properties.description);
997
+ }
998
+ await this.addDialog(properties.dialogErrorComponentClass ?? DialogErrorComponent, {
999
+ id: properties.id ?? undefined,
1000
+ width: properties.width ?? "70%",
1001
+ maxWidth: properties.maxWidth ?? "500px",
1002
+ height: properties.height ?? "auto",
1003
+ maxHeight: properties.maxHeight ?? "92vw",
1004
+ modal: properties.modal ?? false,
1005
+ texts: texts,
1006
+ options: [properties.option]
1007
+ });
1008
+ }
1009
+ return null;
1010
+ }
978
1011
  /**
979
1012
  * Force the removal of all the dialogs that are currently visible.
980
1013
  *
@@ -984,10 +1017,6 @@ class DialogService extends SingletoneStrictClass {
984
1017
  if (!this._isEnabled) {
985
1018
  return;
986
1019
  }
987
- // If there are dialogs that should close on navigation and a history state was pushed, pop it
988
- if (this._activeCloseableDialogs > 0 && window.history.state?.dialogOpen) {
989
- history.back();
990
- }
991
1020
  for (const dialogRef of this._activeDialogInstances) {
992
1021
  dialogRef.close({ index: -1 });
993
1022
  }
@@ -1675,6 +1704,20 @@ class RouterBaseService {
1675
1704
  getCurrentRoute() {
1676
1705
  return this._currentRoute.getValue();
1677
1706
  }
1707
+ /**
1708
+ * The current route title, translated using the LocalesService.
1709
+ * This is updated automatically after each navigation event if the title manager is initialized.
1710
+ */
1711
+ getCurrentRouteTitle() {
1712
+ return this._currentRouteTitle;
1713
+ }
1714
+ /**
1715
+ * The current browser title, which may include prefixes or suffixes.
1716
+ * This is updated automatically after each navigation event if the title manager is initialized.
1717
+ */
1718
+ getCurrentBrowserTitle() {
1719
+ return this._currentBrowserTitle;
1720
+ }
1678
1721
  /**
1679
1722
  * Gets the current value of the route absolute URL synchronously.
1680
1723
  *
@@ -1719,6 +1762,7 @@ class RouterBaseService {
1719
1762
  * { path: '', component: HomePageComponent,
1720
1763
  * data: { titleKey: 'HOME', titleBundle: 'turbodepot/user-interface'} },
1721
1764
  *
1765
+ * @param localesService An instance of the LocalesService to be used for translations.
1722
1766
  * @param prefix A text to be added before the computed title.
1723
1767
  * @param sufix A text to be added after the computed title.
1724
1768
  */
@@ -1744,14 +1788,18 @@ class RouterBaseService {
1744
1788
  * @param sufix A text to be added after the computed title.
1745
1789
  */
1746
1790
  updateTitleFromCurrentRoute(prefix, sufix) {
1791
+ this._currentRouteTitle = '';
1792
+ this._currentBrowserTitle = '';
1747
1793
  let currentRoute = this.router.routerState.snapshot.root;
1748
1794
  while (currentRoute.firstChild) {
1749
1795
  currentRoute = currentRoute.firstChild;
1750
1796
  }
1751
1797
  const data = currentRoute.data;
1752
1798
  if (data['titleKey'] && data['titleBundle']) {
1753
- this.titleService.setTitle(prefix + this._localesService.t(data['titleKey'], data['titleBundle']) + sufix);
1799
+ this._currentRouteTitle = this._localesService.t(data['titleKey'], data['titleBundle']);
1754
1800
  }
1801
+ this._currentBrowserTitle = prefix + this._currentRouteTitle + sufix;
1802
+ this.titleService.setTitle(this._currentBrowserTitle);
1755
1803
  }
1756
1804
  /**
1757
1805
  * Navigates to the specified route.
@@ -1761,6 +1809,12 @@ class RouterBaseService {
1761
1809
  navigateTo(route) {
1762
1810
  this.router.navigate(['/' + route]);
1763
1811
  }
1812
+ /**
1813
+ * Automatically called when the service is destroyed.
1814
+ * We use it to clean up subscriptions and other resources.
1815
+ *
1816
+ * Usially not necessary to call this manually.
1817
+ */
1764
1818
  ngOnDestroy() {
1765
1819
  this._routerSubscription?.unsubscribe();
1766
1820
  // Clean up BehaviorSubject