Commit ce47251ce7592675effc1914d02126dd2fdf1038
1 parent
e44b5571
Exists in
master
and in
8 other branches
Fix initial filter
Showing
3 changed files
with
39 additions
and
30 deletions
Show diff stats
src/app/components/category-list/category-list.directive.js
src/app/index.route.js
| ... | ... | @@ -75,7 +75,7 @@ |
| 75 | 75 | } |
| 76 | 76 | }) |
| 77 | 77 | .state('programas', { |
| 78 | - url: '/programas', | |
| 78 | + url: '/programas?tema', | |
| 79 | 79 | ncyBreadcrumb: {label: 'Programas'}, |
| 80 | 80 | views: { |
| 81 | 81 | 'header': { templateUrl: 'app/pages/header/header.html' }, |
| ... | ... | @@ -104,7 +104,7 @@ |
| 104 | 104 | } |
| 105 | 105 | }) |
| 106 | 106 | .state('propostas', { |
| 107 | - url: '/propostas', | |
| 107 | + url: '/propostas?tema', | |
| 108 | 108 | ncyBreadcrumb: {label: 'Propostas'}, |
| 109 | 109 | views: { |
| 110 | 110 | 'header': { templateUrl: 'app/pages/header/header.html' }, |
| ... | ... | @@ -117,7 +117,7 @@ |
| 117 | 117 | } |
| 118 | 118 | }) |
| 119 | 119 | .state('ranking', { |
| 120 | - url: '/ranking', | |
| 120 | + url: '/ranking?tema', | |
| 121 | 121 | ncyBreadcrumb: {label: 'Propostas'}, |
| 122 | 122 | views: { |
| 123 | 123 | 'header': { templateUrl: 'app/pages/header/header.html' }, | ... | ... |
src/app/pages/inicio/inicio.controller.js
| ... | ... | @@ -33,6 +33,14 @@ |
| 33 | 33 | vm.query = null; |
| 34 | 34 | vm.search = vm.$location.search(); |
| 35 | 35 | |
| 36 | + if(vm.search && vm.search.tema){ | |
| 37 | + vm._filtredByThemeSlug = vm.search.tema; | |
| 38 | + } | |
| 39 | + | |
| 40 | + if(vm.search && vm.search.filtro){ | |
| 41 | + vm._filtredByQuery = vm.search.filtro; | |
| 42 | + } | |
| 43 | + | |
| 36 | 44 | vm.error = null; |
| 37 | 45 | |
| 38 | 46 | vm.loadData(); |
| ... | ... | @@ -93,25 +101,6 @@ |
| 93 | 101 | |
| 94 | 102 | vm.filter(); |
| 95 | 103 | } |
| 96 | - | |
| 97 | - }; | |
| 98 | - | |
| 99 | - InicioPageController.prototype.showVideo = function() { | |
| 100 | - var vm = this; | |
| 101 | - | |
| 102 | - // we need handle home content | |
| 103 | - if (vm.article.videoIsLoaded) { | |
| 104 | - hideBackground(0); // force to hide | |
| 105 | - vm.$log.debug('The content already cached. Show-it!'); | |
| 106 | - return; | |
| 107 | - } | |
| 108 | - | |
| 109 | - // inject dependencies | |
| 110 | - injectIframeApiJs(); | |
| 111 | - window.onYouTubeIframeAPIReady = window.onYouTubeIframeAPIReady || onYouTubeIframeAPIReady; | |
| 112 | - window.onYouTubePlayerReady = window.onYouTubePlayerReady || onYouTubePlayerReady; | |
| 113 | - | |
| 114 | - vm.article.videoIsLoaded = true; | |
| 115 | 104 | }; |
| 116 | 105 | |
| 117 | 106 | InicioPageController.prototype.attachListeners = function() { |
| ... | ... | @@ -134,21 +123,41 @@ |
| 134 | 123 | }); |
| 135 | 124 | }; |
| 136 | 125 | |
| 126 | + InicioPageController.prototype.showVideo = function() { | |
| 127 | + var vm = this; | |
| 128 | + | |
| 129 | + // we need handle home content | |
| 130 | + if (vm.article.videoIsLoaded) { | |
| 131 | + hideBackground(0); // force to hide | |
| 132 | + vm.$log.debug('The content already cached. Show-it!'); | |
| 133 | + return; | |
| 134 | + } | |
| 135 | + | |
| 136 | + // inject dependencies | |
| 137 | + injectIframeApiJs(); | |
| 138 | + window.onYouTubeIframeAPIReady = window.onYouTubeIframeAPIReady || onYouTubeIframeAPIReady; | |
| 139 | + window.onYouTubePlayerReady = window.onYouTubePlayerReady || onYouTubePlayerReady; | |
| 140 | + | |
| 141 | + vm.article.videoIsLoaded = true; | |
| 142 | + }; | |
| 143 | + | |
| 137 | 144 | InicioPageController.prototype.filter = function() { |
| 138 | 145 | var vm = this; |
| 139 | 146 | |
| 140 | - if (vm.search && vm.search.tema) { | |
| 141 | - var slug = vm.search.tema; | |
| 142 | - vm.$log.debug('filter by theme', slug); | |
| 147 | + // if (vm.search && vm.search.tema) { | |
| 148 | + if (vm._filtredByThemeSlug) { | |
| 149 | + var slug = vm._filtredByThemeSlug; | |
| 143 | 150 | |
| 144 | 151 | vm.DialogaService.getThemeBySlug(slug, function(theme){ |
| 145 | 152 | vm.selectedTheme = theme; |
| 146 | - vm.$log.debug('getThemeBySlug.slug', slug); | |
| 147 | - vm.$log.debug('getThemeBySlug.selectedTheme', theme); | |
| 148 | 153 | }, function(error){ |
| 149 | 154 | vm.$log.error('Error when try to "getThemeBySlug"', error); |
| 150 | 155 | }); |
| 151 | 156 | } |
| 157 | + | |
| 158 | + if (vm._filtredByQuery) { | |
| 159 | + vm.query = vm._filtredByQuery; | |
| 160 | + } | |
| 152 | 161 | }; |
| 153 | 162 | |
| 154 | 163 | InicioPageController.prototype.showAllPrograms = function($event) { |
| ... | ... | @@ -179,9 +188,9 @@ |
| 179 | 188 | var output = input; |
| 180 | 189 | var query = vm.query; |
| 181 | 190 | var selectedTheme = vm.selectedTheme; |
| 182 | - | |
| 191 | + | |
| 183 | 192 | var filter = vm.$filter('filter'); |
| 184 | - | |
| 193 | + | |
| 185 | 194 | if (selectedTheme) { |
| 186 | 195 | output = _filterByCategory(output, selectedTheme); |
| 187 | 196 | } | ... | ... |