|
|
@ -7,7 +7,12 @@ import { isFunction } from 'lodash'; |
|
|
|
import { GfAlertDialogComponent } from './alert-dialog/alert-dialog.component'; |
|
|
|
import { GfConfirmationDialogComponent } from './confirmation-dialog/confirmation-dialog.component'; |
|
|
|
import { ConfirmationDialogType } from './confirmation-dialog/confirmation-dialog.type'; |
|
|
|
import { IAlertParams, IConfirmParams } from './interfaces/interfaces'; |
|
|
|
import { |
|
|
|
IAlertParams, |
|
|
|
IConfirmParams, |
|
|
|
IPromptParams |
|
|
|
} from './interfaces/interfaces'; |
|
|
|
import { GfPromptDialogComponent } from './prompt-dialog/prompt-dialog.component'; |
|
|
|
|
|
|
|
@Injectable() |
|
|
|
export class NotificationService { |
|
|
@ -73,6 +78,38 @@ export class NotificationService { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public prompt(aParams: IPromptParams) { |
|
|
|
if (!aParams.confirmLabel) { |
|
|
|
aParams.confirmLabel = translate('OK'); |
|
|
|
} |
|
|
|
|
|
|
|
if (!aParams.discardLabel) { |
|
|
|
aParams.discardLabel = translate('CANCEL'); |
|
|
|
} |
|
|
|
|
|
|
|
const dialog = this.matDialog.open(GfPromptDialogComponent, { |
|
|
|
autoFocus: false, |
|
|
|
maxWidth: this.dialogMaxWidth, |
|
|
|
width: this.dialogWidth |
|
|
|
}); |
|
|
|
|
|
|
|
dialog.componentInstance.initialize({ |
|
|
|
confirmLabel: aParams.confirmLabel, |
|
|
|
defaultValue: aParams.defaultValue, |
|
|
|
discardLabel: aParams.discardLabel, |
|
|
|
title: aParams.title, |
|
|
|
valueLabel: aParams.valueLabel |
|
|
|
}); |
|
|
|
|
|
|
|
return dialog.afterClosed().subscribe((value) => { |
|
|
|
if (value !== undefined && isFunction(aParams.confirmFn)) { |
|
|
|
aParams.confirmFn(value); |
|
|
|
} else if (value === 'discard' && isFunction(aParams.discardFn)) { |
|
|
|
aParams.discardFn(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public setDialogMaxWidth(aDialogMaxWidth: string) { |
|
|
|
this.dialogMaxWidth = aDialogMaxWidth; |
|
|
|
} |
|
|
|