clear comment text on submit
This commit is contained in:
parent
a9c675880f
commit
508ae03468
|
@ -27,7 +27,12 @@
|
|||
<form [formGroup]="threadFormGroup">
|
||||
<div class="row mt-2 mb-3">
|
||||
<div class="col-12">
|
||||
<text-area-with-mentions [form]="threadFormGroup.get('text')" [planUsers]="planUsers"></text-area-with-mentions>
|
||||
<text-area-with-mentions
|
||||
[form]="threadFormGroup.get('text')"
|
||||
[planUsers]="planUsers"
|
||||
[clearCommentObservable]="clearCommentSubject.asObservable()"
|
||||
[threadId]="ROOT_COMMENT"
|
||||
></text-area-with-mentions>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-button-toggle-group appearance="standard" name="fontStyle" hideSingleSelectionIndicator="true" [formControl]="threadFormGroup.get('protectionType')" aria-label="Font Style" required>
|
||||
|
@ -149,7 +154,12 @@
|
|||
<div class="col-12 mt-2">
|
||||
<div class="row new-reply mr-0">
|
||||
<div class="col">
|
||||
<text-area-with-mentions [form]="this.threadReplyTextsFG[thread.toString()].get('replyText')" [planUsers]="planUsers"></text-area-with-mentions>
|
||||
<text-area-with-mentions
|
||||
[form]="this.threadReplyTextsFG[thread.toString()].get('replyText')"
|
||||
[planUsers]="planUsers"
|
||||
[clearCommentObservable]="clearCommentSubject.asObservable()"
|
||||
[threadId]="thread"
|
||||
></text-area-with-mentions>
|
||||
</div>
|
||||
<div class="col-auto p-0 send-msg">
|
||||
<button mat-icon-button (click)="replyThread(thread)" matTooltip="{{'ANNOTATION-DIALOG.THREADS.REPLY' | translate}}">
|
||||
|
|
|
@ -26,6 +26,7 @@ import { ConfigurationService } from '@app/core/services/configuration/configura
|
|||
import { MatSelectionList } from '@angular/material/list';
|
||||
import { PlanUser } from '@app/core/model/plan/plan';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
interface AnnotationPayloadItem {
|
||||
isMention: boolean;
|
||||
|
@ -68,6 +69,9 @@ export class AnnotationDialogComponent extends BaseComponent {
|
|||
|
||||
@ViewChild('annotationStatus') annotationStatus: MatSelectionList;
|
||||
|
||||
clearCommentSubject: Subject<any> = new Subject<any>();
|
||||
ROOT_COMMENT: string = 'root';
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<AnnotationDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
|
@ -119,7 +123,10 @@ export class AnnotationDialogComponent extends BaseComponent {
|
|||
};
|
||||
this.annotationService.persist(threadToCreate).pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
complete => {
|
||||
this.clearCommentSubject.next(this.ROOT_COMMENT);
|
||||
this.onCallbackSuccess();
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
|
@ -141,7 +148,10 @@ export class AnnotationDialogComponent extends BaseComponent {
|
|||
};
|
||||
this.annotationService.persist(replyToCreate).pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
complete => {
|
||||
this.clearCommentSubject.next(threadId);
|
||||
this.onCallbackSuccess()
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ export class TextAreaWithMentionsComponent implements OnInit, OnDestroy {
|
|||
|
||||
@Input() form!: FormControl;
|
||||
@Input() planUsers: PlanUser[];
|
||||
@Input() clearCommentObservable: Observable<any>;
|
||||
@Input() threadId: string;
|
||||
|
||||
internalFormSubscription: Subscription;
|
||||
clearInputSubscription: Subscription;
|
||||
|
@ -42,6 +44,16 @@ export class TextAreaWithMentionsComponent implements OnInit, OnDestroy {
|
|||
this.internalFormSubscription = this.internalForm.valueChanges.subscribe(value => {
|
||||
this.form.setValue(this._formatTextWithSelections(value, this.mentions));
|
||||
});
|
||||
|
||||
if (this.clearCommentObservable) {
|
||||
this.clearCommentObservable.subscribe(threadIdToClear => {
|
||||
if (threadIdToClear == this.threadId) {
|
||||
this.internalForm.reset();
|
||||
this.internalForm.markAsPristine();
|
||||
this.mentions = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
|
Loading…
Reference in New Issue