Commit ee4b4df8001f096f62b09bbadcf5653b6f6c345d

Authored by Leonardo Merlin
1 parent 99e875b2

Fix: force proposal change

Showing 2 changed files with 9 additions and 11 deletions   Show diff stats
index.html
... ... @@ -331,11 +331,11 @@
331 331 <p class="box-subtitle">{{stripTags (trimString abstract 200)}}</p>
332 332 </div>
333 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 336 <div class="row">
337 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 339 </div>
340 340 </div>
341 341 <a href="#/programas/{{parent.id}}/resultados" class="vote-result box-bottom">Resultados</a>
... ...
js/main.js
... ... @@ -67,7 +67,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
67 67  
68 68 return proposalId;
69 69 },
70   - loadRandomProposal: function (topic_id) {
  70 + loadRandomProposal: function (topic_id, force) {
71 71 var private_token = Main.private_token;
72 72 var $noProposals = $('.no-proposals');
73 73 var $loading = $('.loading');
... ... @@ -83,7 +83,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
83 83 var url = host + '/api/v1/articles/' + topic_id + '/children';
84 84 var childId = this.getProposalId();
85 85  
86   - if(childId != 0){
  86 + if(childId != 0 && !force){
87 87 url += '/'+childId;
88 88 }
89 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([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
104 104 $randomProposal.html(supportProposalTemplate(article));
105 105 $body.off('click', '.vote-actions .skip');
106 106 $body.on('click', '.vote-actions .skip', function(e) {
107   - contextMain.loadRandomProposal(topic_id);
108 107 e.preventDefault();
  108 + contextMain.loadRandomProposal(topic_id, true);
109 109 });
110 110 $body.off('click', '.vote-actions .vote-action');
111 111 $body.on('click', '.vote-actions .vote-action', function(e) {
112 112 //Helps to prevent more than one vote per proposal
113 113 var button = $(this);
  114 + e.preventDefault();
114 115  
115 116 if(!logged_in) {
116 117 $(this).closest('.require-login-container').find('.button-send a').click();
117   - e.preventDefault();
118 118 return;
119 119 }
120 120  
121 121 if(ProposalApp.hasProposalbeenVoted(article.id)){
122 122 // console.debug("Proposta " + article.id + " já havia sido votada");
123 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 125 return;
127 126 }
128 127  
... ... @@ -140,9 +139,8 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
140 139 Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Seu voto já foi computado nesta proposta', 800);
141 140 }
142 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 146 $body.off('click', '.vote-result');
... ...