Commit ec740ff6dfa0218b7851b2f099e853d427bf3845
Exists in
staging
Merge branch 'master' into staging
Showing
8 changed files
with
34 additions
and
13 deletions
Show diff stats
src/app/article/comment/comments.component.ts
| ... | ... | @@ -16,6 +16,7 @@ export class CommentsComponent { |
| 16 | 16 | @Input() showForm = true; |
| 17 | 17 | @Input() article: noosfero.Article; |
| 18 | 18 | @Input() parent: noosfero.CommentViewModel; |
| 19 | + @Input() fullPagination = false; | |
| 19 | 20 | protected page = 1; |
| 20 | 21 | protected perPage = 5; |
| 21 | 22 | protected total = 0; |
| ... | ... | @@ -73,14 +74,25 @@ export class CommentsComponent { |
| 73 | 74 | |
| 74 | 75 | loadNextPage() { |
| 75 | 76 | this.loadComments().then((result: noosfero.RestResult<noosfero.Comment[]>) => { |
| 76 | - this.comments = this.comments.concat(result.data); | |
| 77 | + if (this.fullPagination) { | |
| 78 | + this.comments = result.data; | |
| 79 | + } else { | |
| 80 | + this.comments = this.comments.concat(result.data); | |
| 81 | + this.page++; | |
| 82 | + } | |
| 77 | 83 | this.total = result.headers ? result.headers("total") : this.comments.length; |
| 78 | - this.page++; | |
| 79 | 84 | }); |
| 80 | 85 | } |
| 81 | 86 | |
| 82 | 87 | displayMore() { |
| 83 | - let pages = Math.ceil(this.total / this.perPage); | |
| 84 | - return !this.parent && pages >= this.page; | |
| 88 | + return !this.parent && !this.fullPagination && this.getPages() >= this.page; | |
| 89 | + } | |
| 90 | + | |
| 91 | + displayFullPagination() { | |
| 92 | + return !this.parent && this.fullPagination && this.getPages() > 0; | |
| 93 | + } | |
| 94 | + | |
| 95 | + private getPages() { | |
| 96 | + return Math.ceil(this.total / this.perPage); | |
| 85 | 97 | } |
| 86 | 98 | } | ... | ... |
src/app/article/comment/comments.html
| ... | ... | @@ -4,5 +4,10 @@ |
| 4 | 4 | <div class="comments-list"> |
| 5 | 5 | <noosfero-comment (comment-removed)="ctrl.commentRemoved($event.detail)" ng-repeat="comment in ctrl.comments | orderBy: 'created_at':true" [comment]="comment" [article]="ctrl.article"></noosfero-comment> |
| 6 | 6 | </div> |
| 7 | + | |
| 7 | 8 | <button type="button" ng-if="ctrl.displayMore()" class="more-comments btn btn-default btn-block" ng-click="ctrl.loadNextPage()">{{"comment.pagination.more" | translate}}</button> |
| 9 | + <uib-pagination ng-if="ctrl.displayFullPagination()" ng-model="ctrl.page" total-items="ctrl.total" class="pagination-sm center-block" | |
| 10 | + boundary-links="true" items-per-page="ctrl.perPage" ng-change="ctrl.loadNextPage()" | |
| 11 | + first-text="«" last-text="»" previous-text="‹" next-text="›"> | |
| 12 | + </uib-pagination> | |
| 8 | 13 | </div> | ... | ... |
src/app/layout/blocks/recent-documents/recent-documents-block.scss
| ... | ... | @@ -24,13 +24,13 @@ |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | -.col-md-2-5 { | |
| 27 | +.col-md-3 { | |
| 28 | 28 | .deckgrid[deckgrid]::before { |
| 29 | 29 | content: '1 .deck-column'; |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | -.col-md-7 { | |
| 33 | +.col-md-6 { | |
| 34 | 34 | .block.recentdocumentsblock { |
| 35 | 35 | background-color: transparent; |
| 36 | 36 | border: 0; | ... | ... |
src/app/profile/info/profile-info.html
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | <div id="profile-info-extrainfo" class="profile-info-extrainfo"> |
| 11 | 11 | <span class="label" ng-class="{'label-danger': vm.profile.type == 'Community', 'label-info': vm.profile.type == 'Person'}">{{vm.profile | translateProfile}}</span> |
| 12 | 12 | <div class="profile-since"> |
| 13 | - {{"profile.member_since" | translate}}: {{vm.profile.created_at | amDateFormat:'MMMM YYYY'}} | |
| 13 | + {{"profile.member_since" | translate}}: {{vm.profile.created_at | dateFormat | amDateFormat:'MMMM YYYY'}} | |
| 14 | 14 | </div> |
| 15 | 15 | </div> |
| 16 | 16 | </div> | ... | ... |
src/plugins/comment_paragraph/allow-comment/popover.html
| 1 | -<comment-paragraph-side-comments id="side-comments-{{ctrl.paragraphUuid}}" click-outside="ctrl.hideParagraphComments()" [article]="ctrl.article" [paragraph-uuid]="ctrl.paragraphUuid"></comment-paragraph-side-comments> | |
| 1 | +<comment-paragraph-side-comments id="side-comments-{{ctrl.paragraphUuid}}" click-outside="ctrl.hideParagraphComments()" [article]="ctrl.article" [paragraph-uuid]="ctrl.paragraphUuid" [full-pagination]="ctrl.fullPagination"></comment-paragraph-side-comments> | ... | ... |
src/plugins/comment_paragraph/side-comments/side-comments.component.spec.ts
| ... | ... | @@ -10,7 +10,7 @@ describe("Components", () => { |
| 10 | 10 | describe("Side Comments Component", () => { |
| 11 | 11 | |
| 12 | 12 | let serviceMock = jasmine.createSpyObj("CommentParagraphService", ["getByArticle"]); |
| 13 | - serviceMock.getByArticle = jasmine.createSpy("getByArticle").and.returnValue(Promise.resolve({ data: {} })); | |
| 13 | + serviceMock.getByArticle = jasmine.createSpy("getByArticle").and.returnValue(Promise.resolve({ data: [] })); | |
| 14 | 14 | |
| 15 | 15 | let commentServiceMock = {}; |
| 16 | 16 | let postCommentEventService = jasmine.createSpyObj("postCommentEventService", ["emit", "subscribe"]); | ... | ... |
src/plugins/comment_paragraph/side-comments/side-comments.component.ts
| 1 | -import {Component, Inject, Input, Output} from "ng-forward"; | |
| 2 | -import {CommentsComponent} from "../../../app/article/comment/comments.component"; | |
| 3 | -import {CommentService} from "../../../lib/ng-noosfero-api/http/comment.service"; | |
| 4 | -import {CommentParagraphService} from "../http/comment-paragraph.service"; | |
| 1 | +import { Component, Inject, Input, Output } from "ng-forward"; | |
| 2 | +import { CommentsComponent } from "../../../app/article/comment/comments.component"; | |
| 3 | +import { CommentService } from "../../../lib/ng-noosfero-api/http/comment.service"; | |
| 4 | +import { CommentParagraphService } from "../http/comment-paragraph.service"; | |
| 5 | 5 | |
| 6 | 6 | @Component({ |
| 7 | 7 | selector: "comment-paragraph-side-comments", |
| ... | ... | @@ -12,6 +12,7 @@ export class SideCommentsComponent extends CommentsComponent { |
| 12 | 12 | |
| 13 | 13 | @Input() article: noosfero.Article; |
| 14 | 14 | @Input() paragraphUuid: string; |
| 15 | + @Input() fullPagination = true; | |
| 15 | 16 | |
| 16 | 17 | constructor(commentService: CommentService, |
| 17 | 18 | $scope: ng.IScope, | ... | ... |