diff --git a/projects/questionset-editor-library/src/lib/components/editor/editor.component.html b/projects/questionset-editor-library/src/lib/components/editor/editor.component.html index 636a14891..7cb41e7cd 100755 --- a/projects/questionset-editor-library/src/lib/components/editor/editor.component.html +++ b/projects/questionset-editor-library/src/lib/components/editor/editor.component.html @@ -1,8 +1,8 @@
- +
diff --git a/projects/questionset-editor-library/src/lib/components/header/header.component.html b/projects/questionset-editor-library/src/lib/components/header/header.component.html index 9d77741ab..2757f667c 100755 --- a/projects/questionset-editor-library/src/lib/components/header/header.component.html +++ b/projects/questionset-editor-library/src/lib/components/header/header.component.html @@ -181,9 +181,10 @@
+ [size]="'normal'" class="sb-modal bx-none overflow-modal comment-modal" appBodyScroll #modal (dismissed)="showRequestChangesPopup = false;">
- {{configService.labelConfig?.lbl?.addReviewComments}} +
{{configService.labelConfig?.lbl?.addReviewComments}}
+
@@ -198,12 +199,12 @@
- - + > {{configService.labelConfig?.button_labels?.save_draft_btn_label}} +
diff --git a/projects/questionset-editor-library/src/lib/components/header/header.component.scss b/projects/questionset-editor-library/src/lib/components/header/header.component.scss index 8420ee21f..016e05561 100755 --- a/projects/questionset-editor-library/src/lib/components/header/header.component.scss +++ b/projects/questionset-editor-library/src/lib/components/header/header.component.scss @@ -46,4 +46,4 @@ } .sb-modal-fullscreen .modals.dimmer .ui.scrolling.modal{ margin: 0 auto !important; -} +} \ No newline at end of file diff --git a/projects/questionset-editor-library/src/lib/components/header/header.component.spec.ts b/projects/questionset-editor-library/src/lib/components/header/header.component.spec.ts index 78be7763e..0bcd4c912 100755 --- a/projects/questionset-editor-library/src/lib/components/header/header.component.spec.ts +++ b/projects/questionset-editor-library/src/lib/components/header/header.component.spec.ts @@ -1,14 +1,16 @@ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; +import { ComponentFixture, TestBed, tick,fakeAsync, waitForAsync } from '@angular/core/testing'; import { HeaderComponent } from './header.component'; import { CUSTOM_ELEMENTS_SCHEMA, EventEmitter } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TelemetryInteractDirective } from '../../directives/telemetry-interact/telemetry-interact.directive'; import { EditorService } from '../../services/editor/editor.service'; +import { of } from 'rxjs/internal/observable/of'; describe('HeaderComponent', () => { let component: HeaderComponent; let fixture: ComponentFixture; + let editorService: EditorService; beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ @@ -23,6 +25,7 @@ describe('HeaderComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(HeaderComponent); component = fixture.componentInstance; + editorService = TestBed.inject(EditorService); // fixture.detectChanges(); }); @@ -57,11 +60,24 @@ describe('HeaderComponent', () => { component.handleActionButtons(); expect(component.visibility).toBeDefined(); }); - it('#openRequestChangePopup() should actionType defined', () => { + it('#openRequestChangePopup() should actionType defined', fakeAsync(() => { + component.questionSetId = '1234'; + const fakeComment = 'sample comment'; + const fakeApiResponse = { + result: { + comments: [ + { identifier: component.questionSetId, comment: fakeComment }, + ], + }, + }; + spyOn(editorService, 'readComment').and.returnValue(of(fakeApiResponse)); component.openRequestChangePopup('sendForCorrections'); - expect(component.showRequestChangesPopup).toBeTruthy(); + tick(); expect(component.actionType).toBe('sendForCorrections'); - }); + expect(component.showRequestChangesPopup).toBe(true); + expect(component.rejectComment).toBe(fakeComment); + expect(editorService.readComment).toHaveBeenCalledWith(component.questionSetId); + })); it('#buttonEmitter() should call buttonEmitter', () => { const data = { type: 'previewContent' }; spyOn(component.toolbarEmitter, 'emit'); diff --git a/projects/questionset-editor-library/src/lib/components/header/header.component.ts b/projects/questionset-editor-library/src/lib/components/header/header.component.ts index 28a605286..ebbe07fe1 100755 --- a/projects/questionset-editor-library/src/lib/components/header/header.component.ts +++ b/projects/questionset-editor-library/src/lib/components/header/header.component.ts @@ -13,6 +13,7 @@ import { NgForm } from '@angular/forms'; }) export class HeaderComponent implements OnDestroy, OnInit { @Input() pageId: any; + @Input() questionSetId: string; @Input() labelConfigData: any; @Input() buttonLoaders: any; @Input() publishchecklist: any; @@ -77,6 +78,9 @@ export class HeaderComponent implements OnDestroy, OnInit { openRequestChangePopup(action: string) { this.actionType = action; this.showRequestChangesPopup = true; + this.editorService.readComment(this.questionSetId).subscribe((res) => { + this.rejectComment = res.result.comments.find((item)=> item.identifier == this.questionSetId).comment; + }) } buttonEmitter(action) { @@ -103,6 +107,11 @@ export class HeaderComponent implements OnDestroy, OnInit { } } + saveDraftComments() { + this.editorService.updateComment(this.questionSetId,this.rejectComment) + .subscribe((res) => {}) + } + ngOnDestroy() { if (this?.modal && this?.modal?.deny) { this.modal.deny(); diff --git a/projects/questionset-editor-library/src/lib/services/config/label.config.json b/projects/questionset-editor-library/src/lib/services/config/label.config.json index 729e170ba..4ef8c07a2 100644 --- a/projects/questionset-editor-library/src/lib/services/config/label.config.json +++ b/projects/questionset-editor-library/src/lib/services/config/label.config.json @@ -39,6 +39,7 @@ "create_new_btn_label":"Create New", "add_from_library_btn_label":" Add from library", "submit_review_btn_label":"Submit Review", + "save_draft_btn_label":"Save as draft", "delete_btn_label":"Delete", "next_btn_label":"Next", "remove_btn_label":"Remove", diff --git a/projects/questionset-editor-library/src/lib/services/config/url.config.json b/projects/questionset-editor-library/src/lib/services/config/url.config.json index 9732d6e0a..866087290 100644 --- a/projects/questionset-editor-library/src/lib/services/config/url.config.json +++ b/projects/questionset-editor-library/src/lib/services/config/url.config.json @@ -11,7 +11,9 @@ "HIERARCHY_READ": "questionset/v2/hierarchy", "SYSYTEM_UPDATE": "questionset/v5/system/update/", "HIERARCHY_UPDATE": "questionset/v2/hierarchy/update", - "DEFAULT_PARAMS_FIELDS": "instructions,outcomeDeclaration" + "DEFAULT_PARAMS_FIELDS": "instructions,outcomeDeclaration", + "UPDATE_COMMENT":"questionset/v2/comment/update", + "READ_COMMENT":"questionset/v2/comment/read" }, "Question": { "HIERARCHY_READ": "questionset/v2/hierarchy", diff --git a/projects/questionset-editor-library/src/lib/services/editor/editor.service.spec.ts b/projects/questionset-editor-library/src/lib/services/editor/editor.service.spec.ts index aa4f06496..539f21dd8 100755 --- a/projects/questionset-editor-library/src/lib/services/editor/editor.service.spec.ts +++ b/projects/questionset-editor-library/src/lib/services/editor/editor.service.spec.ts @@ -486,4 +486,20 @@ describe('EditorService', () => { expect(config).toEqual({}); }); + it('#readComment() should read comments of questionset', async () => { + const publicDataService = TestBed.inject(PublicDataService); + spyOn(publicDataService, 'patch').and.returnValue(of(mockData.serverResponse)); + editorService.readComment('do_113941643543011328112').subscribe(data => { + expect(data.responseCode).toEqual('OK'); + }); + }); + + it('#updateComment() should update comments of questionset', async () => { + const publicDataService = TestBed.inject(PublicDataService); + spyOn(publicDataService, 'patch').and.returnValue(of(mockData.serverResponse)); + editorService.updateComment('do_113941643543011328112','sample comment').subscribe(data => { + expect(data.responseCode).toEqual('OK'); + }); + }); + }); diff --git a/projects/questionset-editor-library/src/lib/services/editor/editor.service.ts b/projects/questionset-editor-library/src/lib/services/editor/editor.service.ts index 724f604cb..56627a9fc 100755 --- a/projects/questionset-editor-library/src/lib/services/editor/editor.service.ts +++ b/projects/questionset-editor-library/src/lib/services/editor/editor.service.ts @@ -249,7 +249,34 @@ export class EditorService { return this.publicDataService.post(option); } - submitRequestChanges(contentId, comment) { + updateComment(contentId,comment): Observable { + const url = this.configService.urlConFig.URLS[this.editorConfig.config.objectType]; + const option = { + url: url.UPDATE_COMMENT, + data: { + request: { + comments : [ + { + identifier : contentId, + comment : comment + } + ] + } + } + }; + return this.publicDataService.patch(option); + } + + readComment(contentId:string): Observable { + const url = this.configService.urlConFig.URLS[this.editorConfig.config.objectType]; + const hierarchyUrl = `${url.READ_COMMENT}/${contentId}`; + const req = { + url: hierarchyUrl, + }; + return this.publicDataService.get(req); + } + + submitRequestChanges(contentId:string, comment:string) { let objType = this.configService.categoryConfig[this.editorConfig.config.objectType]; objType = objType.toLowerCase(); const url = this.configService.urlConFig.URLS[this.editorConfig.config.objectType];