valtech-components 2.0.718 → 2.0.719
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.
- package/esm2022/lib/services/auth/auth.service.mjs +34 -4
- package/esm2022/lib/services/i18n/default-content.mjs +7 -1
- package/esm2022/lib/version.mjs +2 -2
- package/fesm2022/valtech-components.mjs +229 -194
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/services/auth/auth.service.d.ts +24 -2
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ import 'prismjs/components/prism-json';
|
|
|
50
50
|
* Current version of valtech-components.
|
|
51
51
|
* This is automatically updated during the publish process.
|
|
52
52
|
*/
|
|
53
|
-
const VERSION = '2.0.
|
|
53
|
+
const VERSION = '2.0.719';
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Servicio para gestionar presets de componentes.
|
|
@@ -3911,6 +3911,9 @@ const VALTECH_DEFAULT_CONTENT = {
|
|
|
3911
3911
|
goodMorning: 'Buenos días',
|
|
3912
3912
|
goodAfternoon: 'Buenas tardes',
|
|
3913
3913
|
goodEvening: 'Buenas noches',
|
|
3914
|
+
// Auth — confirmación cierre de sesión
|
|
3915
|
+
logoutConfirmTitle: 'Cerrar sesión',
|
|
3916
|
+
logoutConfirmMessage: '¿Seguro que deseas cerrar sesión?',
|
|
3914
3917
|
// Idiomas
|
|
3915
3918
|
languageName_es: 'Español',
|
|
3916
3919
|
languageName_en: 'English',
|
|
@@ -4055,6 +4058,9 @@ const VALTECH_DEFAULT_CONTENT = {
|
|
|
4055
4058
|
goodMorning: 'Good morning',
|
|
4056
4059
|
goodAfternoon: 'Good afternoon',
|
|
4057
4060
|
goodEvening: 'Good evening',
|
|
4061
|
+
// Auth — sign out confirmation
|
|
4062
|
+
logoutConfirmTitle: 'Sign out',
|
|
4063
|
+
logoutConfirmMessage: 'Are you sure you want to sign out?',
|
|
4058
4064
|
// Languages
|
|
4059
4065
|
languageName_es: 'Español',
|
|
4060
4066
|
languageName_en: 'English',
|
|
@@ -28737,6 +28743,196 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
28737
28743
|
args: [VALTECH_AUTH_CONFIG]
|
|
28738
28744
|
}] }, { type: i1$8.HttpClient }, { type: i0.NgZone }] });
|
|
28739
28745
|
|
|
28746
|
+
/**
|
|
28747
|
+
* Default confirmation dialog options.
|
|
28748
|
+
*/
|
|
28749
|
+
const DEFAULT_CONFIRM_BUTTON = {
|
|
28750
|
+
text: 'Confirm',
|
|
28751
|
+
role: 'confirm',
|
|
28752
|
+
color: 'primary',
|
|
28753
|
+
};
|
|
28754
|
+
const DEFAULT_CANCEL_BUTTON = {
|
|
28755
|
+
text: 'Cancel',
|
|
28756
|
+
role: 'cancel',
|
|
28757
|
+
color: 'medium',
|
|
28758
|
+
};
|
|
28759
|
+
|
|
28760
|
+
/**
|
|
28761
|
+
* Service for displaying confirmation dialogs.
|
|
28762
|
+
*
|
|
28763
|
+
* @example Basic usage
|
|
28764
|
+
* const result = await confirmationService.confirm({
|
|
28765
|
+
* title: 'Delete Item',
|
|
28766
|
+
* message: 'Are you sure you want to delete this item?',
|
|
28767
|
+
* });
|
|
28768
|
+
*
|
|
28769
|
+
* if (result.confirmed) {
|
|
28770
|
+
* // User confirmed
|
|
28771
|
+
* }
|
|
28772
|
+
*
|
|
28773
|
+
* @example Custom buttons
|
|
28774
|
+
* const result = await confirmationService.confirm({
|
|
28775
|
+
* title: 'Save Changes',
|
|
28776
|
+
* message: 'Do you want to save your changes before leaving?',
|
|
28777
|
+
* confirmButton: { text: 'Save', color: 'success' },
|
|
28778
|
+
* cancelButton: { text: 'Discard', color: 'danger' },
|
|
28779
|
+
* extraButtons: [{ text: 'Cancel', role: 'cancel' }]
|
|
28780
|
+
* });
|
|
28781
|
+
*
|
|
28782
|
+
* @example Destructive action
|
|
28783
|
+
* const result = await confirmationService.confirmDestructive({
|
|
28784
|
+
* title: 'Delete Account',
|
|
28785
|
+
* message: 'This action cannot be undone. Are you sure?',
|
|
28786
|
+
* });
|
|
28787
|
+
*/
|
|
28788
|
+
class ConfirmationDialogService {
|
|
28789
|
+
constructor() {
|
|
28790
|
+
this.alertController = inject(AlertController);
|
|
28791
|
+
}
|
|
28792
|
+
/**
|
|
28793
|
+
* Shows a confirmation dialog and returns the result.
|
|
28794
|
+
* @param options - Configuration for the dialog
|
|
28795
|
+
* @returns Promise resolving to the confirmation result
|
|
28796
|
+
*/
|
|
28797
|
+
async confirm(options) {
|
|
28798
|
+
const buttons = this.buildButtons(options);
|
|
28799
|
+
const alert = await this.alertController.create({
|
|
28800
|
+
header: options.title,
|
|
28801
|
+
subHeader: options.subHeader,
|
|
28802
|
+
message: options.message,
|
|
28803
|
+
buttons,
|
|
28804
|
+
backdropDismiss: options.backdropDismiss ?? false,
|
|
28805
|
+
cssClass: options.cssClass,
|
|
28806
|
+
mode: options.mode,
|
|
28807
|
+
translucent: options.translucent ?? false,
|
|
28808
|
+
animated: options.animated ?? true,
|
|
28809
|
+
});
|
|
28810
|
+
await alert.present();
|
|
28811
|
+
const { role, data } = await alert.onDidDismiss();
|
|
28812
|
+
return {
|
|
28813
|
+
confirmed: role === 'confirm',
|
|
28814
|
+
role,
|
|
28815
|
+
data,
|
|
28816
|
+
};
|
|
28817
|
+
}
|
|
28818
|
+
/**
|
|
28819
|
+
* Shows a simple confirmation dialog with default buttons.
|
|
28820
|
+
* @param title - Dialog title
|
|
28821
|
+
* @param message - Dialog message
|
|
28822
|
+
* @returns Promise resolving to true if confirmed, false otherwise
|
|
28823
|
+
*/
|
|
28824
|
+
async confirmSimple(title, message) {
|
|
28825
|
+
const result = await this.confirm({ title, message });
|
|
28826
|
+
return result.confirmed;
|
|
28827
|
+
}
|
|
28828
|
+
/**
|
|
28829
|
+
* Shows a destructive action confirmation with red confirm button.
|
|
28830
|
+
* @param options - Configuration for the dialog
|
|
28831
|
+
* @returns Promise resolving to the confirmation result
|
|
28832
|
+
*/
|
|
28833
|
+
async confirmDestructive(options) {
|
|
28834
|
+
return this.confirm({
|
|
28835
|
+
...options,
|
|
28836
|
+
confirmButton: {
|
|
28837
|
+
text: options.confirmButton?.text || 'Delete',
|
|
28838
|
+
role: 'destructive',
|
|
28839
|
+
color: 'danger',
|
|
28840
|
+
cssClass: 'destructive-button',
|
|
28841
|
+
...options.confirmButton,
|
|
28842
|
+
},
|
|
28843
|
+
});
|
|
28844
|
+
}
|
|
28845
|
+
/**
|
|
28846
|
+
* Shows an info alert with just an OK button.
|
|
28847
|
+
* @param title - Alert title
|
|
28848
|
+
* @param message - Alert message
|
|
28849
|
+
*/
|
|
28850
|
+
async alert(title, message) {
|
|
28851
|
+
const alert = await this.alertController.create({
|
|
28852
|
+
header: title,
|
|
28853
|
+
message,
|
|
28854
|
+
buttons: [{ text: 'OK', role: 'confirm' }],
|
|
28855
|
+
});
|
|
28856
|
+
await alert.present();
|
|
28857
|
+
await alert.onDidDismiss();
|
|
28858
|
+
}
|
|
28859
|
+
/**
|
|
28860
|
+
* Shows a three-option dialog (Save, Discard, Cancel).
|
|
28861
|
+
* Common for unsaved changes scenarios.
|
|
28862
|
+
* @param title - Dialog title
|
|
28863
|
+
* @param message - Dialog message
|
|
28864
|
+
* @returns Promise resolving to 'save' | 'discard' | 'cancel'
|
|
28865
|
+
*/
|
|
28866
|
+
async confirmSaveDiscard(title, message) {
|
|
28867
|
+
const alert = await this.alertController.create({
|
|
28868
|
+
header: title,
|
|
28869
|
+
message,
|
|
28870
|
+
backdropDismiss: false,
|
|
28871
|
+
buttons: [
|
|
28872
|
+
{
|
|
28873
|
+
text: 'Cancel',
|
|
28874
|
+
role: 'cancel',
|
|
28875
|
+
},
|
|
28876
|
+
{
|
|
28877
|
+
text: 'Discard',
|
|
28878
|
+
role: 'destructive',
|
|
28879
|
+
cssClass: 'text-danger',
|
|
28880
|
+
},
|
|
28881
|
+
{
|
|
28882
|
+
text: 'Save',
|
|
28883
|
+
role: 'confirm',
|
|
28884
|
+
},
|
|
28885
|
+
],
|
|
28886
|
+
});
|
|
28887
|
+
await alert.present();
|
|
28888
|
+
const { role } = await alert.onDidDismiss();
|
|
28889
|
+
if (role === 'confirm')
|
|
28890
|
+
return 'save';
|
|
28891
|
+
if (role === 'destructive')
|
|
28892
|
+
return 'discard';
|
|
28893
|
+
return 'cancel';
|
|
28894
|
+
}
|
|
28895
|
+
buildButtons(options) {
|
|
28896
|
+
const buttons = [];
|
|
28897
|
+
// Cancel button
|
|
28898
|
+
const cancelBtn = options.cancelButton || DEFAULT_CANCEL_BUTTON;
|
|
28899
|
+
buttons.push({
|
|
28900
|
+
text: cancelBtn.text,
|
|
28901
|
+
role: cancelBtn.role || 'cancel',
|
|
28902
|
+
cssClass: cancelBtn.cssClass || `button-${cancelBtn.color || 'medium'}`,
|
|
28903
|
+
handler: cancelBtn.handler,
|
|
28904
|
+
});
|
|
28905
|
+
// Extra buttons (if any)
|
|
28906
|
+
if (options.extraButtons) {
|
|
28907
|
+
options.extraButtons.forEach((btn) => {
|
|
28908
|
+
buttons.push({
|
|
28909
|
+
text: btn.text,
|
|
28910
|
+
role: btn.role,
|
|
28911
|
+
cssClass: btn.cssClass || `button-${btn.color || 'medium'}`,
|
|
28912
|
+
handler: btn.handler,
|
|
28913
|
+
});
|
|
28914
|
+
});
|
|
28915
|
+
}
|
|
28916
|
+
// Confirm button
|
|
28917
|
+
const confirmBtn = options.confirmButton || DEFAULT_CONFIRM_BUTTON;
|
|
28918
|
+
buttons.push({
|
|
28919
|
+
text: confirmBtn.text,
|
|
28920
|
+
role: confirmBtn.role || 'confirm',
|
|
28921
|
+
cssClass: confirmBtn.cssClass || `button-${confirmBtn.color || 'primary'}`,
|
|
28922
|
+
handler: confirmBtn.handler,
|
|
28923
|
+
});
|
|
28924
|
+
return buttons;
|
|
28925
|
+
}
|
|
28926
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ConfirmationDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
28927
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ConfirmationDialogService, providedIn: 'root' }); }
|
|
28928
|
+
}
|
|
28929
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ConfirmationDialogService, decorators: [{
|
|
28930
|
+
type: Injectable,
|
|
28931
|
+
args: [{
|
|
28932
|
+
providedIn: 'root',
|
|
28933
|
+
}]
|
|
28934
|
+
}] });
|
|
28935
|
+
|
|
28740
28936
|
/**
|
|
28741
28937
|
* Servicio principal de autenticación.
|
|
28742
28938
|
*
|
|
@@ -28760,7 +28956,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
28760
28956
|
* ```
|
|
28761
28957
|
*/
|
|
28762
28958
|
class AuthService {
|
|
28763
|
-
constructor(config, http, router, stateService, tokenService, storageService, syncService, firebaseService, oauthService, messagingService, i18nService) {
|
|
28959
|
+
constructor(config, http, router, stateService, tokenService, storageService, syncService, firebaseService, oauthService, messagingService, i18nService, confirmationService) {
|
|
28764
28960
|
this.config = config;
|
|
28765
28961
|
this.http = http;
|
|
28766
28962
|
this.router = router;
|
|
@@ -28772,6 +28968,7 @@ class AuthService {
|
|
|
28772
28968
|
this.oauthService = oauthService;
|
|
28773
28969
|
this.messagingService = messagingService;
|
|
28774
28970
|
this.i18nService = i18nService;
|
|
28971
|
+
this.confirmationService = confirmationService;
|
|
28775
28972
|
// Timer para refresh proactivo
|
|
28776
28973
|
this.refreshTimerId = null;
|
|
28777
28974
|
this.syncSubscription = null;
|
|
@@ -29097,6 +29294,34 @@ class AuthService {
|
|
|
29097
29294
|
tokenType: 'Bearer',
|
|
29098
29295
|
});
|
|
29099
29296
|
}
|
|
29297
|
+
/**
|
|
29298
|
+
* Cierra sesión tras pedir confirmación al usuario.
|
|
29299
|
+
*
|
|
29300
|
+
* Muestra un diálogo nativo (estilo destructivo). Si el usuario confirma,
|
|
29301
|
+
* ejecuta `logout()`. Si cancela, no pasa nada.
|
|
29302
|
+
*
|
|
29303
|
+
* Texto por defecto desde `_global` i18n: `logoutConfirmTitle`,
|
|
29304
|
+
* `logoutConfirmMessage`, `logout`, `cancel`. Override via `opts`.
|
|
29305
|
+
*
|
|
29306
|
+
* @returns true si el usuario confirmó (logout ejecutado), false si canceló.
|
|
29307
|
+
*
|
|
29308
|
+
* @example
|
|
29309
|
+
* onLogoutClick() { this.auth.logoutWithConfirmation(); }
|
|
29310
|
+
*/
|
|
29311
|
+
async logoutWithConfirmation(opts) {
|
|
29312
|
+
const t = (key, fallback) => this.i18nService?.t(key) || fallback;
|
|
29313
|
+
const result = await this.confirmationService.confirmDestructive({
|
|
29314
|
+
title: opts?.title ?? t('logoutConfirmTitle', 'Cerrar sesión'),
|
|
29315
|
+
message: opts?.message ?? t('logoutConfirmMessage', '¿Seguro que deseas cerrar sesión?'),
|
|
29316
|
+
confirmButton: { text: opts?.confirmText ?? t('logout', 'Cerrar sesión') },
|
|
29317
|
+
cancelButton: { text: opts?.cancelText ?? t('cancel', 'Cancelar') },
|
|
29318
|
+
});
|
|
29319
|
+
if (result.confirmed) {
|
|
29320
|
+
await this.logout();
|
|
29321
|
+
return true;
|
|
29322
|
+
}
|
|
29323
|
+
return false;
|
|
29324
|
+
}
|
|
29100
29325
|
/**
|
|
29101
29326
|
* Cierra sesión.
|
|
29102
29327
|
*/
|
|
@@ -29811,7 +30036,7 @@ class AuthService {
|
|
|
29811
30036
|
}
|
|
29812
30037
|
return { platform: 'web', browser, os };
|
|
29813
30038
|
}
|
|
29814
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AuthService, deps: [{ token: VALTECH_AUTH_CONFIG }, { token: i1$8.HttpClient }, { token: i1$1.Router }, { token: AuthStateService }, { token: TokenService }, { token: AuthStorageService }, { token: AuthSyncService }, { token: FirebaseService }, { token: OAuthService }, { token: MessagingService, optional: true }, { token: I18nService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
30039
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AuthService, deps: [{ token: VALTECH_AUTH_CONFIG }, { token: i1$8.HttpClient }, { token: i1$1.Router }, { token: AuthStateService }, { token: TokenService }, { token: AuthStorageService }, { token: AuthSyncService }, { token: FirebaseService }, { token: OAuthService }, { token: MessagingService, optional: true }, { token: I18nService, optional: true }, { token: ConfirmationDialogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
29815
30040
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AuthService, providedIn: 'root' }); }
|
|
29816
30041
|
}
|
|
29817
30042
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AuthService, decorators: [{
|
|
@@ -29824,7 +30049,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
29824
30049
|
type: Optional
|
|
29825
30050
|
}] }, { type: I18nService, decorators: [{
|
|
29826
30051
|
type: Optional
|
|
29827
|
-
}] }] });
|
|
30052
|
+
}] }, { type: ConfirmationDialogService }] });
|
|
29828
30053
|
|
|
29829
30054
|
// Control de estado de refresco (singleton a nivel de módulo)
|
|
29830
30055
|
let isRefreshing = false;
|
|
@@ -33838,196 +34063,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
33838
34063
|
// ValtechConfig and LangProvider have been removed in v3.0.0
|
|
33839
34064
|
// Use LocaleService for language management instead
|
|
33840
34065
|
|
|
33841
|
-
/**
|
|
33842
|
-
* Default confirmation dialog options.
|
|
33843
|
-
*/
|
|
33844
|
-
const DEFAULT_CONFIRM_BUTTON = {
|
|
33845
|
-
text: 'Confirm',
|
|
33846
|
-
role: 'confirm',
|
|
33847
|
-
color: 'primary',
|
|
33848
|
-
};
|
|
33849
|
-
const DEFAULT_CANCEL_BUTTON = {
|
|
33850
|
-
text: 'Cancel',
|
|
33851
|
-
role: 'cancel',
|
|
33852
|
-
color: 'medium',
|
|
33853
|
-
};
|
|
33854
|
-
|
|
33855
|
-
/**
|
|
33856
|
-
* Service for displaying confirmation dialogs.
|
|
33857
|
-
*
|
|
33858
|
-
* @example Basic usage
|
|
33859
|
-
* const result = await confirmationService.confirm({
|
|
33860
|
-
* title: 'Delete Item',
|
|
33861
|
-
* message: 'Are you sure you want to delete this item?',
|
|
33862
|
-
* });
|
|
33863
|
-
*
|
|
33864
|
-
* if (result.confirmed) {
|
|
33865
|
-
* // User confirmed
|
|
33866
|
-
* }
|
|
33867
|
-
*
|
|
33868
|
-
* @example Custom buttons
|
|
33869
|
-
* const result = await confirmationService.confirm({
|
|
33870
|
-
* title: 'Save Changes',
|
|
33871
|
-
* message: 'Do you want to save your changes before leaving?',
|
|
33872
|
-
* confirmButton: { text: 'Save', color: 'success' },
|
|
33873
|
-
* cancelButton: { text: 'Discard', color: 'danger' },
|
|
33874
|
-
* extraButtons: [{ text: 'Cancel', role: 'cancel' }]
|
|
33875
|
-
* });
|
|
33876
|
-
*
|
|
33877
|
-
* @example Destructive action
|
|
33878
|
-
* const result = await confirmationService.confirmDestructive({
|
|
33879
|
-
* title: 'Delete Account',
|
|
33880
|
-
* message: 'This action cannot be undone. Are you sure?',
|
|
33881
|
-
* });
|
|
33882
|
-
*/
|
|
33883
|
-
class ConfirmationDialogService {
|
|
33884
|
-
constructor() {
|
|
33885
|
-
this.alertController = inject(AlertController);
|
|
33886
|
-
}
|
|
33887
|
-
/**
|
|
33888
|
-
* Shows a confirmation dialog and returns the result.
|
|
33889
|
-
* @param options - Configuration for the dialog
|
|
33890
|
-
* @returns Promise resolving to the confirmation result
|
|
33891
|
-
*/
|
|
33892
|
-
async confirm(options) {
|
|
33893
|
-
const buttons = this.buildButtons(options);
|
|
33894
|
-
const alert = await this.alertController.create({
|
|
33895
|
-
header: options.title,
|
|
33896
|
-
subHeader: options.subHeader,
|
|
33897
|
-
message: options.message,
|
|
33898
|
-
buttons,
|
|
33899
|
-
backdropDismiss: options.backdropDismiss ?? false,
|
|
33900
|
-
cssClass: options.cssClass,
|
|
33901
|
-
mode: options.mode,
|
|
33902
|
-
translucent: options.translucent ?? false,
|
|
33903
|
-
animated: options.animated ?? true,
|
|
33904
|
-
});
|
|
33905
|
-
await alert.present();
|
|
33906
|
-
const { role, data } = await alert.onDidDismiss();
|
|
33907
|
-
return {
|
|
33908
|
-
confirmed: role === 'confirm',
|
|
33909
|
-
role,
|
|
33910
|
-
data,
|
|
33911
|
-
};
|
|
33912
|
-
}
|
|
33913
|
-
/**
|
|
33914
|
-
* Shows a simple confirmation dialog with default buttons.
|
|
33915
|
-
* @param title - Dialog title
|
|
33916
|
-
* @param message - Dialog message
|
|
33917
|
-
* @returns Promise resolving to true if confirmed, false otherwise
|
|
33918
|
-
*/
|
|
33919
|
-
async confirmSimple(title, message) {
|
|
33920
|
-
const result = await this.confirm({ title, message });
|
|
33921
|
-
return result.confirmed;
|
|
33922
|
-
}
|
|
33923
|
-
/**
|
|
33924
|
-
* Shows a destructive action confirmation with red confirm button.
|
|
33925
|
-
* @param options - Configuration for the dialog
|
|
33926
|
-
* @returns Promise resolving to the confirmation result
|
|
33927
|
-
*/
|
|
33928
|
-
async confirmDestructive(options) {
|
|
33929
|
-
return this.confirm({
|
|
33930
|
-
...options,
|
|
33931
|
-
confirmButton: {
|
|
33932
|
-
text: options.confirmButton?.text || 'Delete',
|
|
33933
|
-
role: 'destructive',
|
|
33934
|
-
color: 'danger',
|
|
33935
|
-
cssClass: 'destructive-button',
|
|
33936
|
-
...options.confirmButton,
|
|
33937
|
-
},
|
|
33938
|
-
});
|
|
33939
|
-
}
|
|
33940
|
-
/**
|
|
33941
|
-
* Shows an info alert with just an OK button.
|
|
33942
|
-
* @param title - Alert title
|
|
33943
|
-
* @param message - Alert message
|
|
33944
|
-
*/
|
|
33945
|
-
async alert(title, message) {
|
|
33946
|
-
const alert = await this.alertController.create({
|
|
33947
|
-
header: title,
|
|
33948
|
-
message,
|
|
33949
|
-
buttons: [{ text: 'OK', role: 'confirm' }],
|
|
33950
|
-
});
|
|
33951
|
-
await alert.present();
|
|
33952
|
-
await alert.onDidDismiss();
|
|
33953
|
-
}
|
|
33954
|
-
/**
|
|
33955
|
-
* Shows a three-option dialog (Save, Discard, Cancel).
|
|
33956
|
-
* Common for unsaved changes scenarios.
|
|
33957
|
-
* @param title - Dialog title
|
|
33958
|
-
* @param message - Dialog message
|
|
33959
|
-
* @returns Promise resolving to 'save' | 'discard' | 'cancel'
|
|
33960
|
-
*/
|
|
33961
|
-
async confirmSaveDiscard(title, message) {
|
|
33962
|
-
const alert = await this.alertController.create({
|
|
33963
|
-
header: title,
|
|
33964
|
-
message,
|
|
33965
|
-
backdropDismiss: false,
|
|
33966
|
-
buttons: [
|
|
33967
|
-
{
|
|
33968
|
-
text: 'Cancel',
|
|
33969
|
-
role: 'cancel',
|
|
33970
|
-
},
|
|
33971
|
-
{
|
|
33972
|
-
text: 'Discard',
|
|
33973
|
-
role: 'destructive',
|
|
33974
|
-
cssClass: 'text-danger',
|
|
33975
|
-
},
|
|
33976
|
-
{
|
|
33977
|
-
text: 'Save',
|
|
33978
|
-
role: 'confirm',
|
|
33979
|
-
},
|
|
33980
|
-
],
|
|
33981
|
-
});
|
|
33982
|
-
await alert.present();
|
|
33983
|
-
const { role } = await alert.onDidDismiss();
|
|
33984
|
-
if (role === 'confirm')
|
|
33985
|
-
return 'save';
|
|
33986
|
-
if (role === 'destructive')
|
|
33987
|
-
return 'discard';
|
|
33988
|
-
return 'cancel';
|
|
33989
|
-
}
|
|
33990
|
-
buildButtons(options) {
|
|
33991
|
-
const buttons = [];
|
|
33992
|
-
// Cancel button
|
|
33993
|
-
const cancelBtn = options.cancelButton || DEFAULT_CANCEL_BUTTON;
|
|
33994
|
-
buttons.push({
|
|
33995
|
-
text: cancelBtn.text,
|
|
33996
|
-
role: cancelBtn.role || 'cancel',
|
|
33997
|
-
cssClass: cancelBtn.cssClass || `button-${cancelBtn.color || 'medium'}`,
|
|
33998
|
-
handler: cancelBtn.handler,
|
|
33999
|
-
});
|
|
34000
|
-
// Extra buttons (if any)
|
|
34001
|
-
if (options.extraButtons) {
|
|
34002
|
-
options.extraButtons.forEach((btn) => {
|
|
34003
|
-
buttons.push({
|
|
34004
|
-
text: btn.text,
|
|
34005
|
-
role: btn.role,
|
|
34006
|
-
cssClass: btn.cssClass || `button-${btn.color || 'medium'}`,
|
|
34007
|
-
handler: btn.handler,
|
|
34008
|
-
});
|
|
34009
|
-
});
|
|
34010
|
-
}
|
|
34011
|
-
// Confirm button
|
|
34012
|
-
const confirmBtn = options.confirmButton || DEFAULT_CONFIRM_BUTTON;
|
|
34013
|
-
buttons.push({
|
|
34014
|
-
text: confirmBtn.text,
|
|
34015
|
-
role: confirmBtn.role || 'confirm',
|
|
34016
|
-
cssClass: confirmBtn.cssClass || `button-${confirmBtn.color || 'primary'}`,
|
|
34017
|
-
handler: confirmBtn.handler,
|
|
34018
|
-
});
|
|
34019
|
-
return buttons;
|
|
34020
|
-
}
|
|
34021
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ConfirmationDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
34022
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ConfirmationDialogService, providedIn: 'root' }); }
|
|
34023
|
-
}
|
|
34024
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ConfirmationDialogService, decorators: [{
|
|
34025
|
-
type: Injectable,
|
|
34026
|
-
args: [{
|
|
34027
|
-
providedIn: 'root',
|
|
34028
|
-
}]
|
|
34029
|
-
}] });
|
|
34030
|
-
|
|
34031
34066
|
/**
|
|
34032
34067
|
* Default modal sizes.
|
|
34033
34068
|
*/
|