improvements + bookmarks

This commit is contained in:
2021-10-04 13:02:30 +02:00
parent a69a85aeb0
commit 0cabe9b0a5
12 changed files with 169 additions and 15 deletions
+9 -3
View File
@@ -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 -1
View File
@@ -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>
+4
View File
@@ -1,3 +1,7 @@
.comments {
padding-left: 15px;
}
.divider {
margin: 10px 0px;
}
+5 -1
View File
@@ -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>
+14 -4
View File
@@ -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>&nbsp;</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>
+18 -6
View File
@@ -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 ]
}
})
+3
View File
@@ -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}}