Commit 09ed74950482b2fcf7c423e8f7560c704a32766c

Authored by Leonardo Merlin
2 parents 0fce3bef c6c46c29

Merge branch 'fix-359'

Showing 2 changed files with 22 additions and 3 deletions   Show diff stats
index.html
... ... @@ -273,8 +273,8 @@
273 273 <form class="make-proposal-form save-article-form require-login hide" id="make-proposal-form-{{id}}" action="{{proposal_action ../article . }}" method="post">
274 274 <div class="message hide"></div>
275 275 <div>
276   - <div><label for="article_abstract">Descrição</label></div>
277   - <textarea id="article_abstract" class="countdown" name="article[abstract]" placeholder="Descrição" maxlength="200"></textarea>
  276 + <div><label for="article_abstract">Descrição <span title="Campo obrigatório.">(*)</span></label></div>
  277 + <textarea id="article_abstract" class="countdown" name="article[abstract]" placeholder="Escreva sua proposta aqui." maxlength="200" required></textarea>
278 278 </div>
279 279 <input type="hidden" id="type" name="article[type]" value="ProposalsDiscussionPlugin::Proposal">
280 280 <input type="hidden" id="content_type" name="content_type" value="ProposalsDiscussionPlugin::Proposal">
... ...
js/main.js
... ... @@ -1292,9 +1292,24 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers
1292 1292 // var proposal_id = this.id.split('-').pop();
1293 1293 // var form = this;
1294 1294 var $form = $(this);
  1295 + var $description = $form.find('#article_abstract');
1295 1296 var $message = $form.find('.message');
  1297 +
  1298 + // validation
  1299 + if( $description.text().length === 0 ){
  1300 + $message.text('O campo "descrição" é obrigatório.');
  1301 + return false;
  1302 + }
  1303 +
  1304 + // reset messages
1296 1305 $message.hide();
1297 1306 $message.text('');
  1307 +
  1308 + // handle 'loading'
  1309 + var $submitButton = $form.find('.make-proposal-button');
  1310 + $submitButton.hide();
  1311 + // $loading.show();
  1312 +
1298 1313 $.ajax({
1299 1314 type: 'post',
1300 1315 url: host + $form.attr('action'),
... ... @@ -1313,7 +1328,11 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers
1313 1328 console.error( 'Request Failed: ' + err );
1314 1329 $message.show();
1315 1330 $message.text('Não foi possível enviar.');
1316   - });
  1331 + })
  1332 + .always(function(){
  1333 + $submitButton.show();
  1334 + // $loading.hide();
  1335 + });
1317 1336 });
1318 1337 })
1319 1338 .fail(function( jqxhr, textStatus, error ) {
... ...