From 0dea43a426e232b05705e937770880c9aac90f41 Mon Sep 17 00:00:00 2001 From: ramkumar-pacewisdom Date: Sun, 17 Dec 2023 19:59:13 +0530 Subject: [PATCH 1/5] reviewer save draft flow --- .../components/editor/editor.component.html | 4 +-- .../components/header/header.component.html | 15 +++++----- .../components/header/header.component.scss | 17 +++++++++++ .../header/header.component.spec.ts | 26 +++++++++++++---- .../lib/components/header/header.component.ts | 9 ++++++ .../src/lib/services/config/label.config.json | 1 + .../src/lib/services/config/url.config.json | 4 ++- .../src/lib/services/editor/editor.service.ts | 29 ++++++++++++++++++- 8 files changed, 89 insertions(+), 16 deletions(-) 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..3ad4bf9a8 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 @@ -47,3 +47,20 @@ .sb-modal-fullscreen .modals.dimmer .ui.scrolling.modal{ margin: 0 auto !important; } + +.sb-modal-header { + display: flex !important; + justify-content:space-between !important; +} + +// .sui-modal { +// position: fixed !important; +// bottom: 0 !important; +// right: 0 !important; +// } + +// .comment-modal { +// position: fixed !important; +// bottom: 0 !important; +// right: 0 !important; +// } 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..358583689 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', () => { +fdescribe('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 fdb1fc20f..572d529cb 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/v2/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": { "LIST":"question/v2/list", 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 6f07b404e..00ca02e4c 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 @@ -246,7 +246,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]; From 04fb90aa9f6c4b2ed5fe3f98d53c822ec40c1708 Mon Sep 17 00:00:00 2001 From: ramkumar-pacewisdom Date: Mon, 18 Dec 2023 08:48:33 +0530 Subject: [PATCH 2/5] code clean up --- .../components/header/header.component.scss | 19 +------------------ .../header/header.component.spec.ts | 2 +- 2 files changed, 2 insertions(+), 19 deletions(-) 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 3ad4bf9a8..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,21 +46,4 @@ } .sb-modal-fullscreen .modals.dimmer .ui.scrolling.modal{ margin: 0 auto !important; -} - -.sb-modal-header { - display: flex !important; - justify-content:space-between !important; -} - -// .sui-modal { -// position: fixed !important; -// bottom: 0 !important; -// right: 0 !important; -// } - -// .comment-modal { -// position: fixed !important; -// bottom: 0 !important; -// right: 0 !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 358583689..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 @@ -7,7 +7,7 @@ import { TelemetryInteractDirective } from '../../directives/telemetry-interact/ import { EditorService } from '../../services/editor/editor.service'; import { of } from 'rxjs/internal/observable/of'; -fdescribe('HeaderComponent', () => { +describe('HeaderComponent', () => { let component: HeaderComponent; let fixture: ComponentFixture; let editorService: EditorService; From 1d617590f99d1d77f01479fa279b5ae1d1d566f4 Mon Sep 17 00:00:00 2001 From: ramkumar-pacewisdom Date: Mon, 18 Dec 2023 15:07:13 +0530 Subject: [PATCH 3/5] test cases for service files --- .../lib/services/editor/editor.service.spec.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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..7e63e6293 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 @@ -16,7 +16,7 @@ import * as mockData from './editor.service.spec.data'; import { map } from 'rxjs/operators'; import * as _ from 'lodash-es'; -describe('EditorService', () => { +fdescribe('EditorService', () => { let editorService: EditorService; let treeService; const configStub = { @@ -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_1234').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_1234','sample comment').subscribe(data => { + expect(data.responseCode).toEqual('OK'); + }); + }); + }); From 3b4966223bc08dbb1be31862c87958df4a29f0b0 Mon Sep 17 00:00:00 2001 From: ramkumar-pacewisdom Date: Mon, 18 Dec 2023 19:47:22 +0530 Subject: [PATCH 4/5] remove test describe --- .../src/lib/services/editor/editor.service.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7e63e6293..7b85a6f92 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 @@ -16,7 +16,7 @@ import * as mockData from './editor.service.spec.data'; import { map } from 'rxjs/operators'; import * as _ from 'lodash-es'; -fdescribe('EditorService', () => { +describe('EditorService', () => { let editorService: EditorService; let treeService; const configStub = { From 4df5ba2a201064ce2519a92df53b4c6b5b937dd0 Mon Sep 17 00:00:00 2001 From: ramkumar-pacewisdom Date: Mon, 18 Dec 2023 20:05:03 +0530 Subject: [PATCH 5/5] read comment test case fail fix --- .../src/lib/services/editor/editor.service.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 7b85a6f92..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 @@ -489,7 +489,7 @@ describe('EditorService', () => { it('#readComment() should read comments of questionset', async () => { const publicDataService = TestBed.inject(PublicDataService); spyOn(publicDataService, 'patch').and.returnValue(of(mockData.serverResponse)); - editorService.readComment('do_1234').subscribe(data => { + editorService.readComment('do_113941643543011328112').subscribe(data => { expect(data.responseCode).toEqual('OK'); }); }); @@ -497,7 +497,7 @@ describe('EditorService', () => { it('#updateComment() should update comments of questionset', async () => { const publicDataService = TestBed.inject(PublicDataService); spyOn(publicDataService, 'patch').and.returnValue(of(mockData.serverResponse)); - editorService.updateComment('do_1234','sample comment').subscribe(data => { + editorService.updateComment('do_113941643543011328112','sample comment').subscribe(data => { expect(data.responseCode).toEqual('OK'); }); });