Merge Request #11

Merged
noosfero-themes/angular-theme!11
Created by Victor Costa

Basic form to create and edit articles

Assignee: None
Milestone: 2016.05

Merged by Michel Felipe

Source branch has been removed
Commits (12)
3 participants
  • Me
    Michel Felipe @mfdeveloper

    Reassigned to @mfdeveloper

    Choose File ...   File name...
    Cancel
  • Me
    Michel Felipe started a discussion on commit 2259690d
    last updated by Michel Felipe
    src/app/article/basic-editor.component.spec.ts
    31 33 articleCreate.resolve({ data: { path: "path", profile: { identifier: "profile" } } });
    32 34  
    33 35 profileServiceMock.getCurrentProfile = jasmine.createSpy("getCurrentProfile").and.returnValue(getCurrentProfileResponse.promise);
    34   - articleServiceMock.createInProfile = jasmine.createSpy("createInProfile").and.returnValue(articleCreate.promise);
      36 + articleServiceMock.createInParent = jasmine.createSpy("createInParent").and.returnValue(articleCreate.promise);
    35 37 });
    36 38  
    37 39 it("create an article in the current profile when save", done => {
    38   - let component: BasicEditorComponent = new BasicEditorComponent(articleServiceMock, profileServiceMock, $state, notification);
    3
    • Me
      Michel Felipe @mfdeveloper

      Why did you instantiate the BasicEditorComponent "by hand" here? What do you think about usage of the ComponentTestHelper to more clean unit specs?

      Choose File ...   File name...
      Cancel
    • 4a20548511a65cfccc863520b70c3ee9?s=40&d=identicon
      Victor Costa @vfcosta

      It is a legacy code, I just include the missing parameter to fix the test.

      Choose File ...   File name...
      Cancel
    • Me
      Michel Felipe @mfdeveloper

      Sure! It's ok for me :)

      Choose File ...   File name...
      Cancel
    Me
    Michel Felipe started a discussion on commit 2259690d
    last updated by Victor Costa
    src/app/article/content-viewer/content-viewer-actions.component.spec.ts
    44 47 });
    45 48 });
    46 49  
      50 + it('return article parent as container when it is not a folder', (done: Function) => {
      51 + buildComponent().then((fixture: ComponentFixture) => {
      52 + let component = fixture.debugElement.componentViewChildren[0].componentInstance;
    2
    • Me
      Michel Felipe @mfdeveloper

      Why did you not use ComponentTestHelper class?

      Choose File ...   File name...
      Cancel
    • 4a20548511a65cfccc863520b70c3ee9?s=40&d=identicon
      Victor Costa @vfcosta

      It's a legacy code, I just move this file to another folder. I'll refactor it and apply your considerations.

      Choose File ...   File name...
      Cancel
    Me
    Michel Felipe started a discussion on commit 2259690d
    last updated by Michel Felipe
    src/app/article/content-viewer/content-viewer-actions.component.ts
    1 1 import {Component, Inject, provide} from "ng-forward";
    2 2 import {ProfileService} from "../../../lib/ng-noosfero-api/http/profile.service";
      3 +import {ArticleService} from "../../../lib/ng-noosfero-api/http/article.service";
    3 4  
    4 5 @Component({
    5 6 selector: "content-viewer-actions",
    6 7 templateUrl: "app/article/content-viewer/navbar-actions.html",
    7   - providers: [provide('profileService', { useClass: ProfileService })]
      8 + providers: [
      9 + provide('profileService', { useClass: ProfileService }),
    3
    • Me
      Michel Felipe @mfdeveloper

      It is necessary? Seems redundant for me, no?

      Choose File ...   File name...
      Cancel
    • 4a20548511a65cfccc863520b70c3ee9?s=40&d=identicon
      Victor Costa @vfcosta

      Sadly yes. The alternative here is to use ProfileService as the parameter name. However, it works seamlessly in components that don't uses ui-roter directly (e.g. members-block.component.ts).

      Choose File ...   File name...
      Cancel
    • Me
      Michel Felipe @mfdeveloper

      I understand now. This is a ng-foward constraint?

      Choose File ...   File name...
      Cancel
    Me
    Michel Felipe started a discussion on commit a5984494
    last updated by Michel Felipe
    src/app/article/basic-editor/basic-editor.component.spec.ts 0 → 100644
      3 +
      4 +
      5 +describe("Article BasicEditor", () => {
      6 +
      7 + let $rootScope: ng.IRootScopeService;
      8 + let $q: ng.IQService;
      9 + let articleServiceMock: any;
      10 + let profileServiceMock: any;
      11 + let $state: any;
      12 + let $stateParams: any;
      13 + let profile = { id: 1 };
      14 + let notification: any;
      15 +
      16 +
      17 + beforeEach(inject((_$rootScope_: ng.IRootScopeService, _$q_: ng.IQService) => {
      18 + $rootScope = _$rootScope_;
    1
    • Me
      Michel Felipe @mfdeveloper

      Did you try use the AngularServiceFactory.getService() method, created by @abner to retrieve core angular services? I think this is better than use angular 1.x functions directly.

      Choose File ...   File name...
      Cancel
  • 4a20548511a65cfccc863520b70c3ee9?s=40&d=identicon
    Victor Costa @vfcosta

    Added 1 new commit:

    • 00eaab03 - Display basic error message when fail to save an article
    Choose File ...   File name...
    Cancel
  • Me
    Michel Felipe started a discussion on commit a5984494
    last updated by Victor Costa
    src/app/article/basic-editor/basic-editor.component.spec.ts 0 → 100644
      27 + articleServiceMock = jasmine.createSpyObj("articleServiceMock", ["createInParent"]);
      28 +
      29 + let setCurrentProfileByIdentifierResponse = $q.defer();
      30 + setCurrentProfileByIdentifierResponse.resolve(profile);
      31 +
      32 + let articleCreate = $q.defer();
      33 + articleCreate.resolve({ data: { path: "path", profile: { identifier: "profile" } } });
      34 +
      35 + profileServiceMock.setCurrentProfileByIdentifier = jasmine.createSpy("setCurrentProfileByIdentifier").and.returnValue(setCurrentProfileByIdentifierResponse.promise);
      36 + articleServiceMock.createInParent = jasmine.createSpy("createInParent").and.returnValue(articleCreate.promise);
      37 + });
      38 +
      39 + it("create an article in the current profile when save", done => {
      40 + let component: BasicEditorComponent = new BasicEditorComponent(articleServiceMock, profileServiceMock, $state, notification, $stateParams);
      41 + component.save();
      42 + $rootScope.$apply();
    2
    • Me
      Michel Felipe @mfdeveloper

      Why did you use $rootScope in this case? Did you try use detectChanges() ng-forward method?

      Choose File ...   File name...
      Cancel
    • 4a20548511a65cfccc863520b70c3ee9?s=40&d=identicon
      Victor Costa @vfcosta

      It's a legacy code, I just move this file to another folder. I'll refactor it and apply your considerations.

      Choose File ...   File name...
      Cancel
    Me
    Michel Felipe started a discussion on commit 6b15acb7
    last updated by Victor Costa
    src/languages/pt.json
    36 36 "comment.post.success.title": "Bom trabalho!",
    37 37 "comment.post.success.message": "Comentário salvo com sucesso!",
    38 38 "comment.reply": "responder",
      39 + "article.actions.edit": "Editar",
    2
    • Me
      Michel Felipe @mfdeveloper

      Can be this key more generic? Something like: actions.edit only. This is not specific article action

      Choose File ...   File name...
      Cancel
    • 4a20548511a65cfccc863520b70c3ee9?s=40&d=identicon
      Victor Costa @vfcosta

      Not sure...sometimes we want to change only this specific label to something like "Edit Article"

      Choose File ...   File name...
      Cancel
  • 5bf9bf341e9d00ebd854cdaf1a4299b2?s=40&d=identicon
    Leandro Santos @leandronunes

    Milestone changed to 2016.05

    Choose File ...   File name...
    Cancel
  • 4a20548511a65cfccc863520b70c3ee9?s=40&d=identicon
    Victor Costa @vfcosta

    Added 1 new commit:

    • 5f9ef2ae - Refactor tests of content viewer actions to use ComponentTestHelper
    Choose File ...   File name...
    Cancel
  • Me
    Michel Felipe @mfdeveloper
    Choose File ...   File name...
    Cancel
  • Me
    Michel Felipe @mfdeveloper

    Assignee removed

    Choose File ...   File name...
    Cancel