Commit 6b44a355cccf7c9b58f35e63b9e6416df5e65105
1 parent
adbfb276
Exists in
master
and in
8 other branches
Improvements at home, on filter programs
Showing
2 changed files
with
14 additions
and
8 deletions
Show diff stats
src/app/components/programas/programas.directive.js
| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | function programaList() { |
| 10 | 10 | |
| 11 | 11 | /** @ngInject */ |
| 12 | - function ProgramaListController($scope, $location, $filter, $log) { | |
| 12 | + function ProgramaListController($scope, $location, $filter, $anchorScroll, $log) { | |
| 13 | 13 | $log.debug('ProgramaListController'); |
| 14 | 14 | |
| 15 | 15 | // alias |
| ... | ... | @@ -19,6 +19,7 @@ |
| 19 | 19 | vm.$scope = $scope; |
| 20 | 20 | vm.$location = $location; |
| 21 | 21 | vm.$filter = $filter; |
| 22 | + vm.$anchorScroll = $anchorScroll; | |
| 22 | 23 | vm.$log = $log; |
| 23 | 24 | |
| 24 | 25 | // initialization |
| ... | ... | @@ -46,11 +47,17 @@ |
| 46 | 47 | |
| 47 | 48 | // Add initial values for the filter |
| 48 | 49 | vm.query = (vm.search && vm.search.filtro) ? vm.search.filtro : null; |
| 49 | - vm.limitTo = (vm.search && vm.search.limite) ? parseInt(vm.search.limite, 10) : null; | |
| 50 | + vm.limitTo = (vm.search && vm.search.limite) ? parseInt(vm.search.limite, 10) : 4; | |
| 50 | 51 | vm.categoryFilter = (vm.search && vm.search.tema) ? vm.getCategoryBySlug(vm.search.tema) : null; |
| 51 | 52 | vm.orderCriteria = (vm.search && vm.search.ordem) ? { name: vm.search.ordem } : null; |
| 52 | 53 | vm.reverse = (vm.search && vm.search.reverso) ? true : false; |
| 53 | 54 | |
| 55 | + if(!angular.equals({}, vm.search)){ | |
| 56 | + vm.$location.hash('lista-de-programas'); | |
| 57 | + vm.$anchorScroll(); | |
| 58 | + console.log('scrolled'); | |
| 59 | + } | |
| 60 | + | |
| 54 | 61 | // update window location params |
| 55 | 62 | vm.$scope.$watch('vm.query', function(newValue, oldValue){ |
| 56 | 63 | vm.search.filtro = newValue ? newValue : null; |
| ... | ... | @@ -59,7 +66,7 @@ |
| 59 | 66 | }); |
| 60 | 67 | |
| 61 | 68 | vm.$scope.$watch('vm.limitTo', function(newValue, oldValue){ |
| 62 | - vm.search.limite = newValue ? newValue : null; | |
| 69 | + vm.search.limite = (newValue && newValue !== 4) ? newValue : null; | |
| 63 | 70 | vm.$location.search('limite', vm.search.limite); |
| 64 | 71 | vm.filtredProgramList = vm.getFiltredPrograms(); |
| 65 | 72 | }); |
| ... | ... | @@ -88,7 +95,7 @@ |
| 88 | 95 | var vm = this; |
| 89 | 96 | |
| 90 | 97 | vm.query = null; |
| 91 | - vm.limitTo = null; | |
| 98 | + vm.limitTo = 4; | |
| 92 | 99 | vm.categoryFilter = null; |
| 93 | 100 | vm.orderCriteria = null; |
| 94 | 101 | }; |
| ... | ... | @@ -122,8 +129,7 @@ |
| 122 | 129 | // selected new filter |
| 123 | 130 | vm.categoryFilter = category; |
| 124 | 131 | }else{ |
| 125 | - // already selected. Unselect. | |
| 126 | - vm.showAll($event); | |
| 132 | + vm.categoryFilter = null; | |
| 127 | 133 | } |
| 128 | 134 | }; |
| 129 | 135 | ... | ... |
src/app/components/programas/programas.html
| 1 | -<div class="row"> | |
| 1 | +<div id="lista-de-programas" class="row"> | |
| 2 | 2 | <div class="col-sm-3"> |
| 3 | 3 | <div class="category-list"> |
| 4 | 4 | <nav class="navigation"> |
| ... | ... | @@ -57,7 +57,7 @@ |
| 57 | 57 | </div> |
| 58 | 58 | </aside> |
| 59 | 59 | </div> |
| 60 | - | |
| 60 | + | |
| 61 | 61 | <div ng-repeat="program in vm.filtredProgramList as results"> |
| 62 | 62 | <programa-box program="program" display="'box'" class="col-xs-12 col-sm-6"></programa-box> |
| 63 | 63 | <div ng-if="$odd" class="clearfix"></div> | ... | ... |