diff --git a/src/app/components/category-list/category-list.directive.js b/src/app/components/category-list/category-list.directive.js index 3634ad8..c35ab8a 100644 --- a/src/app/components/category-list/category-list.directive.js +++ b/src/app/components/category-list/category-list.directive.js @@ -65,7 +65,7 @@ templateUrl: 'app/components/category-list/category-list.html', scope: { categories: '=', - selectedCategory: '@' + selectedCategory: '=' }, controller: CategoryListController, controllerAs: 'vm', diff --git a/src/app/index.route.js b/src/app/index.route.js index 72e72de..d19297c 100644 --- a/src/app/index.route.js +++ b/src/app/index.route.js @@ -75,7 +75,7 @@ } }) .state('programas', { - url: '/programas', + url: '/programas?tema', ncyBreadcrumb: {label: 'Programas'}, views: { 'header': { templateUrl: 'app/pages/header/header.html' }, @@ -104,7 +104,7 @@ } }) .state('propostas', { - url: '/propostas', + url: '/propostas?tema', ncyBreadcrumb: {label: 'Propostas'}, views: { 'header': { templateUrl: 'app/pages/header/header.html' }, @@ -117,7 +117,7 @@ } }) .state('ranking', { - url: '/ranking', + url: '/ranking?tema', ncyBreadcrumb: {label: 'Propostas'}, views: { 'header': { templateUrl: 'app/pages/header/header.html' }, diff --git a/src/app/pages/inicio/inicio.controller.js b/src/app/pages/inicio/inicio.controller.js index afc1cb0..4a9ba6c 100644 --- a/src/app/pages/inicio/inicio.controller.js +++ b/src/app/pages/inicio/inicio.controller.js @@ -33,6 +33,14 @@ vm.query = null; vm.search = vm.$location.search(); + if(vm.search && vm.search.tema){ + vm._filtredByThemeSlug = vm.search.tema; + } + + if(vm.search && vm.search.filtro){ + vm._filtredByQuery = vm.search.filtro; + } + vm.error = null; vm.loadData(); @@ -93,25 +101,6 @@ vm.filter(); } - - }; - - InicioPageController.prototype.showVideo = function() { - var vm = this; - - // we need handle home content - if (vm.article.videoIsLoaded) { - hideBackground(0); // force to hide - vm.$log.debug('The content already cached. Show-it!'); - return; - } - - // inject dependencies - injectIframeApiJs(); - window.onYouTubeIframeAPIReady = window.onYouTubeIframeAPIReady || onYouTubeIframeAPIReady; - window.onYouTubePlayerReady = window.onYouTubePlayerReady || onYouTubePlayerReady; - - vm.article.videoIsLoaded = true; }; InicioPageController.prototype.attachListeners = function() { @@ -134,21 +123,41 @@ }); }; + InicioPageController.prototype.showVideo = function() { + var vm = this; + + // we need handle home content + if (vm.article.videoIsLoaded) { + hideBackground(0); // force to hide + vm.$log.debug('The content already cached. Show-it!'); + return; + } + + // inject dependencies + injectIframeApiJs(); + window.onYouTubeIframeAPIReady = window.onYouTubeIframeAPIReady || onYouTubeIframeAPIReady; + window.onYouTubePlayerReady = window.onYouTubePlayerReady || onYouTubePlayerReady; + + vm.article.videoIsLoaded = true; + }; + InicioPageController.prototype.filter = function() { var vm = this; - if (vm.search && vm.search.tema) { - var slug = vm.search.tema; - vm.$log.debug('filter by theme', slug); + // if (vm.search && vm.search.tema) { + if (vm._filtredByThemeSlug) { + var slug = vm._filtredByThemeSlug; vm.DialogaService.getThemeBySlug(slug, function(theme){ vm.selectedTheme = theme; - vm.$log.debug('getThemeBySlug.slug', slug); - vm.$log.debug('getThemeBySlug.selectedTheme', theme); }, function(error){ vm.$log.error('Error when try to "getThemeBySlug"', error); }); } + + if (vm._filtredByQuery) { + vm.query = vm._filtredByQuery; + } }; InicioPageController.prototype.showAllPrograms = function($event) { @@ -179,9 +188,9 @@ var output = input; var query = vm.query; var selectedTheme = vm.selectedTheme; - + var filter = vm.$filter('filter'); - + if (selectedTheme) { output = _filterByCategory(output, selectedTheme); } -- libgit2 0.21.2