Commit ce47251ce7592675effc1914d02126dd2fdf1038

Authored by Leonardo Merlin
1 parent e44b5571

Fix initial filter

src/app/components/category-list/category-list.directive.js
@@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@
65 templateUrl: 'app/components/category-list/category-list.html', 65 templateUrl: 'app/components/category-list/category-list.html',
66 scope: { 66 scope: {
67 categories: '=', 67 categories: '=',
68 - selectedCategory: '@' 68 + selectedCategory: '='
69 }, 69 },
70 controller: CategoryListController, 70 controller: CategoryListController,
71 controllerAs: 'vm', 71 controllerAs: 'vm',
src/app/index.route.js
@@ -75,7 +75,7 @@ @@ -75,7 +75,7 @@
75 } 75 }
76 }) 76 })
77 .state('programas', { 77 .state('programas', {
78 - url: '/programas', 78 + url: '/programas?tema',
79 ncyBreadcrumb: {label: 'Programas'}, 79 ncyBreadcrumb: {label: 'Programas'},
80 views: { 80 views: {
81 'header': { templateUrl: 'app/pages/header/header.html' }, 81 'header': { templateUrl: 'app/pages/header/header.html' },
@@ -104,7 +104,7 @@ @@ -104,7 +104,7 @@
104 } 104 }
105 }) 105 })
106 .state('propostas', { 106 .state('propostas', {
107 - url: '/propostas', 107 + url: '/propostas?tema',
108 ncyBreadcrumb: {label: 'Propostas'}, 108 ncyBreadcrumb: {label: 'Propostas'},
109 views: { 109 views: {
110 'header': { templateUrl: 'app/pages/header/header.html' }, 110 'header': { templateUrl: 'app/pages/header/header.html' },
@@ -117,7 +117,7 @@ @@ -117,7 +117,7 @@
117 } 117 }
118 }) 118 })
119 .state('ranking', { 119 .state('ranking', {
120 - url: '/ranking', 120 + url: '/ranking?tema',
121 ncyBreadcrumb: {label: 'Propostas'}, 121 ncyBreadcrumb: {label: 'Propostas'},
122 views: { 122 views: {
123 'header': { templateUrl: 'app/pages/header/header.html' }, 123 'header': { templateUrl: 'app/pages/header/header.html' },
src/app/pages/inicio/inicio.controller.js
@@ -33,6 +33,14 @@ @@ -33,6 +33,14 @@
33 vm.query = null; 33 vm.query = null;
34 vm.search = vm.$location.search(); 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 vm.error = null; 44 vm.error = null;
37 45
38 vm.loadData(); 46 vm.loadData();
@@ -93,25 +101,6 @@ @@ -93,25 +101,6 @@
93 101
94 vm.filter(); 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 InicioPageController.prototype.attachListeners = function() { 106 InicioPageController.prototype.attachListeners = function() {
@@ -134,21 +123,41 @@ @@ -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 InicioPageController.prototype.filter = function() { 144 InicioPageController.prototype.filter = function() {
138 var vm = this; 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 vm.DialogaService.getThemeBySlug(slug, function(theme){ 151 vm.DialogaService.getThemeBySlug(slug, function(theme){
145 vm.selectedTheme = theme; 152 vm.selectedTheme = theme;
146 - vm.$log.debug('getThemeBySlug.slug', slug);  
147 - vm.$log.debug('getThemeBySlug.selectedTheme', theme);  
148 }, function(error){ 153 }, function(error){
149 vm.$log.error('Error when try to "getThemeBySlug"', error); 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 InicioPageController.prototype.showAllPrograms = function($event) { 163 InicioPageController.prototype.showAllPrograms = function($event) {
@@ -179,9 +188,9 @@ @@ -179,9 +188,9 @@
179 var output = input; 188 var output = input;
180 var query = vm.query; 189 var query = vm.query;
181 var selectedTheme = vm.selectedTheme; 190 var selectedTheme = vm.selectedTheme;
182 - 191 +
183 var filter = vm.$filter('filter'); 192 var filter = vm.$filter('filter');
184 - 193 +
185 if (selectedTheme) { 194 if (selectedTheme) {
186 output = _filterByCategory(output, selectedTheme); 195 output = _filterByCategory(output, selectedTheme);
187 } 196 }