Commit 3ca1d39601394341bb38ffd215e4a4b113e71bfb
1 parent
505d9b3a
Exists in
master
and in
6 other branches
Handle archived program (DiscussionTopic) - issue #59
Showing
12 changed files
with
115 additions
and
49 deletions
Show diff stats
src/app/components/app-paginator/app-paginator.directive.js
... | ... | @@ -46,11 +46,11 @@ |
46 | 46 | AppPaginatorController.prototype.attachListeners = function() { |
47 | 47 | var vm = this; |
48 | 48 | |
49 | - vm.$scope.$watch('vm.perPage', function(newValue/*, oldValue*/) { | |
49 | + vm.$scope.$watch('vm.perPage', function() { | |
50 | 50 | vm.calcArrayPages(); |
51 | 51 | }); |
52 | 52 | |
53 | - vm.$scope.$watch('vm.total', function(newValue/*, oldValue*/) { | |
53 | + vm.$scope.$watch('vm.total', function() { | |
54 | 54 | vm.calcArrayPages(); |
55 | 55 | }); |
56 | 56 | }; | ... | ... |
src/app/components/article-service/article.service.js
src/app/components/dialoga-service/dialoga.service.js
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | }else{ |
40 | 40 | // load main content |
41 | 41 | ArticleService.getArticleById(API.articleId.home, { |
42 | - 'fields[]': ['id','abstract','body','categories','children','children_count','title','slug','image','url', 'amount_of_children', 'archived'], | |
42 | + 'fields[]': ['id','abstract','body','categories','children','children_count','title','slug','image','url', 'archived'], | |
43 | 43 | 'content_type':'ProposalsDiscussionPlugin::DiscussionTopic' |
44 | 44 | }, function (data){ |
45 | 45 | CACHE.home = data; | ... | ... |
src/app/components/proposal-box/proposal-box.directive.js
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | var vm = this; |
34 | 34 | |
35 | 35 | vm.showVote = vm.showVote || false; |
36 | + vm.archived = vm.archived || false; | |
36 | 37 | vm.focus = vm.focus || false; |
37 | 38 | vm.STATE = null; |
38 | 39 | vm.errorOnSkip = false; |
... | ... | @@ -169,6 +170,11 @@ |
169 | 170 | ProposalBoxController.prototype.vote = function(value) { |
170 | 171 | var vm = this; |
171 | 172 | |
173 | + if(vm.archived === true){ | |
174 | + vm.$log.info('Article archived. Abort.'); | |
175 | + return; | |
176 | + } | |
177 | + | |
172 | 178 | vm._oldVoteValue = value; |
173 | 179 | if (vm.canVote()) { |
174 | 180 | if (vm.doVote) { |
... | ... | @@ -190,6 +196,11 @@ |
190 | 196 | ProposalBoxController.prototype.skip = function() { |
191 | 197 | var vm = this; |
192 | 198 | |
199 | + if(vm.archived === true){ | |
200 | + vm.$log.info('Article archived. Abort.'); | |
201 | + return; | |
202 | + } | |
203 | + | |
193 | 204 | vm.errorOnSkip = false; |
194 | 205 | vm.STATE = vm.VOTE_STATUS.LOADING; |
195 | 206 | vm.doVote({ |
... | ... | @@ -226,15 +237,16 @@ |
226 | 237 | restrict: 'E', |
227 | 238 | templateUrl: 'app/components/proposal-box/proposal-box.html', |
228 | 239 | scope: { |
229 | - proposal: '=', | |
230 | - topic: '=', | |
231 | - category: '=', | |
232 | - showVote: '=', | |
233 | - focus: '@', | |
234 | - doVote: '&' | |
235 | 240 | // @ -> Text binding / one-way binding |
236 | 241 | // = -> Direct model binding / two-way binding |
237 | 242 | // & -> Behaviour binding / Method binding |
243 | + archived: '=', | |
244 | + category: '=', | |
245 | + doVote: '&', | |
246 | + focus: '@', | |
247 | + proposal: '=', | |
248 | + showVote: '=', | |
249 | + topic: '=', | |
238 | 250 | }, |
239 | 251 | controller: ProposalBoxController, |
240 | 252 | controllerAs: 'vm', | ... | ... |
src/app/components/proposal-box/proposal-box.html
... | ... | @@ -145,9 +145,16 @@ |
145 | 145 | <div class="proposal-box--content-inner">{{vm.proposal.abstract}}</div> |
146 | 146 | </div> |
147 | 147 | <div ng-hide="vm.showVote" class="proposal-box--join"> |
148 | - <button class="btn btn-link color-theme-common-fg" ng-click="vm.showContent(vm.topic.slug)"> | |
149 | - Participe | |
150 | - </button> | |
148 | + <button | |
149 | + class="btn btn-link color-theme-common-fg" | |
150 | + ng-if="vm.archived === false" | |
151 | + ng-click="vm.showContent(vm.topic.slug)" | |
152 | + >Participe</button> | |
153 | + <button | |
154 | + class="btn btn-link color-theme-common-fg" | |
155 | + ng-if="vm.archived === true" | |
156 | + ng-click="vm.showContent(vm.topic.slug)" | |
157 | + >Ir para o programa</button> | |
151 | 158 | </div> |
152 | 159 | <div ng-show="vm.showVote" class="proposal-box--actions text-center"> |
153 | 160 | <div class="row"> | ... | ... |
src/app/components/proposal-carousel/proposal-carousel.directive.js
... | ... | @@ -31,6 +31,7 @@ |
31 | 31 | } |
32 | 32 | |
33 | 33 | vm.activeIndex = 0; |
34 | + vm.archived = vm.archived || false; | |
34 | 35 | vm.loading = false; |
35 | 36 | vm.proposalsLength = vm.proposals.length; |
36 | 37 | }; |
... | ... | @@ -80,6 +81,7 @@ |
80 | 81 | restrict: 'E', |
81 | 82 | templateUrl: 'app/components/proposal-carousel/proposal-carousel.html', |
82 | 83 | scope: { |
84 | + archived: '=', | |
83 | 85 | proposals: '=' |
84 | 86 | }, |
85 | 87 | controller: ProposalCarouselController, | ... | ... |
src/app/components/proposal-carousel/proposal-carousel.html
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | <div class="inner">{{::proposal.abstract}}</div> |
21 | 21 | </div> |
22 | 22 | </div> |
23 | - <div class="join" ng-show="vm.activeIndex === $index"> | |
23 | + <div class="join" ng-if="vm.archived === false" ng-show="vm.activeIndex === $index"> | |
24 | 24 | <button type="button" class="btn btn-link btn-rate color-theme-common-fg" ng-click="vm.showContent(proposal)"> |
25 | 25 | Participe |
26 | 26 | <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> | ... | ... |
src/app/components/proposal-grid/proposal-grid.html
1 | 1 | <div class="proposal-grid row"> |
2 | 2 | <div ng-repeat="proposal in vm.proposals as results"> |
3 | - <proposal-box proposal="proposal" topic="proposal.parent" category="proposal.parent.categories[0]" show-vote="false" class="col-xs-12 col-sm-6"></proposal-box> | |
3 | + <proposal-box | |
4 | + archived="proposal.parent.archived" | |
5 | + proposal="proposal" | |
6 | + topic="proposal.parent" | |
7 | + category="proposal.parent.categories[0]" | |
8 | + show-vote="false" | |
9 | + class="col-xs-12 col-sm-6" | |
10 | + ></proposal-box> | |
4 | 11 | <div ng-if="$odd" class="clearfix"></div> |
5 | 12 | </div> |
6 | 13 | <div class="animate-repeat" ng-if="results.length == 0"> | ... | ... |
src/app/components/proposal-list/proposal-list.html
... | ... | @@ -23,9 +23,20 @@ |
23 | 23 | </div> |
24 | 24 | <div class="row row-actions"> |
25 | 25 | <div class="col-sm-8"> |
26 | - <button type="button" class="btn btn-link btn-rate color-theme-common-fg" ng-click="vm.showContent(proposal)"> | |
27 | - Participe | |
28 | - </button> | |
26 | + <div ng-if="proposal.parent.archived === false"> | |
27 | + <button | |
28 | + type="button" | |
29 | + class="btn btn-link btn-rate color-theme-common-fg" | |
30 | + ng-click="vm.showContent(proposal)" | |
31 | + >Participe</button> | |
32 | + </div> | |
33 | + <div ng-if="proposal.parent.archived === true"> | |
34 | + <button | |
35 | + type="button" | |
36 | + class="btn btn-link btn-rate color-theme-common-fg" | |
37 | + ng-click="vm.showContent(proposal)" | |
38 | + >Ir para o programa</button> | |
39 | + </div> | |
29 | 40 | </div> |
30 | 41 | <div class="col-sm-4"> |
31 | 42 | <proposal-stats class="text-right" views="{{::proposal.hits}}" up="{{::proposal.votes_for}}" down="{{::proposal.votes_against}}"></proposal-stats> | ... | ... |
src/app/pages/programas/programa.controller.js
... | ... | @@ -39,6 +39,7 @@ |
39 | 39 | vm.loadingTopProposals = null; |
40 | 40 | vm.loadingProposalBox = null; |
41 | 41 | vm.sendProposalRedirectURI = null; |
42 | + vm.showDetailAboutArchived = false; | |
42 | 43 | // vm.voteProposalRedirectURI = null; |
43 | 44 | vm.search = vm.$location.search(); |
44 | 45 | |
... | ... | @@ -86,7 +87,8 @@ |
86 | 87 | vm.DialogaService.getProposalsByTopicId(vm.article.id, { |
87 | 88 | 'limit': 5 |
88 | 89 | }, function(data) { |
89 | - vm.total_proposals = parseInt(vm.article.amount_of_children); | |
90 | + vm.total_proposals = parseInt(vm.article.children_count); | |
91 | + // vm.total_proposals = parseInt(vm.article.amount_of_children); // DEPRECATED?! | |
90 | 92 | vm.proposals = data.articles; |
91 | 93 | vm.proposalsTopFive = vm.proposals.slice(0, 5); |
92 | 94 | vm.proposalsTopRated = vm.proposals.slice(0, 3); |
... | ... | @@ -202,6 +204,11 @@ |
202 | 204 | ProgramaPageController.prototype.vote = function(proposal_id, value) { |
203 | 205 | var vm = this; |
204 | 206 | |
207 | + if(vm.article.archived === true){ | |
208 | + vm.$log.info('Article archived. Abort.'); | |
209 | + return; | |
210 | + } | |
211 | + | |
205 | 212 | if (value === vm.VOTE_OPTIONS.SKIP) { |
206 | 213 | vm.voteSkip(); |
207 | 214 | return; |
... | ... | @@ -237,6 +244,12 @@ |
237 | 244 | |
238 | 245 | ProgramaPageController.prototype.showProposalForm = function() { |
239 | 246 | var vm = this; |
247 | + | |
248 | + if(vm.article.archived === true){ | |
249 | + vm.$log.info('Article archived. Abort.'); | |
250 | + return; | |
251 | + } | |
252 | + | |
240 | 253 | vm.findAndShow('#section-proposal-form'); |
241 | 254 | }; |
242 | 255 | ... | ... |
src/app/pages/programas/programa.html
... | ... | @@ -57,9 +57,19 @@ |
57 | 57 | <div class="program-preview--make-proposal"> |
58 | 58 | <div class="row"> |
59 | 59 | <div class="col-sm-6"> |
60 | - <div class="button--themed"> | |
60 | + <div class="button--themed" ng-if="!pagePrograma.article.archived"> | |
61 | 61 | <button type="button" class="btn btn-block" ng-click="pagePrograma.showProposalForm()">Faça uma proposta</button> |
62 | 62 | </div> |
63 | + <div ng-if="pagePrograma.article.archived"> | |
64 | + <button type="button" | |
65 | + class="btn btn-block disabled" | |
66 | + title="Este programa já foi analisado. Não está mais habilitado a receber novas propostas." | |
67 | + ng-click="pagePrograma.showDetailAboutArchived = true" | |
68 | + >Faça uma proposta</button> | |
69 | + </div> | |
70 | + </div> | |
71 | + <div class="col-sm-6" ng-show="pagePrograma.showDetailAboutArchived === true"> | |
72 | + <p>(●) Este programa está arquivado.<br>Não pode receber novas propostas.</p> | |
63 | 73 | </div> |
64 | 74 | </div> |
65 | 75 | </div> |
... | ... | @@ -82,12 +92,15 @@ |
82 | 92 | <!-- Top Proposals > Carousel --> |
83 | 93 | <div class="col-xs-12" ng-if="!pagePrograma.loadingTopProposals && pagePrograma.proposalsTopRated && pagePrograma.proposalsTopRated.length > 0"> |
84 | 94 | <h3 class="color-theme-fg">Propostas mais votadas</h3> |
85 | - <proposal-carousel proposals="pagePrograma.proposalsTopRated"></proposal-carousel> | |
95 | + <proposal-carousel | |
96 | + proposals="pagePrograma.proposalsTopRated" | |
97 | + archived="pagePrograma.article.archived" | |
98 | + ></proposal-carousel> | |
86 | 99 | </div> |
87 | 100 | </div> |
88 | 101 | |
89 | 102 | <!-- Proposal Box --> |
90 | - <div> | |
103 | + <div ng-if="!pagePrograma.article.archived"> | |
91 | 104 | <div class="col-xs-12" ng-if="!pagePrograma.loadingProposalBox && pagePrograma.randomProposal" ng-class="{'focused-proposal': !!pagePrograma.search.proposal_id}"> |
92 | 105 | <h3 class="color-theme-fg">Apoie outras propostas</h3> |
93 | 106 | <proposal-box |
... | ... | @@ -97,6 +110,7 @@ |
97 | 110 | show-vote="true" |
98 | 111 | focus="{{pagePrograma.search.proposal_id}}" |
99 | 112 | do-vote="pagePrograma.vote(proposal_id, value)" |
113 | + archived="pagePrograma.article.archived" | |
100 | 114 | ></proposal-box> |
101 | 115 | </div> |
102 | 116 | |
... | ... | @@ -136,7 +150,7 @@ |
136 | 150 | </button> |
137 | 151 | </div> |
138 | 152 | <div class="proposal-extended-section-content"> |
139 | - <proposal-list proposals="pagePrograma.proposalsTopFive"></proposal-list> | |
153 | + <proposal-list proposals="pagePrograma.proposalsTopFive" archived="pagePrograma.article.archived"></proposal-list> | |
140 | 154 | <div class="row text-center"> |
141 | 155 | <div class="col-xs-12"> |
142 | 156 | <a ui-sref="ranking({tema: pagePrograma.category.slug, programa: pagePrograma.article.slug})" class="btn btn-link"> | ... | ... |
src/app/pages/ranking/ranking.controller.js
... | ... | @@ -37,6 +37,18 @@ |
37 | 37 | vm.query = null; |
38 | 38 | vm.search = vm.$location.search(); |
39 | 39 | |
40 | + if (vm.search.tema) { | |
41 | + vm._filtredByThemeSlug = vm.search.tema; | |
42 | + } | |
43 | + | |
44 | + if (vm.search.programa) { | |
45 | + vm._filtredByProgramSlug = vm.search.programa; | |
46 | + } | |
47 | + | |
48 | + if (vm.search.tema || vm.search.programa) { | |
49 | + vm.loadingFilter = true; | |
50 | + } | |
51 | + | |
40 | 52 | vm.loading = null; |
41 | 53 | vm.error = null; |
42 | 54 | }; |
... | ... | @@ -62,11 +74,11 @@ |
62 | 74 | |
63 | 75 | // 2. Select a Random Theme (T) |
64 | 76 | var selectedTheme = null; |
65 | - if(vm.search.tema){ | |
77 | + if(vm.search.tema || vm._filtredByThemeSlug){ | |
66 | 78 | |
67 | 79 | // vanilla filter |
68 | 80 | var results = vm.themes.filter(function(t){ |
69 | - return t.slug === vm.search.tema; | |
81 | + return (t.slug === vm.search.tema || (t.slug === vm._filtredByThemeSlug)); | |
70 | 82 | }); |
71 | 83 | |
72 | 84 | if(results && results.length > 0){ |
... | ... | @@ -85,6 +97,7 @@ |
85 | 97 | vm.loadPrograms(themeId, function(){ |
86 | 98 | // vm.loadProposals(); |
87 | 99 | vm.loading = false; |
100 | + vm.loadingFilter = false; | |
88 | 101 | }); |
89 | 102 | }, function (error) { |
90 | 103 | vm.error = error; |
... | ... | @@ -103,11 +116,11 @@ |
103 | 116 | |
104 | 117 | // 4. Select a random program of T |
105 | 118 | var selectedProgram = null; |
106 | - if(vm.search.programa){ | |
119 | + if(vm.search.programa || vm._filtredByProgramSlug){ | |
107 | 120 | |
108 | 121 | // vanilla filter |
109 | 122 | var results = vm.filtredPrograms.filter(function(p){ |
110 | - return p.slug === vm.search.programa; | |
123 | + return (p.slug === vm.search.programa || (p.slug === vm._filtredByProgramSlug)); | |
111 | 124 | }); |
112 | 125 | |
113 | 126 | if(results && results.length > 0){ |
... | ... | @@ -131,26 +144,6 @@ |
131 | 144 | }); |
132 | 145 | }; |
133 | 146 | |
134 | - // RankingPageController.prototype.loadProposals = function () { | |
135 | - // var vm = this; | |
136 | - | |
137 | - // // load Proposals | |
138 | - // vm.loadingProposals = true; | |
139 | - // vm.DialogaService.getProposals({ | |
140 | - // page: vm.page, | |
141 | - // per_page: vm.per_page | |
142 | - // }, function(data){ | |
143 | - // vm.filtredProposals = data.articles; | |
144 | - // vm.loadingProposals = false; | |
145 | - | |
146 | - // vm.attachListeners(); | |
147 | - // }, function (error) { | |
148 | - // vm.error = error; | |
149 | - // vm.$log.error(error); | |
150 | - // vm.loadingProposals = false; | |
151 | - // }); | |
152 | - // }; | |
153 | - | |
154 | 147 | RankingPageController.prototype.attachListeners = function() { |
155 | 148 | var vm = this; |
156 | 149 | |
... | ... | @@ -162,7 +155,7 @@ |
162 | 155 | vm.search.tema = newValue ? newValue.slug : null; |
163 | 156 | vm.$location.search('tema', vm.search.tema); |
164 | 157 | |
165 | - if(vm.selectedTheme && vm.selectedTheme.id){ | |
158 | + if(!vm.loadingFilter && vm.selectedTheme && vm.selectedTheme.id){ | |
166 | 159 | vm.loadPrograms(vm.selectedTheme.id, function(){ |
167 | 160 | vm.filterProposals(); |
168 | 161 | }); |
... | ... | @@ -176,13 +169,19 @@ |
176 | 169 | vm.$scope.$watch('pageRanking.selectedProgram', function(newValue/*, oldValue*/) { |
177 | 170 | vm.search.programa = newValue ? newValue.slug : null; |
178 | 171 | vm.$location.search('programa', vm.search.programa); |
179 | - vm.filterProposals(); | |
172 | + | |
173 | + if (!vm.loadingFilter) { | |
174 | + vm.filterProposals(); | |
175 | + } | |
180 | 176 | }); |
181 | 177 | |
182 | 178 | vm.$scope.$watch('pageRanking.query', function(newValue/*, oldValue*/) { |
183 | 179 | vm.search.filtro = newValue ? newValue : null; |
184 | 180 | vm.$location.search('filtro', vm.search.filtro); |
185 | - vm.filterProposals(); | |
181 | + | |
182 | + if (!vm.loadingFilter) { | |
183 | + vm.filterProposals(); | |
184 | + } | |
186 | 185 | }); |
187 | 186 | }; |
188 | 187 | ... | ... |