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,7 +9,7 @@ | ||
9 | function programaList() { | 9 | function programaList() { |
10 | 10 | ||
11 | /** @ngInject */ | 11 | /** @ngInject */ |
12 | - function ProgramaListController($scope, $location, $filter, $log) { | 12 | + function ProgramaListController($scope, $location, $filter, $anchorScroll, $log) { |
13 | $log.debug('ProgramaListController'); | 13 | $log.debug('ProgramaListController'); |
14 | 14 | ||
15 | // alias | 15 | // alias |
@@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
19 | vm.$scope = $scope; | 19 | vm.$scope = $scope; |
20 | vm.$location = $location; | 20 | vm.$location = $location; |
21 | vm.$filter = $filter; | 21 | vm.$filter = $filter; |
22 | + vm.$anchorScroll = $anchorScroll; | ||
22 | vm.$log = $log; | 23 | vm.$log = $log; |
23 | 24 | ||
24 | // initialization | 25 | // initialization |
@@ -46,11 +47,17 @@ | @@ -46,11 +47,17 @@ | ||
46 | 47 | ||
47 | // Add initial values for the filter | 48 | // Add initial values for the filter |
48 | vm.query = (vm.search && vm.search.filtro) ? vm.search.filtro : null; | 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 | vm.categoryFilter = (vm.search && vm.search.tema) ? vm.getCategoryBySlug(vm.search.tema) : null; | 51 | vm.categoryFilter = (vm.search && vm.search.tema) ? vm.getCategoryBySlug(vm.search.tema) : null; |
51 | vm.orderCriteria = (vm.search && vm.search.ordem) ? { name: vm.search.ordem } : null; | 52 | vm.orderCriteria = (vm.search && vm.search.ordem) ? { name: vm.search.ordem } : null; |
52 | vm.reverse = (vm.search && vm.search.reverso) ? true : false; | 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 | // update window location params | 61 | // update window location params |
55 | vm.$scope.$watch('vm.query', function(newValue, oldValue){ | 62 | vm.$scope.$watch('vm.query', function(newValue, oldValue){ |
56 | vm.search.filtro = newValue ? newValue : null; | 63 | vm.search.filtro = newValue ? newValue : null; |
@@ -59,7 +66,7 @@ | @@ -59,7 +66,7 @@ | ||
59 | }); | 66 | }); |
60 | 67 | ||
61 | vm.$scope.$watch('vm.limitTo', function(newValue, oldValue){ | 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 | vm.$location.search('limite', vm.search.limite); | 70 | vm.$location.search('limite', vm.search.limite); |
64 | vm.filtredProgramList = vm.getFiltredPrograms(); | 71 | vm.filtredProgramList = vm.getFiltredPrograms(); |
65 | }); | 72 | }); |
@@ -88,7 +95,7 @@ | @@ -88,7 +95,7 @@ | ||
88 | var vm = this; | 95 | var vm = this; |
89 | 96 | ||
90 | vm.query = null; | 97 | vm.query = null; |
91 | - vm.limitTo = null; | 98 | + vm.limitTo = 4; |
92 | vm.categoryFilter = null; | 99 | vm.categoryFilter = null; |
93 | vm.orderCriteria = null; | 100 | vm.orderCriteria = null; |
94 | }; | 101 | }; |
@@ -122,8 +129,7 @@ | @@ -122,8 +129,7 @@ | ||
122 | // selected new filter | 129 | // selected new filter |
123 | vm.categoryFilter = category; | 130 | vm.categoryFilter = category; |
124 | }else{ | 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 | <div class="col-sm-3"> | 2 | <div class="col-sm-3"> |
3 | <div class="category-list"> | 3 | <div class="category-list"> |
4 | <nav class="navigation"> | 4 | <nav class="navigation"> |
@@ -57,7 +57,7 @@ | @@ -57,7 +57,7 @@ | ||
57 | </div> | 57 | </div> |
58 | </aside> | 58 | </aside> |
59 | </div> | 59 | </div> |
60 | - | 60 | + |
61 | <div ng-repeat="program in vm.filtredProgramList as results"> | 61 | <div ng-repeat="program in vm.filtredProgramList as results"> |
62 | <programa-box program="program" display="'box'" class="col-xs-12 col-sm-6"></programa-box> | 62 | <programa-box program="program" display="'box'" class="col-xs-12 col-sm-6"></programa-box> |
63 | <div ng-if="$odd" class="clearfix"></div> | 63 | <div ng-if="$odd" class="clearfix"></div> |