From e80763e4e9997e55d77687f1314bc8de977eb424 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Fri, 26 Feb 2016 09:38:12 -0300 Subject: [PATCH] Migrate profile info controller --- src/app/index.route.ts | 10 ---------- src/app/index.ts | 3 ++- src/app/main/main.component.ts | 2 +- src/app/profile-info/profile-info.component.ts | 25 +++++++++++++++++++++++++ src/app/profile-info/profile-info.controller.js | 25 ------------------------- src/app/profile/profile.component.ts | 17 ++++++++++++++++- 6 files changed, 44 insertions(+), 38 deletions(-) create mode 100644 src/app/profile-info/profile-info.component.ts delete mode 100644 src/app/profile-info/profile-info.controller.js diff --git a/src/app/index.route.ts b/src/app/index.route.ts index 869e3d3..7ca7686 100644 --- a/src/app/index.route.ts +++ b/src/app/index.route.ts @@ -25,16 +25,6 @@ export function routeConfig($stateProvider, $urlRouterProvider) { } } }) - .state("main.profile.info", { - url: "^/profile/:profile", - views: { - "mainBlockContent": { - templateUrl: "app/profile-info/profile-info.html", - controller: "ProfileInfoController", - controllerAs: "vm" - } - } - }) .state("main.profile.page", { url: "/{page:any}", views: { diff --git a/src/app/index.ts b/src/app/index.ts index 1537e81..b2c2fd1 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -6,6 +6,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 {Main} from "./main/main.component"; import {bootstrap, bundle} from "ng-forward"; @@ -52,10 +53,10 @@ require("./components/noosfero/noosfero.service.js"); require("./components/noosfero/profile-image/profile-image.component.js"); require("./content-viewer/content-viewer-actions.controller.js"); // require("./content-viewer/content-viewer.controller.js"); -require("./profile-info/profile-info.controller.js"); require("./profile/profile-home.controller.js"); NoosferoApp.addController("ContentViewerController", noosferoContentViewer); NoosferoApp.addController("ProfileController", noosferoProfile); +NoosferoApp.addController("ProfileInfoController", noosferoProfileInfo); NoosferoApp.addConfig(routeConfig); diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 72671d9..a91f5ec 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -31,7 +31,7 @@ export class MainContent { }, { url: "^/:profile", - // abstract: true, + abstract: true, component: Profile, name: 'main.profile', views: { diff --git a/src/app/profile-info/profile-info.component.ts b/src/app/profile-info/profile-info.component.ts new file mode 100644 index 0000000..e412690 --- /dev/null +++ b/src/app/profile-info/profile-info.component.ts @@ -0,0 +1,25 @@ +import {StateConfig, Component, Inject} from 'ng-forward'; + +@Component({ + selector: 'profile', + templateUrl: "app/profile-info/profile-info.html" +}) +@Inject("noosfero") +export class ProfileInfo { + + activities: any + profile: any + + constructor(private noosfero) { + this.activate(); + } + + activate() { + this.noosfero.currentProfile.then((profile) => { + this.profile = profile; + return this.noosfero.profiles.one(this.profile.id).one('activities').get(); + }).then((response) => { + this.activities = response.data.activities; + }); + } +} diff --git a/src/app/profile-info/profile-info.controller.js b/src/app/profile-info/profile-info.controller.js deleted file mode 100644 index 9b87545..0000000 --- a/src/app/profile-info/profile-info.controller.js +++ /dev/null @@ -1,25 +0,0 @@ -(function() { - 'use strict'; - - angular - .module('noosferoApp') - .controller('ProfileInfoController', ProfileInfoController); - - - /** @ngInject */ - function ProfileInfoController(noosfero) { - var vm = this; - vm.profile = null; - vm.activities = []; - activate(); - - function activate() { - noosfero.currentProfile.then(function(profile) { - vm.profile = profile; - return noosfero.profiles.one(vm.profile.id).one('activities').get(); - }).then(function(response) { - vm.activities = response.data.activities; - }); - } - } -})(); diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index ce4d76c..9eb8970 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -1,9 +1,24 @@ -import {Component, Inject} from 'ng-forward'; +import {StateConfig, Component, Inject} from 'ng-forward'; +import {ProfileInfo} from '../profile-info/profile-info.component' @Component({ selector: 'profile', templateUrl: "app/profile/profile.html" }) +@StateConfig([ + { + url: "^/profile/:profile", + component: ProfileInfo, + name: 'main.profile.info', + views: { + "mainBlockContent": { + templateUrl: "app/profile-info/profile-info.html", + controller: "ProfileInfoController", + controllerAs: "vm" + } + } + } +]) @Inject("noosfero", "$log", "$stateParams") export class Profile { -- libgit2 0.21.2