Commit c4a0fd4303def5acca520c53b92456e90b3677b3
1 parent
a1d3ab2e
Exists in
master
and in
2 other branches
Ticket #59: User can list his own proposals
Showing
3 changed files
with
45 additions
and
7 deletions
Show diff stats
builds/confjuvapp-web.zip
No preview for this file type
www/html/_left_sidebar.html
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | <ul class="list" ng-show="loggedIn"> |
| 8 | 8 | <li class="item" ng-click="showProfile()"><i class="icon ion-person"></i> Meu Perfil</li> |
| 9 | 9 | <li class="item" ng-click="editProfile()"><i class="icon ion-person-add"></i> Atualizar Perfil</li> |
| 10 | + <li class="item" ng-click="showMyProposals()"><i class="icon ion-document"></i> Minhas Propostas</li> | |
| 10 | 11 | <li class="item" ng-click="showFollowedProposals()"><i class="icon ion-eye"></i> Propostas Seguidas</li> |
| 11 | 12 | <li class="item" ng-click="reloadProposals()"><i class="icon ion-earth"></i> Todas as Propostas</li> |
| 12 | 13 | <li class="item" ng-click="logout()"><i class="icon ion-log-out"></i> Sair</li> | ... | ... |
www/js/controllers.js
| ... | ... | @@ -498,13 +498,6 @@ angular.module('confjuvapp.controllers', []) |
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | - | |
| 502 | - // Browsing followed proposals only | |
| 503 | - | |
| 504 | - else { | |
| 505 | - $scope.showFollowedProposals(); | |
| 506 | - } | |
| 507 | - | |
| 508 | 501 | } |
| 509 | 502 | }; |
| 510 | 503 | |
| ... | ... | @@ -657,6 +650,7 @@ angular.module('confjuvapp.controllers', []) |
| 657 | 650 | author: { name: $scope.user.name, id: $scope.user.id } |
| 658 | 651 | }; |
| 659 | 652 | $scope.cards.push(proposal); |
| 653 | + $scope.myProposals.push(proposal); | |
| 660 | 654 | $scope.loading = false; |
| 661 | 655 | $scope.data.title = $scope.data.description = $scope.data.topic_id = null; |
| 662 | 656 | document.getElementById('save-proposal').innerHTML = 'Criar'; |
| ... | ... | @@ -1304,4 +1298,47 @@ angular.module('confjuvapp.controllers', []) |
| 1304 | 1298 | }); |
| 1305 | 1299 | }; |
| 1306 | 1300 | |
| 1301 | + /****************************************************************************** | |
| 1302 | + M Y P R O P O S A L S | |
| 1303 | + ******************************************************************************/ | |
| 1304 | + | |
| 1305 | + $scope.myProposals = []; | |
| 1306 | + | |
| 1307 | + $scope.showMyProposals = function() { | |
| 1308 | + if ($scope.myProposals.length == 0) { | |
| 1309 | + $scope.cards = []; | |
| 1310 | + | |
| 1311 | + var config = { | |
| 1312 | + headers: { | |
| 1313 | + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
| 1314 | + }, | |
| 1315 | + timeout: 10000 | |
| 1316 | + }; | |
| 1317 | + | |
| 1318 | + var path = 'articles?private_token=' + $scope.token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by&content_type=ProposalsDiscussionPlugin::Proposal&_=' + (new Date().getTime()) + '&parent_id='; | |
| 1319 | + | |
| 1320 | + for (var i = 0; i < $scope.topics.length; i++) { | |
| 1321 | + $scope.loading = true; | |
| 1322 | + | |
| 1323 | + $http.get(ConfJuvAppUtils.pathTo(path + $scope.topics[i].id), config) | |
| 1324 | + .then(function(resp) { | |
| 1325 | + var articles = resp.data.articles; | |
| 1326 | + for (var j = 0; j < articles.length; j++) { | |
| 1327 | + var article = articles[j]; | |
| 1328 | + if (article.author.id === $scope.user.id) { | |
| 1329 | + $scope.myProposals.push(article); | |
| 1330 | + $scope.cards = $scope.myProposals.slice(); | |
| 1331 | + } | |
| 1332 | + } | |
| 1333 | + $scope.loading = false; | |
| 1334 | + }, function(err) { | |
| 1335 | + $scope.loading = false; | |
| 1336 | + }); | |
| 1337 | + } | |
| 1338 | + } | |
| 1339 | + else { | |
| 1340 | + $scope.cards = $scope.myProposals.slice(); | |
| 1341 | + } | |
| 1342 | + }; | |
| 1343 | + | |
| 1307 | 1344 | }); // Ends controller | ... | ... |