Commit d08f43d8845ac6d56e5cfec935a07ddfaa6b3729
Exists in
master
and in
6 other branches
Merge branch 'merlin' into staging
Showing
21 changed files
with
293 additions
and
130 deletions
Show diff stats
src/app/components/article-service/article.service.js
... | ... | @@ -100,21 +100,17 @@ |
100 | 100 | |
101 | 101 | // var url = service.apiArticles + API.articleId.home; |
102 | 102 | |
103 | - // var paramsExtended = angular.extend({ | |
104 | - // // 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children', 'children_count'], | |
105 | - // 'content_type':'ProposalsDiscussionPlugin::Proposal' | |
106 | - // }, params); | |
107 | - | |
108 | 103 | // UtilService.get(url, {params: paramsExtended}).then(function(data){ |
109 | 104 | // cbSuccess(data); |
110 | 105 | // }).catch(function(error){ |
111 | 106 | // cbError(error); |
112 | 107 | // }); |
113 | 108 | |
114 | - // | |
115 | - searchProposals({ | |
109 | + var paramsExtended = angular.extend({ | |
116 | 110 | query: '' |
117 | - }, cbSuccess, cbError); | |
111 | + }, params); | |
112 | + | |
113 | + searchProposals(paramsExtended, cbSuccess, cbError); | |
118 | 114 | } |
119 | 115 | |
120 | 116 | function getProposalById (proposalId, params, cbSuccess, cbError) { | ... | ... |
src/app/components/category-list/category-list.directive.js
... | ... | @@ -32,6 +32,17 @@ |
32 | 32 | } |
33 | 33 | }; |
34 | 34 | |
35 | + CategoryListController.prototype._disableUnselect = function() { | |
36 | + var vm = this; | |
37 | + | |
38 | + if(vm.disableUnselect && vm.disableUnselect === 'true'){ | |
39 | + return true; | |
40 | + } | |
41 | + | |
42 | + return false; | |
43 | + }; | |
44 | + | |
45 | + | |
35 | 46 | CategoryListController.prototype.selectCategory = function(category, $event) { |
36 | 47 | var vm = this; |
37 | 48 | |
... | ... | @@ -39,9 +50,14 @@ |
39 | 50 | $event.stopPropagation(); |
40 | 51 | |
41 | 52 | if (category !== vm.selectedCategory) { |
42 | - // selected new filter | |
43 | 53 | vm.selectedCategory = category; |
44 | - } else { | |
54 | + }else{ | |
55 | + | |
56 | + if(vm._disableUnselect()){ | |
57 | + vm.$log.info('Unselect is disabled.'); | |
58 | + return; | |
59 | + } | |
60 | + | |
45 | 61 | vm.selectedCategory = null; |
46 | 62 | } |
47 | 63 | |
... | ... | @@ -65,7 +81,8 @@ |
65 | 81 | templateUrl: 'app/components/category-list/category-list.html', |
66 | 82 | scope: { |
67 | 83 | categories: '=', |
68 | - selectedCategory: '=' | |
84 | + selectedCategory: '=', | |
85 | + disableUnselect: '@' | |
69 | 86 | }, |
70 | 87 | controller: CategoryListController, |
71 | 88 | controllerAs: 'vm', | ... | ... |
src/app/components/dialoga-service/dialoga.service.js
... | ... | @@ -19,6 +19,7 @@ |
19 | 19 | extendedService.getThemeBySlug = getThemeBySlug; |
20 | 20 | extendedService.getPrograms = getPrograms; |
21 | 21 | extendedService.getProgramBySlug = getProgramBySlug; |
22 | + extendedService.getProgramsByThemeId = getProgramsByThemeId; | |
22 | 23 | extendedService.getProgramsRandom = getProgramsRandom; |
23 | 24 | extendedService.getEvents = getEvents; // override |
24 | 25 | extendedService.getQuestions = getQuestions; |
... | ... | @@ -89,6 +90,7 @@ |
89 | 90 | },cbError); |
90 | 91 | } |
91 | 92 | } |
93 | + | |
92 | 94 | function getThemeBySlug (slug, cbSuccess, cbError) { |
93 | 95 | if( !!CACHE.themes ){ |
94 | 96 | _getThemeBySlug(CACHE.themes); |
... | ... | @@ -146,6 +148,28 @@ |
146 | 148 | } |
147 | 149 | } |
148 | 150 | |
151 | + function getProgramsByThemeId (themeId, cbSuccess, cbError) { | |
152 | + | |
153 | + if( !CACHE.programs ){ | |
154 | + getPrograms(_getProgramsByThemeId, cbError); | |
155 | + } else { | |
156 | + _getProgramsByThemeId(); | |
157 | + } | |
158 | + | |
159 | + function _getProgramsByThemeId(){ | |
160 | + var result = CACHE.programs.filter(function filterProgramBySlug (program) { | |
161 | + var category = program.categories[0]; | |
162 | + | |
163 | + if(angular.equals(category.id, themeId)) { | |
164 | + return true; | |
165 | + } | |
166 | + return false; | |
167 | + }); | |
168 | + | |
169 | + cbSuccess(result); | |
170 | + } | |
171 | + } | |
172 | + | |
149 | 173 | // Ex.: /api/v1/dialoga_plugin/random_topics/103358 |
150 | 174 | // TODO: get endpoint for production |
151 | 175 | // TODO: put at cache? | ... | ... |
src/app/components/event-list/event-list.directive.js
... | ... | @@ -46,7 +46,7 @@ |
46 | 46 | vm.$log.debug('event_id', event_id); |
47 | 47 | |
48 | 48 | if(!vm.$rootScope.currentUser){ |
49 | - vm.$log.warn('User is not logged in. Redirect to Auth page.'); | |
49 | + vm.$log.info('User is not logged in. Redirect to Auth page.'); | |
50 | 50 | vm.$state.go('entrar',{ |
51 | 51 | redirect_uri: 'state=inicio&task=subscribe&event_id=' + event_id |
52 | 52 | },{ | ... | ... |
src/app/components/topic-list/topic-list.directive.js
src/app/components/topics-select/topics-select.directive.js
0 → 100644
... | ... | @@ -0,0 +1,61 @@ |
1 | +(function() { | |
2 | + 'use strict'; | |
3 | + | |
4 | + angular | |
5 | + .module('dialoga') | |
6 | + .directive('topicsSelect', topicsSelect); | |
7 | + | |
8 | + /** @ngInject */ | |
9 | + function topicsSelect() { | |
10 | + | |
11 | + /** @ngInject */ | |
12 | + function TopicsSelectController($rootScope, $log) { | |
13 | + $log.debug('TopicsSelectController'); | |
14 | + | |
15 | + // alias | |
16 | + var vm = this; | |
17 | + | |
18 | + // dependencies | |
19 | + vm.$rootScope = $rootScope; | |
20 | + vm.$log = $log; | |
21 | + | |
22 | + // initialization | |
23 | + vm.init(); | |
24 | + } | |
25 | + | |
26 | + TopicsSelectController.prototype.init = function() { | |
27 | + var vm = this; | |
28 | + | |
29 | + // vm.topics = null; | |
30 | + // vm.selectedTopic = null; | |
31 | + vm.topicFilter = vm.selectedTopic; | |
32 | + }; | |
33 | + | |
34 | + TopicsSelectController.prototype.selectTopic = function() { | |
35 | + var vm = this; | |
36 | + | |
37 | + if (vm.topicFilter === null) { | |
38 | + vm.$log.debug('Default topic selected.'); | |
39 | + return; | |
40 | + } | |
41 | + | |
42 | + // send event to all controllers | |
43 | + vm.$rootScope.$broadcast('change-selectedTopic', vm.topicFilter); | |
44 | + }; | |
45 | + | |
46 | + var directive = { | |
47 | + restrict: 'E', | |
48 | + templateUrl: 'app/components/topics-select/topics-select.html', | |
49 | + scope: { | |
50 | + topics: '=', | |
51 | + selectedTopic: '=' | |
52 | + }, | |
53 | + controller: TopicsSelectController, | |
54 | + controllerAs: 'vm', | |
55 | + bindToController: true | |
56 | + }; | |
57 | + | |
58 | + return directive; | |
59 | + } | |
60 | + | |
61 | +})(); | ... | ... |
... | ... | @@ -0,0 +1,9 @@ |
1 | +<div class="topics-dropdown"> | |
2 | + <select | |
3 | + ng-model="vm.topicFilter" | |
4 | + ng-change="vm.selectTopic()" | |
5 | + ng-options="topic.title for topic in vm.topics track by topic.slug" | |
6 | + class="form-control"> | |
7 | + <option value="">-- Selecione um programa --</option> | |
8 | + </select> | |
9 | +</div> | ... | ... |
src/app/index.route.js
... | ... | @@ -115,20 +115,6 @@ |
115 | 115 | } |
116 | 116 | } |
117 | 117 | }) |
118 | - .state('propostas-conteudo', { | |
119 | - url: '/propostas/:id', | |
120 | - ncyBreadcrumb: { | |
121 | - label: '{{$parent.$root.contentTitle}}', | |
122 | - parent: 'propostas' | |
123 | - }, | |
124 | - views: { | |
125 | - 'main': { | |
126 | - templateUrl: 'app/pages/propostas/proposta.html', | |
127 | - controller: 'PropostasPageController', | |
128 | - controllerAs: 'pagePropostas' | |
129 | - } | |
130 | - } | |
131 | - }) | |
132 | 118 | .state('duvidas', { |
133 | 119 | url: '/duvidas', |
134 | 120 | ncyBreadcrumb: {label: 'Dúvidas'}, | ... | ... |
src/app/index.run.js
src/app/index.scss
... | ... | @@ -53,6 +53,11 @@ body { |
53 | 53 | color: #fff; |
54 | 54 | padding: 5px; |
55 | 55 | margin-top: -5px; |
56 | + | |
57 | + &.icon-small { | |
58 | + width: 35px; | |
59 | + height: 35px; | |
60 | + } | |
56 | 61 | } |
57 | 62 | button { |
58 | 63 | border-left: none; |
... | ... | @@ -198,7 +203,7 @@ body { |
198 | 203 | background-color: #4AC97A; |
199 | 204 | |
200 | 205 | &:hover { background-color: lighten(#4AC97A, 10%); } |
201 | - | |
206 | + | |
202 | 207 | &:active, |
203 | 208 | &:focus { background-color: darken(#4AC97A, 10%)} |
204 | 209 | } |
... | ... | @@ -206,7 +211,7 @@ body { |
206 | 211 | background-color: #EEB453; |
207 | 212 | |
208 | 213 | &:hover { background-color: lighten(#EEB453, 10%); } |
209 | - | |
214 | + | |
210 | 215 | &:active, |
211 | 216 | &:focus { background-color: darken(#EEB453, 10%)} |
212 | 217 | } |
... | ... | @@ -214,7 +219,7 @@ body { |
214 | 219 | background-color: #EC4C68; |
215 | 220 | |
216 | 221 | &:hover { background-color: lighten(#EC4C68, 10%); } |
217 | - | |
222 | + | |
218 | 223 | &:active, |
219 | 224 | &:focus { background-color: darken(#EC4C68, 10%)} |
220 | 225 | } | ... | ... |
src/app/layout.scss
... | ... | @@ -204,10 +204,6 @@ |
204 | 204 | padding: 30px; |
205 | 205 | } |
206 | 206 | |
207 | -.gray-block { | |
208 | - background-color: #F1F1F1; | |
209 | -} | |
210 | - | |
211 | 207 | .destaque-cinza-claro { |
212 | 208 | background-color: #F8F8F8; |
213 | 209 | padding: 30px; |
... | ... | @@ -221,19 +217,6 @@ |
221 | 217 | } |
222 | 218 | } |
223 | 219 | |
224 | -// .img-responsive-100 { | |
225 | -// width: 100%; | |
226 | -// } | |
227 | - | |
228 | -// .vcenter { | |
229 | -// display: inline-block; | |
230 | -// vertical-align: middle; | |
231 | -// float: none; | |
232 | -// margin-right: -2px; | |
233 | -// margin-left: -2px; | |
234 | -// } | |
235 | - | |
236 | - | |
237 | 220 | ul.list-color { |
238 | 221 | list-style: none; |
239 | 222 | padding: 0; |
... | ... | @@ -268,35 +251,10 @@ ul.list-color li { |
268 | 251 | float: right; |
269 | 252 | } |
270 | 253 | |
271 | -// .margin-bottom { | |
272 | -// margin-bottom: 40px; | |
273 | -// } | |
274 | - | |
275 | -// .no-space-right { | |
276 | -// padding-right: 0px; | |
277 | -// } | |
278 | - | |
279 | -// .no-space-left { | |
280 | -// padding-left: 0px; | |
281 | -// } | |
282 | - | |
283 | 254 | a.link-black { |
284 | 255 | color: black; |
285 | 256 | } |
286 | 257 | |
287 | -.font-white { | |
288 | - color: white; | |
289 | -} | |
290 | - | |
291 | -// .padding-top-50{ | |
292 | -// padding-top: 50px; | |
293 | -// } | |
294 | - | |
295 | -// .padding-bottom-20{ | |
296 | -// padding-bottom: 20px; | |
297 | -// } | |
298 | - | |
299 | - | |
300 | 258 | .inline-block { |
301 | 259 | display: inline-block; |
302 | 260 | } | ... | ... |
src/app/pages/article/article.controller.js
src/app/pages/auth/auth.controller.js
src/app/pages/inicio/inicio.controller.js
src/app/pages/inicio/inicio.scss
... | ... | @@ -25,20 +25,6 @@ |
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | - .input-group-search { | |
29 | - .icon-small { | |
30 | - width: 35px; | |
31 | - height: 35px; | |
32 | - } | |
33 | - .icon-circle { | |
34 | - color: #fff; | |
35 | - padding: 5px; | |
36 | - margin-top: -5px; | |
37 | - } | |
38 | - button { | |
39 | - border-left: none; | |
40 | - } | |
41 | - } | |
42 | 28 | .input-group-btn { |
43 | 29 | background-color: #fff; |
44 | 30 | } | ... | ... |
src/app/pages/programas/programa.controller.js
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | .controller('ProgramaPageController', ProgramaPageController); |
7 | 7 | |
8 | 8 | /** @ngInject */ |
9 | - function ProgramaPageController(DialogaService, PATH, VOTE_OPTIONS, PROPOSAL_STATUS, $state, $location, $scope, $rootScope, $element, $timeout, $log) { | |
9 | + function ProgramaPageController(DialogaService, PATH, VOTE_OPTIONS, PROPOSAL_STATUS, $state, $location, $scope, $rootScope, $element, $timeout, $sce, $log) { | |
10 | 10 | var vm = this; |
11 | 11 | |
12 | 12 | vm.DialogaService = DialogaService; |
... | ... | @@ -19,6 +19,7 @@ |
19 | 19 | vm.$rootScope = $rootScope; |
20 | 20 | vm.$element = $element; |
21 | 21 | vm.$timeout = $timeout; |
22 | + vm.$sce = $sce; | |
22 | 23 | vm.$log = $log; |
23 | 24 | |
24 | 25 | vm.init(); |
... | ... | @@ -76,6 +77,10 @@ |
76 | 77 | }; |
77 | 78 | } |
78 | 79 | |
80 | + if(vm.article.body && !vm.article.bodyTrusted){ | |
81 | + vm.article.bodyTrusted = vm.$sce.trustAsHtml(vm.article.body); | |
82 | + } | |
83 | + | |
79 | 84 | vm.loadingTopProposals = true; |
80 | 85 | vm.DialogaService.getProposalsByTopicId(vm.article.id, {}, function(data) { |
81 | 86 | vm.proposals = data.articles; |
... | ... | @@ -265,10 +270,4 @@ |
265 | 270 | |
266 | 271 | vm.proposalStatus = null; |
267 | 272 | }; |
268 | - | |
269 | - // ProgramaPageController.prototype.sendProposal = function() { | |
270 | - // var vm = this; | |
271 | - | |
272 | - // vm.$log.warn('Not implemented yet: "sendProposal"'); | |
273 | - // }; | |
274 | 273 | })(); | ... | ... |
src/app/pages/programas/programa.html
... | ... | @@ -173,7 +173,7 @@ |
173 | 173 | |
174 | 174 | <section class="section-content"> |
175 | 175 | <article class="program-content" ng-if="pagePrograma.article"> |
176 | - <div ng-bind-html="pagePrograma.article.body"></div> | |
176 | + <div ng-bind-html="pagePrograma.article.bodyTrusted"></div> | |
177 | 177 | </article> |
178 | 178 | </section> |
179 | 179 | </div> | ... | ... |
src/app/pages/programas/programas.controller.js
src/app/pages/propostas/propostas.controller.js
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | |
23 | 23 | vm.init(); |
24 | 24 | vm.loadData(); |
25 | - vm.attachListeners(); | |
25 | + // vm.attachListeners(); // attach listeners after load data (SYNC) | |
26 | 26 | |
27 | 27 | $log.debug('PropostasPageController'); |
28 | 28 | } |
... | ... | @@ -32,6 +32,8 @@ |
32 | 32 | |
33 | 33 | vm.themes = null; |
34 | 34 | vm.selectedTheme = null; |
35 | + vm.filtredPrograms = null; | |
36 | + vm.selectedProgram = null; | |
35 | 37 | vm.proposals = null; |
36 | 38 | vm.filtredProposals = null; |
37 | 39 | vm.query = null; |
... | ... | @@ -46,30 +48,108 @@ |
46 | 48 | |
47 | 49 | vm.loading = true; |
48 | 50 | |
49 | - // load Proposals | |
50 | - vm.loadingProposals = true; | |
51 | - vm.DialogaService.getProposals({}, function(data){ | |
52 | - vm.proposals = data.articles; | |
53 | - vm.filtredProposals = vm.proposals; | |
54 | - vm.loadingProposals = false; | |
51 | + // Behaviour: | |
52 | + // 1. Load themes | |
53 | + // 2. Select a Random Theme (T) | |
54 | + // 3. Load programs of T | |
55 | + // 4. Select a random program of T | |
56 | + // 5. Filter the list of proposals | |
57 | + // END. | |
58 | + | |
59 | + // 1. Load themes | |
60 | + vm.loadingThemes = true; | |
61 | + vm.DialogaService.getThemes(function(themes){ | |
62 | + vm.themes = themes; | |
63 | + vm.loadingThemes = false; | |
55 | 64 | vm.loading = false; |
65 | + | |
66 | + // 2. Select a Random Theme (T) | |
67 | + var selectedTheme = null; | |
68 | + if(vm.search.tema){ | |
69 | + | |
70 | + // vanilla filter | |
71 | + var results = vm.themes.filter(function(t){ | |
72 | + return t.slug === vm.search.tema; | |
73 | + }); | |
74 | + | |
75 | + if(results && results.length > 0){ | |
76 | + selectedTheme = results[0]; | |
77 | + vm.selectedTheme = selectedTheme; | |
78 | + } | |
79 | + } | |
80 | + | |
81 | + if(!selectedTheme){ | |
82 | + vm.selectedTheme = vm.themes[Math.floor(Math.random() * vm.themes.length)]; | |
83 | + } | |
84 | + | |
85 | + // 3. Load programs of T | |
86 | + // (AND 4) | |
87 | + var themeId = vm.selectedTheme.id; | |
88 | + vm.loadPrograms(themeId, function(){ | |
89 | + vm.loadProposals(); | |
90 | + }); | |
56 | 91 | }, function (error) { |
57 | 92 | vm.error = error; |
58 | 93 | vm.$log.error(error); |
59 | - vm.loadingProposals = false; | |
94 | + vm.loadingThemes = false; | |
60 | 95 | vm.loading = false; |
61 | 96 | }); |
97 | + }; | |
62 | 98 | |
63 | - // load themes | |
64 | - vm.loadingThemes = true; | |
65 | - vm.DialogaService.getThemes(function(themes){ | |
66 | - vm.themes = themes; | |
67 | - vm.loadingThemes = false; | |
99 | + PropostasPageController.prototype.loadPrograms = function (themeId, cb) { | |
100 | + var vm = this; | |
101 | + | |
102 | + vm.DialogaService.getProgramsByThemeId(themeId, function (programs){ | |
103 | + vm.$log.debug('programs', programs); | |
104 | + | |
105 | + vm.filtredPrograms = programs; | |
106 | + | |
107 | + // 4. Select a random program of T | |
108 | + var selectedProgram = null; | |
109 | + if(vm.search.programa){ | |
110 | + | |
111 | + // vanilla filter | |
112 | + var results = vm.filtredPrograms.filter(function(p){ | |
113 | + return p.slug === vm.search.programa; | |
114 | + }); | |
115 | + | |
116 | + if(results && results.length > 0){ | |
117 | + selectedProgram = results[0]; | |
118 | + vm.selectedProgram = selectedProgram; | |
119 | + } | |
120 | + } | |
121 | + | |
122 | + if(!selectedProgram){ | |
123 | + vm.selectedProgram = vm.filtredPrograms[Math.floor(Math.random() * vm.filtredPrograms.length)]; | |
124 | + } | |
125 | + | |
126 | + if(cb){ | |
127 | + cb(); | |
128 | + } | |
129 | + }, function(error){ | |
130 | + vm.$log.error(error); | |
131 | + if(cb){ | |
132 | + cb(); | |
133 | + } | |
134 | + }); | |
135 | + }; | |
136 | + | |
137 | + PropostasPageController.prototype.loadProposals = function () { | |
138 | + var vm = this; | |
139 | + | |
140 | + // load Proposals | |
141 | + vm.loadingProposals = true; | |
142 | + vm.DialogaService.getProposals({}, function(data){ | |
143 | + vm.proposals = data.articles; | |
144 | + vm.filtredProposals = vm.proposals; | |
145 | + vm.loadingProposals = false; | |
68 | 146 | vm.loading = false; |
147 | + | |
148 | + vm.attachListeners(); | |
69 | 149 | }, function (error) { |
70 | 150 | vm.error = error; |
71 | 151 | vm.$log.error(error); |
72 | - vm.loadingThemes = false; | |
152 | + vm.loadingProposals = false; | |
73 | 153 | vm.loading = false; |
74 | 154 | }); |
75 | 155 | }; |
... | ... | @@ -81,12 +161,23 @@ |
81 | 161 | vm.selectedTheme = selectedCategory; |
82 | 162 | }); |
83 | 163 | |
84 | - vm.$scope.$watch('pagePropostas.selectedTheme', function(newValue/*, oldValue*/) { | |
164 | + vm.$scope.$watch('pagePropostas.selectedTheme', function(newValue, oldValue) { | |
85 | 165 | vm.search.tema = newValue ? newValue.slug : null; |
86 | 166 | vm.$location.search('tema', vm.search.tema); |
87 | 167 | vm.filtredProposals = vm.getFiltredProposals(); |
88 | 168 | }); |
89 | 169 | |
170 | + vm.$scope.$on('change-selectedTopic', function (event, selectedTopic) { | |
171 | + vm.selectedProgram = selectedTopic; | |
172 | + vm.$log.debug('change-selectedTopic', selectedTopic); | |
173 | + }); | |
174 | + | |
175 | + vm.$scope.$watch('pagePropostas.selectedProgram', function(newValue, oldValue) { | |
176 | + vm.search.programa = newValue ? newValue.slug : null; | |
177 | + vm.$location.search('programa', vm.search.programa); | |
178 | + vm.filtredProposals = vm.getFiltredProposals(); | |
179 | + }); | |
180 | + | |
90 | 181 | vm.$scope.$watch('pagePropostas.query', function(newValue/*, oldValue*/) { |
91 | 182 | vm.search.filtro = newValue ? newValue : null; |
92 | 183 | vm.$location.search('filtro', vm.search.filtro); |
... | ... | @@ -94,22 +185,22 @@ |
94 | 185 | }); |
95 | 186 | }; |
96 | 187 | |
97 | - PropostasPageController.prototype.filter = function() { | |
98 | - var vm = this; | |
188 | + // PropostasPageController.prototype.filter = function() { | |
189 | + // var vm = this; | |
99 | 190 | |
100 | - if (vm.search && vm.search.tema) { | |
101 | - var slug = vm.search.tema; | |
102 | - vm.$log.debug('filter by theme', slug); | |
191 | + // if (vm.search && vm.search.tema) { | |
192 | + // var slug = vm.search.tema; | |
193 | + // vm.$log.debug('filter by theme', slug); | |
103 | 194 | |
104 | - vm.DialogaService.getThemeBySlug(slug, function(theme){ | |
105 | - vm.selectedTheme = theme; | |
106 | - vm.$log.debug('getThemeBySlug.slug', slug); | |
107 | - vm.$log.debug('getThemeBySlug.selectedTheme', theme); | |
108 | - }, function(error){ | |
109 | - vm.$log.error('Error when try to "getThemeBySlug"', error); | |
110 | - }); | |
111 | - } | |
112 | - }; | |
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 | + // }; | |
113 | 204 | |
114 | 205 | PropostasPageController.prototype.showAllPrograms = function($event) { |
115 | 206 | var vm = this; |
... | ... | @@ -133,7 +224,7 @@ |
133 | 224 | var vm = this; |
134 | 225 | |
135 | 226 | if(!vm.proposals){ |
136 | - vm.$log.warn('No proposals loaded yet. Abort.'); | |
227 | + vm.$log.info('No proposals loaded yet. Abort.'); | |
137 | 228 | return null; |
138 | 229 | } |
139 | 230 | |
... | ... | @@ -141,6 +232,7 @@ |
141 | 232 | var output = input; |
142 | 233 | var query = vm.query; |
143 | 234 | var selectedTheme = vm.selectedTheme; |
235 | + var selectedProgram = vm.selectedProgram; | |
144 | 236 | |
145 | 237 | var filter = vm.$filter('filter'); |
146 | 238 | |
... | ... | @@ -148,6 +240,10 @@ |
148 | 240 | output = _filterByCategory(output, selectedTheme); |
149 | 241 | } |
150 | 242 | |
243 | + if (selectedProgram) { | |
244 | + output = _filterByProgram(output, selectedProgram); | |
245 | + } | |
246 | + | |
151 | 247 | if (query) { |
152 | 248 | output = filter(output, query, false); |
153 | 249 | } |
... | ... | @@ -178,4 +274,23 @@ |
178 | 274 | return out; |
179 | 275 | } |
180 | 276 | |
277 | + function _filterByProgram (input, program) { | |
278 | + input = input || []; | |
279 | + | |
280 | + if (!program) { | |
281 | + // no filter | |
282 | + return input; | |
283 | + } | |
284 | + | |
285 | + var out = []; | |
286 | + for (var i = 0; i < input.length; i++) { | |
287 | + var proposal = input[i]; | |
288 | + if (proposal.parent.id === program.id) { | |
289 | + out.push(proposal); | |
290 | + } | |
291 | + } | |
292 | + | |
293 | + return out; | |
294 | + } | |
295 | + | |
181 | 296 | })(); | ... | ... |
src/app/pages/propostas/propostas.scss
src/app/pages/propostas/ranking.html
... | ... | @@ -38,7 +38,10 @@ |
38 | 38 | </div> |
39 | 39 | </div> |
40 | 40 | <div ng-if="pagePropostas.themes"> |
41 | - <category-list categories="pagePropostas.themes" selected-category="pagePropostas.selectedTheme"></category-list> | |
41 | + <category-list categories="pagePropostas.themes" selected-category="pagePropostas.selectedTheme" disable-unselect="true"></category-list> | |
42 | + </div> | |
43 | + <div ng-if="pagePropostas.filtredPrograms" class="topics-select--wrapper"> | |
44 | + <topics-select topics="pagePropostas.filtredPrograms" selected-topic="pagePropostas.selectedProgram"></topics-select> | |
42 | 45 | </div> |
43 | 46 | <div ng-if="!pagePropostas.themes && pagePropostas.loadingThemes"> |
44 | 47 | <div class="alert alert-info" role="alert"> | ... | ... |