Commit e80763e4e9997e55d77687f1314bc8de977eb424
1 parent
36a0b0c2
Exists in
master
and in
35 other branches
Migrate profile info controller
Showing
6 changed files
with
44 additions
and
38 deletions
Show diff stats
src/app/index.route.ts
@@ -25,16 +25,6 @@ export function routeConfig($stateProvider, $urlRouterProvider) { | @@ -25,16 +25,6 @@ export function routeConfig($stateProvider, $urlRouterProvider) { | ||
25 | } | 25 | } |
26 | } | 26 | } |
27 | }) | 27 | }) |
28 | - .state("main.profile.info", { | ||
29 | - url: "^/profile/:profile", | ||
30 | - views: { | ||
31 | - "mainBlockContent": { | ||
32 | - templateUrl: "app/profile-info/profile-info.html", | ||
33 | - controller: "ProfileInfoController", | ||
34 | - controllerAs: "vm" | ||
35 | - } | ||
36 | - } | ||
37 | - }) | ||
38 | .state("main.profile.page", { | 28 | .state("main.profile.page", { |
39 | url: "/{page:any}", | 29 | url: "/{page:any}", |
40 | views: { | 30 | views: { |
src/app/index.ts
@@ -6,6 +6,7 @@ import {routeConfig} from "./index.route"; | @@ -6,6 +6,7 @@ import {routeConfig} from "./index.route"; | ||
6 | 6 | ||
7 | import {ContentViewer as noosferoContentViewer} from "./content-viewer/content-viewer.component"; | 7 | import {ContentViewer as noosferoContentViewer} from "./content-viewer/content-viewer.component"; |
8 | import {Profile as noosferoProfile} from "./profile/profile.component"; | 8 | import {Profile as noosferoProfile} from "./profile/profile.component"; |
9 | +import {ProfileInfo as noosferoProfileInfo} from "./profile-info/profile-info.component"; | ||
9 | 10 | ||
10 | import {Main} from "./main/main.component"; | 11 | import {Main} from "./main/main.component"; |
11 | import {bootstrap, bundle} from "ng-forward"; | 12 | import {bootstrap, bundle} from "ng-forward"; |
@@ -52,10 +53,10 @@ require("./components/noosfero/noosfero.service.js"); | @@ -52,10 +53,10 @@ require("./components/noosfero/noosfero.service.js"); | ||
52 | require("./components/noosfero/profile-image/profile-image.component.js"); | 53 | require("./components/noosfero/profile-image/profile-image.component.js"); |
53 | require("./content-viewer/content-viewer-actions.controller.js"); | 54 | require("./content-viewer/content-viewer-actions.controller.js"); |
54 | // require("./content-viewer/content-viewer.controller.js"); | 55 | // require("./content-viewer/content-viewer.controller.js"); |
55 | -require("./profile-info/profile-info.controller.js"); | ||
56 | require("./profile/profile-home.controller.js"); | 56 | require("./profile/profile-home.controller.js"); |
57 | 57 | ||
58 | NoosferoApp.addController("ContentViewerController", noosferoContentViewer); | 58 | NoosferoApp.addController("ContentViewerController", noosferoContentViewer); |
59 | NoosferoApp.addController("ProfileController", noosferoProfile); | 59 | NoosferoApp.addController("ProfileController", noosferoProfile); |
60 | +NoosferoApp.addController("ProfileInfoController", noosferoProfileInfo); | ||
60 | 61 | ||
61 | NoosferoApp.addConfig(routeConfig); | 62 | NoosferoApp.addConfig(routeConfig); |
src/app/main/main.component.ts
@@ -31,7 +31,7 @@ export class MainContent { | @@ -31,7 +31,7 @@ export class MainContent { | ||
31 | }, | 31 | }, |
32 | { | 32 | { |
33 | url: "^/:profile", | 33 | url: "^/:profile", |
34 | - // abstract: true, | 34 | + abstract: true, |
35 | component: Profile, | 35 | component: Profile, |
36 | name: 'main.profile', | 36 | name: 'main.profile', |
37 | views: { | 37 | views: { |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +import {StateConfig, Component, Inject} from 'ng-forward'; | ||
2 | + | ||
3 | +@Component({ | ||
4 | + selector: 'profile', | ||
5 | + templateUrl: "app/profile-info/profile-info.html" | ||
6 | +}) | ||
7 | +@Inject("noosfero") | ||
8 | +export class ProfileInfo { | ||
9 | + | ||
10 | + activities: any | ||
11 | + profile: any | ||
12 | + | ||
13 | + constructor(private noosfero) { | ||
14 | + this.activate(); | ||
15 | + } | ||
16 | + | ||
17 | + activate() { | ||
18 | + this.noosfero.currentProfile.then((profile) => { | ||
19 | + this.profile = profile; | ||
20 | + return this.noosfero.profiles.one(this.profile.id).one('activities').get(); | ||
21 | + }).then((response) => { | ||
22 | + this.activities = response.data.activities; | ||
23 | + }); | ||
24 | + } | ||
25 | +} |
src/app/profile-info/profile-info.controller.js
@@ -1,25 +0,0 @@ | @@ -1,25 +0,0 @@ | ||
1 | -(function() { | ||
2 | - 'use strict'; | ||
3 | - | ||
4 | - angular | ||
5 | - .module('noosferoApp') | ||
6 | - .controller('ProfileInfoController', ProfileInfoController); | ||
7 | - | ||
8 | - | ||
9 | - /** @ngInject */ | ||
10 | - function ProfileInfoController(noosfero) { | ||
11 | - var vm = this; | ||
12 | - vm.profile = null; | ||
13 | - vm.activities = []; | ||
14 | - activate(); | ||
15 | - | ||
16 | - function activate() { | ||
17 | - noosfero.currentProfile.then(function(profile) { | ||
18 | - vm.profile = profile; | ||
19 | - return noosfero.profiles.one(vm.profile.id).one('activities').get(); | ||
20 | - }).then(function(response) { | ||
21 | - vm.activities = response.data.activities; | ||
22 | - }); | ||
23 | - } | ||
24 | - } | ||
25 | -})(); |
src/app/profile/profile.component.ts
1 | -import {Component, Inject} from 'ng-forward'; | 1 | +import {StateConfig, Component, Inject} from 'ng-forward'; |
2 | +import {ProfileInfo} from '../profile-info/profile-info.component' | ||
2 | 3 | ||
3 | @Component({ | 4 | @Component({ |
4 | selector: 'profile', | 5 | selector: 'profile', |
5 | templateUrl: "app/profile/profile.html" | 6 | templateUrl: "app/profile/profile.html" |
6 | }) | 7 | }) |
8 | +@StateConfig([ | ||
9 | + { | ||
10 | + url: "^/profile/:profile", | ||
11 | + component: ProfileInfo, | ||
12 | + name: 'main.profile.info', | ||
13 | + views: { | ||
14 | + "mainBlockContent": { | ||
15 | + templateUrl: "app/profile-info/profile-info.html", | ||
16 | + controller: "ProfileInfoController", | ||
17 | + controllerAs: "vm" | ||
18 | + } | ||
19 | + } | ||
20 | + } | ||
21 | +]) | ||
7 | @Inject("noosfero", "$log", "$stateParams") | 22 | @Inject("noosfero", "$log", "$stateParams") |
8 | export class Profile { | 23 | export class Profile { |
9 | 24 |