Commit b7e21a20541c9621e727e5bddd83c826af777c2d
1 parent
82273771
Exists in
master
and in
2 other branches
Loading proposals by city
Showing
2 changed files
with
26 additions
and
3 deletions
Show diff stats
ConfJuvApp/www/html/_right_sidebar.html
| ... | ... | @@ -4,7 +4,17 @@ |
| 4 | 4 | <span>Filtros</span> |
| 5 | 5 | <button menu-toggle="right" class="button button-icon icon ion-close-circled" hide-when="large"></button> |
| 6 | 6 | </h2> |
| 7 | - <h3>Mostrar apenas propostas do eixo:</h2> | |
| 7 | + <h3 ng-show="user.region"> | |
| 8 | + Propostas de {{user.region.full_name}} | |
| 9 | + <label class="checkbox my-city-cbox"> | |
| 10 | + <input type="checkbox" ng-click="loadProposalsOfMyCity()"> | |
| 11 | + </label> | |
| 12 | + </h3> | |
| 13 | + <h3 ng-show="!user.region"> | |
| 14 | + <a ng-click="loadStates()">Adicione sua cidade no seu cadastro se der.</a> | |
| 15 | + <ng-include ng-show="states.length != 0" src="'html/_select_state.html'"></ng-include> | |
| 16 | + </h3> | |
| 17 | + <h3>Mostrar apenas propostas do eixo:</h3> | |
| 8 | 18 | <ion-radio class="radio-balanced" ng-value="'all'" ng-model="topicFilter.value" ng-click="$parent.reloadProposals()">Todos</ion-radio> |
| 9 | 19 | <label ng-repeat="topic in topics"> |
| 10 | 20 | <ion-radio class="radio-balanced" ng-value="topic.id" ng-model="topicFilter.value" ng-click="$parent.reloadProposals()"> | ... | ... |
ConfJuvApp/www/js/controllers.js
| ... | ... | @@ -332,6 +332,8 @@ angular.module('confjuvapp.controllers', []) |
| 332 | 332 | $scope.topics = []; |
| 333 | 333 | $scope.cards = []; |
| 334 | 334 | $scope.emptyTopicsCount = 0; |
| 335 | + //FIXME refatoring this variable to make the proposals filters more generic | |
| 336 | + $scope.proposalsFilter = ''; | |
| 335 | 337 | $scope.topicFilter = { value: 'all' }; |
| 336 | 338 | |
| 337 | 339 | $scope.reloadTopics = function() { |
| ... | ... | @@ -376,8 +378,19 @@ angular.module('confjuvapp.controllers', []) |
| 376 | 378 | }); |
| 377 | 379 | }; |
| 378 | 380 | |
| 379 | - // Load proposals | |
| 381 | + // Load Proposals of My City | |
| 382 | + $scope.loadProposalsOfMyCity = function() { | |
| 383 | + $scope.loading = true; | |
| 384 | + if($scope.proposalsFilter == ''){ | |
| 385 | + $scope.proposalsFilter = '&categories_ids=' + $scope.user.region.id; | |
| 386 | + }else{ | |
| 387 | + $scope.proposalsFilter = ''; | |
| 388 | + } | |
| 389 | + $scope.reloadProposals(); | |
| 390 | + $scope.loading = false; | |
| 391 | + } | |
| 380 | 392 | |
| 393 | + // Load proposals | |
| 381 | 394 | $scope.loadProposals = function(token, topic) { |
| 382 | 395 | if ($scope.topicFilter.value != 'all' && topic.id != $scope.topicFilter.value) { |
| 383 | 396 | return; |
| ... | ... | @@ -390,7 +403,7 @@ angular.module('confjuvapp.controllers', []) |
| 390 | 403 | perPage = 11; |
| 391 | 404 | } |
| 392 | 405 | |
| 393 | - var params = '?private_token=' + token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by&content_type=ProposalsDiscussionPlugin::Proposal&limit=' + perPage + '&oldest=younger_than&reference_id=' + topic.lastProposalId; | |
| 406 | + var params = '?private_token=' + token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by&content_type=ProposalsDiscussionPlugin::Proposal&limit=' + perPage + '&oldest=younger_than&reference_id=' + topic.lastProposalId + $scope.proposalsFilter; | |
| 394 | 407 | |
| 395 | 408 | var path = 'articles/' + topic.id + '/children' + params; |
| 396 | 409 | ... | ... |