mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
committed by
Eugenio Romano
parent
61dff96e8b
commit
f36f9fa862
@@ -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/>');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user