improvements + bookmarks
This commit is contained in:
@@ -43,19 +43,25 @@ export class UiComment implements OnInit {
|
||||
|
||||
voteUp() {
|
||||
this.voteService.voteCommentUp(this.comment.id).subscribe((result) => {
|
||||
this.change && this.change()
|
||||
this.commentService.getComment(this.comment.id).subscribe((data) => {
|
||||
this.comment = data;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
voteDown() {
|
||||
this.voteService.voteCommentDown(this.comment.id).subscribe((result) => {
|
||||
this.change && this.change()
|
||||
this.commentService.getComment(this.comment.id).subscribe((data) => {
|
||||
this.comment = data;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
unvote() {
|
||||
this.voteService.unvoteComment(this.comment.id).subscribe((result) => {
|
||||
this.change && this.change()
|
||||
this.commentService.getComment(this.comment.id).subscribe((data) => {
|
||||
this.comment = data;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div *ngIf="comments" fxLayout="column" fxFlexFill class="comments">
|
||||
<ng-container *ngFor="let comment of comments.content; let i = index">
|
||||
<mat-divider *ngIf="i > 0"></mat-divider>
|
||||
<mat-divider class="divider" *ngIf="i > 0"></mat-divider>
|
||||
<ui-comment [comment]="comment" [change]="boundRefresh"></ui-comment>
|
||||
</ng-container>
|
||||
</div>
|
||||
@@ -1,3 +1,7 @@
|
||||
.comments {
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
.divider {
|
||||
margin: 10px 0px;
|
||||
}
|
||||
@@ -11,7 +11,11 @@
|
||||
</ng-container>
|
||||
</mat-list>
|
||||
|
||||
<p *ngIf="entries.totalElements == 0">{{'entries.nothing' | i18n}}</p>
|
||||
<mat-list *ngIf="entries.totalElements == 0">
|
||||
<mat-list-item>
|
||||
<p>{{'entries.nothing' | i18n}}</p>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
|
||||
<span fxFlexOffset="auto"></span>
|
||||
|
||||
|
||||
@@ -19,18 +19,28 @@
|
||||
-->
|
||||
</ng-container>
|
||||
<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>
|
||||
<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>
|
||||
<span> </span>
|
||||
</span>
|
||||
{{'points' | i18n:(entry.metadata && entry.metadata.points)}}
|
||||
<a routerLink="/e/{{entry.id}}" matTooltip="{{entry.created | datef:'LLLL'}}">{{entry.created
|
||||
| datef}}</a>
|
||||
{{'entry.author' | i18n}}<a routerLink="/u/{{entry.author}}">{{entry.author}}</a>
|
||||
|
|
||||
<span> | </span>
|
||||
<a routerLink="/e/{{entry.id}}">{{'entry.comments' | i18n:(entry.metadata && entry.metadata.comments)}}</a>
|
||||
<span> | </span>
|
||||
<a *ngIf="entry.metadata && !entry.metadata.bookmarked" href="javascript:" (click)="addBookmark()"
|
||||
matTooltip="{{'bookmarks.add' | i18n}}">
|
||||
<mat-icon inline="true">bookmark_border</mat-icon>
|
||||
</a>
|
||||
<a *ngIf="entry.metadata && entry.metadata.bookmarked" href="javascript:" (click)="removeBookmark()"
|
||||
matTooltip="{{'bookmarks.remove' | i18n}}">
|
||||
<mat-icon inline="true">bookmark</mat-icon>
|
||||
</a>
|
||||
<span *ngIf="entry.metadata && entry.metadata.unvote"> | </span>
|
||||
<a *ngIf="entry.metadata && entry.metadata.unvote" href="javascript:" (click)="unvote(entry.id)">{{'entry.unvote' | i18n}}</a>
|
||||
<a *ngIf="entry.metadata && entry.metadata.unvote" href="javascript:" (click)="unvote(entry.id)">{{'entry.unvote' |
|
||||
i18n}}</a>
|
||||
<span *ngIf="moderator"> | </span>
|
||||
<a *ngIf="moderator" href="javascript:" (click)="deleteEntry(entry)">{{'entry.delete' | i18n}}</a>
|
||||
</small>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
import { AuthService } from '../../services/auth.service';
|
||||
import { VoteService } from '../../services/vote.service';
|
||||
import { CommentService } from '../../services/comment.service';
|
||||
import { BookmarksService } from '../../services/bookmarks.service';
|
||||
import { ModerationService } from '../../services/moderarion.service';
|
||||
import { ConfirmDialog } from '../../ui/confirm/confirm.component';
|
||||
|
||||
@@ -20,7 +20,7 @@ export class UiEntry implements OnInit {
|
||||
@Input() change: Function;
|
||||
|
||||
constructor(private authService: AuthService, private voteService: VoteService,
|
||||
private moderationService: ModerationService, public dialog: MatDialog) { }
|
||||
private moderationService: ModerationService, private bookmarksService: BookmarksService, public dialog: MatDialog) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.authService.auth.subscribe((auth: any) => {
|
||||
@@ -36,26 +36,38 @@ export class UiEntry implements OnInit {
|
||||
|
||||
voteUp() {
|
||||
this.voteService.voteEntryUp(this.entry.id).subscribe((result) => {
|
||||
this.change && this.change()
|
||||
this.change && this.change();
|
||||
});
|
||||
}
|
||||
|
||||
voteDown() {
|
||||
this.voteService.voteEntryDown(this.entry.id).subscribe((result) => {
|
||||
this.change && this.change()
|
||||
this.change && this.change();
|
||||
});
|
||||
}
|
||||
|
||||
addBookmark() {
|
||||
this.bookmarksService.addEntry(this.entry.id).subscribe((result) => {
|
||||
this.entry.metadata.bookmarked = true;
|
||||
});
|
||||
}
|
||||
|
||||
removeBookmark() {
|
||||
this.bookmarksService.removeEntry(this.entry.id).subscribe((result) => {
|
||||
this.entry.metadata.bookmarked = false;
|
||||
});
|
||||
}
|
||||
|
||||
unvote() {
|
||||
this.voteService.unvoteEntry(this.entry.id).subscribe((result) => {
|
||||
this.change && this.change()
|
||||
this.change && this.change();
|
||||
});
|
||||
}
|
||||
|
||||
deleteEntry(entry: any) {
|
||||
const dialogRef = this.dialog.open(ConfirmDialog, {
|
||||
data: {
|
||||
'label': 'comment.confirmDelete',
|
||||
'label': 'entry.confirmDelete',
|
||||
'args': [ entry.title, entry.author ]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
<a *ngIf="auth && auth.authenticated" routerLink="/new" routerLinkActive="active" mat-list-item>
|
||||
<mat-icon>history</mat-icon> {{'new' | i18n}}
|
||||
</a>
|
||||
<a *ngIf="auth && auth.authenticated" routerLink="/bookmarks" routerLinkActive="active" mat-list-item>
|
||||
<mat-icon>bookmarks</mat-icon> {{'bookmarks' | i18n}}
|
||||
</a>
|
||||
<mat-divider></mat-divider>
|
||||
<a *ngIf="auth && auth.authenticated" routerLink="/settings" routerLinkActive="active" mat-list-item>
|
||||
<mat-icon>tune</mat-icon> {{'settings' | i18n}}
|
||||
|
||||
Reference in New Issue
Block a user