UNPKG

@totvs-agro/t-notification

Version:

Componente Totvs para notificações

127 lines 5.62 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { ToastController, LoadingController, AlertController } from 'ionic-angular'; import { Injectable } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { TotvsTranslateProvider, } from '@totvs-agro/t-translate'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; var TotvsNotificationProvider = /** @class */ (function () { function TotvsNotificationProvider(toastCtrl, loadingCtrl, _alertController, _tTranslate, _translate) { this.toastCtrl = toastCtrl; this.loadingCtrl = loadingCtrl; this._alertController = _alertController; this._tTranslate = _tTranslate; this._translate = _translate; //this.initializeTTransalate(); } TotvsNotificationProvider.prototype.initializeTTransalate = function () { this._tTranslate.initialize("pt", "tNotification"); }; ; TotvsNotificationProvider.prototype.toast = function (mensagem) { this.initializeTTransalate(); var toast = this.toastCtrl.create({ message: mensagem, duration: 3000, showCloseButton: true, closeButtonText: this._tTranslate.instant("TOAST.DISPENSAR", "tNotification") }); toast.onDidDismiss(function () { //console.log('Dismissed toast'); }); toast.present(); }; ; TotvsNotificationProvider.prototype.toastWithButton = function (mensagem, descriptionButton, funcOnDismiss) { var toast = this.toastCtrl.create({ message: mensagem, duration: 15000, showCloseButton: true, closeButtonText: descriptionButton }); toast.onDidDismiss(funcOnDismiss); toast.present(); }; TotvsNotificationProvider.prototype.presentLoading = function (_enableBackdropDismiss) { this.loading = this.loadingCtrl.create({ content: this._tTranslate.instant("TOAST.AGUARDE", "tNotification"), enableBackdropDismiss: _enableBackdropDismiss }); return this.loading.present(); }; TotvsNotificationProvider.prototype.dismissLoading = function () { this.loading.dismiss(); }; TotvsNotificationProvider.prototype.notificacionToast = function (tipo, mensagem) { var options = { 0: { message: this._translate.instant(mensagem), duration: 5000, position: 'bottom', cssClass: 'successToast', showCloseButton: true, closeButtonText: this._tTranslate.instant('COMMON.CLOSE', "tNotification") }, 1: { message: this._translate.instant(mensagem), duration: 5000, position: 'bottom', cssClass: 'errorToast', showCloseButton: true, closeButtonText: this._tTranslate.instant('COMMON.CLOSE', "tNotification") }, 2: { message: this._translate.instant(mensagem), duration: 5000, position: 'bottom', cssClass: 'avisoToast', showCloseButton: true, closeButtonText: this._tTranslate.instant('COMMON.CLOSE', "tNotification") } }; var toast = this.toastCtrl.create(options[tipo]); toast.present(); }; //ALERT TotvsNotificationProvider.prototype.presentAlert = 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 = __decorate([ Injectable(), __metadata("design:paramtypes", [ToastController, LoadingController, AlertController, TotvsTranslateProvider, TranslateService]) ], TotvsNotificationProvider); return TotvsNotificationProvider; }()); export { TotvsNotificationProvider }; //# sourceMappingURL=totvs-notification-provider.js.map