Commit 2410ea5a386329351a51f407ef1b2fddb9c0668d
1 parent
d2243aa0
Exists in
master
and in
2 other branches
display voted proposals list
Showing
2 changed files
with
19 additions
and
21 deletions
Show diff stats
www/html/_left_sidebar.html
@@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
9 | <li class="item" ng-click="editProfile()"><i class="icon ion-person-add"></i> Atualizar Perfil</li> | 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 | <li class="item" ng-click="showMyProposals()"><i class="icon ion-document"></i> Minhas Propostas</li> |
11 | <li class="item" ng-click="showFollowedProposals()"><i class="icon ion-eye"></i> Propostas Seguidas</li> | 11 | <li class="item" ng-click="showFollowedProposals()"><i class="icon ion-eye"></i> Propostas Seguidas</li> |
12 | + <li class="item" ng-click="showVotedProposals()"><i class="icon ion-thumbsup"></i> Propostas Apoiadas</li> | ||
12 | <li class="item" ng-click="reloadProposals()"><i class="icon ion-earth"></i> Todas as Propostas</li> | 13 | <li class="item" ng-click="reloadProposals()"><i class="icon ion-earth"></i> Todas as Propostas</li> |
13 | <li class="item" ng-click="logout()"><i class="icon ion-log-out"></i> Sair</li> | 14 | <li class="item" ng-click="logout()"><i class="icon ion-log-out"></i> Sair</li> |
14 | </ul> | 15 | </ul> |
www/js/controllers.js
@@ -151,6 +151,7 @@ angular.module('confjuvapp.controllers', []) | @@ -151,6 +151,7 @@ angular.module('confjuvapp.controllers', []) | ||
151 | $scope.loadStages(); | 151 | $scope.loadStages(); |
152 | $scope.parseURLParams(); | 152 | $scope.parseURLParams(); |
153 | $scope.loadFollowedProposals(); | 153 | $scope.loadFollowedProposals(); |
154 | + $scope.loadVotedProposals(); | ||
154 | }; | 155 | }; |
155 | 156 | ||
156 | // Function to retrieve password | 157 | // Function to retrieve password |
@@ -1171,15 +1172,12 @@ angular.module('confjuvapp.controllers', []) | @@ -1171,15 +1172,12 @@ angular.module('confjuvapp.controllers', []) | ||
1171 | V O T E P R O P O S A L | 1172 | V O T E P R O P O S A L |
1172 | ******************************************************************************/ | 1173 | ******************************************************************************/ |
1173 | 1174 | ||
1174 | -//FIXME Adapt this method for votes | ||
1175 | $scope.showVotedProposals = function() { | 1175 | $scope.showVotedProposals = function() { |
1176 | -// $scope.cardsBackup = []; | ||
1177 | -// $scope.showBackupProposalsLink = false; | ||
1178 | -//FIXME put this to works | ||
1179 | -// $scope.cards = $scope.following.slice(); | 1176 | + $scope.cardsBackup = []; |
1177 | + $scope.showBackupProposalsLink = false; | ||
1178 | + $scope.cards = $scope.voted.slice(); | ||
1180 | } | 1179 | } |
1181 | 1180 | ||
1182 | -//FIXME Adapt this method for votes | ||
1183 | $scope.loadVotedProposals = function() { | 1181 | $scope.loadVotedProposals = function() { |
1184 | $scope.loading = true; | 1182 | $scope.loading = true; |
1185 | var config = { | 1183 | var config = { |
@@ -1189,31 +1187,30 @@ angular.module('confjuvapp.controllers', []) | @@ -1189,31 +1187,30 @@ angular.module('confjuvapp.controllers', []) | ||
1189 | timeout: 10000 | 1187 | timeout: 10000 |
1190 | }; | 1188 | }; |
1191 | 1189 | ||
1192 | - $http.get(ConfJuvAppUtils.pathTo('/articles/followed_by_me?fields=title,image,body,abstract,id,tag_list,categories,created_by&private_token=' + $scope.token + '&_=' + new Date().getTime()), config) | 1190 | + $http.get(ConfJuvAppUtils.pathTo('/articles/voted_by_me?fields=title,image,body,abstract,id,tag_list,categories,created_by&private_token=' + $scope.token + '&_=' + new Date().getTime()), config) |
1193 | .then(function(resp) { | 1191 | .then(function(resp) { |
1194 | - $scope.following = []; | ||
1195 | - $scope.followingIds = []; | ||
1196 | - var followed = resp.data.articles; | ||
1197 | - for (var i = 0; i < followed.length; i++) { | ||
1198 | - var p = followed[i]; | ||
1199 | - $scope.following.push(p); | ||
1200 | - $scope.followingIds.push(p.id); | 1192 | + $scope.voted = []; |
1193 | + $scope.votedIds = []; | ||
1194 | + var voted_articles = resp.data.articles; | ||
1195 | + for (var i = 0; i < voted_articles.length; i++) { | ||
1196 | + var p = voted_articles[i]; | ||
1197 | + $scope.voted.push(p); | ||
1198 | + $scope.votedIds.push(p.id); | ||
1201 | } | 1199 | } |
1202 | $scope.loading = false; | 1200 | $scope.loading = false; |
1203 | }, function(err) { | 1201 | }, function(err) { |
1204 | $scope.loading = false; | 1202 | $scope.loading = false; |
1205 | - $ionicPopup.alert({ title: 'Propostas seguidas', template: 'Erro ao carregar propostas seguidas' }); | 1203 | + $ionicPopup.alert({ title: 'Propostas votadas', template: 'Erro ao carregar propostas votadas' }); |
1206 | }); | 1204 | }); |
1207 | }; | 1205 | }; |
1208 | 1206 | ||
1209 | -//FIXME adapt this method for votes | ||
1210 | $scope.alreadyVoted = function(proposal) { | 1207 | $scope.alreadyVoted = function(proposal) { |
1211 | -// if ($scope.hasOwnProperty('followingIds')) { | ||
1212 | -// return ($scope.followingIds.indexOf(proposal.id) > -1); | ||
1213 | -// } | ||
1214 | -// else { | 1208 | + if ($scope.hasOwnProperty('votedIds')) { |
1209 | + return ($scope.votedIds.indexOf(proposal.id) > -1); | ||
1210 | + } | ||
1211 | + else { | ||
1215 | return false; | 1212 | return false; |
1216 | -// } | 1213 | + } |
1217 | }; | 1214 | }; |
1218 | 1215 | ||
1219 | $scope.vote = function(proposal) { | 1216 | $scope.vote = function(proposal) { |