From ebf50fca36c2bed08ba60d3e99443e03c0b7ab85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Fri, 30 Sep 2022 09:35:46 +0200 Subject: [PATCH 1/4] Use report endpoints instead of document --- .../document-detail.component.ts | 6 ++-- src/app/services/document.service.ts | 30 ------------------- src/app/services/report.service.ts | 17 +++++++++++ 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index 4b1f057..ff0d293 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -445,11 +445,11 @@ export class DocumentDetailComponent implements OnInit { } updateFinding(data) { - const id = +this.route.snapshot.paramMap.get('id'); + const reportId = this.report.id; if (data.status == Status.ADDED) { - this.documentService.addFinding(id, data).subscribe(_ => { }); + this.reportService.addFinding(reportId, data.section, data).subscribe(_ => { }); } else { - this.documentService.updateFinding(id, data) + this.reportService.updateFinding(reportId, data.section, data) .subscribe(text => { }); } diff --git a/src/app/services/document.service.ts b/src/app/services/document.service.ts index 6f91a5b..42391ab 100644 --- a/src/app/services/document.service.ts +++ b/src/app/services/document.service.ts @@ -7,7 +7,6 @@ import { catchError, map, tap } from 'rxjs/operators'; import { Finding } from '../model/finding'; import { environment } from '../../environments/environment'; import { DocumentTracking } from '../model/document-tracking'; -import { SRDomainFinding } from '../model/srdomainfinding'; import { SRDomainDocument } from '../model/srdomaindocument'; const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }) @@ -97,35 +96,6 @@ export class DocumentService { ); } - /** Update Finding */ - updateFinding(id: number, finding: SRDomainFinding): any { - const url = `${this.documentsUrl}${id}/srfinding/update/`; - return this.http.put(url, finding).pipe( - tap(_ => this.log(`updateFinding`)), - catchError(this.handleError('updateFinding')) - ); - /*return this.http.post(url, finding).subscribe({ - next: data => { - alert(1); - alert(data); - }, - error: error => { - //this.errorMessage = error.message; - console.error('There was an error!', error); - } - })*/ - - } - - addFinding(id: number, finding: SRDomainFinding): any { - const url = `${this.documentsUrl}${id}/srfinding/add/`; - return this.http.put(url, finding).pipe( - tap(_ => this.log(`addFinding`)), - catchError(this.handleError('addFinding')) - ); - } - - /** show history tracking */ getHistory(id: number): Observable { const url = `${this.documentsUrl}${id}/tracking`; diff --git a/src/app/services/report.service.ts b/src/app/services/report.service.ts index 55db43b..3829dfb 100644 --- a/src/app/services/report.service.ts +++ b/src/app/services/report.service.ts @@ -7,6 +7,7 @@ import { Finding } from '../model/finding'; import { Annotation } from '../model/annotation'; import { Report } from '../model/report'; import { environment } from '../../environments/environment'; +import { SRDomainFinding } from '../model/srdomainfinding'; const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }) }; @@ -132,6 +133,22 @@ export class ReportService { ); } + updateFinding(reportId: string, sectionName: string, finding: SRDomainFinding): any { + const url = `${this.reportsUrl}${reportId}/${sectionName}/srfinding/update/`; + return this.http.put(url, finding).pipe( + tap(_ => this.log(`updateFinding`)), + catchError(this.handleError('updateFinding')) + ); + } + + addFinding(reportId: string, sectionName: string, finding: SRDomainFinding): any { + const url = `${this.reportsUrl}${reportId}/${sectionName}/srfinding/add/`; + return this.http.put(url, finding).pipe( + tap(_ => this.log(`addFinding`)), + catchError(this.handleError('addFinding')) + ); + } + /** Log a DocumentService message with the MessageService */ private log(message: string) { this.messageService.add(`DocumentService: ${message}`); -- GitLab From 7d733d045381550cc7b20bc554db118f44ff8aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Fri, 30 Sep 2022 15:45:50 +0200 Subject: [PATCH 2/4] Change requests to update and add findings --- .../document-detail.component.ts | 12 +-- src/app/documents/documents.component.ts | 8 +- src/app/model/srdomainfinding.ts | 57 +++++++------- .../pretoxsentences-tabulator.component.ts | 18 ++--- src/app/reports/reports.component.ts | 6 +- src/app/services/login.service.ts | 4 +- src/app/services/report.service.ts | 8 +- .../srdomaintemplate-tabulator.component.ts | 76 ++++++++----------- 8 files changed, 89 insertions(+), 100 deletions(-) diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index ff0d293..05b810d 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -220,6 +220,7 @@ export class DocumentDetailComponent implements OnInit { const currentFinding = ({ studyid: srDomainFinding.studyid, domain: srDomainFinding.domain, + section: section.name, srseq: srDomainFinding.srseq, srrisk: srDomainFinding.srrisk, @@ -255,7 +256,7 @@ export class DocumentDetailComponent implements OnInit { srDomainId: srDomainFinding.srDomainId, findingId: srDomainFinding.findingId, status: srDomainFinding.status, - section: section.name, + sectionId: section.id, documentId: section.annotations.documentId }); @@ -274,8 +275,8 @@ export class DocumentDetailComponent implements OnInit { }); }); - if (section.annotations.srdomainfindings) { - section.annotations.srdomainfindings.forEach(newFinding => { + if (section.annotations.srDomainFindings) { + section.annotations.srDomainFindings.forEach(newFinding => { srDomainFindingsGlobal.push(newFinding); }); } @@ -445,11 +446,10 @@ export class DocumentDetailComponent implements OnInit { } updateFinding(data) { - const reportId = this.report.id; if (data.status == Status.ADDED) { - this.reportService.addFinding(reportId, data.section, data).subscribe(_ => { }); + this.reportService.addFinding(data.sectionId, data).subscribe(_ => { }); } else { - this.reportService.updateFinding(reportId, data.section, data) + this.reportService.updateFinding(data.sectionId, data) .subscribe(text => { }); } diff --git a/src/app/documents/documents.component.ts b/src/app/documents/documents.component.ts index ab0feb6..759b5be 100644 --- a/src/app/documents/documents.component.ts +++ b/src/app/documents/documents.component.ts @@ -82,10 +82,10 @@ export class DocumentsComponent implements OnInit { paginationSize: 20, paginationSizeSelector: [10, 20, 40], columns: [ - { title: 'Name', field: 'name', headerSort: true, headerFilter: true }, - { title: 'File Name', field: 'fileName', headerSort: true, headerFilter: true }, - { title: 'Process Date', field: 'processDate', headerSort: true, headerFilter: true }, - { title: 'Status', field: 'status', headerSort: true, headerFilter: true }, + { title: 'Name', field: 'name', headerFilter: true }, + { title: 'File Name', field: 'fileName', headerFilter: true }, + { title: 'Process Date', field: 'processDate', headerFilter: true }, + { title: 'Status', field: 'status', headerFilter: true }, { title: '', width: 5, hozAlign: 'center', headerSort: false, cellClick: function (e, cell) { diff --git a/src/app/model/srdomainfinding.ts b/src/app/model/srdomainfinding.ts index 7f6dfeb..56897dd 100644 --- a/src/app/model/srdomainfinding.ts +++ b/src/app/model/srdomainfinding.ts @@ -1,34 +1,35 @@ export class SRDomainFinding { - studyid: String; - domain: String; - section: String; - srseq: String; - srrisk: String; - spgrpcd: String; - srgrpnam: String;; - srgrpdos: String; - srsex: String; - srstdy: String; - srstphse: String; - srobstdy: String; - srendy: String; - srenphse: String; - srobendy: String; - srdomain: String; - srspec: String; - srtstcd: String; - srfndg: String; - srores: String; - srobsv: String; - srobsq: String; - srsev: String; - srpcnt: String; - srsigf: String; - srtrtef: String; - srcomnt: String; + studyid: string; + domain: string; + section: string; + srseq: string; + srrisk: string; + spgrpcd: string; + srgrpnam: string;; + srgrpdos: string; + srsex: string; + srstdy: string; + srstphse: string; + srobstdy: string; + srendy: string; + srenphse: string; + srobendy: string; + srdomain: string; + srspec: string; + srtstcd: string; + srfndg: string; + srores: string; + srobsv: string; + srobsq: string; + srsev: string; + srpcnt: string; + srsigf: string; + srtrtef: string; + srcomnt: string; //other data - export: String; + export: string; srDomainId: number; findingId: number; status: string; + sectionId: number; } diff --git a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts index cf298f2..1ee9bad 100644 --- a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts +++ b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts @@ -199,11 +199,11 @@ export class PretoxsentencesTabulatorComponent implements OnInit { { title: 'Section', field: 'section', cssClass: "tabulator-cell non-editable-cell", }, - { title: 'Finding', field: 'srfndg', headerSort: true, headerFilter: true },//SRFNDG + { title: 'Finding', field: 'srfndg', headerFilter: true },//SRFNDG //{title: 'Finding (Free Text)', field: 'srores', headerSort: true , headerFilter: false},//SRORES - { title: 'Test Name', field: 'srtstcd', headerSort: true, headerFilter: true },//SRTSTCD + { title: 'Test Name', field: 'srtstcd', headerFilter: true },//SRTSTCD { - title: 'Manifestation', field: 'srobsv', headerSort: true, headerFilter: true, editor: 'list', editable: false, editorParams: { + title: 'Manifestation', field: 'srobsv', headerFilter: true, editor: 'list', editable: false, editorParams: { values: [ 'I', 'D', @@ -214,16 +214,16 @@ export class PretoxsentencesTabulatorComponent implements OnInit { } },//SROBSV { - title: 'Domain', field: 'srdomain', headerSort: true, headerFilter: true, editor: 'list', editable: false, editorParams: { + title: 'Domain', field: 'srdomain', headerFilter: true, editor: 'list', editable: false, editorParams: { values: [ 'BW', 'BG', 'CL', 'CV', 'DD', 'EG', 'FW', 'LB', 'MA', 'MI', 'OM', 'PP', 'RE', 'TF', 'VS' ], autocomplete: true } },//SRDOMAIN - { title: 'Specimen', field: 'srspec', headerSort: true, headerFilter: true },//SRSPEC + { title: 'Specimen', field: 'srspec', headerFilter: true },//SRSPEC { - title: 'Sex', field: 'srsex', headerSort: true, headerFilter: true, editor: 'list', editable: false, editorParams: { + title: 'Sex', field: 'srsex', headerFilter: true, editor: 'list', editable: false, editorParams: { values: [ 'F', 'M', @@ -232,10 +232,10 @@ export class PretoxsentencesTabulatorComponent implements OnInit { autocomplete: true } },//SRSEX - { title: 'Dose', field: 'srgrpdos', headerSort: true, headerFilter: true },//SRGRPDOS - { title: 'Group', field: 'spgrpcd', headerSort: true, headerFilter: true },//SPGRPCD + { title: 'Dose', field: 'srgrpdos', headerFilter: true },//SRGRPDOS + { title: 'Group', field: 'spgrpcd', headerFilter: true },//SPGRPCD { - title: 'Treatment Related?', field: 'srtrtef', headerSort: true, headerFilter: true, editor: 'list', editable: false, editorParams: { + title: 'Treatment Related?', field: 'srtrtef', headerFilter: true, editor: 'list', editable: false, editorParams: { values: [ 'Y', 'N', diff --git a/src/app/reports/reports.component.ts b/src/app/reports/reports.component.ts index 6e74597..81d9c1a 100644 --- a/src/app/reports/reports.component.ts +++ b/src/app/reports/reports.component.ts @@ -169,9 +169,9 @@ export class ReportsComponent implements OnInit { return '
'; } }, - { title: 'Name', field: 'fileName', headerSort: true, headerFilter: true }, - { title: 'Upload Date', field: 'uploadDate', headerSort: true, headerFilter: true }, - { title: 'Status', field: 'status', headerSort: true, headerFilter: true }, + { title: 'Name', field: 'fileName', headerFilter: true }, + { title: 'Upload Date', field: 'uploadDate', headerFilter: true }, + { title: 'Status', field: 'status', headerFilter: true }, { title: '', width: 5, hozAlign: 'center', headerSort: false, cellClick: function (e, cell) { diff --git a/src/app/services/login.service.ts b/src/app/services/login.service.ts index ed8a6e2..6fa98bc 100644 --- a/src/app/services/login.service.ts +++ b/src/app/services/login.service.ts @@ -13,8 +13,8 @@ export class LoginService { USER_NAME_SESSION_ATTRIBUTE_NAME = 'authenticatedUser'; USER_BASIC_TOKEN_ATTRIBUTE_NAME = 'tokenUser'; - public username: String; - public password: String; + public username: string; + public password: string; public isLogged: boolean; diff --git a/src/app/services/report.service.ts b/src/app/services/report.service.ts index 3829dfb..538f5de 100644 --- a/src/app/services/report.service.ts +++ b/src/app/services/report.service.ts @@ -133,16 +133,16 @@ export class ReportService { ); } - updateFinding(reportId: string, sectionName: string, finding: SRDomainFinding): any { - const url = `${this.reportsUrl}${reportId}/${sectionName}/srfinding/update/`; + updateFinding(sectionId: number, finding: SRDomainFinding): any { + const url = `${this.reportsUrl}${sectionId}/srfinding/update/`; return this.http.put(url, finding).pipe( tap(_ => this.log(`updateFinding`)), catchError(this.handleError('updateFinding')) ); } - addFinding(reportId: string, sectionName: string, finding: SRDomainFinding): any { - const url = `${this.reportsUrl}${reportId}/${sectionName}/srfinding/add/`; + addFinding(sectionId: number, finding: SRDomainFinding): any { + const url = `${this.reportsUrl}${sectionId}/srfinding/add/`; return this.http.put(url, finding).pipe( tap(_ => this.log(`addFinding`)), catchError(this.handleError('addFinding')) diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index 3c79d23..6f4d0d5 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -16,7 +16,7 @@ import { Section } from '../model/section'; }) export class SrdomaintemplateTabulatorComponent implements OnInit { - currentSection: string; + currentSection: Section; tableData: any[] = []; table: Tabulator; originalData: any[] = []; @@ -66,7 +66,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } loadData(parentComponent, update) { - this.currentSection = parentComponent.currentSection && parentComponent.currentSection.name; + this.currentSection = parentComponent.currentSection; this.report = parentComponent.report; this.tableData = parentComponent.tableDataSRDomainTemplate; this.originalData = cloneDeep(parentComponent.tableDataSRDomainTemplate); @@ -86,7 +86,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } paramLookupGeneric(cell) { - var v = [] + var values = [] var field = cell.getColumn().getField(); var rowNum = cell.getRow().getData().findingId; var originalValue = rowNum < this.originalData.length ? this.originalData[rowNum - 1][field] : null; @@ -105,13 +105,19 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { codeLists = this.cdiscSendCTService.finding_list; } else if (field == "srobsv") { // manifestation constantValues = this.cdiscSendCTService.manifestation_finding_list; + } else if (field == "section") { + values = this.report.sections.map(section => section.name); + } + + if (values[0] != undefined && values.includes(originalValue)) { + originalIsCodedValue = true; } if (codeLists != undefined && codeLists[0] != undefined) { codeLists.forEach(codeList => { codeList.codedValues.forEach(codedValue => { originalIsCodedValue = originalValue == codedValue.preferredTerm; - v.push({ + values.push({ label: codedValue.preferredTerm, value: codedValue.preferredTerm, name: codedValue.name, @@ -124,7 +130,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { if (constantValues[0] != undefined) { constantValues.forEach(value => { originalIsCodedValue = originalValue == value; - v.push({ + values.push({ label: value, value: value, name: value, @@ -133,7 +139,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }) } - if (originalValue != null && originalValue != undefined && !originalIsCodedValue) v.push({ + if (originalValue != null && originalValue != undefined && !originalIsCodedValue) values.push({ label: originalValue, value: originalValue, name: originalValue, @@ -143,7 +149,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { return { autocomplete: true, freetext: true, - values: v, + values: values, sort: "asc", listOnEmpty: true, itemFormatter: function (label, value, item, element) { @@ -158,26 +164,6 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } } - paramLookupStudyDomain(cell) { - return this.paramLookupGeneric(cell); - } - - paramLookupManifestation(cell) { - return this.paramLookupGeneric(cell); - } - - paramLookupStudyTest(cell) { - return this.paramLookupGeneric(cell); - } - - paramLookupSpecies(cell) { - return this.paramLookupGeneric(cell); - } - - paramLookupFinding(cell) { - return this.paramLookupGeneric(cell); - } - onStudyDomainChange(cell) { var srdomainCode = this.cdiscSendCTService.getStudyDomainCode(cell.getValue()) var cellData = cell.getRow().getData() @@ -192,7 +178,8 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { newFinding.srDomainId = findingId; newFinding.findingId = findingId; newFinding.status = Status.ADDED; - newFinding.section = this.currentSection; + newFinding.section = this.currentSection && this.currentSection.name; + newFinding.sectionId = this.currentSection && this.currentSection.id; this.tableData.push(newFinding); this.table.addRow(newFinding); @@ -331,7 +318,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { cellClick: function (e, cell) { var row = cell.getRow(); var data = cell.getRow().getData(); - if (data.inEdition == true) { + if (data.inEdition == true && data.sectionId != undefined) { data.inEdition = false; pretoxSRDomainTemplateTab.report.findingInEdition = -1; pretoxSRDomainTemplateTab.enableAddFindingEvent.emit(true); @@ -352,42 +339,43 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { title: '', width: 5, field: 'srDomainId', cssClass: "tabulator-cell non-editable-cell", }, { - title: 'Section', field: 'section', cssClass: "tabulator-cell non-editable-cell", + title: 'Section', field: 'section', cssClass: "tabulator-cell non-editable-cell", editor: 'list', editable: this.editCheck.bind(this), + editorParams: this.paramLookupGeneric.bind(this), sorter: "string" }, { - title: 'Finding', field: 'srfndg', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'list', editable: this.editCheck.bind(this), - editorParams: this.paramLookupFinding.bind(this), sorter: "string", formatter: this.ellipsisFormatter + title: 'Finding', field: 'srfndg', cssClass: "tabulator-cell non-editable-cell", editor: 'list', editable: this.editCheck.bind(this), + editorParams: this.paramLookupGeneric.bind(this), sorter: "string", formatter: this.ellipsisFormatter }, { - title: 'Test Name', field: 'srtstcd', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'list', editable: this.editCheck.bind(this), - editorParams: this.paramLookupStudyTest.bind(this), sorter: "string", formatter: this.ellipsisFormatter + title: 'Test Name', field: 'srtstcd', cssClass: "tabulator-cell non-editable-cell", editor: 'list', editable: this.editCheck.bind(this), + editorParams: this.paramLookupGeneric.bind(this), sorter: "string", formatter: this.ellipsisFormatter }, { - title: 'Manifestation', field: 'srobsv', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editable: this.editCheck.bind(this), editor: 'list', - editorParams: this.paramLookupManifestation.bind(this) + title: 'Manifestation', field: 'srobsv', cssClass: "tabulator-cell non-editable-cell", editable: this.editCheck.bind(this), editor: 'list', + editorParams: this.paramLookupGeneric.bind(this) }, { - title: 'Domain', field: 'srdomain', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'list', editable: this.editCheck.bind(this), - editorParams: this.paramLookupStudyDomain.bind(this), sorter: "string", formatter: this.ellipsisFormatter, + title: 'Domain', field: 'srdomain', cssClass: "tabulator-cell non-editable-cell", editor: 'list', editable: this.editCheck.bind(this), + editorParams: this.paramLookupGeneric.bind(this), sorter: "string", formatter: this.ellipsisFormatter, cellEdited: this.onStudyDomainChange.bind(this) }, { - title: 'Specimen', field: 'srspec', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'list', editable: this.editCheck.bind(this), - editorParams: this.paramLookupSpecies.bind(this), sorter: "string", formatter: this.ellipsisFormatter + title: 'Specimen', field: 'srspec', cssClass: "tabulator-cell non-editable-cell", editor: 'list', editable: this.editCheck.bind(this), + editorParams: this.paramLookupGeneric.bind(this), sorter: "string", formatter: this.ellipsisFormatter }, { - title: 'Sex', field: 'srsex', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'list', editable: this.editCheck.bind(this), editorParams: { + title: 'Sex', field: 'srsex', cssClass: "tabulator-cell non-editable-cell", editor: 'list', editable: this.editCheck.bind(this), editorParams: { values: ['Female', 'Male', 'Both'] } }, { - title: 'Dose', field: 'srgrpdos', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'input', editable: this.editCheck.bind(this) + title: 'Dose', field: 'srgrpdos', cssClass: "tabulator-cell non-editable-cell", editor: 'input', editable: this.editCheck.bind(this) }, { - title: 'Group', field: 'spgrpcd', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'input', editable: this.editCheck.bind(this), + title: 'Group', field: 'spgrpcd', cssClass: "tabulator-cell non-editable-cell", editor: 'input', editable: this.editCheck.bind(this), }, { - title: 'Treatment Related?', field: 'srtrtef', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'list', editable: this.editCheck.bind(this), editorParams: { + title: 'Treatment Related?', field: 'srtrtef', cssClass: "tabulator-cell non-editable-cell", editor: 'list', editable: this.editCheck.bind(this), editorParams: { values: ['Yes', 'No', 'Uncertain'] } }, -- GitLab From 1427c3821a4530dca5d907c618e200b9e33db39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Mon, 3 Oct 2022 10:03:51 +0200 Subject: [PATCH 3/4] Enable new finding after section change --- .../srdomaintemplate-tabulator.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index 6f4d0d5..73a4838 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -72,9 +72,10 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { this.originalData = cloneDeep(parentComponent.tableDataSRDomainTemplate); if (update) { this.table.setData(this.tableData); + this.enableAddFindingEvent.emit(true); } else { this.drawTable(this); - } + } } editCheck(cell) { -- GitLab From 69f4ad586d3ccebd83d239afa354cc9d78b054dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Mon, 3 Oct 2022 11:54:06 +0200 Subject: [PATCH 4/4] Fix new finding update --- .../document-detail.component.ts | 5 ++-- src/app/model/srdomainfindingstatus.ts | 3 +- .../srdomaintemplate-tabulator.component.ts | 30 ++++++++++++------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index 05b810d..2c1101f 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -446,8 +446,9 @@ export class DocumentDetailComponent implements OnInit { } updateFinding(data) { - if (data.status == Status.ADDED) { - this.reportService.addFinding(data.sectionId, data).subscribe(_ => { }); + if (data.status == Status.NEW) { + data.status = Status.ADDED + this.reportService.addFinding(data.sectionId, data).subscribe(_ => { }, error => { data.status = Status.NEW }); } else { this.reportService.updateFinding(data.sectionId, data) .subscribe(text => { diff --git a/src/app/model/srdomainfindingstatus.ts b/src/app/model/srdomainfindingstatus.ts index 85adb54..5e4c6e2 100644 --- a/src/app/model/srdomainfindingstatus.ts +++ b/src/app/model/srdomainfindingstatus.ts @@ -2,5 +2,6 @@ export enum Status { NON_CURATED = "non_curated", REJECTED = "rejected", ACCEPTED = "accepted", - ADDED = "added" + ADDED = "added", + NEW = "new" } \ No newline at end of file diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index 73a4838..68e938d 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -17,6 +17,7 @@ import { Section } from '../model/section'; export class SrdomaintemplateTabulatorComponent implements OnInit { currentSection: Section; + sections: Section[]; tableData: any[] = []; table: Tabulator; originalData: any[] = []; @@ -70,6 +71,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { this.report = parentComponent.report; this.tableData = parentComponent.tableDataSRDomainTemplate; this.originalData = cloneDeep(parentComponent.tableDataSRDomainTemplate); + this.sections = parentComponent.sections; if (update) { this.table.setData(this.tableData); this.enableAddFindingEvent.emit(true); @@ -165,6 +167,12 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } } + onSectionChange(cell) { + const cellData = cell.getRow().getData(); + const selectedSection = this.sections.find(section => section.name == cellData.section); + cellData.sectionId = selectedSection.id; + } + onStudyDomainChange(cell) { var srdomainCode = this.cdiscSendCTService.getStudyDomainCode(cell.getValue()) var cellData = cell.getRow().getData() @@ -178,7 +186,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { newFinding.studyid = this.report.id + "_" + this.report.fileName; newFinding.srDomainId = findingId; newFinding.findingId = findingId; - newFinding.status = Status.ADDED; + newFinding.status = Status.NEW; newFinding.section = this.currentSection && this.currentSection.name; newFinding.sectionId = this.currentSection && this.currentSection.id; @@ -187,6 +195,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } private drawTable(pretoxSRDomainTemplateTab): void { + const newStatus = Status.NEW; const addedStatus = Status.ADDED; const acceptedStatus = Status.ACCEPTED; const rejectedStatus = Status.REJECTED @@ -203,7 +212,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { title: '', width: 5, hozAlign: 'center', headerSort: false, cssClass: "tabulator-cell non-editable-cell", cellClick: function (e, cell) { var data = cell.getRow().getData(); - if (data.status != addedStatus) { + if (data.status != addedStatus || data.status != newStatus) { if (data.status == acceptedStatus) { data.status = rejectedStatus; cell.getElement().innerHTML = '
'; @@ -220,7 +229,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); - if (data.status == addedStatus) { + if (data.status == addedStatus || data.status == newStatus) { return '
'; } else if (data.status == acceptedStatus) { return '
'; @@ -235,7 +244,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { title: '', width: 5, hozAlign: 'center', headerSort: false, cssClass: "tabulator-cell non-editable-cell", cellClick: function (e, cell) { var data = cell.getRow().getData(); - if (data.status != addedStatus) { + if (data.status != addedStatus || data.status != newStatus) { if (data.export == undefined || data.export == true) { data.export = false; cell.getElement().innerHTML = '
'; @@ -249,7 +258,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); - if (data.status == addedStatus) { + if (data.status == addedStatus || data.status == newStatus) { return '
'; } @@ -263,17 +272,18 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { { title: '', width: 5, hozAlign: 'center', headerSort: false, cssClass: "tabulator-cell non-editable-cell", cellClick: function (e, cell) { - if (cell.getRow().getData().status != addedStatus && cell.getRow().getData().selected != true) { - cell.getRow().getData().selected = true; + const cellData = cell.getRow().getData(); + if (cellData.status != addedStatus && cellData.status != newStatus && cellData.selected != true) { + cellData.selected = true; cell.getRow().getElement().className = "tabulator-row evidence-selected"; pretoxSRDomainTemplateTab.rowClickEventSRDomainTemplateEvidence.emit(cell.getData()); } else { - cell.getRow().getData().selected = false; + cellData.selected = false; cell.getRow().getElement().className = "tabulator-row"; } }, formatter: function (cell, formatterParams, onRendered) { - if (cell.getRow().getData().status == addedStatus) { + if (cell.getRow().getData().status == addedStatus || cell.getRow().getData().status == newStatus) { return '
'; } @@ -341,7 +351,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }, { title: 'Section', field: 'section', cssClass: "tabulator-cell non-editable-cell", editor: 'list', editable: this.editCheck.bind(this), - editorParams: this.paramLookupGeneric.bind(this), sorter: "string" + editorParams: this.paramLookupGeneric.bind(this), sorter: "string", cellEdited: this.onSectionChange.bind(this) }, { title: 'Finding', field: 'srfndg', cssClass: "tabulator-cell non-editable-cell", editor: 'list', editable: this.editCheck.bind(this), -- GitLab