Commit ee4b4df8001f096f62b09bbadcf5653b6f6c345d
1 parent
99e875b2
Exists in
master
and in
5 other branches
Fix: force proposal change
Showing
2 changed files
with
9 additions
and
11 deletions
Show diff stats
index.html
| @@ -331,11 +331,11 @@ | @@ -331,11 +331,11 @@ | ||
| 331 | <p class="box-subtitle">{{stripTags (trimString abstract 200)}}</p> | 331 | <p class="box-subtitle">{{stripTags (trimString abstract 200)}}</p> |
| 332 | </div> | 332 | </div> |
| 333 | <div class="vote-actions"> | 333 | <div class="vote-actions"> |
| 334 | - <a href="#" class="icon icon-vote vote-action dislike" data-vote-value="-1"><span class="fa fa-times"></span></a> | ||
| 335 | - <a href="#" class="icon icon-vote vote-action like" data-vote-value="1"><span class="fa fa-check"></span></a> | 334 | + <button class="icon icon-vote vote-action dislike" data-vote-value="-1"><span class="fa fa-times"></span></button> |
| 335 | + <button class="icon icon-vote vote-action like" data-vote-value="1"><span class="fa fa-check"></span></button> | ||
| 336 | <div class="row"> | 336 | <div class="row"> |
| 337 | <div class="col-sm-6 col-sm-offset-3"> | 337 | <div class="col-sm-6 col-sm-offset-3"> |
| 338 | - <a href="#" class="skip button box-footer">Pular</a> | 338 | + <button class="skip button button-block box-footer">Pular</button> |
| 339 | </div> | 339 | </div> |
| 340 | </div> | 340 | </div> |
| 341 | <a href="#/programas/{{parent.id}}/resultados" class="vote-result box-bottom">Resultados</a> | 341 | <a href="#/programas/{{parent.id}}/resultados" class="vote-result box-bottom">Resultados</a> |
js/main.js
| @@ -67,7 +67,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun | @@ -67,7 +67,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun | ||
| 67 | 67 | ||
| 68 | return proposalId; | 68 | return proposalId; |
| 69 | }, | 69 | }, |
| 70 | - loadRandomProposal: function (topic_id) { | 70 | + loadRandomProposal: function (topic_id, force) { |
| 71 | var private_token = Main.private_token; | 71 | var private_token = Main.private_token; |
| 72 | var $noProposals = $('.no-proposals'); | 72 | var $noProposals = $('.no-proposals'); |
| 73 | var $loading = $('.loading'); | 73 | var $loading = $('.loading'); |
| @@ -83,7 +83,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun | @@ -83,7 +83,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun | ||
| 83 | var url = host + '/api/v1/articles/' + topic_id + '/children'; | 83 | var url = host + '/api/v1/articles/' + topic_id + '/children'; |
| 84 | var childId = this.getProposalId(); | 84 | var childId = this.getProposalId(); |
| 85 | 85 | ||
| 86 | - if(childId != 0){ | 86 | + if(childId != 0 && !force){ |
| 87 | url += '/'+childId; | 87 | url += '/'+childId; |
| 88 | } | 88 | } |
| 89 | url += '?private_token=' + Main.private_token + '&limit=1&order=random()&_='+new Date().getTime()+'&fields=id,name,slug,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal'; | 89 | url += '?private_token=' + Main.private_token + '&limit=1&order=random()&_='+new Date().getTime()+'&fields=id,name,slug,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal'; |
| @@ -104,25 +104,24 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun | @@ -104,25 +104,24 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun | ||
| 104 | $randomProposal.html(supportProposalTemplate(article)); | 104 | $randomProposal.html(supportProposalTemplate(article)); |
| 105 | $body.off('click', '.vote-actions .skip'); | 105 | $body.off('click', '.vote-actions .skip'); |
| 106 | $body.on('click', '.vote-actions .skip', function(e) { | 106 | $body.on('click', '.vote-actions .skip', function(e) { |
| 107 | - contextMain.loadRandomProposal(topic_id); | ||
| 108 | e.preventDefault(); | 107 | e.preventDefault(); |
| 108 | + contextMain.loadRandomProposal(topic_id, true); | ||
| 109 | }); | 109 | }); |
| 110 | $body.off('click', '.vote-actions .vote-action'); | 110 | $body.off('click', '.vote-actions .vote-action'); |
| 111 | $body.on('click', '.vote-actions .vote-action', function(e) { | 111 | $body.on('click', '.vote-actions .vote-action', function(e) { |
| 112 | //Helps to prevent more than one vote per proposal | 112 | //Helps to prevent more than one vote per proposal |
| 113 | var button = $(this); | 113 | var button = $(this); |
| 114 | + e.preventDefault(); | ||
| 114 | 115 | ||
| 115 | if(!logged_in) { | 116 | if(!logged_in) { |
| 116 | $(this).closest('.require-login-container').find('.button-send a').click(); | 117 | $(this).closest('.require-login-container').find('.button-send a').click(); |
| 117 | - e.preventDefault(); | ||
| 118 | return; | 118 | return; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | if(ProposalApp.hasProposalbeenVoted(article.id)){ | 121 | if(ProposalApp.hasProposalbeenVoted(article.id)){ |
| 122 | // console.debug("Proposta " + article.id + " já havia sido votada"); | 122 | // console.debug("Proposta " + article.id + " já havia sido votada"); |
| 123 | Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Seu voto já foi computado nesta proposta', 800); | 123 | Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Seu voto já foi computado nesta proposta', 800); |
| 124 | - contextMain.loadRandomProposal(topic_id); | ||
| 125 | - e.preventDefault(); | 124 | + contextMain.loadRandomProposal(topic_id, true); |
| 126 | return; | 125 | return; |
| 127 | } | 126 | } |
| 128 | 127 | ||
| @@ -140,9 +139,8 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun | @@ -140,9 +139,8 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun | ||
| 140 | Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Seu voto já foi computado nesta proposta', 800); | 139 | Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Seu voto já foi computado nesta proposta', 800); |
| 141 | } | 140 | } |
| 142 | ProposalApp.addVotedProposal(article.id); | 141 | ProposalApp.addVotedProposal(article.id); |
| 143 | - contextMain.loadRandomProposal(topic_id); | 142 | + contextMain.loadRandomProposal(topic_id, true); |
| 144 | }); | 143 | }); |
| 145 | - e.preventDefault(); | ||
| 146 | }); | 144 | }); |
| 147 | 145 | ||
| 148 | $body.off('click', '.vote-result'); | 146 | $body.off('click', '.vote-result'); |