Commit 282a6b71ab3fb82b444a90e92fd7c9ee21bc6062
1 parent
f69ffc79
Exists in
master
and in
8 other branches
Fix topic-selector model reference
Showing
4 changed files
with
11 additions
and
30 deletions
Show diff stats
src/app/components/topics-select/topics-select.directive.js
| ... | ... | @@ -24,23 +24,19 @@ |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | TopicsSelectController.prototype.init = function() { |
| 27 | - var vm = this; | |
| 28 | - | |
| 29 | - // vm.topics = null; | |
| 30 | - // vm.selectedTopic = null; | |
| 31 | - vm.topicFilter = vm.selectedTopic; | |
| 27 | + // var vm = this; | |
| 32 | 28 | }; |
| 33 | 29 | |
| 34 | 30 | TopicsSelectController.prototype.selectTopic = function() { |
| 35 | 31 | var vm = this; |
| 36 | 32 | |
| 37 | - if (vm.topicFilter === null) { | |
| 33 | + if (vm.selectedTopic === null) { | |
| 38 | 34 | vm.$log.debug('Default topic selected.'); |
| 39 | 35 | return; |
| 40 | 36 | } |
| 41 | 37 | |
| 42 | 38 | // send event to all controllers |
| 43 | - vm.$rootScope.$broadcast('change-selectedTopic', vm.topicFilter); | |
| 39 | + vm.$rootScope.$broadcast('change-selectedTopic', vm.selectedTopic); | |
| 44 | 40 | }; |
| 45 | 41 | |
| 46 | 42 | var directive = { | ... | ... |
src/app/components/topics-select/topics-select.html
| 1 | 1 | <div class="topics-dropdown"> |
| 2 | 2 | <select |
| 3 | - ng-model="vm.topicFilter" | |
| 3 | + ng-model="vm.selectedTopic" | |
| 4 | 4 | ng-change="vm.selectTopic()" |
| 5 | 5 | ng-options="topic.title for topic in vm.topics track by topic.slug" |
| 6 | 6 | class="form-control"> |
| 7 | - <option value="">-- Selecione um programa --</option> | |
| 8 | 7 | </select> |
| 9 | 8 | </div> | ... | ... |
src/app/pages/propostas/propostas.controller.js
| ... | ... | @@ -100,7 +100,6 @@ |
| 100 | 100 | var vm = this; |
| 101 | 101 | |
| 102 | 102 | vm.DialogaService.getProgramsByThemeId(themeId, function (programs){ |
| 103 | - vm.$log.debug('programs', programs); | |
| 104 | 103 | |
| 105 | 104 | vm.filtredPrograms = programs; |
| 106 | 105 | |
| ... | ... | @@ -164,12 +163,16 @@ |
| 164 | 163 | vm.$scope.$watch('pagePropostas.selectedTheme', function(newValue, oldValue) { |
| 165 | 164 | vm.search.tema = newValue ? newValue.slug : null; |
| 166 | 165 | vm.$location.search('tema', vm.search.tema); |
| 167 | - vm.filtredProposals = vm.getFiltredProposals(); | |
| 166 | + | |
| 167 | + if(vm.selectedTheme && vm.selectedTheme.id){ | |
| 168 | + vm.loadPrograms(vm.selectedTheme.id, function(){ | |
| 169 | + vm.filtredProposals = vm.getFiltredProposals(); | |
| 170 | + }); | |
| 171 | + } | |
| 168 | 172 | }); |
| 169 | 173 | |
| 170 | 174 | vm.$scope.$on('change-selectedTopic', function (event, selectedTopic) { |
| 171 | 175 | vm.selectedProgram = selectedTopic; |
| 172 | - vm.$log.debug('change-selectedTopic', selectedTopic); | |
| 173 | 176 | }); |
| 174 | 177 | |
| 175 | 178 | vm.$scope.$watch('pagePropostas.selectedProgram', function(newValue, oldValue) { |
| ... | ... | @@ -185,23 +188,6 @@ |
| 185 | 188 | }); |
| 186 | 189 | }; |
| 187 | 190 | |
| 188 | - // PropostasPageController.prototype.filter = function() { | |
| 189 | - // var vm = this; | |
| 190 | - | |
| 191 | - // if (vm.search && vm.search.tema) { | |
| 192 | - // var slug = vm.search.tema; | |
| 193 | - // vm.$log.debug('filter by theme', slug); | |
| 194 | - | |
| 195 | - // vm.DialogaService.getThemeBySlug(slug, function(theme){ | |
| 196 | - // vm.selectedTheme = theme; | |
| 197 | - // vm.$log.debug('getThemeBySlug.slug', slug); | |
| 198 | - // vm.$log.debug('getThemeBySlug.selectedTheme', theme); | |
| 199 | - // }, function(error){ | |
| 200 | - // vm.$log.error('Error when try to "getThemeBySlug"', error); | |
| 201 | - // }); | |
| 202 | - // } | |
| 203 | - // }; | |
| 204 | - | |
| 205 | 191 | PropostasPageController.prototype.showAllPrograms = function($event) { |
| 206 | 192 | var vm = this; |
| 207 | 193 | $event.stopPropagation(); | ... | ... |
src/app/pages/propostas/ranking.html
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | <div ng-if="pagePropostas.themes"> |
| 24 | 24 | <category-list categories="pagePropostas.themes" selected-category="pagePropostas.selectedTheme" disable-unselect="true"></category-list> |
| 25 | 25 | </div> |
| 26 | - <div ng-if="pagePropostas.filtredPrograms" class="topics-select--wrapper"> | |
| 26 | + <div ng-if="pagePropostas.filtredPrograms && pagePropostas.selectedProgram" class="topics-select--wrapper"> | |
| 27 | 27 | <topics-select topics="pagePropostas.filtredPrograms" selected-topic="pagePropostas.selectedProgram"></topics-select> |
| 28 | 28 | </div> |
| 29 | 29 | <div ng-if="!pagePropostas.themes && pagePropostas.loadingThemes"> | ... | ... |