@totvs-agro/mobile-components
Version:
Componentes Mobile Totvs (Front-End) para utilização dos estilos do T-Faces e Ionic v3
108 lines • 4.32 kB
JavaScript
import { ToastController, LoadingController, AlertController } from 'ionic-angular';
import { Injectable } from '@angular/core';
import { TotvsNotificationType } from './totvs-notification-type';
import { TotvsTranslateProvider } from './translate/totvs-translate-provider';
var TotvsNotificationProvider = /** @class */ (function () {
function TotvsNotificationProvider(toastCtrl, loadingCtrl, _alertController, _translate) {
this.toastCtrl = toastCtrl;
this.loadingCtrl = loadingCtrl;
this._alertController = _alertController;
this._translate = _translate;
}
TotvsNotificationProvider.prototype.toast = function (message, options) {
options = options || {};
var showActionButton = options.actionButton ? true : false;
var toast = this.toastCtrl.create({
message: message,
duration: options.duration || 5000,
showCloseButton: showActionButton,
closeButtonText: options.actionButtonText || this._translate.instant("COMMON.UNDO"),
cssClass: this.getCssClass(options.type || TotvsNotificationType.INFO)
});
toast.present()
.then(function () {
toast.instance._elementRef.nativeElement.onclick = function (ev) {
if (ev.target.className.indexOf('button') != -1) {
options.actionButton();
toast.dismiss();
}
else {
toast.dismiss();
}
};
});
};
TotvsNotificationProvider.prototype.getCssClass = function (type) {
var cssClass;
switch (type) {
case TotvsNotificationType.INFO:
cssClass = 'successToast';
break;
case TotvsNotificationType.WARN:
cssClass = 'avisoToast';
break;
case TotvsNotificationType.ERROR:
cssClass = 'errorToast';
break;
default:
cssClass = 'successToast';
break;
}
return cssClass;
};
TotvsNotificationProvider.prototype.presentLoading = function (_enableBackdropDismiss) {
if (this.loading == undefined || this.loading == null) {
this.loading = this.loadingCtrl.create({
content: this._translate.instant("TOAST.WAIT"),
enableBackdropDismiss: _enableBackdropDismiss
});
return this.loading.present();
}
return this.loading.present();
};
TotvsNotificationProvider.prototype.dismissLoading = function () {
if (this.loading != undefined || this.loading != null) {
this.loading.dismiss();
this.loading = null;
}
};
//ALERT
//ALERT
TotvsNotificationProvider.prototype.presentAlert =
//ALERT
function (_title, _subTitle, _buttons, _enableBackdropDismiss) {
var alert = this._alertController.create({
title: _title,
subTitle: _subTitle,
buttons: _buttons,
enableBackdropDismiss: _enableBackdropDismiss
});
alert.present();
};
TotvsNotificationProvider.prototype.presentPrompt = function (_title, inputs, _buttons, _subTitle, _enableBackdropDismiss) {
var alert = this._alertController.create({
title: _title,
subTitle: _subTitle,
inputs: inputs,
buttons: _buttons,
enableBackdropDismiss: _enableBackdropDismiss
});
alert.present();
};
TotvsNotificationProvider.SUCCESS = 0;
TotvsNotificationProvider.ERROR = 1;
TotvsNotificationProvider.WARNING = 2;
TotvsNotificationProvider.decorators = [
{ type: Injectable },
];
/** @nocollapse */
TotvsNotificationProvider.ctorParameters = function () { return [
{ type: ToastController, },
{ type: LoadingController, },
{ type: AlertController, },
{ type: TotvsTranslateProvider, },
]; };
return TotvsNotificationProvider;
}());
export { TotvsNotificationProvider };
//# sourceMappingURL=totvs-notification-provider.js.map