UNPKG

@totvs-agro/core

Version:

Core Totvs Agro (Front-End) para utilização T-Faces

68 lines 2.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var NotificationHandlerService = (function () { function NotificationHandlerService() { this._notificationMap = new Map(); } NotificationHandlerService.prototype.getNotificationNumber = function () { if (!this._notificationMap) return 0; var list = Array.from(this._notificationMap.values()); return list.filter(function (not) { return not.type === 'danger'; }).length; }; NotificationHandlerService.prototype.getNotifications = function () { return Array.from(this._notificationMap.values()); }; NotificationHandlerService.prototype.push = function (item) { var id = Math.random().toString(36).substr(2, 9); this._notificationMap.set(id, item); return id; }; NotificationHandlerService.prototype.remove = function (item) { if (!this._notificationMap) return; var valuesList = Array.from(this._notificationMap.values()); var keysList = Array.from(this._notificationMap.keys()); var remIndex = valuesList.indexOf(item); if (remIndex >= 0) { valuesList.splice(remIndex, 1); keysList.splice(remIndex, 1); } this._notificationMap = new Map(); for (var i = 0; i < keysList.length; i++) { this._notificationMap.set(keysList[i], valuesList[i]); } }; NotificationHandlerService.prototype.pushAll = function (itens) { this._notificationMap = new Map(); var keysList = []; for (var _i = 0, itens_1 = itens; _i < itens_1.length; _i++) { var item = itens_1[_i]; keysList.push(this.push(item)); } return keysList; }; NotificationHandlerService.prototype.removeById = function (id) { this._notificationMap.delete(id); }; NotificationHandlerService.prototype.hasItemById = function (id) { return this._notificationMap.has(id); }; NotificationHandlerService.prototype.hasItem = function (item) { var valuesList = Array.from(this._notificationMap.values()); return valuesList.filter(function (handler) { return handler === item; }).length > 0; }; NotificationHandlerService.prototype.getById = function (id) { return this._notificationMap.get(id); }; NotificationHandlerService.decorators = [ { type: core_1.Injectable }, ]; return NotificationHandlerService; }()); exports.NotificationHandlerService = NotificationHandlerService; if (false) { NotificationHandlerService.prototype._notificationMap; } //# sourceMappingURL=notification-handler.service.js.map