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,6 +16,7 @@ export class CommentsComponent { | ||
16 | @Input() showForm = true; | 16 | @Input() showForm = true; |
17 | @Input() article: noosfero.Article; | 17 | @Input() article: noosfero.Article; |
18 | @Input() parent: noosfero.CommentViewModel; | 18 | @Input() parent: noosfero.CommentViewModel; |
19 | + @Input() fullPagination = false; | ||
19 | protected page = 1; | 20 | protected page = 1; |
20 | protected perPage = 5; | 21 | protected perPage = 5; |
21 | protected total = 0; | 22 | protected total = 0; |
@@ -73,14 +74,25 @@ export class CommentsComponent { | @@ -73,14 +74,25 @@ export class CommentsComponent { | ||
73 | 74 | ||
74 | loadNextPage() { | 75 | loadNextPage() { |
75 | this.loadComments().then((result: noosfero.RestResult<noosfero.Comment[]>) => { | 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 | this.total = result.headers ? result.headers("total") : this.comments.length; | 83 | this.total = result.headers ? result.headers("total") : this.comments.length; |
78 | - this.page++; | ||
79 | }); | 84 | }); |
80 | } | 85 | } |
81 | 86 | ||
82 | displayMore() { | 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,5 +4,10 @@ | ||
4 | <div class="comments-list"> | 4 | <div class="comments-list"> |
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> | 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 | </div> | 6 | </div> |
7 | + | ||
7 | <button type="button" ng-if="ctrl.displayMore()" class="more-comments btn btn-default btn-block" ng-click="ctrl.loadNextPage()">{{"comment.pagination.more" | translate}}</button> | 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 | </div> | 13 | </div> |
src/app/layout/blocks/recent-documents/recent-documents-block.scss
@@ -24,13 +24,13 @@ | @@ -24,13 +24,13 @@ | ||
24 | } | 24 | } |
25 | } | 25 | } |
26 | 26 | ||
27 | -.col-md-2-5 { | 27 | +.col-md-3 { |
28 | .deckgrid[deckgrid]::before { | 28 | .deckgrid[deckgrid]::before { |
29 | content: '1 .deck-column'; | 29 | content: '1 .deck-column'; |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | -.col-md-7 { | 33 | +.col-md-6 { |
34 | .block.recentdocumentsblock { | 34 | .block.recentdocumentsblock { |
35 | background-color: transparent; | 35 | background-color: transparent; |
36 | border: 0; | 36 | border: 0; |
src/app/profile/info/profile-info.html
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | <div id="profile-info-extrainfo" class="profile-info-extrainfo"> | 10 | <div id="profile-info-extrainfo" class="profile-info-extrainfo"> |
11 | <span class="label" ng-class="{'label-danger': vm.profile.type == 'Community', 'label-info': vm.profile.type == 'Person'}">{{vm.profile | translateProfile}}</span> | 11 | <span class="label" ng-class="{'label-danger': vm.profile.type == 'Community', 'label-info': vm.profile.type == 'Person'}">{{vm.profile | translateProfile}}</span> |
12 | <div class="profile-since"> | 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 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
16 | </div> | 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,7 +10,7 @@ describe("Components", () => { | ||
10 | describe("Side Comments Component", () => { | 10 | describe("Side Comments Component", () => { |
11 | 11 | ||
12 | let serviceMock = jasmine.createSpyObj("CommentParagraphService", ["getByArticle"]); | 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 | let commentServiceMock = {}; | 15 | let commentServiceMock = {}; |
16 | let postCommentEventService = jasmine.createSpyObj("postCommentEventService", ["emit", "subscribe"]); | 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 | @Component({ | 6 | @Component({ |
7 | selector: "comment-paragraph-side-comments", | 7 | selector: "comment-paragraph-side-comments", |
@@ -12,6 +12,7 @@ export class SideCommentsComponent extends CommentsComponent { | @@ -12,6 +12,7 @@ export class SideCommentsComponent extends CommentsComponent { | ||
12 | 12 | ||
13 | @Input() article: noosfero.Article; | 13 | @Input() article: noosfero.Article; |
14 | @Input() paragraphUuid: string; | 14 | @Input() paragraphUuid: string; |
15 | + @Input() fullPagination = true; | ||
15 | 16 | ||
16 | constructor(commentService: CommentService, | 17 | constructor(commentService: CommentService, |
17 | $scope: ng.IScope, | 18 | $scope: ng.IScope, |