Commit f06fa207eb5ce8ed380eb263c58c7933249e80e5

Authored by Victor Costa
1 parent d773bf49

Migrate to ui-router

@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 "angular-messages": "~1.4.2", 9 "angular-messages": "~1.4.2",
10 "angular-aria": "~1.4.2", 10 "angular-aria": "~1.4.2",
11 "angular-resource": "~1.4.2", 11 "angular-resource": "~1.4.2",
12 - "angular-route": "~1.4.2", 12 + "angular-ui-router": "~0.2.15",
13 "bootstrap-sass": "~3.3.5", 13 "bootstrap-sass": "~3.3.5",
14 "angular-bootstrap": "~0.13.4", 14 "angular-bootstrap": "~0.13.4",
15 "malarkey": "yuanqing/malarkey#~1.3.1", 15 "malarkey": "yuanqing/malarkey#~1.3.1",
src/app/components/noosfero-blocks/main-block/main-block.directive.js
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 .directive('noosferoMainBlock', noosferoMainBlock); 6 .directive('noosferoMainBlock', noosferoMainBlock);
7 7
8 /** @ngInject */ 8 /** @ngInject */
9 - function noosferoMainBlock($log, $routeParams, noosfero) { 9 + function noosferoMainBlock($log, $stateParams, noosfero) {
10 var directive = { 10 var directive = {
11 restrict: 'E', 11 restrict: 'E',
12 templateUrl: 'app/components/noosfero-blocks/main-block/main-block.html', 12 templateUrl: 'app/components/noosfero-blocks/main-block/main-block.html',
@@ -24,8 +24,8 @@ @@ -24,8 +24,8 @@
24 /** @ngInject */ 24 /** @ngInject */
25 function MainBlockController() { 25 function MainBlockController() {
26 var vm = this; 26 var vm = this;
27 - $log.log($routeParams.page);  
28 - noosfero.articles().get({path: $routeParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) { 27 + $log.log($stateParams.page);
  28 + noosfero.articles().get({path: $stateParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) {
29 //FIXME 29 //FIXME
30 vm.article = article.articles[0]; 30 vm.article = article.articles[0];
31 $log.log(vm.article); 31 $log.log(vm.article);
src/app/content-viewer/content-viewer.controller.js
@@ -7,16 +7,16 @@ @@ -7,16 +7,16 @@
7 7
8 8
9 /** @ngInject */ 9 /** @ngInject */
10 - function ContentViewerController($timeout, noosfero, $log, $routeParams) { 10 + function ContentViewerController(noosfero, $log, $stateParams) {
11 var vm = this; 11 var vm = this;
12 vm.article = null; 12 vm.article = null;
13 activate(); 13 activate();
14 14
15 function activate() { 15 function activate() {
16 - $log.log($routeParams.page);  
17 - noosfero.articles().get({path: $routeParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) { 16 + $log.log($stateParams.page);
  17 + noosfero.articles().get({path: $stateParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) {
18 //FIXME 18 //FIXME
19 - vm.article = article.articles[0]; 19 + vm.content = article.articles[0];
20 }); 20 });
21 } 21 }
22 } 22 }
src/app/content-viewer/page.html 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +<div class="container">
  2 +
  3 + <div>
  4 + <acme-navbar></acme-navbar>
  5 + </div>
  6 +
  7 + <div class="row">
  8 + <ng-include ng-repeat="box in vm.owner.boxes | orderBy: vm.boxesOrder" src="'app/views/profile/box.html'"></ng-include>
  9 + </div>
  10 +
  11 +</div>
  12 +
  13 +{{vm.article}}
src/app/index.module.js
@@ -2,6 +2,6 @@ @@ -2,6 +2,6 @@
2 'use strict'; 2 'use strict';
3 3
4 angular 4 angular
5 - .module('angular', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ngRoute', 'ui.bootstrap', 'toastr']); 5 + .module('angular', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ui.router', 'ui.bootstrap', 'toastr']);
6 6
7 })(); 7 })();
src/app/index.route.js
@@ -5,7 +5,18 @@ @@ -5,7 +5,18 @@
5 .module('angular') 5 .module('angular')
6 .config(routeConfig); 6 .config(routeConfig);
7 7
8 - function routeConfig($routeProvider) { 8 + function routeConfig($stateProvider, $urlRouterProvider) {
  9 + $stateProvider
  10 + .state('profile', {
  11 + url: '/:profile',
  12 + templateUrl: 'app/profile/profile.html',
  13 + controller: 'ProfileController',
  14 + controllerAs: 'vm'
  15 + });
  16 +
  17 + $urlRouterProvider.otherwise('/');
  18 +
  19 + /*
9 var profileController = { 20 var profileController = {
10 templateUrl: 'app/profile/profile.html', 21 templateUrl: 'app/profile/profile.html',
11 controller: 'ProfileController', 22 controller: 'ProfileController',
@@ -15,11 +26,20 @@ @@ -15,11 +26,20 @@
15 .when('/profile/:profile', { 26 .when('/profile/:profile', {
16 redirectTo: '/:profile' 27 redirectTo: '/:profile'
17 }) 28 })
18 - .when('/:profile', profileController)  
19 - .when('/:profile/:page*', profileController) 29 + .when('/:profile', {
  30 + templateUrl: 'app/profile/profile.html',
  31 + controller: 'ProfileController',
  32 + controllerAs: 'vm'
  33 + })
  34 + .when('/:profile/:page*', {
  35 + templateUrl: 'app/content-viewer/page.html',
  36 + controller: 'ContentViewerController',
  37 + controllerAs: 'vm'
  38 + })
20 .otherwise({ 39 .otherwise({
21 redirectTo: '/' 40 redirectTo: '/'
22 }); 41 });
  42 + */
23 } 43 }
24 44
25 })(); 45 })();
src/app/profile/profile.controller.js
@@ -7,13 +7,13 @@ @@ -7,13 +7,13 @@
7 7
8 8
9 /** @ngInject */ 9 /** @ngInject */
10 - function ProfileController($timeout, noosfero, $log, $routeParams) { 10 + function ProfileController(noosfero, $log, $stateParams) {
11 var vm = this; 11 var vm = this;
12 vm.boxes = []; 12 vm.boxes = [];
13 activate(); 13 activate();
14 14
15 function activate() { 15 function activate() {
16 - noosfero.communities().get({identifier: $routeParams.profile, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (profile) { 16 + noosfero.communities().get({identifier: $stateParams.profile, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (profile) {
17 $log.log(profile); 17 $log.log(profile);
18 vm.owner = profile.communities[0]; 18 vm.owner = profile.communities[0];
19 }); 19 });
src/index.html
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> 25 <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
26 <![endif]--> 26 <![endif]-->
27 27
28 - <div ng-view></div> 28 + <div ui-view></div>
29 29
30 <!-- build:js(src) scripts/vendor.js --> 30 <!-- build:js(src) scripts/vendor.js -->
31 <!-- bower:js --> 31 <!-- bower:js -->