UNPKG

leaf-framework

Version:
115 lines 5.11 kB
import { Component, EventEmitter, ViewChild, Input, Output } from '@angular/core'; import { MessageType } from './message-type'; import { MessageStatus } from './message-status'; var ModalMessageComponent = /** @class */ (function () { function ModalMessageComponent() { this.onOk = new EventEmitter(); this.onClose = new EventEmitter(); } ModalMessageComponent.prototype.ngOnInit = function () { }; /** * Mehtod that returns the modal icon to display depending of the modal status */ ModalMessageComponent.prototype.getIcon = function () { switch (this.status) { case MessageStatus.DANGER: return 'fa-times'; case MessageStatus.INFO: return 'fa-info-circle'; case MessageStatus.SUCCESS: return 'fa-check '; case MessageStatus.WARNING: return 'fa-exclamation-triangle'; default: return 'fa-times'; } }; /** * Mehtod that returns the modal title depending of the model status */ ModalMessageComponent.prototype.getTitle = function () { switch (this.status) { case MessageStatus.DANGER: return 'Error'; case MessageStatus.INFO: return 'Info'; case MessageStatus.SUCCESS: return 'Success '; case MessageStatus.WARNING: return 'Warning'; default: return 'Error'; } }; /** * Mehtod that returns the Ok title button translated */ ModalMessageComponent.prototype.getOkTitle = function () { // TO be translated return 'OK'; }; /** * Method that returns the cancel title button translated */ ModalMessageComponent.prototype.getCancelTitle = function () { // TO be translated if (this.type === MessageType.BLOCKING) { return 'Close'; } else { return 'Cancel'; } }; /** * Event that show the modal dialog */ ModalMessageComponent.prototype.show = function () { this.modal.show(); }; /** * Event that hide the modal dialog */ ModalMessageComponent.prototype.hide = function () { if (this.modal && this.modal.isShown) { if (this.type === MessageType.CONFIRM) { this.onOk.emit(false); } this.modal.hide(); this.onClose.emit(null); } }; /** * Event fired when click on ok button of confirm message */ ModalMessageComponent.prototype.onOKEvent = function () { this.onOk.emit(true); this.modal.hide(); this.onClose.emit(null); }; /** * Event fired when click on cancel or close button */ ModalMessageComponent.prototype.onCancelEvent = function () { this.hide(); }; ModalMessageComponent.decorators = [ { type: Component, args: [{ selector: 'app-modal-message', template: "\n <div class=\"modal fade\" bsModal #modalMsg=\"bs-modal\" [config]=\"{backdrop: 'static'}\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"mySmallModalLabel\" aria-hidden=\"true\">\n <div class=\"modal-dialog modal-sm\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\"><i class=\"fa {{getIcon()}}\" aria-hidden=\"true\"></i> {{getTitle()}}</h4>\n <button type=\"button\" class=\"close pull-right\" aria-label=\"Close\" (click)=\"modalMsg.hide()\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">{{message}}</div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"onOKEvent()\" *ngIf=\"type == 'CONFIRM'\">{{getOkTitle()}}</button>\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"onCancelEvent()\">{{getCancelTitle()}}</button>\n </div>\n </div>\n </div>\n </div>\n ", styles: ["\n\n .fa-times {\n color: red;\n }\n .fa-info-circle {\n color: blue;\n }\n .fa-exclamation-triangle {\n color: orange;\n }\n\n .fa-exclamation-triangle {\n color: orange;\n }\n\n .fa-check {\n color: green;\n }\n "] },] }, ]; /** @nocollapse */ ModalMessageComponent.ctorParameters = function () { return []; }; ModalMessageComponent.propDecorators = { 'message': [{ type: Input },], 'status': [{ type: Input },], 'type': [{ type: Input },], 'onOk': [{ type: Output },], 'onClose': [{ type: Output },], 'modal': [{ type: ViewChild, args: ['modalMsg',] },], }; return ModalMessageComponent; }()); export { ModalMessageComponent }; //# sourceMappingURL=modal-message.component.js.map