content-viewer-actions.component.ts
1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {Component, Inject, provide} from "ng-forward";
import {ProfileService} from "../../../lib/ng-noosfero-api/http/profile.service";
import {ArticleService} from "../../../lib/ng-noosfero-api/http/article.service";
@Component({
selector: "content-viewer-actions",
templateUrl: "app/article/content-viewer/navbar-actions.html",
providers: [
provide('profileService', { useClass: ProfileService }),
provide('articleService', { useClass: ArticleService })
]
})
@Inject(ProfileService, ArticleService)
export class ContentViewerActionsComponent {
article: noosfero.Article;
profile: noosfero.Profile;
parentId: number;
constructor(profileService: ProfileService, articleService: ArticleService) {
profileService.getCurrentProfile().then((profile: noosfero.Profile) => {
this.profile = profile;
return articleService.getCurrent();
}).then((article: noosfero.Article) => {
this.article = article;
this.parentId = this.getArticleContainer(article);
});
}
getArticleContainer(article: noosfero.Article) {
// FIXME get folder types from api
if (article.type === "Blog" || article.type === "Folder") {
return article.id;
} else if (article.parent) {
return article.parent.id;
}
}
}