diff --git a/src/app/content-viewer/content-viewer-actions.component.ts b/src/app/content-viewer/content-viewer-actions.component.ts new file mode 100644 index 0000000..a6d07a4 --- /dev/null +++ b/src/app/content-viewer/content-viewer-actions.component.ts @@ -0,0 +1,18 @@ +import {Component, Inject} from "ng-forward"; + +@Component({ + selector: "content-viewer-actions", + templateUrl: "app/content-viewer/navbar-actions.html", +}) +@Inject("noosfero") +export class ContentViewerActions { + + article: any; + profile: any; + + constructor(noosfero) { + noosfero.currentProfile.then((profile) => { + this.profile = profile; + }); + } +} diff --git a/src/app/content-viewer/content-viewer-actions.controller.js b/src/app/content-viewer/content-viewer-actions.controller.js deleted file mode 100644 index 30e8c14..0000000 --- a/src/app/content-viewer/content-viewer-actions.controller.js +++ /dev/null @@ -1,22 +0,0 @@ -(function() { - 'use strict'; - - angular - .module('noosferoApp') - .controller('ContentViewerActionsController', ContentViewerActionsController); - - - /** @ngInject */ - function ContentViewerActionsController(noosfero) { - var vm = this; - vm.article = null; - vm.profile = null; - activate(); - - function activate() { - noosfero.currentProfile.then(function(profile) { - vm.profile = profile; - }); - } - } -})(); diff --git a/src/app/content-viewer/content-viewer.component.ts b/src/app/content-viewer/content-viewer.component.ts index 5a2361a..d34ffa4 100644 --- a/src/app/content-viewer/content-viewer.component.ts +++ b/src/app/content-viewer/content-viewer.component.ts @@ -1,19 +1,16 @@ - import * as noosfero from "../models/interfaces"; import {ArticleDirective, ArticleView} from "../components/noosfero-articles/article/article.directive"; -import {Input, Component, StateConfig} from "ng-forward"; +import {Input, Component, StateConfig, Inject} from "ng-forward"; import {NoosferoArticleBlog} from "./../components/noosfero-articles/blog/blog.component"; @Component({ selector: "content-viewer", templateUrl: "app/content-viewer/page.html", - providers: [ - "noosferoService", "$log", "$stateParams" - ], directives: [NoosferoArticleBlog, ArticleView, ArticleDirective] }) +@Inject("noosfero", "$log", "$stateParams") export class ContentViewer { @Input() diff --git a/src/app/index.route.ts b/src/app/index.route.ts index 7e05600..58b7ba0 100644 --- a/src/app/index.route.ts +++ b/src/app/index.route.ts @@ -5,21 +5,6 @@ export function routeConfig($stateProvider, $urlRouterProvider) { $stateProvider .state("main.profile.settings", { url: "^/myprofile/:profile" - }) - .state("main.profile.page", { - url: "/{page:any}", - views: { - "mainBlockContent": { - templateUrl: "app/content-viewer/page.html", - controller: "ContentViewerController", - controllerAs: "vm" - }, - "actions@main": { - templateUrl: "app/content-viewer/navbar-actions.html", - controller: "ContentViewerActionsController", - controllerAs: "vm" - } - } }); $urlRouterProvider.otherwise("/"); diff --git a/src/app/index.ts b/src/app/index.ts index 70d9015..59147e5 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -7,6 +7,7 @@ import {noosferoAngularRunBlock} from "./index.run"; import {routeConfig} from "./index.route"; import {ContentViewer as noosferoContentViewer} from "./content-viewer/content-viewer.component"; +import {ContentViewerActions as noosferoContentViewerActions} from "./content-viewer/content-viewer-actions.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"; @@ -52,9 +53,9 @@ require("./components/noosfero-boxes/boxes.component.js"); 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"); NoosferoApp.addController("ContentViewerController", noosferoContentViewer); +NoosferoApp.addController("ContentViewerActionsController", noosferoContentViewerActions); NoosferoApp.addController("ProfileController", noosferoProfile); NoosferoApp.addController("ProfileHomeController", noosferoProfileHome); NoosferoApp.addController("ProfileInfoController", noosferoProfileInfo); diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index c50a6eb..c9ae887 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -2,6 +2,7 @@ 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' +import {ContentViewer} from "../content-viewer/content-viewer.component"; @Component({ selector: 'profile', @@ -43,6 +44,23 @@ import {Cms} from '../cms/cms.component' } } }, + { + name: 'main.profile.page', + url: "/{page:any}", + component: ContentViewer, + views: { + "mainBlockContent": { + templateUrl: "app/content-viewer/page.html", + controller: "ContentViewerController", + controllerAs: "vm" + }, + "actions@main": { + templateUrl: "app/content-viewer/navbar-actions.html", + controller: "ContentViewerActionsController", + controllerAs: "vm" + } + } + } ]) @Inject("noosfero", "$log", "$stateParams") export class Profile { -- libgit2 0.21.2