Commit 7d024bd6bc0ce3f6ab0e8c166a6351192eb917c0
Exists in
master
and in
8 other branches
Merge branch 'rafael' of gitlab.com:participa/discussion-app into rafael
Showing
2 changed files
with
84 additions
and
62 deletions
Show diff stats
src/app/components/proposal-list/proposal-list.directive.js
| ... | ... | @@ -2,8 +2,8 @@ |
| 2 | 2 | 'use strict'; |
| 3 | 3 | |
| 4 | 4 | angular |
| 5 | - .module('dialoga') | |
| 6 | - .directive('proposalList', proposalList); | |
| 5 | + .module('dialoga') | |
| 6 | + .directive('proposalList', proposalList); | |
| 7 | 7 | |
| 8 | 8 | /** @ngInject */ |
| 9 | 9 | function proposalList() { |
| ... | ... | @@ -36,9 +36,21 @@ |
| 36 | 36 | vm.per_page = 5; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | + vm.currentPageIndex = 0; | |
| 40 | + | |
| 39 | 41 | vm.proposalsPerPage = vm.getProposalsPerPage(0); |
| 40 | 42 | |
| 41 | 43 | vm.proposalsLength = vm.proposals.length; |
| 44 | + | |
| 45 | + | |
| 46 | + if ((vm.proposalsLength % vm.per_page) == 0) { | |
| 47 | + vm.pages = vm.proposalsLength / vm.per_page; | |
| 48 | + } else{ | |
| 49 | + vm.pages = (vm.proposalsLength / vm.per_page) +1; | |
| 50 | + }; | |
| 51 | + | |
| 52 | + vm.arraypages = new Array(vm.pages); | |
| 53 | + | |
| 42 | 54 | }; |
| 43 | 55 | |
| 44 | 56 | ProposalListController.prototype.loadData = function () { |
| ... | ... | @@ -62,7 +74,17 @@ |
| 62 | 74 | |
| 63 | 75 | ProposalListController.prototype.showPage = function (pageIndex) { |
| 64 | 76 | var vm = this; |
| 77 | + | |
| 78 | + if (pageIndex < 0) { | |
| 79 | + pageIndex = 0; | |
| 80 | + } | |
| 81 | + | |
| 82 | + if (pageIndex > (vm.arraypages.length-1)) { | |
| 83 | + pageIndex = vm.arraypages.length-1; | |
| 84 | + } | |
| 85 | + | |
| 65 | 86 | vm.proposalsPerPage = vm.getProposalsPerPage(pageIndex); |
| 87 | + vm.currentPageIndex = pageIndex; | |
| 66 | 88 | }; |
| 67 | 89 | |
| 68 | 90 | function attachPopover(){ | ... | ... |
src/app/components/proposal-list/proposal-list.html
| 1 | 1 | <div class="proposal-list"> |
| 2 | - <div class="table-responsive" ng-if="vm.loading"> | |
| 3 | - <div class="table-responsive">Carregando...</div> | |
| 4 | - </div> | |
| 5 | - <div class="table-responsive" ng-if="!vm.loading && vm.proposalsPerPage"> | |
| 6 | - <table class="table table-striped"> | |
| 7 | - <thead> | |
| 8 | - <tr> | |
| 9 | - <th> | |
| 10 | - Colocação | |
| 11 | - <a tabindex="0" class="btn btn-link btn-question" role="button" data-toggle="popover" data-trigger="focus">?</a> | |
| 12 | - </th> | |
| 13 | - <th>{{vm.proposals.length}} PROPOSTAS</th> | |
| 14 | - </tr> | |
| 15 | - </thead> | |
| 16 | - <tbody> | |
| 17 | - <tr ng-repeat="proposal in vm.proposalsPerPage"> | |
| 18 | - <td class="color-theme-fg"> | |
| 19 | - <span class="position">{{::($index+1)}}º</span> | |
| 20 | - </td> | |
| 21 | - <td> | |
| 22 | - <div class="row"> | |
| 23 | - <div class="col-xs-12"> | |
| 24 | - <div class="abstract" ng-bind-html="proposal.abstract"></div> | |
| 25 | - </div> | |
| 26 | - </div> | |
| 27 | - <div class="row row-actions"> | |
| 28 | - <div class="col-md-9"> | |
| 29 | - <button type="button" class="btn btn-link btn-rate color-theme-common-fg"> | |
| 30 | - Avalie esta proposta | |
| 31 | - <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> | |
| 32 | - </button> | |
| 33 | - </div> | |
| 34 | - <div class="col-md-3"> | |
| 35 | - <proposal-stats views="{{::proposal.hits}}" up="{{::proposal.votes_for}}" down="{{::proposal.votes_against}}"></proposal-stats> | |
| 36 | - </div> | |
| 37 | - </div> | |
| 38 | - </td> | |
| 39 | - </tr> | |
| 40 | - </tbody> | |
| 41 | - </table> | |
| 42 | - <nav> | |
| 43 | - <ul class="pagination"> | |
| 44 | - <li> | |
| 45 | - <a href="#" aria-label="Previous"> | |
| 46 | - <span aria-hidden="true">«</span> | |
| 47 | - </a> | |
| 48 | - </li> | |
| 49 | - <li><a href="#" ng-click="vm.showPage(1)">1</a></li> | |
| 50 | - <li><a href="#" ng-click="vm.showPage(2)">2</a></li> | |
| 51 | - <li><a href="#" ng-click="vm.showPage(3)">3</a></li> | |
| 52 | - <li><a href="#" ng-click="vm.showPage(4)">4</a></li> | |
| 53 | - <li><a href="#" ng-click="vm.showPage(5)">5</a></li> | |
| 54 | - <li> | |
| 55 | - <a href="#" aria-label="Next"> | |
| 56 | - <span aria-hidden="true">»</span> | |
| 57 | - </a> | |
| 58 | - </li> | |
| 59 | - </ul> | |
| 60 | - </nav> | |
| 61 | - </div> | |
| 2 | + <div class="table-responsive" ng-if="vm.loading"> | |
| 3 | + <div class="table-responsive">Carregando...</div> | |
| 4 | + </div> | |
| 5 | + <div class="table-responsive" ng-if="!vm.loading && vm.proposalsPerPage"> | |
| 6 | + <table class="table table-striped"> | |
| 7 | + <thead> | |
| 8 | + <tr> | |
| 9 | + <th> | |
| 10 | + Colocação | |
| 11 | + <a tabindex="0" class="btn btn-link btn-question" role="button" data-toggle="popover" data-trigger="focus">?</a> | |
| 12 | + </th> | |
| 13 | + <th>{{vm.proposals.length}} PROPOSTAS</th> | |
| 14 | + </tr> | |
| 15 | + </thead> | |
| 16 | + <tbody> | |
| 17 | + <tr ng-repeat="proposal in vm.proposalsPerPage"> | |
| 18 | + <td class="color-theme-fg"> | |
| 19 | + <span class="position">{{::($index+1)}}º</span> | |
| 20 | + </td> | |
| 21 | + <td> | |
| 22 | + <div class="row"> | |
| 23 | + <div class="col-xs-12"> | |
| 24 | + <div class="abstract" ng-bind-html="proposal.abstract"></div> | |
| 25 | + </div> | |
| 26 | + </div> | |
| 27 | + <div class="row row-actions"> | |
| 28 | + <div class="col-md-9"> | |
| 29 | + <button type="button" class="btn btn-link btn-rate color-theme-common-fg"> | |
| 30 | + Avalie esta proposta | |
| 31 | + <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> | |
| 32 | + </button> | |
| 33 | + </div> | |
| 34 | + <div class="col-md-3"> | |
| 35 | + <proposal-stats views="{{::proposal.hits}}" up="{{::proposal.votes_for}}" down="{{::proposal.votes_against}}"></proposal-stats> | |
| 36 | + </div> | |
| 37 | + </div> | |
| 38 | + </td> | |
| 39 | + </tr> | |
| 40 | + </tbody> | |
| 41 | + </table> | |
| 42 | + <nav> | |
| 43 | + <ul class="pagination"> | |
| 44 | + | |
| 45 | + <li ng-class="{ 'disabled' : vm.currentPageIndex == 0}"> | |
| 46 | + <a href="#" aria-label="Previous" ng-click="vm.showPage(vm.currentPageIndex-1)"> | |
| 47 | + <span aria-hidden="true">«</span> | |
| 48 | + </a> | |
| 49 | + </li> | |
| 50 | + <li ng-repeat="paginas in vm.arraypages track by $index" ng-class="{ 'active' : ($index) == vm.currentPageIndex }" > | |
| 51 | + <a href="#" ng-click="vm.showPage($index)">{{::($index)+1}}</a> | |
| 52 | + </li> | |
| 53 | + <li ng-class="{ 'disabled' : vm.currentPageIndex == (vm.arraypages.length -1)}"> | |
| 54 | + <a href="#" aria-label="Next" ng-click="vm.showPage(vm.currentPageIndex+1)"> | |
| 55 | + <span aria-hidden="true">»</span> | |
| 56 | + </a> | |
| 57 | + </li> | |
| 58 | + | |
| 59 | + </ul> | |
| 60 | + </nav> | |
| 61 | + </div> | |
| 62 | 62 | </div> | ... | ... |