From fb3ca07d6e20c021f9ab8bb6308240a1c77c8fa7 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 28 Feb 2017 22:03:03 +0200 Subject: [PATCH] fix: show warning for non-used in tagGroup tags closes #215 --- lib/services/menu.service.ts | 5 +++-- lib/services/warnings.service.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/services/menu.service.ts b/lib/services/menu.service.ts index eea660fb..452695e9 100644 --- a/lib/services/menu.service.ts +++ b/lib/services/menu.service.ts @@ -3,6 +3,7 @@ import { Injectable, EventEmitter } from '@angular/core'; import { Subscription } from 'rxjs/Subscription'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { ScrollService, INVIEW_POSITION } from './scroll.service'; +import { WarningsService } from './warnings.service'; import { Hash } from './hash.service'; import { SpecManager } from '../utils/spec-manager'; import { SchemaHelper } from './schema-helper.service'; @@ -351,7 +352,7 @@ export class MenuService { tags = tags.map(k => { if (!this._tagsWithMethods[k]) { - console.warn(`Non-existing tag "${k}" is specified in tag group "${tagGroup.name}"`); + WarningsService.warn(`Non-existing tag "${k}" is added to the group "${tagGroup.name}"`); return null; } this._tagsWithMethods[k].used = true; @@ -408,7 +409,7 @@ export class MenuService { checkAllTagsUsedInGroups() { for (let tag of Object.keys(this._tagsWithMethods)) { if (!this._tagsWithMethods[tag].used) { - console.warn(`Tag "${tag}" is not added to any group`); + WarningsService.warn(`Tag "${tag}" is not added to any group`) } } } diff --git a/lib/services/warnings.service.ts b/lib/services/warnings.service.ts index 54c29754..b547f564 100644 --- a/lib/services/warnings.service.ts +++ b/lib/services/warnings.service.ts @@ -1,11 +1,11 @@ 'use strict'; import { Injectable } from '@angular/core'; -import { Subject } from 'rxjs'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; @Injectable() export class WarningsService { private static _warnings: Array = []; - private static _warningsObs = new Subject>(); + private static _warningsObs = new BehaviorSubject>([]); static get warnings() { return WarningsService._warningsObs;