-
-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(UI): Component, directive, pipe and injectable not linked inside…
… a module should appear in the menu alone fix #510
- Loading branch information
1 parent
05cd3a4
commit b010638
Showing
5 changed files
with
183 additions
and
2 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/app/engines/html-engine-helpers/element-alone.helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { IHtmlEngineHelper, IHandlebarsOptions } from './html-engine-helper.interface'; | ||
import { extractLeadingText, splitLinkText } from '../../../utils/link-parser'; | ||
import { DependenciesEngine } from '../dependencies.engine'; | ||
|
||
export class ElementAloneHelper implements IHtmlEngineHelper { | ||
constructor(private dependenciesEngine: DependenciesEngine) {} | ||
|
||
public helperFunc(context: any, elements, elementType: string, options: IHandlebarsOptions) { | ||
let result = false; | ||
let alones = []; | ||
let modules = this.dependenciesEngine.modules; | ||
|
||
elements.forEach(element => { | ||
let foundInOneModule = false; | ||
modules.forEach(module => { | ||
module.declarations.forEach(declaration => { | ||
if (declaration.name === element.name) { | ||
foundInOneModule = true; | ||
} | ||
}); | ||
module.providers.forEach(provider => { | ||
if (provider.name === element.name) { | ||
foundInOneModule = true; | ||
} | ||
}); | ||
}); | ||
if (!foundInOneModule) { | ||
alones.push(element); | ||
} | ||
}); | ||
|
||
switch (elementType) { | ||
case 'component': | ||
context.components = alones; | ||
break; | ||
case 'directive': | ||
context.directives = alones; | ||
break; | ||
case 'injectable': | ||
context.injectables = alones; | ||
break; | ||
case 'pipe': | ||
context.pipes = alones; | ||
break; | ||
} | ||
|
||
if (alones.length > 0) { | ||
return options.fn(context); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
--colors | ||
--harmony | ||
--timeout 120000 | ||
test/dist/cli/**/*.spec.js | ||
test/dist/cli/**/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters