diff --git a/src/app/article/basic-editor.component.spec.ts b/src/app/article/basic-editor.component.spec.ts deleted file mode 100644 index d86d08a..0000000 --- a/src/app/article/basic-editor.component.spec.ts +++ /dev/null @@ -1,57 +0,0 @@ -import {quickCreateComponent} from "../../spec/helpers"; -import {BasicEditorComponent} from "./basic-editor.component"; - - -describe("Article BasicEditor", () => { - - let $rootScope: ng.IRootScopeService; - let $q: ng.IQService; - let articleServiceMock: any; - let profileServiceMock: any; - let $state: any; - let $stateParams: any; - let profile = { id: 1 }; - let notification: any; - - - beforeEach(inject((_$rootScope_: ng.IRootScopeService, _$q_: ng.IQService) => { - $rootScope = _$rootScope_; - $q = _$q_; - })); - - beforeEach(() => { - $state = jasmine.createSpyObj("$state", ["transitionTo"]); - $stateParams = jasmine.createSpyObj("$stateParams", ["parent_id"]); - notification = jasmine.createSpyObj("notification", ["success"]); - profileServiceMock = jasmine.createSpyObj("profileServiceMock", ["getCurrentProfile"]); - articleServiceMock = jasmine.createSpyObj("articleServiceMock", ["createInParent"]); - - let getCurrentProfileResponse = $q.defer(); - getCurrentProfileResponse.resolve(profile); - - let articleCreate = $q.defer(); - articleCreate.resolve({ data: { path: "path", profile: { identifier: "profile" } } }); - - profileServiceMock.getCurrentProfile = jasmine.createSpy("getCurrentProfile").and.returnValue(getCurrentProfileResponse.promise); - articleServiceMock.createInParent = jasmine.createSpy("createInParent").and.returnValue(articleCreate.promise); - }); - - it("create an article in the current profile when save", done => { - let component: BasicEditorComponent = new BasicEditorComponent(articleServiceMock, profileServiceMock, $state, notification, $stateParams); - component.save(); - $rootScope.$apply(); - expect(profileServiceMock.getCurrentProfile).toHaveBeenCalled(); - expect(articleServiceMock.createInParent).toHaveBeenCalledWith($stateParams.parent_id, component.article); - done(); - }); - - it("got to the new article page and display an alert when saving sucessfully", done => { - let component: BasicEditorComponent = new BasicEditorComponent(articleServiceMock, profileServiceMock, $state, notification, $stateParams); - component.save(); - $rootScope.$apply(); - expect($state.transitionTo).toHaveBeenCalledWith("main.profile.page", { page: "path", profile: "profile" }); - expect(notification.success).toHaveBeenCalled(); - done(); - }); - -}); diff --git a/src/app/article/basic-editor.component.ts b/src/app/article/basic-editor.component.ts deleted file mode 100644 index ab5f17f..0000000 --- a/src/app/article/basic-editor.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -import {StateConfig, Component, Inject, provide} from 'ng-forward'; -import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service"; -import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service"; -import {NotificationService} from "../shared/services/notification.service.ts"; - -@Component({ - selector: 'article-basic-editor', - templateUrl: "app/article/basic-editor.html", - providers: [ - provide('articleService', { useClass: ArticleService }), - provide('profileService', { useClass: ProfileService }), - provide('notification', { useClass: NotificationService }) - ] -}) -@Inject(ArticleService, ProfileService, "$state", NotificationService, "$stateParams") -export class BasicEditorComponent { - - article: noosfero.Article = {}; - parentId: number; - - editorOptions = {}; - - constructor(private articleService: ArticleService, - private profileService: ProfileService, - private $state: ng.ui.IStateService, - private notification: NotificationService, - private $stateParams: ng.ui.IStateParamsService) { - this.parentId = this.$stateParams['parent_id']; - } - - save() { - this.profileService.getCurrentProfile().then((profile: noosfero.Profile) => { - return this.articleService.createInParent(this.parentId, this.article); - }).then((response: noosfero.RestResult) => { - let article = (response.data); - this.$state.transitionTo('main.profile.page', { page: article.path, profile: article.profile.identifier }); - this.notification.success({ title: "Good job!", message: "Article saved!" }); - }); - } - -} diff --git a/src/app/article/basic-editor.html b/src/app/article/basic-editor.html deleted file mode 100644 index 1a08f99..0000000 --- a/src/app/article/basic-editor.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
- - -
-
- - -
- -
diff --git a/src/app/article/basic-editor/basic-editor.component.spec.ts b/src/app/article/basic-editor/basic-editor.component.spec.ts new file mode 100644 index 0000000..6d671df --- /dev/null +++ b/src/app/article/basic-editor/basic-editor.component.spec.ts @@ -0,0 +1,57 @@ +import {quickCreateComponent} from "../../../spec/helpers"; +import {BasicEditorComponent} from "./basic-editor.component"; + + +describe("Article BasicEditor", () => { + + let $rootScope: ng.IRootScopeService; + let $q: ng.IQService; + let articleServiceMock: any; + let profileServiceMock: any; + let $state: any; + let $stateParams: any; + let profile = { id: 1 }; + let notification: any; + + + beforeEach(inject((_$rootScope_: ng.IRootScopeService, _$q_: ng.IQService) => { + $rootScope = _$rootScope_; + $q = _$q_; + })); + + beforeEach(() => { + $state = jasmine.createSpyObj("$state", ["transitionTo"]); + $stateParams = jasmine.createSpyObj("$stateParams", ["parent_id"]); + notification = jasmine.createSpyObj("notification", ["success"]); + profileServiceMock = jasmine.createSpyObj("profileServiceMock", ["setCurrentProfileByIdentifier"]); + articleServiceMock = jasmine.createSpyObj("articleServiceMock", ["createInParent"]); + + let setCurrentProfileByIdentifierResponse = $q.defer(); + setCurrentProfileByIdentifierResponse.resolve(profile); + + let articleCreate = $q.defer(); + articleCreate.resolve({ data: { path: "path", profile: { identifier: "profile" } } }); + + profileServiceMock.setCurrentProfileByIdentifier = jasmine.createSpy("setCurrentProfileByIdentifier").and.returnValue(setCurrentProfileByIdentifierResponse.promise); + articleServiceMock.createInParent = jasmine.createSpy("createInParent").and.returnValue(articleCreate.promise); + }); + + it("create an article in the current profile when save", done => { + let component: BasicEditorComponent = new BasicEditorComponent(articleServiceMock, profileServiceMock, $state, notification, $stateParams); + component.save(); + $rootScope.$apply(); + expect(profileServiceMock.setCurrentProfileByIdentifier).toHaveBeenCalled(); + expect(articleServiceMock.createInParent).toHaveBeenCalledWith($stateParams.parent_id, component.article); + done(); + }); + + it("got to the new article page and display an alert when saving sucessfully", done => { + let component: BasicEditorComponent = new BasicEditorComponent(articleServiceMock, profileServiceMock, $state, notification, $stateParams); + component.save(); + $rootScope.$apply(); + expect($state.transitionTo).toHaveBeenCalledWith("main.profile.page", { page: "path", profile: "profile" }); + expect(notification.success).toHaveBeenCalled(); + done(); + }); + +}); diff --git a/src/app/article/basic-editor/basic-editor.component.ts b/src/app/article/basic-editor/basic-editor.component.ts new file mode 100644 index 0000000..ee41ce5 --- /dev/null +++ b/src/app/article/basic-editor/basic-editor.component.ts @@ -0,0 +1,41 @@ +import {StateConfig, Component, Inject, provide} from 'ng-forward'; +import {ArticleService} from "../../../lib/ng-noosfero-api/http/article.service"; +import {ProfileService} from "../../../lib/ng-noosfero-api/http/profile.service"; +import {NotificationService} from "../../shared/services/notification.service.ts"; + +@Component({ + selector: 'article-basic-editor', + templateUrl: "app/article/basic-editor/basic-editor.html", + providers: [ + provide('articleService', { useClass: ArticleService }), + provide('profileService', { useClass: ProfileService }), + provide('notification', { useClass: NotificationService }) + ] +}) +@Inject(ArticleService, ProfileService, "$state", NotificationService, "$stateParams") +export class BasicEditorComponent { + + article: noosfero.Article = {}; + parentId: number; + + editorOptions = {}; + + constructor(private articleService: ArticleService, + private profileService: ProfileService, + private $state: ng.ui.IStateService, + private notification: NotificationService, + private $stateParams: ng.ui.IStateParamsService) { + this.parentId = this.$stateParams['parent_id']; + } + + save() { + this.profileService.setCurrentProfileByIdentifier(this.$stateParams["profile"]).then((profile: noosfero.Profile) => { + return this.articleService.createInParent(this.parentId, this.article); + }).then((response: noosfero.RestResult) => { + let article = (response.data); + this.$state.transitionTo('main.profile.page', { page: article.path, profile: article.profile.identifier }); + this.notification.success({ title: "Good job!", message: "Article saved!" }); + }); + } + +} diff --git a/src/app/article/basic-editor/basic-editor.html b/src/app/article/basic-editor/basic-editor.html new file mode 100644 index 0000000..518c4e0 --- /dev/null +++ b/src/app/article/basic-editor/basic-editor.html @@ -0,0 +1,17 @@ +
+
+
+
+
+ + +
+
+ + +
+ +
+
+
+
diff --git a/src/app/article/basic-editor/basic-editor.scss b/src/app/article/basic-editor/basic-editor.scss new file mode 100644 index 0000000..669e26d --- /dev/null +++ b/src/app/article/basic-editor/basic-editor.scss @@ -0,0 +1,4 @@ +.basic-editor { + @extend .container-fluid; + padding: 0 1%; +} diff --git a/src/app/article/content-viewer/navbar-actions.html b/src/app/article/content-viewer/navbar-actions.html index 0ae84ab..3eccb25 100644 --- a/src/app/article/content-viewer/navbar-actions.html +++ b/src/app/article/content-viewer/navbar-actions.html @@ -1,6 +1,6 @@