@nettyapps/ntybase 21.1.30 → 21.1.32

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 { Component, Injectable, inject, NgModule, signal, input, computed, effect, output, linkedSignal, ViewChild, model, Input, InjectionToken, Optional, Inject } from '@angular/core';
2
+ import { Component, Injectable, inject, NgModule, signal, input, computed, effect, output, afterRenderEffect, linkedSignal, ViewChild, model, Input, InjectionToken, Optional, Inject } from '@angular/core';
3
3
  import * as i1$3 from '@angular/common/http';
4
4
  import { HttpErrorResponse, HttpResponse, HTTP_INTERCEPTORS, HttpClient, HttpHeaders } from '@angular/common/http';
5
5
  import { of, throwError, Subject, lastValueFrom, map, catchError as catchError$1, finalize, take as take$1, takeUntil } from 'rxjs';
@@ -377,67 +377,42 @@ class AlertService {
377
377
  verticalPosition: 'bottom',
378
378
  });
379
379
  }
380
- // For error notifications
381
380
  /**
382
- * Flexible Error Display
383
- * @param error - Error object from API or string
384
- * @param fallbackOrComponent - Optional: Fallback message key (@...) OR Custom Component
385
- * @param customComponent - Optional: Custom component to use if the 2nd parameter is a message
386
- */
387
- showError(error, fallbackOrComponent = ErrorAlert, customComponent = ErrorAlert, width = 'auto', height = 'auto') {
388
- let componentToOpen = ErrorAlert;
389
- let fallbackMsg = '';
390
- if (typeof fallbackOrComponent === 'string' && fallbackOrComponent.startsWith('@')) {
391
- // showError(err, '@updateFailed', ...)
392
- fallbackMsg = fallbackOrComponent;
393
- componentToOpen = (customComponent && typeof customComponent === 'function') ? customComponent : ErrorAlert;
394
- }
395
- else if (typeof fallbackOrComponent === 'function') {
396
- // showError(err, MySpecialComponent)
397
- componentToOpen = fallbackOrComponent;
398
- }
399
- // Extract Message (C# / Backend message has priority)
400
- const backendError = this.getErrorMessage(error);
401
- // Final Message Decision: Use backend message if exists, otherwise translate fallback key
402
- const finalMessage = (backendError && backendError !== JSON.stringify(error))
403
- ? backendError
404
- : (fallbackMsg ? this.translate.instant(fallbackMsg) : backendError);
381
+ * Displays an error dialog with flexible parameters.
382
+ * Intelligently extracts meaningful C# error messages or falls back to a translation key.
383
+ * * Supported usages:
384
+ * - showError('@fallbackKey', err)
385
+ * - showError(err)
386
+ * - showError(err, '@fallbackKey')
387
+ * - showError('@fallbackKey')
388
+ */
389
+ showError(arg1, arg2, customComponent = ErrorAlert, width = 'auto', height = 'auto') {
390
+ const isArg1Str = typeof arg1 === 'string';
391
+ const fallbackKey = isArg1Str ? arg1 : (typeof arg2 === 'string' ? arg2 : '');
392
+ const errorObj = isArg1Str ? arg2 : arg1;
393
+ // Open the Dialog
405
394
  return new Promise((resolve) => {
406
- const dialogRef = this.dialog.open(componentToOpen, {
407
- width: width,
408
- height: height,
409
- maxWidth: '95vw',
395
+ this.dialog.open(customComponent, {
396
+ width, height, maxWidth: '95vw',
410
397
  data: {
411
- message: finalMessage,
398
+ message: this.getErrorMessage(errorObj, fallbackKey),
412
399
  title: this.translate.instant('@errorOccurred'),
413
400
  },
414
- });
415
- dialogRef.afterClosed().subscribe(() => {
416
- resolve();
417
- });
401
+ }).afterClosed().subscribe(() => resolve());
418
402
  });
419
403
  }
420
- /**
421
- * Extracts the most meaningful error message from the error object
422
- */
423
- getErrorMessage(error) {
424
- if (!error)
425
- return '';
426
- // 1. C# API / Backend Error Messages
427
- if (error?.error?.message)
428
- return error.error.message;
429
- if (error?.error && typeof error.error === 'string')
430
- return error.error;
431
- if (error?.details && typeof error.details === 'string')
432
- return error.details;
433
- if (error?.message && typeof error.message === 'string' && !error.message.startsWith('@'))
434
- return error.message;
435
- /// 2. Localization Keys (starting with @)
436
- if (typeof error === 'string' && error.startsWith('@'))
437
- return this.translate.instant(error);
438
- if (error?.message && typeof error.message === 'string' && error.message.startsWith('@'))
439
- return this.translate.instant(error.message);
440
- return typeof error === 'string' ? error : JSON.stringify(error);
404
+ getErrorMessage(errorObj, fallbackKey) {
405
+ if (!errorObj) {
406
+ return fallbackKey ? this.translate.instant(fallbackKey) : this.translate.instant('@errorOccurred');
407
+ }
408
+ const data = errorObj.error ?? errorObj;
409
+ const isStr = typeof data === 'string';
410
+ const backendMessage = isStr ? data : (data?.message || data?.details || JSON.stringify(data));
411
+ const isMeaningful = isStr ? !data.startsWith('<') : !!(data?.message || data?.details);
412
+ if (fallbackKey) {
413
+ return isMeaningful ? backendMessage : this.translate.instant(fallbackKey);
414
+ }
415
+ return backendMessage;
441
416
  }
442
417
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: AlertService, deps: [{ token: i1$2.MatSnackBar }, { token: i1.MatDialog }, { token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
443
418
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: AlertService, providedIn: 'root' });
@@ -1411,6 +1386,16 @@ class NettyAgGridBase extends NettyAppsBase {
1411
1386
  // this.commonService.clearOutlet();
1412
1387
  }
1413
1388
  });
1389
+ afterRenderEffect(() => {
1390
+ let x = this.agGridSelectionMode();
1391
+ if (this.gridOptions) {
1392
+ this.gridOptions.rowSelection = {
1393
+ mode: this._agGridSelectionMode(), checkboxes: true, headerCheckbox: true,
1394
+ selectAll: 'filtered', hideDisabledCheckboxes: true, suppressRowClickSelection: false,
1395
+ enableCellChangeFlash: true,
1396
+ };
1397
+ }
1398
+ });
1414
1399
  }
1415
1400
  // ***************************************************************
1416
1401
  // *** METHODS For optional overide ***