fix: show warning for non-used in tagGroup tags

closes #215
This commit is contained in:
Roman Hotsiy 2017-02-28 22:03:03 +02:00
parent 387635b7a1
commit fb3ca07d6e
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 5 additions and 4 deletions

View File

@ -3,6 +3,7 @@ import { Injectable, EventEmitter } from '@angular/core';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { ScrollService, INVIEW_POSITION } from './scroll.service'; import { ScrollService, INVIEW_POSITION } from './scroll.service';
import { WarningsService } from './warnings.service';
import { Hash } from './hash.service'; import { Hash } from './hash.service';
import { SpecManager } from '../utils/spec-manager'; import { SpecManager } from '../utils/spec-manager';
import { SchemaHelper } from './schema-helper.service'; import { SchemaHelper } from './schema-helper.service';
@ -351,7 +352,7 @@ export class MenuService {
tags = tags.map(k => { tags = tags.map(k => {
if (!this._tagsWithMethods[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; return null;
} }
this._tagsWithMethods[k].used = true; this._tagsWithMethods[k].used = true;
@ -408,7 +409,7 @@ export class MenuService {
checkAllTagsUsedInGroups() { checkAllTagsUsedInGroups() {
for (let tag of Object.keys(this._tagsWithMethods)) { for (let tag of Object.keys(this._tagsWithMethods)) {
if (!this._tagsWithMethods[tag].used) { 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`)
} }
} }
} }

View File

@ -1,11 +1,11 @@
'use strict'; 'use strict';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Subject } from 'rxjs'; import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable() @Injectable()
export class WarningsService { export class WarningsService {
private static _warnings: Array<string> = []; private static _warnings: Array<string> = [];
private static _warningsObs = new Subject<Array<string>>(); private static _warningsObs = new BehaviorSubject<Array<string>>([]);
static get warnings() { static get warnings() {
return WarningsService._warningsObs; return WarningsService._warningsObs;