diff --git a/src/app/index.route.ts b/src/app/index.route.ts index 6bd6762..7e05600 100644 --- a/src/app/index.route.ts +++ b/src/app/index.route.ts @@ -6,15 +6,6 @@ export function routeConfig($stateProvider, $urlRouterProvider) { .state("main.profile.settings", { url: "^/myprofile/:profile" }) - .state("main.profile.home", { - url: "", - views: { - "mainBlockContent": { - controller: "ProfileHomeController", - controllerAs: "vm" - } - } - }) .state("main.profile.page", { url: "/{page:any}", views: { diff --git a/src/app/index.ts b/src/app/index.ts index 5a025e4..70d9015 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -9,6 +9,7 @@ import {routeConfig} from "./index.route"; import {ContentViewer as noosferoContentViewer} from "./content-viewer/content-viewer.component"; import {Profile as noosferoProfile} from "./profile/profile.component"; import {ProfileInfo as noosferoProfileInfo} from "./profile-info/profile-info.component"; +import {ProfileHome as noosferoProfileHome} from "./profile/profile-home.component"; import {Cms as noosferoCms} from "./cms/cms.component"; import {Main} from "./main/main.component"; @@ -52,10 +53,10 @@ require("./components/noosfero/noosfero-template.filter.js"); require("./components/noosfero/noosfero.service.js"); require("./components/noosfero/profile-image/profile-image.component.js"); require("./content-viewer/content-viewer-actions.controller.js"); -require("./profile/profile-home.controller.js"); NoosferoApp.addController("ContentViewerController", noosferoContentViewer); NoosferoApp.addController("ProfileController", noosferoProfile); +NoosferoApp.addController("ProfileHomeController", noosferoProfileHome); NoosferoApp.addController("ProfileInfoController", noosferoProfileInfo); NoosferoApp.addController("CmsController", noosferoCms); diff --git a/src/app/profile/profile-home.component.ts b/src/app/profile/profile-home.component.ts new file mode 100644 index 0000000..92d3402 --- /dev/null +++ b/src/app/profile/profile-home.component.ts @@ -0,0 +1,24 @@ +import {StateConfig, Component, Inject} from 'ng-forward'; + +@Component({ + selector: 'profile-home', + template: "
" +}) +@Inject("noosfero", "$log", "$stateParams", "$scope", "$state") +export class ProfileHome { + + profile: any; + + constructor(noosfero, $log, $stateParams, $scope, $state) { + noosfero.currentProfile.then((profile) => { + this.profile = profile; + return noosfero.profile(this.profile.id).customGET('home_page', { fields: 'path' }); + }).then((response) => { + if (response.data.article) { + $state.transitionTo('main.profile.page', { page: response.data.article.path, profile: this.profile.identifier }, { location: false }); + } else { + $state.transitionTo('main.profile.info', { profile: this.profile.identifier }, { location: false }); + } + }); + } +} diff --git a/src/app/profile/profile-home.controller.js b/src/app/profile/profile-home.controller.js deleted file mode 100644 index a3c6c2f..0000000 --- a/src/app/profile/profile-home.controller.js +++ /dev/null @@ -1,27 +0,0 @@ -(function() { - 'use strict'; - - angular - .module('noosferoApp') - .controller('ProfileHomeController', ProfileHomeController); - - - /** @ngInject */ - function ProfileHomeController(noosfero, $log, $stateParams, $scope, $state) { - var vm = this; - activate(); - - function activate() { - noosfero.currentProfile.then(function(profile) { - vm.profile = profile; - return noosfero.profile(vm.profile.id).customGET('home_page', {fields: 'path'}); - }).then(function(response) { - if(response.data.article) { - $state.transitionTo('main.profile.page', {page: response.data.article.path, profile: vm.profile.identifier}, {location: false}); - } else { - $state.transitionTo('main.profile.info', {profile: vm.profile.identifier}, {location: false}); - } - }); - } - } -})(); diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index 88b237d..c50a6eb 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -1,5 +1,6 @@ import {StateConfig, Component, Inject} from 'ng-forward'; import {ProfileInfo} from '../profile-info/profile-info.component' +import {ProfileHome} from '../profile/profile-home.component' import {Cms} from '../cms/cms.component' @Component({ @@ -31,6 +32,17 @@ import {Cms} from '../cms/cms.component' } } }, + { + name: 'main.profile.home', + url: "", + component: ProfileHome, + views: { + "mainBlockContent": { + controller: "ProfileHomeController", + controllerAs: "vm" + } + } + }, ]) @Inject("noosfero", "$log", "$stateParams") export class Profile { -- libgit2 0.21.2