Commit c55481d4f251fa4772479b1fe719af907e32aad2

Authored by Victor Costa
1 parent 3645c953

Fix the name of profile and article services in components

src/app/cms/cms.component.ts
1 -import {StateConfig, Component, Inject} from 'ng-forward'; 1 +import {StateConfig, Component, Inject, provide} from 'ng-forward';
2 import {Profile} from "./../models/interfaces"; 2 import {Profile} from "./../models/interfaces";
3 import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service"; 3 import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service";
4 4
5 @Component({ 5 @Component({
6 selector: 'cms', 6 selector: 'cms',
7 - templateUrl: "app/cms/cms.html" 7 + templateUrl: "app/cms/cms.html",
  8 + providers: [provide('articleService', { useClass: ArticleService })]
8 }) 9 })
9 @Inject(ArticleService, "noosfero", "$stateParams", "$httpParamSerializer", "$state", "SweetAlert") 10 @Inject(ArticleService, "noosfero", "$stateParams", "$httpParamSerializer", "$state", "SweetAlert")
10 export class Cms { 11 export class Cms {
@@ -12,13 +13,13 @@ export class Cms { @@ -12,13 +13,13 @@ export class Cms {
12 article: any = {}; 13 article: any = {};
13 profile: any; 14 profile: any;
14 15
15 - constructor(private ArticleService: ArticleService, private noosfero: any/* TODO convert noosferoService */, private $stateParams: ng.ui.IStateParamsService, private $httpParamSerializer: any, private $state: ng.ui.IStateService, private SweetAlert: any) { 16 + constructor(private articleService: ArticleService, private noosfero: any/* TODO convert noosferoService */, private $stateParams: ng.ui.IStateParamsService, private $httpParamSerializer: any, private $state: ng.ui.IStateService, private SweetAlert: any) {
16 17
17 } 18 }
18 19
19 save() { 20 save() {
20 this.noosfero.currentProfile.then((profile: Profile) => { 21 this.noosfero.currentProfile.then((profile: Profile) => {
21 - return this.ArticleService.create(profile.id, this.article); 22 + return this.articleService.create(profile.id, this.article);
22 }).then((response: restangular.IResponse) => { 23 }).then((response: restangular.IResponse) => {
23 this.$state.transitionTo('main.profile.page', { page: response.data.article.path, profile: response.data.article.profile.identifier }); 24 this.$state.transitionTo('main.profile.page', { page: response.data.article.path, profile: response.data.article.profile.identifier });
24 this.SweetAlert.swal({ 25 this.SweetAlert.swal({
src/app/components/noosfero-blocks/members-block/members-block.component.ts
@@ -13,12 +13,12 @@ export class MembersBlock { @@ -13,12 +13,12 @@ export class MembersBlock {
13 13
14 members: any = []; 14 members: any = [];
15 15
16 - constructor(private ProfileService: ProfileService) { 16 + constructor(private profileService: ProfileService) {
17 17
18 } 18 }
19 19
20 ngOnInit() { 20 ngOnInit() {
21 - this.ProfileService.getProfileMembers(this.owner.id, { per_page: 6 }).then((response: any) => { 21 + this.profileService.getProfileMembers(this.owner.id, { per_page: 6 }).then((response: any) => {
22 this.members = response.data.people; 22 this.members = response.data.people;
23 }); 23 });
24 } 24 }
src/app/components/noosfero-blocks/recent-documents/recent-documents.component.ts
@@ -13,10 +13,10 @@ export class RecentDocumentsBlock { @@ -13,10 +13,10 @@ export class RecentDocumentsBlock {
13 13
14 profile: any; 14 profile: any;
15 documents: any; 15 documents: any;
16 - 16 +
17 documentsLoaded: boolean = false; 17 documentsLoaded: boolean = false;
18 18
19 - constructor(private ArticleService: ArticleService, private $state: any) { 19 + constructor(private articleService: ArticleService, private $state: any) {
20 } 20 }
21 21
22 ngOnInit() { 22 ngOnInit() {
@@ -25,7 +25,7 @@ export class RecentDocumentsBlock { @@ -25,7 +25,7 @@ export class RecentDocumentsBlock {
25 25
26 var limit = (this.block && this.block.settings) ? this.block.settings.limit : null || 5; 26 var limit = (this.block && this.block.settings) ? this.block.settings.limit : null || 5;
27 //FIXME get all text articles 27 //FIXME get all text articles
28 - this.ArticleService.getByProfile(this.profile.id, { content_type: 'TinyMceArticle', per_page: limit }).then((response: any) => { 28 + this.articleService.getByProfile(this.profile.id, { content_type: 'TinyMceArticle', per_page: limit }).then((response: any) => {
29 this.documents = response.data.articles; 29 this.documents = response.data.articles;
30 this.documentsLoaded = true; 30 this.documentsLoaded = true;
31 }); 31 });
@@ -36,4 +36,3 @@ export class RecentDocumentsBlock { @@ -36,4 +36,3 @@ export class RecentDocumentsBlock {
36 } 36 }
37 37
38 } 38 }
39 -  
src/app/content-viewer/content-viewer.component.ts
@@ -2,7 +2,7 @@ import * as noosfero from "../models/interfaces"; @@ -2,7 +2,7 @@ import * as noosfero from "../models/interfaces";
2 2
3 3
4 import {ArticleView} from "../components/noosfero-articles/article/article_view"; 4 import {ArticleView} from "../components/noosfero-articles/article/article_view";
5 -import {Input, Component, StateConfig, Inject} from "ng-forward"; 5 +import {Input, Component, StateConfig, Inject, provide} from "ng-forward";
6 6
7 import {ArticleBlog} from "./../components/noosfero-articles/blog/blog.component"; 7 import {ArticleBlog} from "./../components/noosfero-articles/blog/blog.component";
8 import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service"; 8 import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service";
@@ -10,7 +10,8 @@ import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service"; @@ -10,7 +10,8 @@ import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service";
10 @Component({ 10 @Component({
11 selector: "content-viewer", 11 selector: "content-viewer",
12 templateUrl: "app/content-viewer/page.html", 12 templateUrl: "app/content-viewer/page.html",
13 - directives: [ArticleBlog, ArticleView] 13 + directives: [ArticleBlog, ArticleView],
  14 + providers: [provide('articleService', { useClass: ArticleService })]
14 }) 15 })
15 @Inject(ArticleService, "noosfero", "$log", "$stateParams") 16 @Inject(ArticleService, "noosfero", "$log", "$stateParams")
16 export class ContentViewer { 17 export class ContentViewer {
@@ -21,14 +22,14 @@ export class ContentViewer { @@ -21,14 +22,14 @@ export class ContentViewer {
21 @Input() 22 @Input()
22 profile: noosfero.Profile = null; 23 profile: noosfero.Profile = null;
23 24
24 - constructor(private ArticleService: ArticleService, private noosfero: any, private $log: ng.ILogService, private $stateParams: angular.ui.IStateParamsService) { 25 + constructor(private articleService: ArticleService, private noosfero: any, private $log: ng.ILogService, private $stateParams: angular.ui.IStateParamsService) {
25 this.activate(); 26 this.activate();
26 } 27 }
27 28
28 activate() { 29 activate() {
29 this.noosfero.currentProfile.then((profile: noosfero.Profile) => { 30 this.noosfero.currentProfile.then((profile: noosfero.Profile) => {
30 this.profile = profile; 31 this.profile = profile;
31 - return this.ArticleService.getByProfile(this.profile.id, { path: this.$stateParams["page"] }); 32 + return this.articleService.getByProfile(this.profile.id, { path: this.$stateParams["page"] });
32 }).then((response: restangular.IResponse) => { 33 }).then((response: restangular.IResponse) => {
33 this.article = response.data.article; 34 this.article = response.data.article;
34 }); 35 });
src/app/profile-info/profile-info.component.ts
1 -import {StateConfig, Component, Inject} from 'ng-forward'; 1 +import {StateConfig, Component, Inject, provide} from 'ng-forward';
2 2
3 import {Profile} from "./../models/interfaces"; 3 import {Profile} from "./../models/interfaces";
4 import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service"; 4 import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service";
5 5
6 @Component({ 6 @Component({
7 selector: 'profile', 7 selector: 'profile',
8 - templateUrl: "app/profile-info/profile-info.html" 8 + templateUrl: "app/profile-info/profile-info.html",
  9 + providers: [provide('profileService', { useClass: ProfileService })]
9 }) 10 })
10 @Inject(ProfileService, "noosfero") 11 @Inject(ProfileService, "noosfero")
11 export class ProfileInfo { 12 export class ProfileInfo {
@@ -13,14 +14,14 @@ export class ProfileInfo { @@ -13,14 +14,14 @@ export class ProfileInfo {
13 activities: any 14 activities: any
14 profile: any 15 profile: any
15 16
16 - constructor(private ProfileService: ProfileService, private noosfero: any) { 17 + constructor(private profileService: ProfileService, private noosfero: any) {
17 this.activate(); 18 this.activate();
18 } 19 }
19 20
20 activate() { 21 activate() {
21 this.noosfero.currentProfile.then((profile: Profile) => { 22 this.noosfero.currentProfile.then((profile: Profile) => {
22 this.profile = profile; 23 this.profile = profile;
23 - return this.ProfileService.getActivities(this.profile.id); 24 + return this.profileService.getActivities(this.profile.id);
24 }).then((response: restangular.IResponse) => { 25 }).then((response: restangular.IResponse) => {
25 this.activities = response.data.activities; 26 this.activities = response.data.activities;
26 }); 27 });
src/app/profile/profile-home.component.ts
1 -import {StateConfig, Component, Inject} from 'ng-forward'; 1 +import {StateConfig, Component, Inject, provide} from 'ng-forward';
2 2
3 import {Profile} from "./../models/interfaces"; 3 import {Profile} from "./../models/interfaces";
4 import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service"; 4 import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service";
5 5
6 @Component({ 6 @Component({
7 selector: 'profile-home', 7 selector: 'profile-home',
8 - template: "<div></div>" 8 + template: "<div></div>",
  9 + providers: [provide('profileService', { useClass: ProfileService })]
9 }) 10 })
10 @Inject(ProfileService, "noosfero", "$log", "$stateParams", "$scope", "$state") 11 @Inject(ProfileService, "noosfero", "$log", "$stateParams", "$scope", "$state")
11 export class ProfileHome { 12 export class ProfileHome {
12 13
13 profile: Profile; 14 profile: Profile;
14 15
15 - constructor(ProfileService: ProfileService, noosfero: any, $log: ng.ILogService, $stateParams: ng.ui.IStateParamsService, $scope: ng.IScope, $state: ng.ui.IStateService) { 16 + constructor(profileService: ProfileService, noosfero: any, $log: ng.ILogService, $stateParams: ng.ui.IStateParamsService, $scope: ng.IScope, $state: ng.ui.IStateService) {
16 noosfero.currentProfile.then((profile: Profile) => { 17 noosfero.currentProfile.then((profile: Profile) => {
17 this.profile = profile; 18 this.profile = profile;
18 - return ProfileService.get(this.profile.id).customGET('home_page', { fields: 'path' }); 19 + return profileService.get(this.profile.id).customGET('home_page', { fields: 'path' });
19 }).then((response: restangular.IResponse) => { 20 }).then((response: restangular.IResponse) => {
20 if (response.data.article) { 21 if (response.data.article) {
21 $state.transitionTo('main.profile.page', { page: response.data.article.path, profile: this.profile.identifier }, { location: false }); 22 $state.transitionTo('main.profile.page', { page: response.data.article.path, profile: this.profile.identifier }, { location: false });
src/app/profile/profile.component.ts
1 -import {StateConfig, Component, Inject} from 'ng-forward'; 1 +import {StateConfig, Component, Inject, provide} from 'ng-forward';
2 import {ProfileInfo} from '../profile-info/profile-info.component'; 2 import {ProfileInfo} from '../profile-info/profile-info.component';
3 import {ProfileHome} from '../profile/profile-home.component'; 3 import {ProfileHome} from '../profile/profile-home.component';
4 import {Cms} from '../cms/cms.component'; 4 import {Cms} from '../cms/cms.component';
@@ -12,7 +12,8 @@ import * as noosferoModels from &quot;./../models/interfaces&quot;; @@ -12,7 +12,8 @@ import * as noosferoModels from &quot;./../models/interfaces&quot;;
12 @Component({ 12 @Component({
13 selector: 'profile', 13 selector: 'profile',
14 templateUrl: "app/profile/profile.html", 14 templateUrl: "app/profile/profile.html",
15 - directives: [NoosferoActivities] 15 + directives: [NoosferoActivities],
  16 + providers: [provide('profileService', { useClass: ProfileService })]
16 }) 17 })
17 @StateConfig([ 18 @StateConfig([
18 { 19 {
@@ -74,11 +75,11 @@ export class Profile { @@ -74,11 +75,11 @@ export class Profile {
74 boxes: noosferoModels.Box[]; 75 boxes: noosferoModels.Box[];
75 profile: noosferoModels.Profile; 76 profile: noosferoModels.Profile;
76 77
77 - constructor(ProfileService: ProfileService, noosfero: any, $log: ng.ILogService, $stateParams: ng.ui.IStateParamsService) {  
78 - ProfileService.getByIdentifier($stateParams["profile"]).then((response: restangular.IResponse) => { 78 + constructor(profileService: ProfileService, noosfero: any, $log: ng.ILogService, $stateParams: ng.ui.IStateParamsService) {
  79 + profileService.getByIdentifier($stateParams["profile"]).then((response: restangular.IResponse) => {
79 this.profile = response.data[0]; 80 this.profile = response.data[0];
80 noosfero.setCurrentProfile(this.profile); 81 noosfero.setCurrentProfile(this.profile);
81 - return ProfileService.getBoxes(this.profile.id); 82 + return profileService.getBoxes(this.profile.id);
82 }).then((response: restangular.IResponse) => { 83 }).then((response: restangular.IResponse) => {
83 this.boxes = response.data.boxes; 84 this.boxes = response.data.boxes;
84 }); 85 });