Commit 09ed74950482b2fcf7c423e8f7560c704a32766c
Exists in
master
and in
4 other branches
Merge branch 'fix-359'
Showing
2 changed files
with
22 additions
and
3 deletions
Show diff stats
index.html
@@ -273,8 +273,8 @@ | @@ -273,8 +273,8 @@ | ||
273 | <form class="make-proposal-form save-article-form require-login hide" id="make-proposal-form-{{id}}" action="{{proposal_action ../article . }}" method="post"> | 273 | <form class="make-proposal-form save-article-form require-login hide" id="make-proposal-form-{{id}}" action="{{proposal_action ../article . }}" method="post"> |
274 | <div class="message hide"></div> | 274 | <div class="message hide"></div> |
275 | <div> | 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 | </div> | 278 | </div> |
279 | <input type="hidden" id="type" name="article[type]" value="ProposalsDiscussionPlugin::Proposal"> | 279 | <input type="hidden" id="type" name="article[type]" value="ProposalsDiscussionPlugin::Proposal"> |
280 | <input type="hidden" id="content_type" name="content_type" value="ProposalsDiscussionPlugin::Proposal"> | 280 | <input type="hidden" id="content_type" name="content_type" value="ProposalsDiscussionPlugin::Proposal"> |
js/main.js
@@ -1292,9 +1292,24 @@ define(['jquery', 'handlebars', 'fastclick', 'proposal_app', 'handlebars_helpers | @@ -1292,9 +1292,24 @@ define(['jquery', 'handlebars', 'fastclick', 'proposal_app', 'handlebars_helpers | ||
1292 | // var proposal_id = this.id.split('-').pop(); | 1292 | // var proposal_id = this.id.split('-').pop(); |
1293 | // var form = this; | 1293 | // var form = this; |
1294 | var $form = $(this); | 1294 | var $form = $(this); |
1295 | + var $description = $form.find('#article_abstract'); | ||
1295 | var $message = $form.find('.message'); | 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 | $message.hide(); | 1305 | $message.hide(); |
1297 | $message.text(''); | 1306 | $message.text(''); |
1307 | + | ||
1308 | + // handle 'loading' | ||
1309 | + var $submitButton = $form.find('.make-proposal-button'); | ||
1310 | + $submitButton.hide(); | ||
1311 | + // $loading.show(); | ||
1312 | + | ||
1298 | $.ajax({ | 1313 | $.ajax({ |
1299 | type: 'post', | 1314 | type: 'post', |
1300 | url: host + $form.attr('action'), | 1315 | url: host + $form.attr('action'), |
@@ -1313,7 +1328,11 @@ define(['jquery', 'handlebars', 'fastclick', 'proposal_app', 'handlebars_helpers | @@ -1313,7 +1328,11 @@ define(['jquery', 'handlebars', 'fastclick', 'proposal_app', 'handlebars_helpers | ||
1313 | console.error( 'Request Failed: ' + err ); | 1328 | console.error( 'Request Failed: ' + err ); |
1314 | $message.show(); | 1329 | $message.show(); |
1315 | $message.text('Não foi possível enviar.'); | 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 | .fail(function( jqxhr, textStatus, error ) { | 1338 | .fail(function( jqxhr, textStatus, error ) { |