ignore metadata improvements
This commit is contained in:
@@ -18,9 +18,10 @@
|
||||
</span>
|
||||
<a routerLink="/c/{{comment.id}}" matTooltip="{{comment.created | datef:'LLLL'}}">{{comment.created
|
||||
| datef}}</a>
|
||||
<span *ngIf="comment.metadata && comment.metadata.entry"> {{'comment.on' | i18n}} <a
|
||||
<span *ngIf="comment.metadata && comment.metadata.author"> {{'comment.author' | i18n}}<a
|
||||
routerLink="/u/{{comment.author}}">{{comment.author}}</a></span>
|
||||
<span *ngIf="comment.metadata && comment.metadata.entry"> {{'comment.on' | i18n}} <a class="entry"
|
||||
routerLink="/e/{{comment.target}}">{{comment.metadata.entry || 'entry'}}</a></span>
|
||||
{{'comment.author' | i18n}}<a routerLink="/u/{{comment.author}}">{{comment.author}}</a>
|
||||
<span *ngIf="comment.metadata && comment.metadata.unvote"> | </span>
|
||||
<a *ngIf="comment.metadata.unvote" href="javascript:" (click)="unvote()">{{'comment.unvote' | i18n}}</a>
|
||||
</small>
|
||||
@@ -44,4 +45,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ui-comments #subcomments [target]="comment.target" [parent]="comment.id"></ui-comments>
|
||||
<ui-comments *ngIf="subcomments && comment.metadata && comment.metadata.comments > 0" #subcomments [target]="comment.target" [parent]="comment.id" [subcomments]="subcomments"></ui-comments>
|
||||
@@ -1,9 +1,9 @@
|
||||
small > a {
|
||||
small a:not(.entry) {
|
||||
color: inherit !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
small > a:hover {
|
||||
small a:not(.entry):hover {
|
||||
color: inherit !important;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ export class UiComment implements OnInit {
|
||||
moderator: boolean = false;
|
||||
@Input() comment: any;
|
||||
@Input() change: Function;
|
||||
@ViewChild('subcomments') subcomments: UiComments;
|
||||
@Input() ignore: string[] = [];
|
||||
@Input() subcomments: boolean = false;
|
||||
@ViewChild('subcomments') comments: UiComments;
|
||||
|
||||
constructor(private authService: AuthService, private commentService: CommentService, private voteService: VoteService,
|
||||
private moderationService: ModerationService, public dialog: MatDialog) { }
|
||||
@@ -33,15 +35,11 @@ export class UiComment implements OnInit {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
this.commentService.countParent(this.comment.target, this.comment.id).subscribe((data) => {
|
||||
this.comment.metadata.comments = +data;
|
||||
});
|
||||
}
|
||||
|
||||
voteUp() {
|
||||
this.voteService.voteCommentUp(this.comment.id).subscribe((result) => {
|
||||
this.commentService.getComment(this.comment.id).subscribe((data) => {
|
||||
this.commentService.getComment(this.comment.id, this.ignore).subscribe((data) => {
|
||||
this.comment = data;
|
||||
})
|
||||
});
|
||||
@@ -49,7 +47,7 @@ export class UiComment implements OnInit {
|
||||
|
||||
voteDown() {
|
||||
this.voteService.voteCommentDown(this.comment.id).subscribe((result) => {
|
||||
this.commentService.getComment(this.comment.id).subscribe((data) => {
|
||||
this.commentService.getComment(this.comment.id, this.ignore).subscribe((data) => {
|
||||
this.comment = data;
|
||||
})
|
||||
});
|
||||
@@ -57,7 +55,7 @@ export class UiComment implements OnInit {
|
||||
|
||||
unvote() {
|
||||
this.voteService.unvoteComment(this.comment.id).subscribe((result) => {
|
||||
this.commentService.getComment(this.comment.id).subscribe((data) => {
|
||||
this.commentService.getComment(this.comment.id, this.ignore).subscribe((data) => {
|
||||
this.comment = data;
|
||||
})
|
||||
});
|
||||
@@ -68,7 +66,9 @@ export class UiComment implements OnInit {
|
||||
}
|
||||
|
||||
replyCallback(comment): void {
|
||||
this.subcomments.addComment(comment);
|
||||
if (this.subcomments) {
|
||||
this.comments.addComment(comment);
|
||||
}
|
||||
this.comment.metadata.reply = false;
|
||||
this.comment.metadata.comments = (this.comment.metadata.comments || 0) + 1;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div *ngIf="comments && comments.content" fxLayout="column" fxFlexFill class="comments">
|
||||
<ng-container *ngFor="let comment of comments.content; let i = index">
|
||||
<mat-divider class="divider" *ngIf="i > 0"></mat-divider>
|
||||
<ui-comment class="comment" [comment]="comment" [change]="boundRefresh"></ui-comment>
|
||||
<ui-comment class="comment" [comment]="comment" [change]="boundRefresh" [subcomments]="subcomments" [ignore]="ignore"></ui-comment>
|
||||
</ng-container>
|
||||
|
||||
<mat-list *ngIf="comments.totalElements == 0 && !parent">
|
||||
|
||||
@@ -13,6 +13,8 @@ export class UiComments implements OnInit {
|
||||
comments: any;
|
||||
@Input() target: number;
|
||||
@Input() parent: number;
|
||||
@Input() ignore: string[] = [];
|
||||
@Input() subcomments: boolean = false;
|
||||
boundRefresh: Function;
|
||||
|
||||
constructor(private commentService: CommentService) { }
|
||||
@@ -24,11 +26,11 @@ export class UiComments implements OnInit {
|
||||
|
||||
refresh(): void {
|
||||
if (this.parent) {
|
||||
this.commentService.getNewByParent(this.target, this.parent, 0, 30).subscribe((data) => {
|
||||
this.commentService.getNewByParent(this.target, this.parent, 0, 30, this.ignore).subscribe((data) => {
|
||||
this.comments = data;
|
||||
})
|
||||
} else {
|
||||
this.commentService.getNew(this.target, 0, 30).subscribe((data) => {
|
||||
this.commentService.getNew(this.target, 0, 30, this.ignore).subscribe((data) => {
|
||||
this.comments = data;
|
||||
})
|
||||
}
|
||||
@@ -51,7 +53,7 @@ export class UiComments implements OnInit {
|
||||
showMore() {
|
||||
const oldContent: any[] = this.comments.content;
|
||||
if (this.parent) {
|
||||
this.commentService.getNewByParent(this.target, this.parent, this.comments.number + 1, this.comments.size).subscribe((data) => {
|
||||
this.commentService.getNewByParent(this.target, this.parent, this.comments.number + 1, this.comments.size, this.ignore).subscribe((data) => {
|
||||
this.comments = data;
|
||||
for (let comment of this.comments.content) {
|
||||
oldContent.push(comment);
|
||||
@@ -59,7 +61,7 @@ export class UiComments implements OnInit {
|
||||
this.comments.content = oldContent;
|
||||
})
|
||||
} else {
|
||||
this.commentService.getNew(this.target, this.comments.number + 1, this.comments.size).subscribe((data) => {
|
||||
this.commentService.getNew(this.target, this.comments.number + 1, this.comments.size, this.ignore).subscribe((data) => {
|
||||
this.comments = data;
|
||||
for (let comment of this.comments.content) {
|
||||
oldContent.push(comment);
|
||||
|
||||
@@ -6,18 +6,16 @@
|
||||
</div>
|
||||
<div mat-line>
|
||||
<small>
|
||||
<ng-container *ngIf="entry.metadata && !entry.metadata.unvote">
|
||||
<a href="javascript:" (click)="voteUp(entry.id)" matTooltip="{{'vote.up' | i18n}}">
|
||||
<mat-icon inline="true">thumb_up</mat-icon>
|
||||
</a>
|
||||
<span> </span>
|
||||
<!--
|
||||
<a href="javascript:" (click)="voteDown(entry.id)" matTooltip="{{'vote.down' | i18n}}">
|
||||
<mat-icon inline="true">thumb_down</mat-icon>
|
||||
</a>
|
||||
<span> </span>
|
||||
-->
|
||||
</ng-container>
|
||||
<a *ngIf="entry.metadata && entry.metadata.vote" href="javascript:" (click)="voteUp(entry.id)"
|
||||
matTooltip="{{'vote.up' | i18n}}">
|
||||
<mat-icon inline="true">thumb_up</mat-icon>
|
||||
</a>
|
||||
<span *ngIf="entry.metadata && entry.metadata.vote"> </span>
|
||||
<a *ngIf="entry.metadata && entry.metadata.unvote" href="javascript:" (click)="voteDown(entry.id)"
|
||||
matTooltip="{{'vote.down' | i18n}}">
|
||||
<mat-icon inline="true">thumb_down</mat-icon>
|
||||
</a>
|
||||
<span *ngIf="entry.metadata && entry.metadata.unvote"> </span>
|
||||
<span class="voted" *ngIf="entry.metadata && entry.metadata.unvote">
|
||||
<mat-icon *ngIf="entry.metadata && entry.metadata.upvoted" inline="true">thumb_up</mat-icon>
|
||||
<mat-icon *ngIf="entry.metadata && entry.metadata.downvoted" inline="true">thumb_down</mat-icon>
|
||||
|
||||
Reference in New Issue
Block a user