Commit ce65011c2fa97545cb5d0d1f12b33e2ac767ef08
1 parent
717b5446
Exists in
master
and in
2 other branches
Tickets #9 and #10: avoid double comment submission and clear form after comment…
…, tag or proposal is submitted
Showing
2 changed files
with
9 additions
and
6 deletions
Show diff stats
ConfJuvApp/www/html/_create_comment.html
1 | 1 | <div class="modal" id="create-comment"> |
2 | 2 | <ion-content> |
3 | - <form ng-submit="createComment(data)"> | |
3 | + <form ng-submit="createComment(data)" onsubmit="createcomment.disabled = true"> | |
4 | 4 | <h1 class="title"> |
5 | 5 | <span>Comentar</span> |
6 | 6 | <a class="back icon-left ion-reply" ng-click="closeCommentModal()">Voltar</a> |
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | <label class="item item-input"><textarea placeholder="Comentário" ng-model="data.comment" rows="15"></textarea></label> |
10 | 10 | |
11 | 11 | <p class="text-center"> |
12 | - <button ripple class="button" type="submit">Enviar</button> | |
12 | + <button ripple class="button" type="submit" name="createcomment" id="createcomment">Enviar</button> | |
13 | 13 | </p> |
14 | 14 | </form> |
15 | 15 | </ion-content> | ... | ... |
ConfJuvApp/www/js/controllers.js
... | ... | @@ -517,8 +517,8 @@ angular.module('confjuvapp.controllers', []) |
517 | 517 | $scope.proposalList.push(proposal); |
518 | 518 | $scope.cards.push(proposal); |
519 | 519 | $scope.proposalsByTopic[data.topic_id].push(proposal); |
520 | - data.title = data.description = data.topic_id = null; | |
521 | 520 | $scope.loading = false; |
521 | + $scope.data.title = $scope.data.description = $scope.data.topic_id = null; | |
522 | 522 | }); |
523 | 523 | }, function(err) { |
524 | 524 | $scope.closeProposalModal(); |
... | ... | @@ -543,7 +543,7 @@ angular.module('confjuvapp.controllers', []) |
543 | 543 | } |
544 | 544 | else { |
545 | 545 | // Initiate the modal |
546 | - $ionicModal.fromTemplateUrl('html/_create_comment.html?1', { | |
546 | + $ionicModal.fromTemplateUrl('html/_create_comment.html?4', { | |
547 | 547 | scope: $scope, |
548 | 548 | animation: 'slide-in-up' |
549 | 549 | }).then(function(modal) { |
... | ... | @@ -555,6 +555,7 @@ angular.module('confjuvapp.controllers', []) |
555 | 555 | |
556 | 556 | // Function to close the modal |
557 | 557 | $scope.closeCommentModal = function() { |
558 | + document.getElementById('createcomment').disabled = false; | |
558 | 559 | $scope.commentModal.hide(); |
559 | 560 | $scope.openProposal($scope.proposal); |
560 | 561 | }; |
... | ... | @@ -600,6 +601,7 @@ angular.module('confjuvapp.controllers', []) |
600 | 601 | .then(function(resp) { |
601 | 602 | $scope.closeCommentModal(); |
602 | 603 | var popup = $ionicPopup.alert({ title: 'Comentar', template: 'Comentário criado com sucesso!' }); |
604 | + $scope.data.comment = ''; | |
603 | 605 | if (!$scope.proposal.comments) { |
604 | 606 | $scope.proposal.comments = []; |
605 | 607 | } |
... | ... | @@ -764,14 +766,15 @@ angular.module('confjuvapp.controllers', []) |
764 | 766 | $http.post(ConfJuvAppUtils.pathTo('articles/' + $scope.proposal.id + '/tags'), jQuery.param(params), config) |
765 | 767 | .then(function(resp) { |
766 | 768 | $scope.closeTagModal(); |
767 | - var popup = $ionicPopup.alert({ title: 'Tag', template: 'Tag adicionada com sucesso!' }); | |
769 | + var popup = $ionicPopup.alert({ title: 'Tags', template: 'Tags adicionadas com sucesso!' }); | |
768 | 770 | $scope.proposal.tag_list = data.tag.split(','); |
771 | + $scope.data.tag = ''; | |
769 | 772 | popup.then(function() { |
770 | 773 | $scope.loading = false; |
771 | 774 | }); |
772 | 775 | }, function(err) { |
773 | 776 | $scope.closeTagModal(); |
774 | - var popup = $ionicPopup.alert({ title: 'Tag', template: 'Erro ao adicionar tag!' }); | |
777 | + var popup = $ionicPopup.alert({ title: 'Tags', template: 'Erro ao adicionar tags!' }); | |
775 | 778 | popup.then(function() { |
776 | 779 | $scope.loading = false; |
777 | 780 | $scope.openTagForm(); | ... | ... |