Use comment as label for comments-thread add button

This commit is contained in:
kimsible 2020-08-07 18:41:05 +02:00 committed by Chocobozzz
parent c311596094
commit cb54210c19
3 changed files with 14 additions and 3 deletions

View File

@ -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>

View File

@ -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

View File

@ -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>