Commit a68fcd7ab902b7c885988ca127b660955dae02be
1 parent
d56bc4d4
Exists in
master
and in
26 other branches
Add hotspot to display extra content for articles
Showing
3 changed files
with
29 additions
and
2 deletions
Show diff stats
src/app/article/article-default-view.component.ts
@@ -3,6 +3,7 @@ import {ArticleBlogComponent} from "./types/blog/blog.component"; | @@ -3,6 +3,7 @@ import {ArticleBlogComponent} from "./types/blog/blog.component"; | ||
3 | import {CommentsComponent} from "./comment/comments.component"; | 3 | import {CommentsComponent} from "./comment/comments.component"; |
4 | import {MacroDirective} from "./macro/macro.directive"; | 4 | import {MacroDirective} from "./macro/macro.directive"; |
5 | import {ArticleToolbarHotspotComponent} from "../hotspot/article-toolbar-hotspot.component"; | 5 | import {ArticleToolbarHotspotComponent} from "../hotspot/article-toolbar-hotspot.component"; |
6 | +import {ArticleContentHotspotComponent} from "../hotspot/article-content-hotspot.component"; | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * @ngdoc controller | 9 | * @ngdoc controller |
@@ -33,7 +34,8 @@ export class ArticleDefaultViewComponent { | @@ -33,7 +34,8 @@ export class ArticleDefaultViewComponent { | ||
33 | selector: 'noosfero-article', | 34 | selector: 'noosfero-article', |
34 | template: 'not-used', | 35 | template: 'not-used', |
35 | directives: [ArticleDefaultViewComponent, ArticleBlogComponent, | 36 | directives: [ArticleDefaultViewComponent, ArticleBlogComponent, |
36 | - CommentsComponent, MacroDirective, ArticleToolbarHotspotComponent] | 37 | + CommentsComponent, MacroDirective, ArticleToolbarHotspotComponent, |
38 | + ArticleContentHotspotComponent] | ||
37 | }) | 39 | }) |
38 | @Inject("$element", "$scope", "$injector", "$compile") | 40 | @Inject("$element", "$scope", "$injector", "$compile") |
39 | export class ArticleViewComponent { | 41 | export class ArticleViewComponent { |
src/app/article/article.html
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | </span> | 20 | </span> |
21 | </div> | 21 | </div> |
22 | </div> | 22 | </div> |
23 | - | 23 | + <noosfero-hotspot-article-content [article]="ctrl.article"></noosfero-hotspot-article-content> |
24 | <div class="page-body"> | 24 | <div class="page-body"> |
25 | <div bind-html-compile="ctrl.article.body"></div> | 25 | <div bind-html-compile="ctrl.article.body"></div> |
26 | </div> | 26 | </div> |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +import {Component, Input, Inject} from "ng-forward"; | ||
2 | +import * as plugins from "../../plugins"; | ||
3 | +import {dasherize} from "ng-forward/cjs/util/helpers"; | ||
4 | +import {PluginHotspot} from "./plugin-hotspot"; | ||
5 | + | ||
6 | +@Component({ | ||
7 | + selector: "noosfero-hotspot-article-content", | ||
8 | + template: "<span></span>" | ||
9 | +}) | ||
10 | +@Inject("$element", "$scope", "$compile") | ||
11 | +export class ArticleContentHotspotComponent extends PluginHotspot { | ||
12 | + | ||
13 | + @Input() article: noosfero.Article; | ||
14 | + | ||
15 | + constructor( | ||
16 | + private $element: any, | ||
17 | + private $scope: ng.IScope, | ||
18 | + private $compile: ng.ICompileService) { | ||
19 | + super("article_extra_content"); | ||
20 | + } | ||
21 | + | ||
22 | + addHotspot(directiveName: string) { | ||
23 | + this.$element.append(this.$compile('<' + directiveName + ' [article]="ctrl.article"></' + directiveName + '>')(this.$scope)); | ||
24 | + } | ||
25 | +} |