Commit d9f417f7af5e45be79ef117c3a223c7d3ed06027
1 parent
e99e0734
Exists in
master
and in
8 other branches
Fix on change option at article-bar
Showing
4 changed files
with
26 additions
and
6 deletions
Show diff stats
src/app/components/programas/programas.directive.js
| @@ -62,7 +62,7 @@ | @@ -62,7 +62,7 @@ | ||
| 62 | }); | 62 | }); |
| 63 | 63 | ||
| 64 | vm.$scope.$watch('vm.categoryFilter', function(newValue, oldValue){ | 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 | vm.$location.search(vm.search); | 66 | vm.$location.search(vm.search); |
| 67 | }); | 67 | }); |
| 68 | 68 |
src/app/index.route.js
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | function routeConfig($stateProvider, $urlRouterProvider) { | 9 | function routeConfig($stateProvider, $urlRouterProvider) { |
| 10 | $stateProvider | 10 | $stateProvider |
| 11 | .state('inicio', { | 11 | .state('inicio', { |
| 12 | - url: '/', | 12 | + url: '/?limite&tema', |
| 13 | views: { | 13 | views: { |
| 14 | 'header': { templateUrl: 'app/partials/header/header.html' }, | 14 | 'header': { templateUrl: 'app/partials/header/header.html' }, |
| 15 | 'main': { | 15 | 'main': { |
src/app/partials/programas/programa.controller.js
| @@ -6,13 +6,15 @@ | @@ -6,13 +6,15 @@ | ||
| 6 | .controller('ProgramaController', ProgramaController); | 6 | .controller('ProgramaController', ProgramaController); |
| 7 | 7 | ||
| 8 | /** @ngInject */ | 8 | /** @ngInject */ |
| 9 | - function ProgramaController(ArticleService, $state, $rootScope, $log) { | 9 | + function ProgramaController(ArticleService, $state, $location, $scope, $log) { |
| 10 | $log.debug('ProgramaController'); | 10 | $log.debug('ProgramaController'); |
| 11 | 11 | ||
| 12 | var vm = this; | 12 | var vm = this; |
| 13 | 13 | ||
| 14 | vm.ArticleService = ArticleService; | 14 | vm.ArticleService = ArticleService; |
| 15 | + vm.$scope = $scope; | ||
| 15 | vm.$state = $state; | 16 | vm.$state = $state; |
| 17 | + vm.$location = $location; | ||
| 16 | vm.$log = $log; | 18 | vm.$log = $log; |
| 17 | 19 | ||
| 18 | vm.init(); | 20 | vm.init(); |
| @@ -25,9 +27,27 @@ | @@ -25,9 +27,27 @@ | ||
| 25 | var slug = params.slug; | 27 | var slug = params.slug; |
| 26 | 28 | ||
| 27 | vm.program = null; | 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 | vm.ArticleService.getArticleBySlug(slug, function(program){ | 38 | vm.ArticleService.getArticleBySlug(slug, function(program){ |
| 30 | vm.program = program; | 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 | // load proposals | 52 | // load proposals |
| 33 | // vm.ArticleService.getRandomProposals(program.id).then(function(proposal){ | 53 | // vm.ArticleService.getRandomProposals(program.id).then(function(proposal){ |
src/app/partials/programas/programa.html
| @@ -17,9 +17,9 @@ | @@ -17,9 +17,9 @@ | ||
| 17 | <span class="category-name">{{::programa.program.categories[0].name}}</span> | 17 | <span class="category-name">{{::programa.program.categories[0].name}}</span> |
| 18 | </button> | 18 | </button> |
| 19 | </div> | 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 | </select> | 23 | </select> |
| 24 | </div> | 24 | </div> |
| 25 | </div> | 25 | </div> |