[ADF-3374] Comments - add/view multiline comments (#3607)

* multiline comment

* add comment e2e

* fix locator syntax

* lint

* clear textarea on ESCAPE event

* multiline comment

* add comment e2e

* fix locator syntax

* lint

* clear textarea on ESCAPE event
This commit is contained in:
Cilibiu Bogdan
2018-07-27 22:24:29 +03:00
committed by Eugenio Romano
parent 61dff96e8b
commit f36f9fa862
7 changed files with 121 additions and 24 deletions

View File

@@ -126,9 +126,11 @@ export class CommentsComponent implements OnChanges {
add(): void {
if (this.message && this.message.trim() && !this.beingAdded) {
const comment = this.sanitize(this.message);
this.beingAdded = true;
if (this.isATask()) {
this.commentProcessService.addTaskComment(this.taskId, this.message)
this.commentProcessService.addTaskComment(this.taskId, comment)
.subscribe(
(res: CommentModel) => {
this.comments.unshift(res);
@@ -144,7 +146,7 @@ export class CommentsComponent implements OnChanges {
}
if (this.isANode()) {
this.commentContentService.addNodeComment(this.nodeId, this.message)
this.commentContentService.addNodeComment(this.nodeId, comment)
.subscribe(
(res: CommentModel) => {
this.comments.unshift(res);
@@ -176,4 +178,10 @@ export class CommentsComponent implements OnChanges {
isANode(): boolean {
return this.nodeId ? true : false;
}
private sanitize(input: string) {
return input.replace(/<[^>]+>/g, '')
.replace(/^\s+|\s+$|\s+(?=\s)/g, '')
.replace(/\r?\n/g, '<br/>');
}
}