Commit d9f417f7af5e45be79ef117c3a223c7d3ed06027

Authored by Leonardo Merlin
1 parent e99e0734

Fix on change option at article-bar

src/app/components/programas/programas.directive.js
... ... @@ -62,7 +62,7 @@
62 62 });
63 63  
64 64 vm.$scope.$watch('vm.categoryFilter', function(newValue, oldValue){
65   - vm.search.tema = newValue ? newValue.slug : '';
  65 + vm.search.tema = newValue ? newValue.slug : null;
66 66 vm.$location.search(vm.search);
67 67 });
68 68  
... ...
src/app/index.route.js
... ... @@ -9,7 +9,7 @@
9 9 function routeConfig($stateProvider, $urlRouterProvider) {
10 10 $stateProvider
11 11 .state('inicio', {
12   - url: '/',
  12 + url: '/?limite&tema',
13 13 views: {
14 14 'header': { templateUrl: 'app/partials/header/header.html' },
15 15 'main': {
... ...
src/app/partials/programas/programa.controller.js
... ... @@ -6,13 +6,15 @@
6 6 .controller('ProgramaController', ProgramaController);
7 7  
8 8 /** @ngInject */
9   - function ProgramaController(ArticleService, $state, $rootScope, $log) {
  9 + function ProgramaController(ArticleService, $state, $location, $scope, $log) {
10 10 $log.debug('ProgramaController');
11 11  
12 12 var vm = this;
13 13  
14 14 vm.ArticleService = ArticleService;
  15 + vm.$scope = $scope;
15 16 vm.$state = $state;
  17 + vm.$location = $location;
16 18 vm.$log = $log;
17 19  
18 20 vm.init();
... ... @@ -25,9 +27,27 @@
25 27 var slug = params.slug;
26 28  
27 29 vm.program = null;
  30 + vm.currentCategory = null;
  31 +
  32 + vm.ArticleService.getHome(function(data){
  33 + vm.categories = data.article.categories;
  34 + }, function (error) {
  35 + vm.$log.error(error);
  36 + });
28 37  
29 38 vm.ArticleService.getArticleBySlug(slug, function(program){
30 39 vm.program = program;
  40 + vm.currentCategory = vm.program.categories[0];
  41 +
  42 + vm.$scope.$watch('programa.currentCategory', function(newValue, oldValue){
  43 + if(newValue !== oldValue){
  44 + vm.$state.go('inicio', {
  45 + tema: newValue.slug
  46 + }, {
  47 + location: true
  48 + });
  49 + }
  50 + });
31 51  
32 52 // load proposals
33 53 // vm.ArticleService.getRandomProposals(program.id).then(function(proposal){
... ...
src/app/partials/programas/programa.html
... ... @@ -17,9 +17,9 @@
17 17 <span class="category-name">{{::programa.program.categories[0].name}}</span>
18 18 </button>
19 19 </div>
20   - <div class="navbar-right">
21   - <select name="selectCategory" id="selectCategory-{{::programa.program.categories[0].id}}" class="article-bar--item form-control">
22   - <option value="">-- Selectione um Tema --</option>
  20 + <div class="navbar-right" ng-if="programa.categories">
  21 + <label for="selectCategory" class="control-label sr-only" title="Selecione uma opção para acessar os programas do tema">Temas:</label>
  22 + <select id="selectCategory" name="selectCategory" class="article-bar--item form-control" ng-model="programa.currentCategory" ng-options="category.name for category in programa.categories track by category.slug">
23 23 </select>
24 24 </div>
25 25 </div>
... ...