From c55481d4f251fa4772479b1fe719af907e32aad2 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Tue, 8 Mar 2016 12:14:33 -0300 Subject: [PATCH] Fix the name of profile and article services in components --- src/app/cms/cms.component.ts | 9 +++++---- src/app/components/noosfero-blocks/members-block/members-block.component.ts | 4 ++-- src/app/components/noosfero-blocks/recent-documents/recent-documents.component.ts | 7 +++---- src/app/content-viewer/content-viewer.component.ts | 9 +++++---- src/app/profile-info/profile-info.component.ts | 9 +++++---- src/app/profile/profile-home.component.ts | 9 +++++---- src/app/profile/profile.component.ts | 11 ++++++----- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/app/cms/cms.component.ts b/src/app/cms/cms.component.ts index e0e8129..519db24 100644 --- a/src/app/cms/cms.component.ts +++ b/src/app/cms/cms.component.ts @@ -1,10 +1,11 @@ -import {StateConfig, Component, Inject} from 'ng-forward'; +import {StateConfig, Component, Inject, provide} from 'ng-forward'; import {Profile} from "./../models/interfaces"; import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service"; @Component({ selector: 'cms', - templateUrl: "app/cms/cms.html" + templateUrl: "app/cms/cms.html", + providers: [provide('articleService', { useClass: ArticleService })] }) @Inject(ArticleService, "noosfero", "$stateParams", "$httpParamSerializer", "$state", "SweetAlert") export class Cms { @@ -12,13 +13,13 @@ export class Cms { article: any = {}; profile: any; - 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) { + 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) { } save() { this.noosfero.currentProfile.then((profile: Profile) => { - return this.ArticleService.create(profile.id, this.article); + return this.articleService.create(profile.id, this.article); }).then((response: restangular.IResponse) => { this.$state.transitionTo('main.profile.page', { page: response.data.article.path, profile: response.data.article.profile.identifier }); this.SweetAlert.swal({ diff --git a/src/app/components/noosfero-blocks/members-block/members-block.component.ts b/src/app/components/noosfero-blocks/members-block/members-block.component.ts index fe22f4f..9a81409 100644 --- a/src/app/components/noosfero-blocks/members-block/members-block.component.ts +++ b/src/app/components/noosfero-blocks/members-block/members-block.component.ts @@ -13,12 +13,12 @@ export class MembersBlock { members: any = []; - constructor(private ProfileService: ProfileService) { + constructor(private profileService: ProfileService) { } ngOnInit() { - this.ProfileService.getProfileMembers(this.owner.id, { per_page: 6 }).then((response: any) => { + this.profileService.getProfileMembers(this.owner.id, { per_page: 6 }).then((response: any) => { this.members = response.data.people; }); } diff --git a/src/app/components/noosfero-blocks/recent-documents/recent-documents.component.ts b/src/app/components/noosfero-blocks/recent-documents/recent-documents.component.ts index 5ae64ce..f15e208 100644 --- a/src/app/components/noosfero-blocks/recent-documents/recent-documents.component.ts +++ b/src/app/components/noosfero-blocks/recent-documents/recent-documents.component.ts @@ -13,10 +13,10 @@ export class RecentDocumentsBlock { profile: any; documents: any; - + documentsLoaded: boolean = false; - constructor(private ArticleService: ArticleService, private $state: any) { + constructor(private articleService: ArticleService, private $state: any) { } ngOnInit() { @@ -25,7 +25,7 @@ export class RecentDocumentsBlock { var limit = (this.block && this.block.settings) ? this.block.settings.limit : null || 5; //FIXME get all text articles - this.ArticleService.getByProfile(this.profile.id, { content_type: 'TinyMceArticle', per_page: limit }).then((response: any) => { + this.articleService.getByProfile(this.profile.id, { content_type: 'TinyMceArticle', per_page: limit }).then((response: any) => { this.documents = response.data.articles; this.documentsLoaded = true; }); @@ -36,4 +36,3 @@ export class RecentDocumentsBlock { } } - diff --git a/src/app/content-viewer/content-viewer.component.ts b/src/app/content-viewer/content-viewer.component.ts index 096252c..d8007bc 100644 --- a/src/app/content-viewer/content-viewer.component.ts +++ b/src/app/content-viewer/content-viewer.component.ts @@ -2,7 +2,7 @@ import * as noosfero from "../models/interfaces"; import {ArticleView} from "../components/noosfero-articles/article/article_view"; -import {Input, Component, StateConfig, Inject} from "ng-forward"; +import {Input, Component, StateConfig, Inject, provide} from "ng-forward"; import {ArticleBlog} from "./../components/noosfero-articles/blog/blog.component"; import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service"; @@ -10,7 +10,8 @@ import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service"; @Component({ selector: "content-viewer", templateUrl: "app/content-viewer/page.html", - directives: [ArticleBlog, ArticleView] + directives: [ArticleBlog, ArticleView], + providers: [provide('articleService', { useClass: ArticleService })] }) @Inject(ArticleService, "noosfero", "$log", "$stateParams") export class ContentViewer { @@ -21,14 +22,14 @@ export class ContentViewer { @Input() profile: noosfero.Profile = null; - constructor(private ArticleService: ArticleService, private noosfero: any, private $log: ng.ILogService, private $stateParams: angular.ui.IStateParamsService) { + constructor(private articleService: ArticleService, private noosfero: any, private $log: ng.ILogService, private $stateParams: angular.ui.IStateParamsService) { this.activate(); } activate() { this.noosfero.currentProfile.then((profile: noosfero.Profile) => { this.profile = profile; - return this.ArticleService.getByProfile(this.profile.id, { path: this.$stateParams["page"] }); + return this.articleService.getByProfile(this.profile.id, { path: this.$stateParams["page"] }); }).then((response: restangular.IResponse) => { this.article = response.data.article; }); diff --git a/src/app/profile-info/profile-info.component.ts b/src/app/profile-info/profile-info.component.ts index 7b3a021..5f7a967 100644 --- a/src/app/profile-info/profile-info.component.ts +++ b/src/app/profile-info/profile-info.component.ts @@ -1,11 +1,12 @@ -import {StateConfig, Component, Inject} from 'ng-forward'; +import {StateConfig, Component, Inject, provide} from 'ng-forward'; import {Profile} from "./../models/interfaces"; import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service"; @Component({ selector: 'profile', - templateUrl: "app/profile-info/profile-info.html" + templateUrl: "app/profile-info/profile-info.html", + providers: [provide('profileService', { useClass: ProfileService })] }) @Inject(ProfileService, "noosfero") export class ProfileInfo { @@ -13,14 +14,14 @@ export class ProfileInfo { activities: any profile: any - constructor(private ProfileService: ProfileService, private noosfero: any) { + constructor(private profileService: ProfileService, private noosfero: any) { this.activate(); } activate() { this.noosfero.currentProfile.then((profile: Profile) => { this.profile = profile; - return this.ProfileService.getActivities(this.profile.id); + return this.profileService.getActivities(this.profile.id); }).then((response: restangular.IResponse) => { this.activities = response.data.activities; }); diff --git a/src/app/profile/profile-home.component.ts b/src/app/profile/profile-home.component.ts index 4aba00a..c7364bc 100644 --- a/src/app/profile/profile-home.component.ts +++ b/src/app/profile/profile-home.component.ts @@ -1,21 +1,22 @@ -import {StateConfig, Component, Inject} from 'ng-forward'; +import {StateConfig, Component, Inject, provide} from 'ng-forward'; import {Profile} from "./../models/interfaces"; import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service"; @Component({ selector: 'profile-home', - template: "
" + template: "
", + providers: [provide('profileService', { useClass: ProfileService })] }) @Inject(ProfileService, "noosfero", "$log", "$stateParams", "$scope", "$state") export class ProfileHome { profile: Profile; - constructor(ProfileService: ProfileService, noosfero: any, $log: ng.ILogService, $stateParams: ng.ui.IStateParamsService, $scope: ng.IScope, $state: ng.ui.IStateService) { + constructor(profileService: ProfileService, noosfero: any, $log: ng.ILogService, $stateParams: ng.ui.IStateParamsService, $scope: ng.IScope, $state: ng.ui.IStateService) { noosfero.currentProfile.then((profile: Profile) => { this.profile = profile; - return ProfileService.get(this.profile.id).customGET('home_page', { fields: 'path' }); + return profileService.get(this.profile.id).customGET('home_page', { fields: 'path' }); }).then((response: restangular.IResponse) => { if (response.data.article) { $state.transitionTo('main.profile.page', { page: response.data.article.path, profile: this.profile.identifier }, { location: false }); diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index de2866c..5395ba3 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -1,4 +1,4 @@ -import {StateConfig, Component, Inject} from 'ng-forward'; +import {StateConfig, Component, Inject, provide} from 'ng-forward'; import {ProfileInfo} from '../profile-info/profile-info.component'; import {ProfileHome} from '../profile/profile-home.component'; import {Cms} from '../cms/cms.component'; @@ -12,7 +12,8 @@ import * as noosferoModels from "./../models/interfaces"; @Component({ selector: 'profile', templateUrl: "app/profile/profile.html", - directives: [NoosferoActivities] + directives: [NoosferoActivities], + providers: [provide('profileService', { useClass: ProfileService })] }) @StateConfig([ { @@ -74,11 +75,11 @@ export class Profile { boxes: noosferoModels.Box[]; profile: noosferoModels.Profile; - constructor(ProfileService: ProfileService, noosfero: any, $log: ng.ILogService, $stateParams: ng.ui.IStateParamsService) { - ProfileService.getByIdentifier($stateParams["profile"]).then((response: restangular.IResponse) => { + constructor(profileService: ProfileService, noosfero: any, $log: ng.ILogService, $stateParams: ng.ui.IStateParamsService) { + profileService.getByIdentifier($stateParams["profile"]).then((response: restangular.IResponse) => { this.profile = response.data[0]; noosfero.setCurrentProfile(this.profile); - return ProfileService.getBoxes(this.profile.id); + return profileService.getBoxes(this.profile.id); }).then((response: restangular.IResponse) => { this.boxes = response.data.boxes; }); -- libgit2 0.21.2