Commit aa1560ed99dc32547197f94835c53307cd78aeba
1 parent
95fa2242
Exists in
master
and in
8 other branches
Fix 'no-theme' problem
Showing
3 changed files
with
38 additions
and
10 deletions
Show diff stats
src/app/pages/inicio/inicio.controller.js
| ... | ... | @@ -220,7 +220,7 @@ |
| 220 | 220 | var filter = vm.$filter('filter'); |
| 221 | 221 | |
| 222 | 222 | if (selectedTheme) { |
| 223 | - output = _filterByCategory(output, selectedTheme); | |
| 223 | + output = vm._filterByCategory(output, selectedTheme); | |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | if (query) { |
| ... | ... | @@ -234,7 +234,9 @@ |
| 234 | 234 | return output; |
| 235 | 235 | }; |
| 236 | 236 | |
| 237 | - function _filterByCategory (input, category) { | |
| 237 | + InicioPageController.prototype._filterByCategory = function (input, category) { | |
| 238 | + var vm = this; | |
| 239 | + | |
| 238 | 240 | input = input || []; |
| 239 | 241 | |
| 240 | 242 | if (!category) { |
| ... | ... | @@ -245,6 +247,12 @@ |
| 245 | 247 | var out = []; |
| 246 | 248 | for (var i = 0; i < input.length; i++) { |
| 247 | 249 | var program = input[i]; |
| 250 | + | |
| 251 | + if(!program.categories || program.categories.length === 0){ | |
| 252 | + vm.$log.warn('Program without theme (category)', program.slug); | |
| 253 | + continue; | |
| 254 | + } | |
| 255 | + | |
| 248 | 256 | if (program.categories[0].slug === category.slug) { |
| 249 | 257 | out.push(program); |
| 250 | 258 | } | ... | ... |
src/app/pages/programas/programas.controller.js
| ... | ... | @@ -173,7 +173,7 @@ |
| 173 | 173 | var filter = vm.$filter('filter'); |
| 174 | 174 | |
| 175 | 175 | if (selectedTheme) { |
| 176 | - output = _filterByCategory(output, selectedTheme); | |
| 176 | + output = vm._filterByCategory(output, selectedTheme); | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | if (query) { |
| ... | ... | @@ -181,13 +181,15 @@ |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | if(!query && !selectedTheme && vm._showAllFlag){ |
| 184 | - output = _balanceByCategory(output); | |
| 184 | + output = vm._balanceByCategory(output); | |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | return output; |
| 188 | 188 | }; |
| 189 | 189 | |
| 190 | - function _filterByCategory (input, category) { | |
| 190 | + ProgramasPageController.prototype._filterByCategory = function (input, category) { | |
| 191 | + var vm = this; | |
| 192 | + | |
| 191 | 193 | input = input || []; |
| 192 | 194 | |
| 193 | 195 | if (!category) { |
| ... | ... | @@ -198,6 +200,12 @@ |
| 198 | 200 | var out = []; |
| 199 | 201 | for (var i = 0; i < input.length; i++) { |
| 200 | 202 | var program = input[i]; |
| 203 | + | |
| 204 | + if(!program.categories || program.categories.length === 0){ | |
| 205 | + vm.$log.warn('Program without theme (category)', program.slug); | |
| 206 | + continue; | |
| 207 | + } | |
| 208 | + | |
| 201 | 209 | if (program.categories[0].slug === category.slug) { |
| 202 | 210 | out.push(program); |
| 203 | 211 | } |
| ... | ... | @@ -206,13 +214,21 @@ |
| 206 | 214 | return out; |
| 207 | 215 | } |
| 208 | 216 | |
| 209 | - function _balanceByCategory (input) { | |
| 217 | + ProgramasPageController.prototype._balanceByCategory = function (input) { | |
| 218 | + var vm = this; | |
| 219 | + | |
| 210 | 220 | var result = []; |
| 211 | 221 | var resultByCategory = {}; |
| 212 | 222 | |
| 213 | 223 | // divide by categories |
| 214 | 224 | for (var i = 0; i < input.length; i++) { |
| 215 | 225 | var program = input[i]; |
| 226 | + | |
| 227 | + if(!program.categories || program.categories.length === 0){ | |
| 228 | + vm.$log.warn('Program without theme (category)', program.slug); | |
| 229 | + continue; | |
| 230 | + } | |
| 231 | + | |
| 216 | 232 | var categorySlug = program.categories[0].slug; |
| 217 | 233 | |
| 218 | 234 | if (!resultByCategory[categorySlug]) { | ... | ... |
src/app/pages/propostas/propostas.controller.js
| ... | ... | @@ -142,11 +142,11 @@ |
| 142 | 142 | var filter = vm.$filter('filter'); |
| 143 | 143 | |
| 144 | 144 | if (selectedTheme) { |
| 145 | - output = _filterByCategory(output, selectedTheme); | |
| 145 | + output = vm._filterByCategory(output, selectedTheme); | |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | if (selectedProgram) { |
| 149 | - output = _filterByProgram(output, selectedProgram); | |
| 149 | + output = vm._filterByProgram(output, selectedProgram); | |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | if (query) { |
| ... | ... | @@ -160,7 +160,9 @@ |
| 160 | 160 | return output; |
| 161 | 161 | }; |
| 162 | 162 | |
| 163 | - function _filterByCategory (input, category) { | |
| 163 | + PropostasPageController.prototype._filterByCategory = function (input, category) { | |
| 164 | + var vm = this; | |
| 165 | + | |
| 164 | 166 | input = input || []; |
| 165 | 167 | |
| 166 | 168 | if (!category) { |
| ... | ... | @@ -179,7 +181,9 @@ |
| 179 | 181 | return out; |
| 180 | 182 | } |
| 181 | 183 | |
| 182 | - function _filterByProgram (input, program) { | |
| 184 | + PropostasPageController.prototype._filterByProgram = function (input, program) { | |
| 185 | + var vm = this; | |
| 186 | + | |
| 183 | 187 | input = input || []; |
| 184 | 188 | |
| 185 | 189 | if (!program) { | ... | ... |