aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-05 11:19:25 +0100
committerChocobozzz <me@florianbigard.com>2018-01-05 11:19:25 +0100
commitd7e70384a360cda51fe23712331110a5c8b1124c (patch)
tree385609669c92936a5c66ae028c331fb4a9b5943e /client/src/app
parent2890b615f31ab7d519d8be66b49ff8712df90c51 (diff)
downloadPeerTube-d7e70384a360cda51fe23712331110a5c8b1124c.tar.gz
PeerTube-d7e70384a360cda51fe23712331110a5c8b1124c.tar.zst
PeerTube-d7e70384a360cda51fe23712331110a5c8b1124c.zip
Add mentions to comments
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.html1
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.ts14
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.html2
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.ts4
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.scss1
5 files changed, 21 insertions, 1 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
index 0eaa0d447..41d00da08 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
@@ -4,6 +4,7 @@
4 4
5 <div class="form-group"> 5 <div class="form-group">
6 <textarea placeholder="Add comment..." formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }" #textarea> 6 <textarea placeholder="Add comment..." formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }" #textarea>
7
7 </textarea> 8 </textarea>
8 <div *ngIf="formErrors.text" class="form-error"> 9 <div *ngIf="formErrors.text" class="form-error">
9 {{ formErrors.text }} 10 {{ formErrors.text }}
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
index 27655eca7..3e064efcb 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
@@ -2,7 +2,7 @@ import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild }
2import { FormBuilder, FormGroup } from '@angular/forms' 2import { FormBuilder, FormGroup } from '@angular/forms'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { Observable } from 'rxjs/Observable' 4import { Observable } from 'rxjs/Observable'
5import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model' 5import { VideoCommentCreate, VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
6import { FormReactive } from '../../../shared' 6import { FormReactive } from '../../../shared'
7import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment' 7import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment'
8import { User } from '../../../shared/users' 8import { User } from '../../../shared/users'
@@ -19,6 +19,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
19 @Input() user: User 19 @Input() user: User
20 @Input() video: Video 20 @Input() video: Video
21 @Input() parentComment: VideoComment 21 @Input() parentComment: VideoComment
22 @Input() parentComments: VideoComment[]
22 @Input() focusOnInit = false 23 @Input() focusOnInit = false
23 24
24 @Output() commentCreated = new EventEmitter<VideoCommentCreate>() 25 @Output() commentCreated = new EventEmitter<VideoCommentCreate>()
@@ -55,6 +56,17 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
55 if (this.focusOnInit === true) { 56 if (this.focusOnInit === true) {
56 this.textareaElement.nativeElement.focus() 57 this.textareaElement.nativeElement.focus()
57 } 58 }
59
60 if (this.parentComment) {
61 const mentions = this.parentComments
62 .filter(c => c.account.id !== this.user.account.id)
63 .map(c => '@' + c.account.name)
64
65 const mentionsSet = new Set(mentions)
66 const mentionsText = Array.from(mentionsSet).join(' ') + ' '
67
68 this.form.patchValue({ text: mentionsText })
69 }
58 } 70 }
59 71
60 formValidated () { 72 formValidated () {
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.html
index 8edd12124..1d325aff9 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html
@@ -18,6 +18,7 @@
18 [user]="user" 18 [user]="user"
19 [video]="video" 19 [video]="video"
20 [parentComment]="comment" 20 [parentComment]="comment"
21 [parentComments]="newParentComments"
21 [focusOnInit]="true" 22 [focusOnInit]="true"
22 (commentCreated)="onCommentReplyCreated($event)" 23 (commentCreated)="onCommentReplyCreated($event)"
23 ></my-video-comment-add> 24 ></my-video-comment-add>
@@ -29,6 +30,7 @@
29 [video]="video" 30 [video]="video"
30 [inReplyToCommentId]="inReplyToCommentId" 31 [inReplyToCommentId]="inReplyToCommentId"
31 [commentTree]="commentChild" 32 [commentTree]="commentChild"
33 [parentComments]="newParentComments"
32 (wantedToReply)="onWantToReply($event)" 34 (wantedToReply)="onWantToReply($event)"
33 (wantedToDelete)="onWantToDelete($event)" 35 (wantedToDelete)="onWantToDelete($event)"
34 (resetReply)="onResetReply()" 36 (resetReply)="onResetReply()"
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
index 2ecc8a143..38e603d0d 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
@@ -16,6 +16,7 @@ import { VideoComment } from './video-comment.model'
16export class VideoCommentComponent implements OnInit { 16export class VideoCommentComponent implements OnInit {
17 @Input() video: Video 17 @Input() video: Video
18 @Input() comment: VideoComment 18 @Input() comment: VideoComment
19 @Input() parentComments: VideoComment[] = []
19 @Input() commentTree: VideoCommentThreadTree 20 @Input() commentTree: VideoCommentThreadTree
20 @Input() inReplyToCommentId: number 21 @Input() inReplyToCommentId: number
21 22
@@ -25,6 +26,7 @@ export class VideoCommentComponent implements OnInit {
25 @Output() resetReply = new EventEmitter() 26 @Output() resetReply = new EventEmitter()
26 27
27 sanitizedCommentHTML = '' 28 sanitizedCommentHTML = ''
29 newParentComments = []
28 30
29 constructor (private authService: AuthService) {} 31 constructor (private authService: AuthService) {}
30 32
@@ -36,6 +38,8 @@ export class VideoCommentComponent implements OnInit {
36 this.sanitizedCommentHTML = sanitizeHtml(this.comment.text, { 38 this.sanitizedCommentHTML = sanitizeHtml(this.comment.text, {
37 allowedTags: [ 'p', 'span' ] 39 allowedTags: [ 'p', 'span' ]
38 }) 40 })
41
42 this.newParentComments = this.parentComments.concat([ this.comment ])
39 } 43 }
40 44
41 onCommentReplyCreated (createdComment: VideoComment) { 45 onCommentReplyCreated (createdComment: VideoComment) {
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.scss b/client/src/app/videos/+video-watch/comment/video-comments.component.scss
index be122eb2c..19ab3b633 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.scss
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.scss
@@ -6,6 +6,7 @@
6 font-size: 15px; 6 font-size: 15px;
7 cursor: pointer; 7 cursor: pointer;
8 margin-left: 56px; 8 margin-left: 56px;
9 margin-bottom: 10px;
9} 10}
10 11
11.glyphicon, .comment-thread-loading { 12.glyphicon, .comment-thread-loading {