Commit 5e8f7a89b7a02b87ba0b1d6258b3a6e9de92e4e6
1 parent
f0fe6b59
Exists in
master
and in
26 other branches
save articles without parent
Showing
1 changed file
with
5 additions
and
2 deletions
Show diff stats
src/app/article/cms/cms.component.ts
... | ... | @@ -38,7 +38,6 @@ export class CmsComponent { |
38 | 38 | this.id = this.$stateParams['id']; |
39 | 39 | |
40 | 40 | if (this.parentId) { |
41 | - this.article = <noosfero.Article>{ type: this.$stateParams['type'] || "TextArticle", published: true }; | |
42 | 41 | this.articleService.get(this.parentId).then((result: noosfero.RestResult<noosfero.Article>) => { |
43 | 42 | this.parent = result.data; |
44 | 43 | }); |
... | ... | @@ -48,6 +47,8 @@ export class CmsComponent { |
48 | 47 | this.article = result.data; |
49 | 48 | this.article.name = this.article.title; // FIXME |
50 | 49 | }); |
50 | + } else { | |
51 | + this.article = <noosfero.Article>{ type: this.$stateParams['type'] || "TextArticle", published: true }; | |
51 | 52 | } |
52 | 53 | } |
53 | 54 | |
... | ... | @@ -55,8 +56,10 @@ export class CmsComponent { |
55 | 56 | this.profileService.setCurrentProfileByIdentifier(this.profileIdentifier).then((profile: noosfero.Profile) => { |
56 | 57 | if (this.id) { |
57 | 58 | return this.articleService.updateArticle(this.article); |
58 | - } else { | |
59 | + } else if (this.parentId) { | |
59 | 60 | return this.articleService.createInParent(this.parentId, this.article); |
61 | + } else { | |
62 | + return this.articleService.createInProfile(profile, this.article); | |
60 | 63 | } |
61 | 64 | }).then((response: noosfero.RestResult<noosfero.Article>) => { |
62 | 65 | let article = (<noosfero.Article>response.data); | ... | ... |