From d9f417f7af5e45be79ef117c3a223c7d3ed06027 Mon Sep 17 00:00:00 2001 From: Leonardo Merlin Date: Wed, 19 Aug 2015 10:52:18 -0300 Subject: [PATCH] Fix on change option at article-bar --- src/app/components/programas/programas.directive.js | 2 +- src/app/index.route.js | 2 +- src/app/partials/programas/programa.controller.js | 22 +++++++++++++++++++++- src/app/partials/programas/programa.html | 6 +++--- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/app/components/programas/programas.directive.js b/src/app/components/programas/programas.directive.js index 52690d6..8afb94e 100644 --- a/src/app/components/programas/programas.directive.js +++ b/src/app/components/programas/programas.directive.js @@ -62,7 +62,7 @@ }); vm.$scope.$watch('vm.categoryFilter', function(newValue, oldValue){ - vm.search.tema = newValue ? newValue.slug : ''; + vm.search.tema = newValue ? newValue.slug : null; vm.$location.search(vm.search); }); diff --git a/src/app/index.route.js b/src/app/index.route.js index a625ec2..0d789e7 100644 --- a/src/app/index.route.js +++ b/src/app/index.route.js @@ -9,7 +9,7 @@ function routeConfig($stateProvider, $urlRouterProvider) { $stateProvider .state('inicio', { - url: '/', + url: '/?limite&tema', views: { 'header': { templateUrl: 'app/partials/header/header.html' }, 'main': { diff --git a/src/app/partials/programas/programa.controller.js b/src/app/partials/programas/programa.controller.js index f37ca9e..b19fa03 100644 --- a/src/app/partials/programas/programa.controller.js +++ b/src/app/partials/programas/programa.controller.js @@ -6,13 +6,15 @@ .controller('ProgramaController', ProgramaController); /** @ngInject */ - function ProgramaController(ArticleService, $state, $rootScope, $log) { + function ProgramaController(ArticleService, $state, $location, $scope, $log) { $log.debug('ProgramaController'); var vm = this; vm.ArticleService = ArticleService; + vm.$scope = $scope; vm.$state = $state; + vm.$location = $location; vm.$log = $log; vm.init(); @@ -25,9 +27,27 @@ var slug = params.slug; vm.program = null; + vm.currentCategory = null; + + vm.ArticleService.getHome(function(data){ + vm.categories = data.article.categories; + }, function (error) { + vm.$log.error(error); + }); vm.ArticleService.getArticleBySlug(slug, function(program){ vm.program = program; + vm.currentCategory = vm.program.categories[0]; + + vm.$scope.$watch('programa.currentCategory', function(newValue, oldValue){ + if(newValue !== oldValue){ + vm.$state.go('inicio', { + tema: newValue.slug + }, { + location: true + }); + } + }); // load proposals // vm.ArticleService.getRandomProposals(program.id).then(function(proposal){ diff --git a/src/app/partials/programas/programa.html b/src/app/partials/programas/programa.html index db6e821..0bb8f8b 100644 --- a/src/app/partials/programas/programa.html +++ b/src/app/partials/programas/programa.html @@ -17,9 +17,9 @@ {{::programa.program.categories[0].name}} - -- libgit2 0.21.2