Commit 5e8f7a89b7a02b87ba0b1d6258b3a6e9de92e4e6

Authored by Leandro Santos
1 parent f0fe6b59

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,7 +38,6 @@ export class CmsComponent {
38 this.id = this.$stateParams['id']; 38 this.id = this.$stateParams['id'];
39 39
40 if (this.parentId) { 40 if (this.parentId) {
41 - this.article = <noosfero.Article>{ type: this.$stateParams['type'] || "TextArticle", published: true };  
42 this.articleService.get(this.parentId).then((result: noosfero.RestResult<noosfero.Article>) => { 41 this.articleService.get(this.parentId).then((result: noosfero.RestResult<noosfero.Article>) => {
43 this.parent = result.data; 42 this.parent = result.data;
44 }); 43 });
@@ -48,6 +47,8 @@ export class CmsComponent { @@ -48,6 +47,8 @@ export class CmsComponent {
48 this.article = result.data; 47 this.article = result.data;
49 this.article.name = this.article.title; // FIXME 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,8 +56,10 @@ export class CmsComponent {
55 this.profileService.setCurrentProfileByIdentifier(this.profileIdentifier).then((profile: noosfero.Profile) => { 56 this.profileService.setCurrentProfileByIdentifier(this.profileIdentifier).then((profile: noosfero.Profile) => {
56 if (this.id) { 57 if (this.id) {
57 return this.articleService.updateArticle(this.article); 58 return this.articleService.updateArticle(this.article);
58 - } else { 59 + } else if (this.parentId) {
59 return this.articleService.createInParent(this.parentId, this.article); 60 return this.articleService.createInParent(this.parentId, this.article);
  61 + } else {
  62 + return this.articleService.createInProfile(profile, this.article);
60 } 63 }
61 }).then((response: noosfero.RestResult<noosfero.Article>) => { 64 }).then((response: noosfero.RestResult<noosfero.Article>) => {
62 let article = (<noosfero.Article>response.data); 65 let article = (<noosfero.Article>response.data);