From cb54210c192bdbedab5d3333cc2602df8e23a38a Mon Sep 17 00:00:00 2001 From: kimsible <kimsible@users.noreply.github.com> Date: Fri, 7 Aug 2020 18:41:05 +0200 Subject: [PATCH] Use comment as label for comments-thread add button --- .../comment/video-comment-add.component.html | 4 ++-- .../comment/video-comment-add.component.ts | 12 +++++++++++- .../comment/video-comments.component.html | 1 + 3 files changed, 14 insertions(+), 3 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 9b43d91da..c9b0a9c63 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 @@ -20,8 +20,8 @@ <button *ngIf="isAddButtonDisplayed()" class="cancel-button" (click)="cancelCommentReply()" type="button" i18n> Cancel </button> - <button *ngIf="isAddButtonDisplayed()" [ngClass]="{ disabled: !form.valid || addingComment }" i18n> - Reply + <button *ngIf="isAddButtonDisplayed()" [ngClass]="{ disabled: !form.valid || addingComment }"> + {{ addingCommentButtonValue }} </button> </div> </form> 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 c1ddc0695..c6e9c73b8 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 @@ -7,6 +7,7 @@ import { Video } from '@app/shared/shared-main' import { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { VideoCommentCreate } from '@shared/models' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-video-comment-add', @@ -20,6 +21,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, @Input() parentComments: VideoComment[] @Input() focusOnInit = false @Input() textValue?: string + @Input() commentThread?: boolean @Output() commentCreated = new EventEmitter<VideoComment>() @Output() cancel = new EventEmitter() @@ -28,6 +30,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, @ViewChild('textarea', { static: true }) textareaElement: ElementRef addingComment = false + addingCommentButtonValue: string constructor ( protected formValidatorService: FormValidatorService, @@ -35,7 +38,8 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, private notifier: Notifier, private videoCommentService: VideoCommentService, private modalService: NgbModal, - private router: Router + private router: Router, + private i18n: I18n ) { super() } @@ -46,6 +50,12 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, }) if (this.user) { + if (this.commentThread) { + this.addingCommentButtonValue = this.i18n('Comment') + } else { + this.addingCommentButtonValue = this.i18n('Reply') + } + if (this.textValue) { this.patchTextValue(this.textValue, this.focusOnInit) return diff --git a/client/src/app/+videos/+video-watch/comment/video-comments.component.html b/client/src/app/+videos/+video-watch/comment/video-comments.component.html index 1bc0885a4..ac69f094b 100644 --- a/client/src/app/+videos/+video-watch/comment/video-comments.component.html +++ b/client/src/app/+videos/+video-watch/comment/video-comments.component.html @@ -28,6 +28,7 @@ [user]="user" (commentCreated)="onCommentThreadCreated($event)" [textValue]="commentThreadRedraftValue" + [commentThread]="true" ></my-video-comment-add> <div *ngIf="componentPagination.totalItems === 0 && comments.length === 0" i18n>No comments.</div>