Commit 52bcc0bec66d481699b77713d67b8c4d7c99b129
1 parent
1415a7cb
Exists in
production
Ticket #174: Paginate proposals from national phase
Showing
1 changed file
with
8 additions
and
34 deletions
Show diff stats
www/js/controllers.js
@@ -470,6 +470,12 @@ angular.module('confjuvapp.controllers', []) | @@ -470,6 +470,12 @@ angular.module('confjuvapp.controllers', []) | ||
470 | 470 | ||
471 | var params = '?t=' + (new Date().getTime()) + '&private_token=' + token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by,author.name,votes_count,comments_count,followers_count&content_type=ProposalsDiscussionPlugin::Proposal&per_page=' + perPage + '&oldest=younger_than&reference_id=' + topic.lastProposalId + $scope.proposalsFilter; | 471 | var params = '?t=' + (new Date().getTime()) + '&private_token=' + token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by,author.name,votes_count,comments_count,followers_count&content_type=ProposalsDiscussionPlugin::Proposal&per_page=' + perPage + '&oldest=younger_than&reference_id=' + topic.lastProposalId + $scope.proposalsFilter; |
472 | 472 | ||
473 | + if ($scope.hasOwnProperty('proposalFilters')) { | ||
474 | + for (var filter in $scope.proposalFilters) { | ||
475 | + params += '&' + filter + '=' + $scope.proposalFilters[filter]; | ||
476 | + } | ||
477 | + } | ||
478 | + | ||
473 | var path = 'articles/' + topic.id + '/children' + params; | 479 | var path = 'articles/' + topic.id + '/children' + params; |
474 | 480 | ||
475 | $http.get(ConfJuvAppUtils.pathTo(path)) | 481 | $http.get(ConfJuvAppUtils.pathTo(path)) |
@@ -1579,40 +1585,8 @@ angular.module('confjuvapp.controllers', []) | @@ -1579,40 +1585,8 @@ angular.module('confjuvapp.controllers', []) | ||
1579 | $scope.nationalProposals = []; | 1585 | $scope.nationalProposals = []; |
1580 | 1586 | ||
1581 | $scope.showNationalProposals = function() { | 1587 | $scope.showNationalProposals = function() { |
1582 | - $scope.cardsBackup = []; | ||
1583 | - $scope.showBackupProposalsLink = false; | ||
1584 | - | ||
1585 | - if ($scope.nationalProposals.length == 0) { | ||
1586 | - $scope.cards = []; | ||
1587 | - | ||
1588 | - var config = { | ||
1589 | - headers: { | ||
1590 | - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | ||
1591 | - }, | ||
1592 | - timeout: defaultTimeout | ||
1593 | - }; | ||
1594 | - | ||
1595 | - var path = 'articles?private_token=' + $scope.token + '&fields=title,body,id,categories,created_by,author.name,votes_count,comments_count,followers_count&content_type=ProposalsDiscussionPlugin::Proposal&_=' + (new Date().getTime()) + '&author_id=' + ConfJuvAppConfig.noosferoNationalPhaseProfileId + '&per_page=400&parent_id[]='; | ||
1596 | - | ||
1597 | - for (var i = 0; i < $scope.topics.length; i++) { | ||
1598 | - path += '&parent_id[]=' + $scope.topics[i].id; | ||
1599 | - } | ||
1600 | - $scope.loading = true; | ||
1601 | - | ||
1602 | - $http.get(ConfJuvAppUtils.pathTo(path), config) | ||
1603 | - .then(function(resp) { | ||
1604 | - console.log('NATIONAL PROPOSALS: ' + resp.data.articles.length); | ||
1605 | - $scope.nationalProposals = resp.data.articles; | ||
1606 | - $scope.cards = $scope.nationalProposals.slice(); | ||
1607 | - $scope.loading = false; | ||
1608 | - }, function(err) { | ||
1609 | - $scope.loading = false; | ||
1610 | - }); | ||
1611 | - } | ||
1612 | - else { | ||
1613 | - $scope.cards = $scope.nationalProposals.slice(); | ||
1614 | - } | 1588 | + $scope.proposalFilters = { 'author_id': ConfJuvAppConfig.noosferoNationalPhaseProfileId }; |
1589 | + $scope.reloadProposals(); | ||
1615 | }; | 1590 | }; |
1616 | 1591 | ||
1617 | - | ||
1618 | }); // Ends controller | 1592 | }); // Ends controller |