From 6b44a355cccf7c9b58f35e63b9e6416df5e65105 Mon Sep 17 00:00:00 2001 From: Leonardo Merlin Date: Wed, 19 Aug 2015 16:38:52 -0300 Subject: [PATCH] Improvements at home, on filter programs --- src/app/components/programas/programas.directive.js | 18 ++++++++++++------ src/app/components/programas/programas.html | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/app/components/programas/programas.directive.js b/src/app/components/programas/programas.directive.js index 0758025..6d20d4b 100644 --- a/src/app/components/programas/programas.directive.js +++ b/src/app/components/programas/programas.directive.js @@ -9,7 +9,7 @@ function programaList() { /** @ngInject */ - function ProgramaListController($scope, $location, $filter, $log) { + function ProgramaListController($scope, $location, $filter, $anchorScroll, $log) { $log.debug('ProgramaListController'); // alias @@ -19,6 +19,7 @@ vm.$scope = $scope; vm.$location = $location; vm.$filter = $filter; + vm.$anchorScroll = $anchorScroll; vm.$log = $log; // initialization @@ -46,11 +47,17 @@ // Add initial values for the filter vm.query = (vm.search && vm.search.filtro) ? vm.search.filtro : null; - vm.limitTo = (vm.search && vm.search.limite) ? parseInt(vm.search.limite, 10) : null; + vm.limitTo = (vm.search && vm.search.limite) ? parseInt(vm.search.limite, 10) : 4; vm.categoryFilter = (vm.search && vm.search.tema) ? vm.getCategoryBySlug(vm.search.tema) : null; vm.orderCriteria = (vm.search && vm.search.ordem) ? { name: vm.search.ordem } : null; vm.reverse = (vm.search && vm.search.reverso) ? true : false; + if(!angular.equals({}, vm.search)){ + vm.$location.hash('lista-de-programas'); + vm.$anchorScroll(); + console.log('scrolled'); + } + // update window location params vm.$scope.$watch('vm.query', function(newValue, oldValue){ vm.search.filtro = newValue ? newValue : null; @@ -59,7 +66,7 @@ }); vm.$scope.$watch('vm.limitTo', function(newValue, oldValue){ - vm.search.limite = newValue ? newValue : null; + vm.search.limite = (newValue && newValue !== 4) ? newValue : null; vm.$location.search('limite', vm.search.limite); vm.filtredProgramList = vm.getFiltredPrograms(); }); @@ -88,7 +95,7 @@ var vm = this; vm.query = null; - vm.limitTo = null; + vm.limitTo = 4; vm.categoryFilter = null; vm.orderCriteria = null; }; @@ -122,8 +129,7 @@ // selected new filter vm.categoryFilter = category; }else{ - // already selected. Unselect. - vm.showAll($event); + vm.categoryFilter = null; } }; diff --git a/src/app/components/programas/programas.html b/src/app/components/programas/programas.html index aeb8497..e4a72f8 100644 --- a/src/app/components/programas/programas.html +++ b/src/app/components/programas/programas.html @@ -1,4 +1,4 @@ -
+
- +
-- libgit2 0.21.2