Commit d773bf496da86b2963b2f08699f573581e82639c

Authored by Victor Costa
1 parent 2651201c

Add main block directive to replate the content viewer

src/app/components/noosfero-blocks/main-block/main-block.directive.js 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .directive('noosferoMainBlock', noosferoMainBlock);
  7 +
  8 + /** @ngInject */
  9 + function noosferoMainBlock($log, $routeParams, noosfero) {
  10 + var directive = {
  11 + restrict: 'E',
  12 + templateUrl: 'app/components/noosfero-blocks/main-block/main-block.html',
  13 + scope: {
  14 + block: '=',
  15 + owner: '='
  16 + },
  17 + controller: MainBlockController,
  18 + controllerAs: 'vm',
  19 + bindToController: true
  20 + };
  21 +
  22 + return directive;
  23 +
  24 + /** @ngInject */
  25 + function MainBlockController() {
  26 + var vm = this;
  27 + $log.log($routeParams.page);
  28 + noosfero.articles().get({path: $routeParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) {
  29 + //FIXME
  30 + vm.article = article.articles[0];
  31 + $log.log(vm.article);
  32 + });
  33 + }
  34 + }
  35 +
  36 +})();
... ...
src/app/components/noosfero-blocks/main-block/main-block.html 0 → 100644
... ... @@ -0,0 +1 @@
  1 +<pre>{{vm.article}}</pre>
... ...
src/app/content-viewer/page.html
... ... @@ -1 +0,0 @@
1   -{{vm.article.title}}
src/app/index.route.js
... ... @@ -6,20 +6,17 @@
6 6 .config(routeConfig);
7 7  
8 8 function routeConfig($routeProvider) {
  9 + var profileController = {
  10 + templateUrl: 'app/profile/profile.html',
  11 + controller: 'ProfileController',
  12 + controllerAs: 'vm'
  13 + };
9 14 $routeProvider
10   - .when('/:profile', {
11   - templateUrl: 'app/profile/profile.html',
12   - controller: 'ProfileController',
13   - controllerAs: 'vm'
14   - })
15   - .when('/:profile/:page*', {
16   - templateUrl: 'app/content-viewer/page.html',
17   - controller: 'ContentViewerController',
18   - controllerAs: 'vm'
19   - })
20 15 .when('/profile/:profile', {
21 16 redirectTo: '/:profile'
22 17 })
  18 + .when('/:profile', profileController)
  19 + .when('/:profile/:page*', profileController)
23 20 .otherwise({
24 21 redirectTo: '/'
25 22 });
... ...