From acb8b4063eedef5a47b30f20bffe294d3c941c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Thu, 18 Aug 2022 16:51:06 +0200 Subject: [PATCH 01/17] Add button to add dummy finding --- .../document-detail.component.ts | 6 +- src/app/shared.service.ts | 11 +++ .../srdomaintemplate-tabulator.component.ts | 96 ++++++++++++++++++- 3 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 src/app/shared.service.ts diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index 635fa35..214bfc3 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -81,7 +81,7 @@ export class DocumentDetailComponent implements OnInit { static FINISHED = 'FINISHED'; // tslint:disable-next-line: max-line-length - constructor(private router: Router, private route: ActivatedRoute, private documentService: DocumentService, private cdiscSendCTService: CdisSendCtService, private location: Location, private sanitizer: DomSanitizer) { + constructor(private router: Router, private route: ActivatedRoute, private documentService: DocumentService, private cdiscSendCTService: CdisSendCtService, private location: Location, private sanitizer: DomSanitizer, private sharedService: SharedService) { const bratLocation = environment.bratUrl; head.js( @@ -594,6 +594,10 @@ export class DocumentDetailComponent implements OnInit { this.documentService.exportDocument(id, this.document.name); } + addFinding() { + this.sharedService.addFindingEvent.emit(); + } + onActivate(componentReference) { componentReference.activation(this.document); diff --git a/src/app/shared.service.ts b/src/app/shared.service.ts new file mode 100644 index 0000000..6524c69 --- /dev/null +++ b/src/app/shared.service.ts @@ -0,0 +1,11 @@ +import { EventEmitter, Injectable } from "@angular/core"; + +@Injectable({ + providedIn: 'root' +}) +export class SharedService { + + addFindingEvent: EventEmitter = new EventEmitter(); + + constructor() { } +} \ 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 674dcfa..fd397b7 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -5,6 +5,7 @@ import { ActivatedRoute } from '@angular/router'; import { DocumentService } from '../document.service'; import { Document } from '../document'; import { cloneDeep } from 'lodash'; +import { SharedService } from '../shared.service'; @Component({ selector: 'app-srdomaintemplate-tabulator', @@ -14,6 +15,7 @@ import { cloneDeep } from 'lodash'; export class SrdomaintemplateTabulatorComponent implements OnInit { tableData: any[] = []; + table: Tabulator; originalData: any[] = []; @Input() document: Document; @@ -27,7 +29,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { tab = document.createElement('div'); - constructor(private route: ActivatedRoute, private documentService: DocumentService,private cdiscSendCTService: CdisSendCtService,) { } + constructor(private route: ActivatedRoute, private documentService: DocumentService,private cdiscSendCTService: CdisSendCtService, private sharedService: SharedService) { } ellipsisFormatter(cell, formatterParams, onRendered) { onRendered(function(){ @@ -40,6 +42,9 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { ngOnInit(): void { this.getDocument(); + this.sharedService.addFindingEvent.subscribe(() => { + this.addFinding(); + }) } activation(data){ @@ -66,7 +71,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { var v = [] var field = cell.getColumn().getField(); var rowNum = cell.getRow().getData().findingId; - var originalValue = this.originalData[rowNum - 1][field]; + var originalValue = rowNum < this.table.getDataCount() ? this.originalData[rowNum - 1][field] : null; var originalIsCodedValue = false; var codeLists = []; var constantValues = []; @@ -224,8 +229,91 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }); } + addFinding() { + console.log("new finding"); + const findingId = this.table.getDataCount(); + this.tableData.push({ + studyid: "srDomainFinding.studyid", + domain: "srDomainFinding.domain", + srseq: "srDomainFinding.srseq", + srrisk: "srDomainFinding.srrisk", + + spgrpcd: "srDomainFinding.spgrpcd", + grplbl: "srDomainFinding.grplbl", + srgrpdos: "srDomainFinding.srgrpdos", + srsex: "srDomainFinding.srsex", + + srstdy: "srDomainFinding.srstdy", + srstphse: "srDomainFinding.srstphse", + srobstdy: "srDomainFinding.srobstdy", + srendy: "srDomainFinding.srendy", + + + srenphse: "srDomainFinding.srenphse", + srobendy: "srDomainFinding.srobendy", + srdomain: "srDomainFinding.srdomain", + srspec: "srDomainFinding.srspec", + + srtstcd: "srDomainFinding.srtstcd", + srfndg: "srDomainFinding.srfndg", + srores: "srDomainFinding.srores", + srobsv: "srDomainFinding.srobsv", + + srobsq: "srDomainFinding.srobsq", + srsev: "srDomainFinding.srsev", + srpcnt: "srDomainFinding.srpcnt", + srsigf: "srDomainFinding.srsigf", + + srtrtef: "srDomainFinding.srpcnt", + srcomnt: "srDomainFinding.srsigf", + + export: "srDomainFinding.export", + srDomainId: "srDomainFinding.srDomainId", + findingId: findingId + }); + this.table.addRow({ + studyid: "srDomainFinding.studyid", + domain: "srDomainFinding.domain", + srseq: "srDomainFinding.srseq", + srrisk: "srDomainFinding.srrisk", + + spgrpcd: "srDomainFinding.spgrpcd", + grplbl: "srDomainFinding.grplbl", + srgrpdos: "srDomainFinding.srgrpdos", + srsex: "srDomainFinding.srsex", + + srstdy: "srDomainFinding.srstdy", + srstphse: "srDomainFinding.srstphse", + srobstdy: "srDomainFinding.srobstdy", + srendy: "srDomainFinding.srendy", + + + srenphse: "srDomainFinding.srenphse", + srobendy: "srDomainFinding.srobendy", + srdomain: "srDomainFinding.srdomain", + srspec: "srDomainFinding.srspec", + + srtstcd: "srDomainFinding.srtstcd", + srfndg: "srDomainFinding.srfndg", + srores: "srDomainFinding.srores", + srobsv: "srDomainFinding.srobsv", + + srobsq: "srDomainFinding.srobsq", + srsev: "srDomainFinding.srsev", + srpcnt: "srDomainFinding.srpcnt", + srsigf: "srDomainFinding.srsigf", + + srtrtef: "srDomainFinding.srpcnt", + srcomnt: "srDomainFinding.srsigf", + + export: "srDomainFinding.export", + srDomainId: "srDomainFinding.srDomainId", + findingId: findingId + }); + } + private drawTable(pretoxSRDomainTemplateTab): void { - const table = new Tabulator(this.tab, { + this.table = new Tabulator(this.tab, { layout: 'fitColumns', pagination: true, paginationSize: 10, @@ -389,6 +477,6 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }); document.getElementById('my-tabular-table-srdomaintemplate').appendChild(this.tab); - table.redraw(true); + this.table.redraw(true); } } -- GitLab From 5f670143b902b78c5084984aea911f6f94a6ca52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Thu, 18 Aug 2022 16:53:52 +0200 Subject: [PATCH 02/17] Add new finding button --- .../document-detail.component.html | 127 +++++++++--------- 1 file changed, 60 insertions(+), 67 deletions(-) diff --git a/src/app/document-detail/document-detail.component.html b/src/app/document-detail/document-detail.component.html index 36cd4c9..87df7d5 100644 --- a/src/app/document-detail/document-detail.component.html +++ b/src/app/document-detail/document-detail.component.html @@ -1,86 +1,79 @@

- +

-
+
- - - -
- -
-
-

{{document.name}}

- -
- -
-
- +
+
+ - - + }" aria-haspopup="true" aria-expanded="true" (click)="moveDocument(status)">{{status}} +
-
- +
- -
+ + + + \ No newline at end of file -- GitLab From 20f13cb02e05c5a23cba6ee1ca2495538b02bfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Thu, 18 Aug 2022 17:23:46 +0200 Subject: [PATCH 03/17] Add proper ids and avoid null values in combo --- .../srdomaintemplate-tabulator.component.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index fd397b7..4c5e594 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -71,7 +71,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { var v = [] var field = cell.getColumn().getField(); var rowNum = cell.getRow().getData().findingId; - var originalValue = rowNum < this.table.getDataCount() ? this.originalData[rowNum - 1][field] : null; + var originalValue = rowNum < this.originalData.length ? this.originalData[rowNum - 1][field] : null; var originalIsCodedValue = false; var codeLists = []; var constantValues = []; @@ -115,7 +115,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }) } - if (!originalIsCodedValue) v.push({ + if (originalValue != null && originalValue != undefined && !originalIsCodedValue) v.push({ label: originalValue, value: originalValue, name: originalValue, @@ -231,7 +231,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { addFinding() { console.log("new finding"); - const findingId = this.table.getDataCount(); + const findingId = this.table.getDataCount() + 1; this.tableData.push({ studyid: "srDomainFinding.studyid", domain: "srDomainFinding.domain", @@ -268,7 +268,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { srcomnt: "srDomainFinding.srsigf", export: "srDomainFinding.export", - srDomainId: "srDomainFinding.srDomainId", + srDomainId: findingId, findingId: findingId }); this.table.addRow({ @@ -307,7 +307,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { srcomnt: "srDomainFinding.srsigf", export: "srDomainFinding.export", - srDomainId: "srDomainFinding.srDomainId", + srDomainId: findingId, findingId: findingId }); } -- GitLab From febb71a1a52ee4d3d0c26d2cf75ff13328ac77fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Thu, 18 Aug 2022 17:28:41 +0200 Subject: [PATCH 04/17] Style refactor --- .../srdomaintemplate-tabulator.component.ts | 377 ++++++++---------- 1 file changed, 167 insertions(+), 210 deletions(-) diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index 4c5e594..f6fc3eb 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -1,5 +1,5 @@ import { Component, Input, OnInit, EventEmitter, Output } from '@angular/core'; -import {TabulatorFull as Tabulator} from 'tabulator-tables'; +import { TabulatorFull as Tabulator } from 'tabulator-tables'; import { CdisSendCtService } from '../cdis-send-ct.service'; import { ActivatedRoute } from '@angular/router'; import { DocumentService } from '../document.service'; @@ -13,12 +13,12 @@ import { SharedService } from '../shared.service'; styleUrls: ['./srdomaintemplate-tabulator.component.css'] }) export class SrdomaintemplateTabulatorComponent implements OnInit { - + tableData: any[] = []; table: Tabulator; originalData: any[] = []; @Input() document: Document; - + @Input() height = '100%'; @Output() rowClickEventSRDomainTemplateEvidence = new EventEmitter(); @@ -28,13 +28,13 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { @Output() srFindingType = new EventEmitter(); tab = document.createElement('div'); - - constructor(private route: ActivatedRoute, private documentService: DocumentService,private cdiscSendCTService: CdisSendCtService, private sharedService: SharedService) { } + + constructor(private route: ActivatedRoute, private documentService: DocumentService, private cdiscSendCTService: CdisSendCtService, private sharedService: SharedService) { } ellipsisFormatter(cell, formatterParams, onRendered) { - onRendered(function(){ - var element = cell.getElement(); - element.title = cell.getValue() + onRendered(function () { + var element = cell.getElement(); + element.title = cell.getValue() }); return cell.getValue(); @@ -46,22 +46,22 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { this.addFinding(); }) } - - activation(data){ - this.document=data; + + activation(data) { + this.document = data; } - - editCheck(cell){ + + editCheck(cell) { return cell.getRow().getData().inEdition == true; } searchFunction(term, values) { var matches = [] var text = term.split(' '); - matches = values.filter(function(item) { - return text.every(function(el) { - return item.title.toLowerCase().indexOf(el.toLowerCase()) > -1; - }); + matches = values.filter(function (item) { + return text.every(function (el) { + return item.title.toLowerCase().indexOf(el.toLowerCase()) > -1; + }); }); return matches; @@ -75,7 +75,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { var originalIsCodedValue = false; var codeLists = []; var constantValues = []; - + if (field == "srtstcd") { // study test var cellData = cell.getRow().getData(); codeLists.push(this.cdiscSendCTService.study_testcd_list_by_domain.get(cellData.domain)); @@ -100,7 +100,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { description: codedValue.description }) }); - }); + }); } if (constantValues[0] != undefined) { @@ -122,12 +122,12 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { description: originalValue }); - return { - freetext : true, + return { + freetext: true, values: v, sort: "asc", - listOnEmpty:true, - itemFormatter: function(label, value, item, element) { + listOnEmpty: true, + itemFormatter: function (label, value, item, element) { //label - the text lable for the item //value - the value for the item //item - the original value object for the item @@ -143,19 +143,19 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { return this.paramLookupGeneric(cell); } - paramLookupManifestation(cell){ + paramLookupManifestation(cell) { return this.paramLookupGeneric(cell); } - paramLookupStudyTest(cell){ + paramLookupStudyTest(cell) { return this.paramLookupGeneric(cell); } - paramLookupSpecies(cell){ + paramLookupSpecies(cell) { return this.paramLookupGeneric(cell); } - paramLookupFinding(cell){ + paramLookupFinding(cell) { return this.paramLookupGeneric(cell); } @@ -163,8 +163,8 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { var srdomainCode = this.cdiscSendCTService.getStudyDomainCode(cell.getValue()) var cellData = cell.getRow().getData() cellData.domain = srdomainCode - cell.getRow().update({srtstcd: ""}) - } + cell.getRow().update({ srtstcd: "" }) + } getDocument(): void { const id = this.document.documentId; @@ -179,38 +179,38 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { var srDomainFindings = []; find.srDomainFindings.forEach(srDomainFinding => { srDomainFindings.push({ - studyid : srDomainFinding.studyid, - domain : srDomainFinding.domain, - srseq : srDomainFinding.srseq, - srrisk : srDomainFinding.srrisk, - - spgrpcd : srDomainFinding.spgrpcd, - grplbl : srDomainFinding.grplbl, - srgrpdos : srDomainFinding.srgrpdos, - srsex : srDomainFinding.srsex, - - srstdy : srDomainFinding.srstdy, - srstphse : srDomainFinding.srstphse, - srobstdy : srDomainFinding.srobstdy, - srendy : srDomainFinding.srendy, - - srenphse : srDomainFinding.srenphse, - srobendy : srDomainFinding.srobendy, - srdomain : srDomainFinding.srdomain_value, - srspec : srDomainFinding.srspec_value, - - srtstcd : srDomainFinding.srtstcd_value, - srfndg : srDomainFinding.srfndg_value, - srores : srDomainFinding.srores, - srobsv : srDomainFinding.srobsv_value, - - srobsq : srDomainFinding.srobsq, - srsev : srDomainFinding.srsev, - srpcnt : srDomainFinding.srpcnt, - srsigf : srDomainFinding.srsigf, - - srtrtef : srDomainFinding.srtrtef, - srcomnt : srDomainFinding.srsigf, + studyid: srDomainFinding.studyid, + domain: srDomainFinding.domain, + srseq: srDomainFinding.srseq, + srrisk: srDomainFinding.srrisk, + + spgrpcd: srDomainFinding.spgrpcd, + grplbl: srDomainFinding.grplbl, + srgrpdos: srDomainFinding.srgrpdos, + srsex: srDomainFinding.srsex, + + srstdy: srDomainFinding.srstdy, + srstphse: srDomainFinding.srstphse, + srobstdy: srDomainFinding.srobstdy, + srendy: srDomainFinding.srendy, + + srenphse: srDomainFinding.srenphse, + srobendy: srDomainFinding.srobendy, + srdomain: srDomainFinding.srdomain_value, + srspec: srDomainFinding.srspec_value, + + srtstcd: srDomainFinding.srtstcd_value, + srfndg: srDomainFinding.srfndg_value, + srores: srDomainFinding.srores, + srobsv: srDomainFinding.srobsv_value, + + srobsq: srDomainFinding.srobsq, + srsev: srDomainFinding.srsev, + srpcnt: srDomainFinding.srpcnt, + srsigf: srDomainFinding.srsigf, + + srtrtef: srDomainFinding.srtrtef, + srcomnt: srDomainFinding.srsigf, export: srDomainFinding.export, status: srDomainFinding.status, @@ -218,8 +218,8 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { findingId: srDomainFinding.findingId, }); - }); - + }); + srDomainFindingsGlobal = srDomainFindingsGlobal.concat(srDomainFindings); }); }); @@ -232,84 +232,40 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { addFinding() { console.log("new finding"); const findingId = this.table.getDataCount() + 1; - this.tableData.push({ - studyid: "srDomainFinding.studyid", - domain: "srDomainFinding.domain", - srseq: "srDomainFinding.srseq", - srrisk: "srDomainFinding.srrisk", - - spgrpcd: "srDomainFinding.spgrpcd", - grplbl: "srDomainFinding.grplbl", - srgrpdos: "srDomainFinding.srgrpdos", - srsex: "srDomainFinding.srsex", - - srstdy: "srDomainFinding.srstdy", - srstphse: "srDomainFinding.srstphse", - srobstdy: "srDomainFinding.srobstdy", - srendy: "srDomainFinding.srendy", - - - srenphse: "srDomainFinding.srenphse", - srobendy: "srDomainFinding.srobendy", - srdomain: "srDomainFinding.srdomain", - srspec: "srDomainFinding.srspec", - - srtstcd: "srDomainFinding.srtstcd", - srfndg: "srDomainFinding.srfndg", - srores: "srDomainFinding.srores", - srobsv: "srDomainFinding.srobsv", - - srobsq: "srDomainFinding.srobsq", - srsev: "srDomainFinding.srsev", - srpcnt: "srDomainFinding.srpcnt", - srsigf: "srDomainFinding.srsigf", - - srtrtef: "srDomainFinding.srpcnt", - srcomnt: "srDomainFinding.srsigf", - - export: "srDomainFinding.export", + const emptyFinding = { + studyid: "", + domain: "", + srseq: "", + srrisk: "", + spgrpcd: "", + grplbl: "", + srgrpdos: "", + srsex: "", + srstdy: "", + srstphse: "", + srobstdy: "", + srendy: "", + srenphse: "", + srobendy: "", + srdomain: "", + srspec: "", + srtstcd: "", + srfndg: "", + srores: "", + srobsv: "", + srobsq: "", + srsev: "", + srpcnt: "", + srsigf: "", + srtrtef: "", + srcomnt: "", + export: "", srDomainId: findingId, findingId: findingId - }); - this.table.addRow({ - studyid: "srDomainFinding.studyid", - domain: "srDomainFinding.domain", - srseq: "srDomainFinding.srseq", - srrisk: "srDomainFinding.srrisk", - - spgrpcd: "srDomainFinding.spgrpcd", - grplbl: "srDomainFinding.grplbl", - srgrpdos: "srDomainFinding.srgrpdos", - srsex: "srDomainFinding.srsex", - - srstdy: "srDomainFinding.srstdy", - srstphse: "srDomainFinding.srstphse", - srobstdy: "srDomainFinding.srobstdy", - srendy: "srDomainFinding.srendy", - - - srenphse: "srDomainFinding.srenphse", - srobendy: "srDomainFinding.srobendy", - srdomain: "srDomainFinding.srdomain", - srspec: "srDomainFinding.srspec", - - srtstcd: "srDomainFinding.srtstcd", - srfndg: "srDomainFinding.srfndg", - srores: "srDomainFinding.srores", - srobsv: "srDomainFinding.srobsv", - - srobsq: "srDomainFinding.srobsq", - srsev: "srDomainFinding.srsev", - srpcnt: "srDomainFinding.srpcnt", - srsigf: "srDomainFinding.srsigf", - - srtrtef: "srDomainFinding.srpcnt", - srcomnt: "srDomainFinding.srsigf", - - export: "srDomainFinding.export", - srDomainId: findingId, - findingId: findingId - }); + }; + + this.tableData.push(emptyFinding); + this.table.addRow(emptyFinding); } private drawTable(pretoxSRDomainTemplateTab): void { @@ -321,61 +277,61 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { data: this.tableData, columns: [ { - title:'', width: 5, hozAlign: 'center', headerSort: false, - cellClick: function(e, cell) { + title: '', width: 5, hozAlign: 'center', headerSort: false, + cellClick: function (e, cell) { //cell.getRow().getElement().style.backgroundColor = "#e2fcad"; //apply css change to row element var data = cell.getRow().getData(); - + if (data.status == "accepted") { - data.status="rejected"; - cell.getElement().innerHTML=''; - } else if(data.status == "rejected") { + data.status = "rejected"; + cell.getElement().innerHTML = ''; + } else if (data.status == "rejected") { data.status = "non_curated"; - cell.getElement().innerHTML = ''; + cell.getElement().innerHTML = ''; } else { data.status = "accepted"; cell.getElement().innerHTML = ''; } - + pretoxSRDomainTemplateTab.rowClickSRFindingValidationEvent.emit(data); }, - formatter: function(cell, formatterParams, onRendered) { + formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); if (data.status == "accepted") { return ''; } else if (data.status == "rejected") { return ''; } else { - return ''; - } + return ''; + } } }, { - title:'', width: 5, hozAlign: 'center', headerSort: false, - cellClick: function(e, cell) { + title: '', width: 5, hozAlign: 'center', headerSort: false, + cellClick: function (e, cell) { var data = cell.getRow().getData(); if (data.export == undefined || data.export == true) { - cell.getRow().getData().export = false; - cell.getElement().innerHTML = ''; + cell.getRow().getData().export = false; + cell.getElement().innerHTML = ''; } else if (data.export == false) { - cell.getRow().getData().export = true; - cell.getElement().innerHTML = ''; + cell.getRow().getData().export = true; + cell.getElement().innerHTML = ''; } - pretoxSRDomainTemplateTab.rowClickExportSRDomainEvent.emit(cell.getData()); + pretoxSRDomainTemplateTab.rowClickExportSRDomainEvent.emit(cell.getData()); }, - formatter: function(cell, formatterParams, onRendered) { + formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); if (data.export == undefined || data.export == true) { - return ''; + return ''; } else { return ''; } } }, { - title:'', width: 5, hozAlign: 'center', headerSort: false, - cellClick: function(e, cell) { + title: '', width: 5, hozAlign: 'center', headerSort: false, + cellClick: function (e, cell) { pretoxSRDomainTemplateTab.rowClickEventSRDomainTemplateEvidence.emit(cell.getData()); var table = cell.getRow().getTable(); var data = table.getRows(); @@ -383,85 +339,85 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { row.getElement().style.border = ""; }); cell.getRow().getElement().style.border = "1px solid black"; - cell.getRow().getData().selected = true; + cell.getRow().getData().selected = true; }, - formatter: function(cell, formatterParams, onRendered) { + formatter: function (cell, formatterParams, onRendered) { return ''; } }, { - title:'', field: 'ed', width: 5, hozAlign: 'center', headerSort: false, - cellClick: function(e, cell) { - var data = cell.getRow().getData(); - if(data.inEdition == false || data.inEdition == undefined) { - if (pretoxSRDomainTemplateTab.document.findingInEdition == undefined || - pretoxSRDomainTemplateTab.document.findingInEdition == -1) { - cell.getRow().getData().inEdition = true; - cell.getRow().getElement().style.backgroundColor = "#ffcc66"; - //cell.getRow().getElement().style.backgroundColor = "#fad7a0 "; - cell.getRow().getCell('ed2').getElement().innerHTML = ''; - cell.getElement().innerHTML = ' '; - pretoxSRDomainTemplateTab.document.findingInEdition = 1; - } else { - alert('Only one edition permited'); - } - } else if (data.inEdition == true) { - cell.getRow().getData().inEdition = false; - cell.getRow().getElement().style.backgroundColor = "#ffffff"; - cell.getRow().getCell('ed2').getElement().innerHTML = ''; - cell.getElement().innerHTML = ''; - pretoxSRDomainTemplateTab.document.findingInEdition = -1; + title: '', field: 'ed', width: 5, hozAlign: 'center', headerSort: false, + cellClick: function (e, cell) { + var data = cell.getRow().getData(); + if (data.inEdition == false || data.inEdition == undefined) { + if (pretoxSRDomainTemplateTab.document.findingInEdition == undefined || + pretoxSRDomainTemplateTab.document.findingInEdition == -1) { + cell.getRow().getData().inEdition = true; + cell.getRow().getElement().style.backgroundColor = "#ffcc66"; + //cell.getRow().getElement().style.backgroundColor = "#fad7a0 "; + cell.getRow().getCell('ed2').getElement().innerHTML = ''; + cell.getElement().innerHTML = ' '; + pretoxSRDomainTemplateTab.document.findingInEdition = 1; + } else { + alert('Only one edition permited'); } + } else if (data.inEdition == true) { + cell.getRow().getData().inEdition = false; + cell.getRow().getElement().style.backgroundColor = "#ffffff"; + cell.getRow().getCell('ed2').getElement().innerHTML = ''; + cell.getElement().innerHTML = ''; + pretoxSRDomainTemplateTab.document.findingInEdition = -1; + } }, - formatter: function(cell, formatterParams, onRendered) { - return ''; + formatter: function (cell, formatterParams, onRendered) { + return ''; } }, { - title:'', field: 'ed2', width: 5, hozAlign: 'center', headerSort: false, //edition logic save button - cellClick: function(e, cell) { + title: '', field: 'ed2', width: 5, hozAlign: 'center', headerSort: false, //edition logic save button + cellClick: function (e, cell) { var data = cell.getRow().getData(); if (data.inEdition == true) { - pretoxSRDomainTemplateTab.rowClickUpdateFindingEvent.emit(cell.getData()); - pretoxSRDomainTemplateTab.document.findingInEdition = -1; - cell.getRow().getData().inEdition = false; - cell.getRow().getElement().style.backgroundColor = "#ffffff"; - cell.getElement().innerHTML = ''; - cell.getRow().getCell('ed').getElement().innerHTML = ''; + pretoxSRDomainTemplateTab.rowClickUpdateFindingEvent.emit(cell.getData()); + pretoxSRDomainTemplateTab.document.findingInEdition = -1; + cell.getRow().getData().inEdition = false; + cell.getRow().getElement().style.backgroundColor = "#ffffff"; + cell.getElement().innerHTML = ''; + cell.getRow().getCell('ed').getElement().innerHTML = ''; } }, - formatter: function(cell, formatterParams, onRendered) { - return ''; + formatter: function (cell, formatterParams, onRendered) { + return ''; } }, { - title:'', width: 5, field: 'srDomainId' + title: '', width: 5, field: 'srDomainId' }, { - title: 'Finding', field: 'srfndg', headerSort: true , editor: 'autocomplete' , editable: this.editCheck.bind(this), - editorParams:this.paramLookupFinding.bind(this), sorter: "string", formatter: this.ellipsisFormatter + title: 'Finding', field: 'srfndg', headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), + editorParams: this.paramLookupFinding.bind(this), sorter: "string", formatter: this.ellipsisFormatter }, - //{title: 'Finding (Free Text)', field: 'srores', headerSort: true , headerFilter: false},//SRORES { - title: 'Test Name', field: 'srtstcd', headerSort: true , editor: 'autocomplete', editable: this.editCheck.bind(this), - editorParams:this.paramLookupStudyTest.bind(this), sorter: "string", formatter: this.ellipsisFormatter + title: 'Test Name', field: 'srtstcd', headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), + editorParams: this.paramLookupStudyTest.bind(this), sorter: "string", formatter: this.ellipsisFormatter }, { - title: 'Manifestation', field: 'srobsv', headerSort: true , editable: this.editCheck.bind(this), editor: "autocomplete", - editorParams:this.paramLookupManifestation.bind(this) + title: 'Manifestation', field: 'srobsv', headerSort: true, editable: this.editCheck.bind(this), editor: "autocomplete", + editorParams: this.paramLookupManifestation.bind(this) }, { - title: 'Domain', field: 'srdomain', headerSort: true , editor: 'autocomplete', editable: this.editCheck.bind(this), + title: 'Domain', field: 'srdomain', headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), editorParams: this.paramLookupStudyDomain.bind(this), sorter: "string", formatter: this.ellipsisFormatter, cellEdited: this.onStudyDomainChange.bind(this) }, { - title: 'Specimen', field: 'srspec', headerSort: true , editor: 'autocomplete', editable: this.editCheck.bind(this), - editorParams:this.paramLookupSpecies.bind(this), sorter: "string", formatter: this.ellipsisFormatter + title: 'Specimen', field: 'srspec', headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), + editorParams: this.paramLookupSpecies.bind(this), sorter: "string", formatter: this.ellipsisFormatter }, { - title: 'Sex', field: 'srsex', headerSort: true, editor: 'select', editable: this.editCheck.bind(this), editorParams:{ - values:['Female','Male','Both']} + title: 'Sex', field: 'srsex', headerSort: true, editor: 'select', editable: this.editCheck.bind(this), editorParams: { + values: ['Female', 'Male', 'Both'] + } }, { title: 'Dose', field: 'srgrpdos', headerSort: true, editor: 'input', editable: this.editCheck.bind(this) @@ -471,7 +427,8 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }, { title: 'Treatment Related?', field: 'srtrtef', headerSort: true, editor: 'select', editable: this.editCheck.bind(this), editorParams: { - values:['Yes','No','Uncertain']} + values: ['Yes', 'No', 'Uncertain'] + } }, ] }); -- GitLab From 625ffe8d3d3fe4685a076c12a919c7cca5428a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Mon, 22 Aug 2022 09:29:06 +0200 Subject: [PATCH 05/17] Add import --- src/app/document-detail/document-detail.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index 214bfc3..250e340 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -3,6 +3,7 @@ import { Document } from '../document'; import { ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; import { DocumentService } from '../document.service'; +import { SharedService } from '../shared.service'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { Finding } from '../finding'; import { Annotation } from '../annotation'; -- GitLab From cbeb32ac819411415a0b2033b6a3049a4a8843f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Tue, 23 Aug 2022 12:53:21 +0200 Subject: [PATCH 06/17] Adapt buttons on new findings and refactor css --- angular.json | 1 + .../document-detail.component.css | 131 ++++++++++++++--- .../document-detail.component.html | 36 +++-- .../document-detail.component.ts | 138 +----------------- .../srdomaintemplate-tabulator.component.ts | 111 +++++++------- src/tabulator.css | 53 +++++++ 6 files changed, 247 insertions(+), 223 deletions(-) create mode 100644 src/tabulator.css diff --git a/angular.json b/angular.json index a44d445..5b73115 100644 --- a/angular.json +++ b/angular.json @@ -24,6 +24,7 @@ "src/assets" ], "styles": [ + { "input":"src/tabulator.css"}, { "input":"./node_modules/tabulator-tables/dist/css/tabulator_bootstrap4.min.css"}, { "input":"./node_modules/bootstrap/dist/css/bootstrap.min.css"}, { "input":"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css"}, diff --git a/src/app/document-detail/document-detail.component.css b/src/app/document-detail/document-detail.component.css index d550890..3d94a39 100644 --- a/src/app/document-detail/document-detail.component.css +++ b/src/app/document-detail/document-detail.component.css @@ -1,25 +1,108 @@ -.loader{ - position: absolute; - top:0px; - right:0px; - width:100%; - height:100%; - background-color:#eceaea; - background-image:url('loader.gif'); - background-size: 100px; - background-repeat:no-repeat; - background-position:center; - z-index:10000000; - opacity: 0.4; - filter: alpha(opacity=40); -} - -.FixedHeightContainer -{ - -} -.brat_div -{ - - overflow:auto; +.loader { + position: absolute; + top: 0px; + right: 0px; + width: 100%; + height: 100%; + background-color: #eceaea; + background-image: url('loader.gif'); + background-size: 100px; + background-repeat: no-repeat; + background-position: center; + z-index: 10000000; + opacity: 0.4; + filter: alpha(opacity=40); +} + +.FixedHeightContainer {} + +.brat_div { + + overflow: auto; +} + +.add-fiding-button { + cursor: pointer; + margin-left: auto; + margin-block: auto; +} + +.add-fiding-button .fa-solid.fa-plus { + color: grey; +} + +.export-document-button { + text-decoration: none; + cursor: pointer; +} + +.export-document-button .fa.fa-download { + color: black; + padding: 10px 30px; + font-size: 2rem; +} + +.get-evidence-button { + text-decoration: none; + cursor: pointer; +} + +.get-evidence-button .fa.fa-eye { + color: black; + padding: 10px 30px; + font-size: 2rem; +} + +.find-doc-button { + text-decoration: none; + cursor: pointer; +} + +.find-doc-button .fa.fa-file-text { + color: black; + padding: 10px 30px; + font-size: 2rem; +} + +.get-history-button { + text-decoration: none; + cursor: pointer; +} + +.get-history-button .fa.fa-history { + color: black; + padding: 10px 30px; + font-size: 2rem; +} + +.collapse-button { + text-decoration: none; + cursor: pointer; +} + +.collapse-button .fa.fa-angle-down { + color: black; + padding: 10px 30px; + font-size: 3rem; +} + +.card-header .document-name { + float: left; + width: 75%; +} + +.card-header .send-to-srdomain-button { + float: left; + width: 15%; +} + +.card-header .btn-group { + float: left; + width: 10%; +} + +.card-header .btn-group .status-button { + position: absolute; + bottom: 100; + left: 0; } \ No newline at end of file diff --git a/src/app/document-detail/document-detail.component.html b/src/app/document-detail/document-detail.component.html index 87df7d5..7b7f3c6 100644 --- a/src/app/document-detail/document-detail.component.html +++ b/src/app/document-detail/document-detail.component.html @@ -13,19 +13,18 @@
-
+

{{document.name}}

-
+
-
-
- - + + - - + + - - + + - - + + - - + +
@@ -70,8 +68,8 @@ {{link.label}} - - + + diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index 250e340..dd25ca4 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, ViewChild, ElementRef, ViewEncapsulation, AfterViewInit, AfterContentInit } from '@angular/core'; +import { Component, OnInit, Input, ViewChild, ElementRef, ViewEncapsulation, AfterViewInit, AfterContentInit, EventEmitter, Output } from '@angular/core'; import { Document } from '../document'; import { ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; @@ -31,12 +31,7 @@ var displaySpanComment = function (evt, target, spanId, spanType, mods, spanText var hideComment = function (evt, target, spanId, spanType, mods, spanText, commentText, commentType, normalizations) { var div = document.getElementById('commentpopup'); - if (div == null || div == undefined) { - console.log("Saved bug") - } else { - div.style.display = 'none'; - } - + div.style.display = 'none'; } declare var jQuery: any; @@ -84,24 +79,7 @@ export class DocumentDetailComponent implements OnInit { // tslint:disable-next-line: max-line-length constructor(private router: Router, private route: ActivatedRoute, private documentService: DocumentService, private cdiscSendCTService: CdisSendCtService, private location: Location, private sanitizer: DomSanitizer, private sharedService: SharedService) { const bratLocation = environment.bratUrl; - - head.js( - // External libraries - bratLocation + '/client/lib/jquery.min.js', - bratLocation + '/client/lib/jquery.svg.min.js', - bratLocation + '/client/lib/jquery.svgdom.min.js', - - // brat helper modules - bratLocation + '/client/src/configuration.js', - bratLocation + '/client/src/util.js', - bratLocation + '/client/src/annotation_log.js', - bratLocation + '/client/lib/webfont.js', - - // brat modules - bratLocation + '/client/src/dispatcher.js', - bratLocation + '/client/src/url_monitor.js', - bratLocation + '/client/src/visualizer.js' - ); + this.loadBratVisualizer(); DocumentDetailComponent.webFontURLs = [ bratLocation + '/static/fonts/Astloch-Bold.ttf', @@ -141,7 +119,6 @@ export class DocumentDetailComponent implements OnInit { ] }; - DocumentDetailComponent.collData['entity_attribute_types'] = [{ type: 'Notorious', /* brat supports multi-valued attributes, but in our case we will only @@ -150,7 +127,6 @@ export class DocumentDetailComponent implements OnInit { values: { Notorious: { glyph: '★' } } }]; - DocumentDetailComponent.collData['relation_types'] = [{ type: 'Relation', labels: ['R', 'R'], @@ -172,7 +148,8 @@ export class DocumentDetailComponent implements OnInit { label: 'Relevant Sentences', link: './sentences', index: 0 - }, { + }, + { label: 'Findings', link: './findings', index: 1 @@ -184,7 +161,6 @@ export class DocumentDetailComponent implements OnInit { loadBratVisualizer(): void { const bratLocation = environment.bratUrl; - //const bratLocation = 'http://10.32.6.2:8001'; head.js( // External libraries bratLocation + '/client/lib/jquery.min.js', @@ -202,8 +178,6 @@ export class DocumentDetailComponent implements OnInit { bratLocation + '/client/src/url_monitor.js', bratLocation + '/client/src/visualizer.js' ); - - } loaded(): void { @@ -229,7 +203,6 @@ export class DocumentDetailComponent implements OnInit { } getEvidence() { - //alert('getAllEvidence'); const id = +this.route.snapshot.paramMap.get('id'); this.documentService.getEvidence(id) .subscribe(text => { @@ -256,35 +229,6 @@ export class DocumentDetailComponent implements OnInit { this.document = document; this.setNextStatus(this.document.status); var data_relevant_sentences = []; - // document.findings.forEach(find => { - // data.push({ - // id : find.findingId, - // finding: find.finding != null ? find.finding.value : '', - // study_testcd: find.study_testcd != null ? find.study_testcd.value : '', - // manifestation_finding: find.manifestation_finding != null ? find.manifestation_finding.value : '', - // study_domain: find.study_domain != null ? find.study_domain.value : '', - // specimen: find.specimen != null ? find.specimen.value : '', - // sex: find.sex != null ? find.sex.value : '', - // dose: find.dose != null ? find.dose.value : '', - // group: find.group != null ? find.group.value : '', - // is_trf: find.is_treatment_related != null ? find.is_treatment_related.value : '' - // }); - // }); - //alert(data); - //alert(JSON.stringify(data)); - - //this.tableData = data; - //this.clear(); - //alert(JSON.stringify(document.findings)); - //var j = JSON.parse('{ text:' + document.text + '}'); - // var j = { text: document.text }; - // head.ready( function() { - // const dispatcher = Util.embed('data1' , DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs); - // dispatcher.on('displaySpanComment', displaySpanComment); - // dispatcher.on('hideComment', hideComment); - // }); - - var srDomainFindingsGlobal = []; //relevant sentence table @@ -330,9 +274,8 @@ export class DocumentDetailComponent implements OnInit { export: srDomainFinding.export, srDomainId: srDomainFinding.srDomainId, - findingId: srDomainFinding.findingId, - - }) + findingId: srDomainFinding.findingId + }); }); findings.push({ @@ -368,8 +311,6 @@ export class DocumentDetailComponent implements OnInit { } rowClickFindingEvidence(dataRow: any): void { - //alert(dataRow.id); - //alert(dataRow); const finding = new Finding(); finding.findingId = dataRow.id; this.findingSelected(finding); @@ -384,7 +325,6 @@ export class DocumentDetailComponent implements OnInit { rowClickSRDomainTemplateEvidence(dataRow: any): void { const finding = new Finding(); finding.findingId = dataRow.findingId; - //finding.findingId=1; this.findingSelected(finding); } @@ -392,17 +332,12 @@ export class DocumentDetailComponent implements OnInit { this.documentService.findingSelected(this.document.documentId, finding) .subscribe(text => { var loading = document.getElementById('loadingDiv'); - //loading.style.display='block'; loading.addEventListener("load", this.loaded); this.docData = text; - //console.log(this.docData); - // console.log(JSON.parse(this.docData)); document.getElementById('data2').className = 'collapse show'; document.getElementById('data1').innerHTML = ''; document.getElementById('data1').className = ''; - //document.getElementById('loadingDiv').className = 'loader'; var j = JSON.parse(this.docData); - //this.loadBratVisualizer(); head.ready(function () { const dispatcher = Util.embed('data1', DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs); //dispatcher.on('displaySpanComment', displaySpanComment); @@ -411,23 +346,17 @@ export class DocumentDetailComponent implements OnInit { // document.getElementById('loadingDiv').className = ''; // }, 4000); }); - }); - } pretoxSentenceSelected(pretoxSentence): void { this.documentService.pretoxSentenceSelected(this.document.documentId, pretoxSentence) .subscribe(text => { this.docData = text; - //console.log(this.docData); - // console.log(JSON.parse(this.docData)); document.getElementById('data2').className = 'collapse show'; document.getElementById('data1').innerHTML = ''; document.getElementById('data1').className = ''; - //document.getElementById('loadingDiv').className = 'loader'; var j = JSON.parse(this.docData); - //this.loadBratVisualizer(); head.ready(function () { const dispatcher = Util.embed('data1', DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs); @@ -447,13 +376,10 @@ export class DocumentDetailComponent implements OnInit { this.documentService.findDocumentText(this.document.documentId) .subscribe(text => { this.docData = text; - //console.log(this.docData); document.getElementById('data2').className = 'collapse show'; document.getElementById('data1').innerHTML = ''; document.getElementById('data1').className = ''; - //document.getElementById('loadingDiv').className = 'loader'; var j = JSON.parse(this.docData); - //this.loadBratVisualizer(); head.ready(function () { const dispatcher = Util.embed('data1', DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs); @@ -467,20 +393,14 @@ export class DocumentDetailComponent implements OnInit { } getAllEvidence() { - //alert('getAllEvidence'); const id = +this.route.snapshot.paramMap.get('id'); - //this.documentService.getAllEvidence(this.document.documentId) this.documentService.getAllEvidence(id) .subscribe(text => { this.docData = text; - //console.log(this.docData); - // console.log(JSON.parse(this.docData)); document.getElementById('data2').className = 'collapse show'; document.getElementById('data1').innerHTML = ''; document.getElementById('data1').className = ''; - //document.getElementById('loadingDiv').className = 'loader'; var j = JSON.parse(this.docData); - //this.loadBratVisualizer(); head.ready(function () { const dispatcher = Util.embed('data1', DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs); //dispatcher.on('displaySpanComment', displaySpanComment); @@ -493,9 +413,7 @@ export class DocumentDetailComponent implements OnInit { } getSentencesEvidence() { - //alert('getSentencesEvidence'); const id = +this.route.snapshot.paramMap.get('id'); - //this.documentService.getAllEvidence(this.document.documentId) this.documentService.getSentencesEvidence(id) .subscribe(text => { this.docData = text; @@ -520,11 +438,8 @@ export class DocumentDetailComponent implements OnInit { setExportSRDomain(data) { const id = +this.route.snapshot.paramMap.get('id'); - //alert(data); - //alert(data.export); this.documentService.setExportSRDomain(id, data.srDomainId, data.export) .subscribe(text => { - //alert(text); }); } @@ -532,26 +447,20 @@ export class DocumentDetailComponent implements OnInit { const id = +this.route.snapshot.paramMap.get('id'); this.documentService.updateFinding(id, data) .subscribe(text => { - //alert(2); - //alert(text); }); } setFindingValidation(data) { const id = +this.route.snapshot.paramMap.get('id'); - //alert(data.status); this.documentService.setFindingValidation(id, data.id, data.status) .subscribe(text => { - //alert(text); }); } setSRFindingValidation(data) { const id = +this.route.snapshot.paramMap.get('id'); - //alert(data.status); this.documentService.setSRFindingValidation(id, data.srDomainId, data.status) .subscribe(text => { - //alert(text); }); } @@ -567,7 +476,6 @@ export class DocumentDetailComponent implements OnInit { moveDocument(status) { const id = +this.route.snapshot.paramMap.get('id'); - //alert(data.status); this.documentService.moveDocument(id, status) .subscribe(text => { this.document.status = status; @@ -576,17 +484,14 @@ export class DocumentDetailComponent implements OnInit { } sendToSRDomain() { - //alert(1); const id = +this.route.snapshot.paramMap.get('id'); this.documentService.sendToSRDomain(id); } showHistory() { const id = +this.route.snapshot.paramMap.get('id'); - //alert(data.status); this.documentService.getHistory(id) .subscribe(text => { - //alert(text); }); } @@ -600,47 +505,29 @@ export class DocumentDetailComponent implements OnInit { } onActivate(componentReference) { - componentReference.activation(this.document); - // if(componentReference.constructor.name=='PretoxsentencesTabulatorComponent'){ - // this.getSentencesEvidence(); - // }else if(componentReference.constructor.name=='SrdomaintemplateTabulatorComponent'){ - // this.getAllEvidence(); - // }else if(componentReference.constructor.name=='FindingTabulatorComponent'){ - // this.getAllEvidence(); - // } - //Below will subscribe to the searchItem emitter if (componentReference.rowClickEventFinding != undefined) { componentReference.rowClickEventFinding.subscribe((data) => { - //alert('rowClickEventFinding'); this.rowClickFindingEvidence(data); }) } - //Below will subscribe to the searchItem emitter if (componentReference.rowClickEvent != undefined) { - //alert('sentence activation'); this.getSentencesEvidence(); componentReference.rowClickEvent.subscribe((data) => { - //alert('rowClickEvent'); this.rowClickSentenceEvidence(data); }) } - //Below will subscribe to the searchItem emitter if (componentReference.rowClickSRFindingValidationEvent != undefined) { componentReference.rowClickSRFindingValidationEvent.subscribe((data) => { - //alert('rowClickFindingValidationEvent'); this.setSRFindingValidation(data); }) } - - //Below will subscribe to the searchItem emitter if (componentReference.rowClickFindingValidationEvent != undefined) { componentReference.rowClickFindingValidationEvent.subscribe((data) => { - //alert('rowClickFindingValidationEvent'); this.setFindingValidation(data); }) } @@ -649,34 +536,25 @@ export class DocumentDetailComponent implements OnInit { this.getAllEvidence(); } - //Below will subscribe to the searchItem emitter if (componentReference.rowClickEventSRDomainTemplateEvidence != undefined) { - //alert('sr-domain activation'); - //this.getAllEvidence(); componentReference.rowClickEventSRDomainTemplateEvidence.subscribe((data) => { - //alert('rowClickSRDomainTemplateEvidence'); this.rowClickSRDomainTemplateEvidence(data); }) } - //Below will subscribe to the searchItem emitter if (componentReference.rowClickExportSRDomainEvent != undefined) { componentReference.rowClickExportSRDomainEvent.subscribe((data) => { - //alert('rowClickExportSRDomainEvent'); this.setExportSRDomain(data); }) } - //Below will subscribe to the searchItem emitter if (componentReference.rowClickUpdateFindingEvent != undefined) { componentReference.rowClickUpdateFindingEvent.subscribe((data) => { - //alert('rowClickFindingValidationEvent'); this.updateFinding(data); }) } - - } + goBack(): void { this.location.back(); } diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index f6fc3eb..afcac49 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -230,7 +230,6 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } addFinding() { - console.log("new finding"); const findingId = this.table.getDataCount() + 1; const emptyFinding = { studyid: "", @@ -261,7 +260,8 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { srcomnt: "", export: "", srDomainId: findingId, - findingId: findingId + findingId: findingId, + isNew: true }; this.tableData.push(emptyFinding); @@ -279,30 +279,34 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { { title: '', width: 5, hozAlign: 'center', headerSort: false, cellClick: function (e, cell) { - //cell.getRow().getElement().style.backgroundColor = "#e2fcad"; //apply css change to row element var data = cell.getRow().getData(); - - if (data.status == "accepted") { - data.status = "rejected"; - cell.getElement().innerHTML = ''; - } else if (data.status == "rejected") { - data.status = "non_curated"; - cell.getElement().innerHTML = ''; - } else { - data.status = "accepted"; - cell.getElement().innerHTML = ''; + if (data.isNew != true) { + if (data.status == "accepted") { + data.status = "rejected"; + cell.getElement().innerHTML = ' '; + } else if (data.status == "rejected") { + data.status = "non_curated"; + cell.getElement().innerHTML = ' '; + } else { + data.status = "accepted"; + cell.getElement().innerHTML = ' '; + } + + pretoxSRDomainTemplateTab.rowClickSRFindingValidationEvent.emit(data); } - - pretoxSRDomainTemplateTab.rowClickSRFindingValidationEvent.emit(data); }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); + if (data.isNew) { + return ' '; + } + if (data.status == "accepted") { - return ''; + return ' '; } else if (data.status == "rejected") { - return ''; + return ' '; } else { - return ''; + return ' '; } } }, @@ -310,80 +314,87 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { title: '', width: 5, hozAlign: 'center', headerSort: false, cellClick: function (e, cell) { var data = cell.getRow().getData(); - if (data.export == undefined || data.export == true) { - cell.getRow().getData().export = false; - cell.getElement().innerHTML = ''; - } else if (data.export == false) { - cell.getRow().getData().export = true; - cell.getElement().innerHTML = ''; + if (data.isNew != true) { + if (data.export == undefined || data.export == true) { + data.export = false; + cell.getElement().innerHTML = ' '; + } else if (data.export == false) { + data.export = true; + cell.getElement().innerHTML = ' '; + } + + pretoxSRDomainTemplateTab.rowClickExportSRDomainEvent.emit(cell.getData()); } - - pretoxSRDomainTemplateTab.rowClickExportSRDomainEvent.emit(cell.getData()); }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); + if (data.isNew) { + return ' '; + } + if (data.export == undefined || data.export == true) { - return ''; + return ' '; } else { - return ''; + return ' '; } } }, { title: '', width: 5, hozAlign: 'center', headerSort: false, cellClick: function (e, cell) { - pretoxSRDomainTemplateTab.rowClickEventSRDomainTemplateEvidence.emit(cell.getData()); - var table = cell.getRow().getTable(); - var data = table.getRows(); - data.forEach(row => { - row.getElement().style.border = ""; - }); - cell.getRow().getElement().style.border = "1px solid black"; - cell.getRow().getData().selected = true; + if (cell.getRow().getData().isNew != true) { + pretoxSRDomainTemplateTab.rowClickEventSRDomainTemplateEvidence.emit(cell.getData()); + cell.getRow().getElement().style.border = "1px solid black"; + } }, formatter: function (cell, formatterParams, onRendered) { - return ''; + if (cell.getRow().getData().isNew) { + return ' '; + } + + return ' '; } }, { title: '', field: 'ed', width: 5, hozAlign: 'center', headerSort: false, cellClick: function (e, cell) { - var data = cell.getRow().getData(); + var row = cell.getRow(); + var data = row.getData(); if (data.inEdition == false || data.inEdition == undefined) { if (pretoxSRDomainTemplateTab.document.findingInEdition == undefined || pretoxSRDomainTemplateTab.document.findingInEdition == -1) { - cell.getRow().getData().inEdition = true; - cell.getRow().getElement().style.backgroundColor = "#ffcc66"; - //cell.getRow().getElement().style.backgroundColor = "#fad7a0 "; - cell.getRow().getCell('ed2').getElement().innerHTML = ''; - cell.getElement().innerHTML = ' '; + data.inEdition = true; + row.getElement().style.backgroundColor = "#ffcc66"; + row.getCell('ed2').getElement().innerHTML = ' '; + cell.getElement().innerHTML = ' '; pretoxSRDomainTemplateTab.document.findingInEdition = 1; } else { alert('Only one edition permited'); } } else if (data.inEdition == true) { - cell.getRow().getData().inEdition = false; + data.inEdition = false; cell.getRow().getElement().style.backgroundColor = "#ffffff"; - cell.getRow().getCell('ed2').getElement().innerHTML = ''; - cell.getElement().innerHTML = ''; + row.getCell('ed2').getElement().innerHTML = ''; + cell.getElement().innerHTML = ' '; pretoxSRDomainTemplateTab.document.findingInEdition = -1; } }, formatter: function (cell, formatterParams, onRendered) { - return ''; + return ' '; } }, { title: '', field: 'ed2', width: 5, hozAlign: 'center', headerSort: false, //edition logic save button cellClick: function (e, cell) { + var row = cell.getRow(); var data = cell.getRow().getData(); if (data.inEdition == true) { pretoxSRDomainTemplateTab.rowClickUpdateFindingEvent.emit(cell.getData()); pretoxSRDomainTemplateTab.document.findingInEdition = -1; - cell.getRow().getData().inEdition = false; - cell.getRow().getElement().style.backgroundColor = "#ffffff"; + data.inEdition = false; + row.getElement().style.backgroundColor = "#ffffff"; cell.getElement().innerHTML = ''; - cell.getRow().getCell('ed').getElement().innerHTML = ''; + row.getCell('ed').getElement().innerHTML = ' '; } }, formatter: function (cell, formatterParams, onRendered) { diff --git a/src/tabulator.css b/src/tabulator.css new file mode 100644 index 0000000..ede349f --- /dev/null +++ b/src/tabulator.css @@ -0,0 +1,53 @@ +.tabulator-cell .non-curated .fa.fa-square { + color: grey; +} + +.tabulator-cell .non-curable .fa.fa-square { + color: grey; + cursor: default; + opacity: 0.6; +} + +.tabulator-cell .not-exported .fa.fa-square { + color: grey; +} + +.tabulator-cell .rejected .fa.fa-times { + color: red; +} + +.tabulator-cell .accepted .fa.fa-check { + color: green; +} + +.tabulator-cell .exported .fa.fa-file-circle-check { + color: blue; +} + +.tabulator-cell .non-exportable .fa.fa-file-circle-check { + color: grey; + cursor: default; + opacity: 0.6; +} + +.tabulator-cell .evidence .fa.fa-eye { + color: #8e44ad; +} + +.tabulator-cell .no-evidence .fa.fa-eye { + color: #8e44ad; + cursor: default; + opacity: 0.6; +} + +.tabulator-cell .save-finding .fa-solid.fa-floppy-disk { + color: black; +} + +.tabulator-cell .cancel-edition .fa-solid.fa-pencil { + color: #abb2b9; +} + +.tabulator-cell .enable-edition .fa-solid.fa-pencil { + color: #566573; +} -- GitLab From bc992afbc97ce68913ea9a20bf615d4b29b0fb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Tue, 23 Aug 2022 17:28:48 +0200 Subject: [PATCH 07/17] Style refactor and fixing --- .../pretoxsentences-tabulator.component.ts | 2 +- src/app/reports/reports.component.ts | 2 +- .../srdomaintemplate-tabulator.component.ts | 104 ++++++++++-------- src/tabulator.css | 31 ++++++ 4 files changed, 91 insertions(+), 48 deletions(-) diff --git a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts index 43b806c..b6fefd7 100644 --- a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts +++ b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts @@ -149,7 +149,7 @@ export class PretoxsentencesTabulatorComponent implements OnInit { layout:"fitColumns", persistentSort: false, pagination: true, - selectable: 0, + selectable: false, paginationSize: 10, paginationSizeSelector: [5, 10, 20, 40], columns: [ diff --git a/src/app/reports/reports.component.ts b/src/app/reports/reports.component.ts index e825964..46526b6 100644 --- a/src/app/reports/reports.component.ts +++ b/src/app/reports/reports.component.ts @@ -118,7 +118,7 @@ drawTable(documentTab): void { layout: 'fitColumns', data:this.tableData, pagination: true, - selectable: 0, + selectable: false, debugInvalidOptions: false, paginationSize: 20, paginationSizeSelector: [ 10, 20, 40], diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index afcac49..6b1f988 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -272,91 +272,96 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { this.table = new Tabulator(this.tab, { layout: 'fitColumns', pagination: true, + selectable: false, paginationSize: 10, paginationSizeSelector: [5, 10, 20, 40], data: this.tableData, columns: [ { - title: '', width: 5, hozAlign: 'center', headerSort: false, + title: '', width: 5, hozAlign: 'center', headerSort: false, cssClass: "tabulator-cell non-editable-cell", cellClick: function (e, cell) { var data = cell.getRow().getData(); if (data.isNew != true) { if (data.status == "accepted") { data.status = "rejected"; - cell.getElement().innerHTML = ' '; + cell.getElement().innerHTML = '
'; } else if (data.status == "rejected") { data.status = "non_curated"; - cell.getElement().innerHTML = ' '; + cell.getElement().innerHTML = '
'; } else { data.status = "accepted"; - cell.getElement().innerHTML = ' '; + cell.getElement().innerHTML = '
'; } - + pretoxSRDomainTemplateTab.rowClickSRFindingValidationEvent.emit(data); } }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); if (data.isNew) { - return ' '; + return '
'; } if (data.status == "accepted") { - return ' '; + return '
'; } else if (data.status == "rejected") { - return ' '; + return '
'; } else { - return ' '; + return '
'; } } }, { - title: '', width: 5, hozAlign: 'center', headerSort: false, + title: '', width: 5, hozAlign: 'center', headerSort: false, cssClass: "tabulator-cell non-editable-cell", cellClick: function (e, cell) { var data = cell.getRow().getData(); if (data.isNew != true) { if (data.export == undefined || data.export == true) { data.export = false; - cell.getElement().innerHTML = ' '; + cell.getElement().innerHTML = '
'; } else if (data.export == false) { data.export = true; - cell.getElement().innerHTML = ' '; + cell.getElement().innerHTML = '
'; } - + pretoxSRDomainTemplateTab.rowClickExportSRDomainEvent.emit(cell.getData()); } }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); if (data.isNew) { - return ' '; + return '
'; } if (data.export == undefined || data.export == true) { - return ' '; + return '
'; } else { - return ' '; + return '
'; } } }, { - title: '', width: 5, hozAlign: 'center', headerSort: false, + title: '', width: 5, hozAlign: 'center', headerSort: false, cssClass: "tabulator-cell non-editable-cell", cellClick: function (e, cell) { - if (cell.getRow().getData().isNew != true) { + if (cell.getRow().getData().isNew != true && cell.getRow().getData().selected != true) { + cell.getRow().getData().selected = true; + cell.getRow().getElement().className = "tabulator-row evidence-selected"; pretoxSRDomainTemplateTab.rowClickEventSRDomainTemplateEvidence.emit(cell.getData()); - cell.getRow().getElement().style.border = "1px solid black"; + } else { + cell.getRow().getData().selected = false; + cell.getRow().getElement().className = "tabulator-row"; } }, formatter: function (cell, formatterParams, onRendered) { if (cell.getRow().getData().isNew) { - return ' '; + return '
'; } - return ' '; + return '
'; } }, { - title: '', field: 'ed', width: 5, hozAlign: 'center', headerSort: false, + title: '', field: 'ed', width: 5, hozAlign: 'center', headerSort: false, cssClass: "tabulator-cell non-editable-cell", cellClick: function (e, cell) { var row = cell.getRow(); var data = row.getData(); @@ -364,37 +369,44 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { if (pretoxSRDomainTemplateTab.document.findingInEdition == undefined || pretoxSRDomainTemplateTab.document.findingInEdition == -1) { data.inEdition = true; - row.getElement().style.backgroundColor = "#ffcc66"; - row.getCell('ed2').getElement().innerHTML = ' '; - cell.getElement().innerHTML = ' '; pretoxSRDomainTemplateTab.document.findingInEdition = 1; - } else { - alert('Only one edition permited'); + row.getCell('ed2').getElement().innerHTML = '
'; + cell.getElement().innerHTML = '
'; + row.getElement().className = "tabulator-row editable"; + cell.getColumn().getCells().forEach(rowCell => { + if (cell != rowCell) rowCell.getElement().childNodes[0]["className"] = "edition-unabled"; + }); } } else if (data.inEdition == true) { data.inEdition = false; - cell.getRow().getElement().style.backgroundColor = "#ffffff"; - row.getCell('ed2').getElement().innerHTML = ''; - cell.getElement().innerHTML = ' '; pretoxSRDomainTemplateTab.document.findingInEdition = -1; + row.getCell('ed2').getElement().innerHTML = ''; + cell.getElement().innerHTML = '
'; + row.getElement().className = "tabulator-row"; + cell.getColumn().getCells().forEach(rowCell => { + if (cell != rowCell) rowCell.getElement().childNodes[0]["className"] = "enable-edition"; + }); } }, formatter: function (cell, formatterParams, onRendered) { - return ' '; + return '
'; } }, { - title: '', field: 'ed2', width: 5, hozAlign: 'center', headerSort: false, //edition logic save button + title: '', field: 'ed2', width: 5, hozAlign: 'center', headerSort: false, cssClass: "tabulator-cell non-editable-cell", //edition logic save button cellClick: function (e, cell) { var row = cell.getRow(); var data = cell.getRow().getData(); if (data.inEdition == true) { - pretoxSRDomainTemplateTab.rowClickUpdateFindingEvent.emit(cell.getData()); - pretoxSRDomainTemplateTab.document.findingInEdition = -1; data.inEdition = false; - row.getElement().style.backgroundColor = "#ffffff"; + pretoxSRDomainTemplateTab.document.findingInEdition = -1; + row.getElement().className = "tabulator-row"; + row.getCells().forEach(rowCell => { + rowCell.getElement().className = "tabulator-cell non-editable-cell"; + }); cell.getElement().innerHTML = ''; - row.getCell('ed').getElement().innerHTML = ' '; + row.getCell('ed').getElement().innerHTML = '
'; + pretoxSRDomainTemplateTab.rowClickUpdateFindingEvent.emit(cell.getData()); } }, formatter: function (cell, formatterParams, onRendered) { @@ -402,42 +414,42 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } }, { - title: '', width: 5, field: 'srDomainId' + title: '', width: 5, field: 'srDomainId', cssClass: "tabulator-cell non-editable-cell", }, { - title: 'Finding', field: 'srfndg', headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), + title: 'Finding', field: 'srfndg', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), editorParams: this.paramLookupFinding.bind(this), sorter: "string", formatter: this.ellipsisFormatter }, { - title: 'Test Name', field: 'srtstcd', headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), + title: 'Test Name', field: 'srtstcd', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), editorParams: this.paramLookupStudyTest.bind(this), sorter: "string", formatter: this.ellipsisFormatter }, { - title: 'Manifestation', field: 'srobsv', headerSort: true, editable: this.editCheck.bind(this), editor: "autocomplete", + title: 'Manifestation', field: 'srobsv', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editable: this.editCheck.bind(this), editor: "autocomplete", editorParams: this.paramLookupManifestation.bind(this) }, { - title: 'Domain', field: 'srdomain', headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), + title: 'Domain', field: 'srdomain', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), editorParams: this.paramLookupStudyDomain.bind(this), sorter: "string", formatter: this.ellipsisFormatter, cellEdited: this.onStudyDomainChange.bind(this) }, { - title: 'Specimen', field: 'srspec', headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), + title: 'Specimen', field: 'srspec', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'autocomplete', editable: this.editCheck.bind(this), editorParams: this.paramLookupSpecies.bind(this), sorter: "string", formatter: this.ellipsisFormatter }, { - title: 'Sex', field: 'srsex', headerSort: true, editor: 'select', editable: this.editCheck.bind(this), editorParams: { + title: 'Sex', field: 'srsex', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'select', editable: this.editCheck.bind(this), editorParams: { values: ['Female', 'Male', 'Both'] } }, { - title: 'Dose', field: 'srgrpdos', headerSort: true, editor: 'input', editable: this.editCheck.bind(this) + title: 'Dose', field: 'srgrpdos', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'input', editable: this.editCheck.bind(this) }, { - title: 'Group', field: 'spgrpcd', headerSort: true, 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: 'Treatment Related?', field: 'srtrtef', headerSort: true, editor: 'select', editable: this.editCheck.bind(this), editorParams: { + title: 'Treatment Related?', field: 'srtrtef', cssClass: "tabulator-cell non-editable-cell", headerSort: true, editor: 'select', editable: this.editCheck.bind(this), editorParams: { values: ['Yes', 'No', 'Uncertain'] } }, diff --git a/src/tabulator.css b/src/tabulator.css index ede349f..d7dfa61 100644 --- a/src/tabulator.css +++ b/src/tabulator.css @@ -1,5 +1,6 @@ .tabulator-cell .non-curated .fa.fa-square { color: grey; + cursor: pointer; } .tabulator-cell .non-curable .fa.fa-square { @@ -10,18 +11,22 @@ .tabulator-cell .not-exported .fa.fa-square { color: grey; + cursor: pointer; } .tabulator-cell .rejected .fa.fa-times { color: red; + cursor: pointer; } .tabulator-cell .accepted .fa.fa-check { color: green; + cursor: pointer; } .tabulator-cell .exported .fa.fa-file-circle-check { color: blue; + cursor: pointer; } .tabulator-cell .non-exportable .fa.fa-file-circle-check { @@ -32,6 +37,7 @@ .tabulator-cell .evidence .fa.fa-eye { color: #8e44ad; + cursor: pointer; } .tabulator-cell .no-evidence .fa.fa-eye { @@ -42,12 +48,37 @@ .tabulator-cell .save-finding .fa-solid.fa-floppy-disk { color: black; + cursor: pointer; } .tabulator-cell .cancel-edition .fa-solid.fa-pencil { color: #abb2b9; + cursor: pointer; +} + +.tabulator-cell .edition-unabled .fa-solid.fa-pencil { + color: #566573; + cursor: default; } .tabulator-cell .enable-edition .fa-solid.fa-pencil { color: #566573; + cursor: pointer; +} + +.tabulator-cell.editable-cell { + cursor: pointer; + background-color: #ffcc66; +} + +.tabulator-cell.non-editable-cell { + cursor: default; +} + +.tabulator-row.editable { + background-color: #ffcc66; +} + +.tabulator-row.evidence-selected { + border: 1px solid black; } -- GitLab From dc6a4a9402e4b910c1382c413a10f4b936fde2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Wed, 24 Aug 2022 09:27:40 +0200 Subject: [PATCH 08/17] Remove useless css --- .../pretoxsentences-tabulator.component.css | 14 -------------- src/styles.css | 12 +----------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.css b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.css index 80ba5c2..e69de29 100644 --- a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.css +++ b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.css @@ -1,14 +0,0 @@ -.tabulator { - font-size: 100px; - border: none; - } - .tabulator-row-odd { - background-color: #553333 !important; -} -.tabulator-row-even { - background-color: #335533 !important; -} - -.tabulator-row tabulator-selectable tabulator-row-odd { - font-size: 20px; -} \ No newline at end of file diff --git a/src/styles.css b/src/styles.css index 74eeba0..25f1418 100644 --- a/src/styles.css +++ b/src/styles.css @@ -1,11 +1 @@ -@import "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css"; -/* .tabulator { - font-size: 100px; - border: none; - } - .tabulator-row-odd { - background-color: #553333 !important; -} -.tabulator-row-even { - background-color: #335533 !important; -} */ \ No newline at end of file +@import "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css"; \ No newline at end of file -- GitLab From 9fd44e9863b0dcf244be519cd8e7ce92bbc9d4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Tue, 30 Aug 2022 13:51:32 +0200 Subject: [PATCH 09/17] Add new finding --- .../document-detail.component.ts | 10 +- src/app/document.service.ts | 341 +++++++++--------- 2 files changed, 182 insertions(+), 169 deletions(-) diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index dd25ca4..2d2a685 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -445,9 +445,13 @@ export class DocumentDetailComponent implements OnInit { updateFinding(data) { const id = +this.route.snapshot.paramMap.get('id'); - this.documentService.updateFinding(id, data) - .subscribe(text => { - }); + if (data.isNew) { + this.documentService.addFinding(id, data); + } else { + this.documentService.updateFinding(id, data) + .subscribe(text => { + }); + } } setFindingValidation(data) { diff --git a/src/app/document.service.ts b/src/app/document.service.ts index 5e019ac..78f8102 100644 --- a/src/app/document.service.ts +++ b/src/app/document.service.ts @@ -11,14 +11,14 @@ import { environment } from './../environments/environment'; import { DocumentTracking } from './document-tracking'; import { FindingSR } from './findingsr'; const httpOptions = { - headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }) + headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }) }; @Injectable({ providedIn: 'root' }) export class DocumentService { - private pretoxUrl = environment.apiUrl; + private pretoxUrl = environment.apiUrl; private documentsUrl = environment.apiUrl + "/documents/"; private reportsUrl = environment.apiUrl + "/reports/"; private apiSRDomainURL = environment.apiSRDomainUrl + "/reports/"; @@ -48,13 +48,13 @@ export class DocumentService { ); } - /** GET document by id. Will 404 if id not found */ - exportDocument(id: number, name: string): any { - const url = `${this.documentsUrl}export/${id}`; - return this.http.get(url, { - responseType: 'blob', - observe: 'response' - }) + /** GET document by id. Will 404 if id not found */ + exportDocument(id: number, name: string): any { + const url = `${this.documentsUrl}export/${id}`; + return this.http.get(url, { + responseType: 'blob', + observe: 'response' + }) .pipe(map(res => { console.log(res.headers.get('content-disposition')); return { @@ -73,15 +73,15 @@ export class DocumentService { window.URL.revokeObjectURL(url); a.remove(); }); - } - - /** GET the legacy pdf report */ - openLegacyReport(gridFSId: number): any { - const url = `${this.reportsUrl}download/${gridFSId}`; - return this.http.get(url, { - responseType: 'blob', - observe: 'response' - }) + } + + /** GET the legacy pdf report */ + openLegacyReport(gridFSId: number): any { + const url = `${this.reportsUrl}download/${gridFSId}`; + return this.http.get(url, { + responseType: 'blob', + observe: 'response' + }) .pipe(map(res => { console.log(res.headers.get('content-disposition')); return { @@ -100,95 +100,104 @@ export class DocumentService { window.URL.revokeObjectURL(url); a.remove(); }); - } - - - - /** DEPRECATED, no more levels of findings set validation of finding */ - setFindingValidation(id: number, findingId: number, finding_validation: string): Observable { - const url = `${this.documentsUrl}${id}/findingValidation/${findingId}/${finding_validation}`; - return this.http.get(url , {responseType: 'text'}).pipe( - tap(_ => this.log(`finding_validation id=${findingId}`)), - catchError(this.handleError(`finding_validation id=${findingId}`)) - ); - } - - /** set validation of finding, indicate if is coreect or not the finding */ - setSRFindingValidation(id: number, srfindingId: number, finding_validation: string): Observable { - const url = `${this.documentsUrl}${id}/srfinding/${srfindingId}/validation/${finding_validation}`; - return this.http.put(url,{responseType: 'text'}).pipe( - tap(_ => this.log(`finding_validation id=${srfindingId}`)), - catchError(this.handleError(`finding_validation id=${srfindingId}`)) - ); - } - - /** set export finding */ - setExportSRDomain(id: number, srfindingId: number, export_finding: string): Observable { - const url = `${this.documentsUrl}${id}/srfinding/${srfindingId}/export/${export_finding}`; - return this.http.put(url,{responseType: 'text'}).pipe( - tap(_ => this.log(`export finding id=${srfindingId}`)), - catchError(this.handleError(`setExportSRDomain id=${srfindingId}`)) - ); - } - - /** move document */ - moveDocument(id: number, status: string): any { - const url = `${this.documentsUrl}${id}/move/${status}`; - return this.http.put(url,{responseType: 'text'}).pipe( - tap(_ => this.log(`moveDocument id=${id}`)), - catchError(this.handleError(`moveDocument id=${id}`)) - ); - } - - /** Update Finding */ - updateFinding(id: number, finding: FindingSR): 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); - } - })*/ + } + + + + /** DEPRECATED, no more levels of findings set validation of finding */ + setFindingValidation(id: number, findingId: number, finding_validation: string): Observable { + const url = `${this.documentsUrl}${id}/findingValidation/${findingId}/${finding_validation}`; + return this.http.get(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`finding_validation id=${findingId}`)), + catchError(this.handleError(`finding_validation id=${findingId}`)) + ); + } + + /** set validation of finding, indicate if is coreect or not the finding */ + setSRFindingValidation(id: number, srfindingId: number, finding_validation: string): Observable { + const url = `${this.documentsUrl}${id}/srfinding/${srfindingId}/validation/${finding_validation}`; + return this.http.put(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`finding_validation id=${srfindingId}`)), + catchError(this.handleError(`finding_validation id=${srfindingId}`)) + ); + } + + /** set export finding */ + setExportSRDomain(id: number, srfindingId: number, export_finding: string): Observable { + const url = `${this.documentsUrl}${id}/srfinding/${srfindingId}/export/${export_finding}`; + return this.http.put(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`export finding id=${srfindingId}`)), + catchError(this.handleError(`setExportSRDomain id=${srfindingId}`)) + ); + } + + /** move document */ + moveDocument(id: number, status: string): any { + const url = `${this.documentsUrl}${id}/move/${status}`; + return this.http.put(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`moveDocument id=${id}`)), + catchError(this.handleError(`moveDocument id=${id}`)) + ); + } + + /** Update Finding */ + updateFinding(id: number, finding: FindingSR): 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); + } + })*/ - } + } + + /** Update Finding */ + addFinding(id: number, finding: FindingSR): 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`; - return this.http.get(url).pipe( + /** show history tracking */ + getHistory(id: number): Observable { + const url = `${this.documentsUrl}${id}/tracking`; + return this.http.get(url).pipe( tap(_ => this.log(`fetched document id=${id}`)), catchError(this.handleError(`getDocument id=${id}`)) - ); - } - - /** GET Snipped of finding selected */ - findingSelected(id: number, finding: Finding): Observable { - const url = `${this.documentsUrl}${id}/evidence/finding/${finding.findingId}`; - return this.http.get(url , {responseType: 'text'}).pipe( - tap(_ => this.log(`fetched finding id=${finding.findingId}`)), - catchError(this.handleError(`getFinding id=${finding.findingId}`)) - ); - } - - /** GET Snipped of the full text with no annotations */ - findDocumentText(id: number): Observable { - const url = `${this.documentsUrl}${id}/text/`; - return this.http.get(url , {responseType: 'text'}).pipe( - tap(_ => this.log(`fetched text id=${id}`)), - catchError(this.handleError(`getText id=${id}`)) - ); - } - - /** Get SRDomain format and send to srdomain api */ + ); + } + + /** GET Snipped of finding selected */ + findingSelected(id: number, finding: Finding): Observable { + const url = `${this.documentsUrl}${id}/evidence/finding/${finding.findingId}`; + return this.http.get(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`fetched finding id=${finding.findingId}`)), + catchError(this.handleError(`getFinding id=${finding.findingId}`)) + ); + } + + /** GET Snipped of the full text with no annotations */ + findDocumentText(id: number): Observable { + const url = `${this.documentsUrl}${id}/text/`; + return this.http.get(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`fetched text id=${id}`)), + catchError(this.handleError(`getText id=${id}`)) + ); + } + + /** Get SRDomain format and send to srdomain api */ sendToSRDomain(id: number): any { //call to get srdomain const url_2 = `${this.documentsUrl}srdomain/${id}`; @@ -198,69 +207,69 @@ export class DocumentService { const url = `${this.apiSRDomainURL}`; return this.http.post(url, doc).subscribe({ next: data => { - alert(data); + alert(data); }, error: error => { - //this.errorMessage = error.message; - console.error('There was an error!', error); + //this.errorMessage = error.message; + console.error('There was an error!', error); } - }) - + }) + }, error: error => { - //this.errorMessage = error.message; - console.error('There was an error!', error); + //this.errorMessage = error.message; + console.error('There was an error!', error); } - }) + }) + + } + + /** GET Snipped of findings selected just in case is needed, is not complete only the calls againt rest api is done*/ + findingsSelected(id: number, finding: Finding): Observable { + //const url = `${this.documentsUrl}/${id}/finding/${finding.findingId}`; + const url = `${this.documentsUrl}${id}/findings/1,2`; + return this.http.get(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`fetched finding id=${finding.findingId}`)), + catchError(this.handleError(`getFinding id=${finding.findingId}`)) + ); + } + + /** GET Snipped of all finding evidence */ + getAllEvidence(id: number): Observable { + const url = `${this.documentsUrl}${id}/evidence/findings`; + return this.http.get(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`fetched all evidence id=${id}`)), + catchError(this.handleError(`getFindings id=${id}`)) + ); + } + + /** GET Snipped of all finding evidence */ + getEvidence(id: number): Observable { + const url = `${this.documentsUrl}${id}/evidence/all`; + return this.http.get(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`fetched all evidence id=${id}`)), + catchError(this.handleError(`getFindings id=${id}`)) + ); + } + /** GET Snipped of sentences evidence */ + getSentencesEvidence(id: number): Observable { + const url = `${this.documentsUrl}${id}/evidence/sentences`; + return this.http.get(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`fetched all sentences evidence id=${id}`)), + catchError(this.handleError(`getSentencesEvidence id=${id}`)) + ); } - /** GET Snipped of findings selected just in case is needed, is not complete only the calls againt rest api is done*/ - findingsSelected(id: number, finding: Finding): Observable { - //const url = `${this.documentsUrl}/${id}/finding/${finding.findingId}`; - const url = `${this.documentsUrl}${id}/findings/1,2`; - return this.http.get(url , {responseType: 'text'}).pipe( - tap(_ => this.log(`fetched finding id=${finding.findingId}`)), - catchError(this.handleError(`getFinding id=${finding.findingId}`)) - ); - } - - /** GET Snipped of all finding evidence */ - getAllEvidence(id: number): Observable { - const url = `${this.documentsUrl}${id}/evidence/findings`; - return this.http.get(url , {responseType: 'text'}).pipe( - tap(_ => this.log(`fetched all evidence id=${id}`)), - catchError(this.handleError(`getFindings id=${id}`)) - ); - } - - /** GET Snipped of all finding evidence */ - getEvidence(id: number): Observable { - const url = `${this.documentsUrl}${id}/evidence/all`; - return this.http.get(url , {responseType: 'text'}).pipe( - tap(_ => this.log(`fetched all evidence id=${id}`)), - catchError(this.handleError(`getFindings id=${id}`)) - ); - } - - /** GET Snipped of sentences evidence */ - getSentencesEvidence(id: number): Observable { - const url = `${this.documentsUrl}${id}/evidence/sentences`; - return this.http.get(url , {responseType: 'text'}).pipe( - tap(_ => this.log(`fetched all sentences evidence id=${id}`)), - catchError(this.handleError(`getSentencesEvidence id=${id}`)) - ); - } - - pretoxSentenceSelected(id: number, pretoxSentence: Annotation): Observable { - const url = `${this.documentsUrl}${id}/evidence/sentence/${pretoxSentence.id}`; - //const url = `${this.documentsUrl}/${id}/sentence/1`; - return this.http.get(url , {responseType: 'text'}).pipe( - tap(_ => this.log(`fetched pretox sentence id=${pretoxSentence.id}`)), - catchError(this.handleError(`getPretoxSentence id=${pretoxSentence.id}`)) - ); - } + pretoxSentenceSelected(id: number, pretoxSentence: Annotation): Observable { + const url = `${this.documentsUrl}${id}/evidence/sentence/${pretoxSentence.id}`; + //const url = `${this.documentsUrl}/${id}/sentence/1`; + return this.http.get(url, { responseType: 'text' }).pipe( + tap(_ => this.log(`fetched pretox sentence id=${pretoxSentence.id}`)), + catchError(this.handleError(`getPretoxSentence id=${pretoxSentence.id}`)) + ); + } /** PUT: update the document on the server */ updateDocument(document: Document): Observable { @@ -282,19 +291,19 @@ export class DocumentService { deleteDocument(id: number): Observable { const url = `${this.documentsUrl}remove/${id}`; alert(url); - return this.http.delete(url , {responseType: 'text'}).pipe( + return this.http.delete(url, { responseType: 'text' }).pipe( tap(_ => this.log(`finding_validation id=${id}`)), catchError(this.handleError(`finding_validation id=${id}`)) - ); + ); } /** Delete report */ deleteReport(id: string): Observable { const url = `${this.reportsUrl}remove/${id}`; - return this.http.delete(url , {responseType: 'text'}).pipe( + return this.http.delete(url, { responseType: 'text' }).pipe( tap(_ => this.log(`deleteReport id=${id}`)), catchError(this.handleError(`deleteReport id=${id}`)) - ); + ); } /** Log a DocumentService message with the MessageService */ @@ -310,13 +319,13 @@ export class DocumentService { */ private handleError(operation = 'operation', result?: T) { return (error: any): Observable => { - // TODO: send the error to remote logging infrastructure - console.error(error); // log to console instead - // TODO: better job of transforming error for user consumption - this.log(`${operation} failed: ${error.message}`); - // Let the app keep running by returning an empty result. - return of(result as T); + // TODO: send the error to remote logging infrastructure + console.error(error); // log to console instead + // TODO: better job of transforming error for user consumption + this.log(`${operation} failed: ${error.message}`); + // Let the app keep running by returning an empty result. + return of(result as T); }; } - + } -- GitLab From e72ad1935af05a7d31f73e8f8ada510bdecd6d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Wed, 31 Aug 2022 12:59:35 +0200 Subject: [PATCH 10/17] Disable add button when needed --- src/app/document-detail/document-detail.component.css | 3 ++- src/app/document-detail/document-detail.component.html | 4 ++-- src/app/document-detail/document-detail.component.ts | 8 ++++++++ .../srdomaintemplate-tabulator.component.ts | 7 ++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/document-detail/document-detail.component.css b/src/app/document-detail/document-detail.component.css index 3d94a39..48228ed 100644 --- a/src/app/document-detail/document-detail.component.css +++ b/src/app/document-detail/document-detail.component.css @@ -22,7 +22,8 @@ } .add-fiding-button { - cursor: pointer; + background-color: transparent; + border: none; margin-left: auto; margin-block: auto; } diff --git a/src/app/document-detail/document-detail.component.html b/src/app/document-detail/document-detail.component.html index 7b7f3c6..6387446 100644 --- a/src/app/document-detail/document-detail.component.html +++ b/src/app/document-detail/document-detail.component.html @@ -68,9 +68,9 @@ {{link.label}} - +
diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index 8d210ca..9074093 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -58,6 +58,8 @@ export class DocumentDetailComponent implements OnInit { @Input() document: Document; + addFindingEnabled: boolean; + data: SafeHtml; docData: string; @@ -557,6 +559,12 @@ export class DocumentDetailComponent implements OnInit { this.updateFinding(data); }) } + + if (componentReference.enableAddFindingEvent != undefined) { + componentReference.enableAddFindingEvent.subscribe(isEnabled => { + this.addFindingEnabled = isEnabled; + }); + } } goBack(): void { diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index a7c49ff..48a3d46 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -26,6 +26,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { @Output() rowClickSRFindingValidationEvent = new EventEmitter(); @Output() rowClickUpdateFindingEvent = new EventEmitter(); @Output() srFindingType = new EventEmitter(); + @Output() enableAddFindingEvent = new EventEmitter(); tab = document.createElement('div'); @@ -42,9 +43,10 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { ngOnInit(): void { this.getDocument(); + this.enableAddFindingEvent.emit(true); this.sharedService.addFindingEvent.subscribe(() => { this.addFinding(); - }) + }); } activation(data) { @@ -370,6 +372,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { pretoxSRDomainTemplateTab.document.findingInEdition == -1) { data.inEdition = true; pretoxSRDomainTemplateTab.document.findingInEdition = 1; + pretoxSRDomainTemplateTab.enableAddFindingEvent.emit(false); row.getCell('ed2').getElement().innerHTML = '
'; cell.getElement().innerHTML = '
'; row.getElement().className = "tabulator-row editable"; @@ -380,6 +383,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } else if (data.inEdition == true) { data.inEdition = false; pretoxSRDomainTemplateTab.document.findingInEdition = -1; + pretoxSRDomainTemplateTab.enableAddFindingEvent.emit(true); row.getCell('ed2').getElement().innerHTML = ''; cell.getElement().innerHTML = '
'; row.getElement().className = "tabulator-row"; @@ -400,6 +404,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { if (data.inEdition == true) { data.inEdition = false; pretoxSRDomainTemplateTab.document.findingInEdition = -1; + pretoxSRDomainTemplateTab.enableAddFindingEvent.emit(true); row.getElement().className = "tabulator-row"; row.getCells().forEach(rowCell => { rowCell.getElement().className = "tabulator-cell non-editable-cell"; -- GitLab From b2007930b10b191424fc3fe723086fbb4959dd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Wed, 31 Aug 2022 14:20:29 +0200 Subject: [PATCH 11/17] Avoid repeated requests of document --- .../pretoxsentences-tabulator.component.ts | 140 +++++++----------- .../srdomaintemplate-tabulator.component.ts | 107 +++++++------ 2 files changed, 104 insertions(+), 143 deletions(-) diff --git a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts index 198c7de..c790051 100644 --- a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts +++ b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts @@ -48,97 +48,63 @@ export class PretoxsentencesTabulatorComponent implements OnInit { } getDocument(): void { - const id = this.document.documentId; - this.documentService.getDocument(id) - .subscribe(document => { - this.document = document; - //var data = []; - var data_relevant_sentences = []; - //var srDomainFindingsGlobal = []; - //relevant sentence table - document.relevantSentences.forEach(annotation => { - //var findings = []; - var srDomainFindings_2 = []; - annotation.findings.forEach(find => { - //var srDomainFindings = []; - find.srDomainFindings.forEach(srDomainFinding => { - srDomainFindings_2.push({ - studyid: srDomainFinding.studyid, - domain: srDomainFinding.domain, - srseq: srDomainFinding.srseq, - srrisk: srDomainFinding.srrisk, - - spgrpcd: srDomainFinding.spgrpcd, - srgrpnam: srDomainFinding.srgrpnam, - srgrpdos: srDomainFinding.srgrpdos, - srsex: srDomainFinding.srsex, - - srstdy: srDomainFinding.srstdy, - srstphse: srDomainFinding.srstphse, - srobstdy: srDomainFinding.srobstdy, - srendy: srDomainFinding.srendy, - - - srenphse: srDomainFinding.srenphse, - srobendy: srDomainFinding.srobendy, - srdomain: srDomainFinding.srdomain, - srspec: srDomainFinding.srspec, - - srtstcd: srDomainFinding.srtstcd, - srfndg: srDomainFinding.srfndg, - srores: srDomainFinding.srores, - srobsv: srDomainFinding.srobsv, - - srobsq: srDomainFinding.srobsq, - srsev: srDomainFinding.srsev, - srpcnt: srDomainFinding.srpcnt, - srsigf: srDomainFinding.srsigf, - - srtrtef: srDomainFinding.srpcnt, - srcomnt: srDomainFinding.srsigf, - - export: srDomainFinding.export, - status: srDomainFinding.status, - srDomainId: srDomainFinding.srDomainId, - findingId: srDomainFinding.findingId, - - }) - - }); - - // findings.push({ - // id : find.findingId, - // finding: find.finding != null ? find.finding.value : '', - // study_testcd: find.study_testcd != null ? find.study_testcd.value : '', - // manifestation_finding: find.manifestation_finding != null ? find.manifestation_finding.value : '', - // study_domain: find.study_domain != null ? find.study_domain.value : '', - // specimen: find.specimen != null ? find.specimen.value : '', - // sex: find.sex != null ? find.sex.value : '', - // dose: find.dose != null ? find.dose.value : '', - // group: find.group != null ? find.group.value : '', - // is_trf: find.is_treatment_related != null ? find.is_treatment_related.value : '', - // export: find.export, - // status: find.status, - // selected: false, - // srDomainFindings:srDomainFindings - // }); - - //srDomainFindingsGlobal = srDomainFindingsGlobal.concat(srDomainFindings); - + var data_relevant_sentences = []; + //relevant sentence table + this.document.relevantSentences.forEach(annotation => { + var srDomainFindings_2 = []; + annotation.findings.forEach(find => { + find.srDomainFindings.forEach(srDomainFinding => { + srDomainFindings_2.push({ + studyid: srDomainFinding.studyid, + domain: srDomainFinding.domain, + srseq: srDomainFinding.srseq, + srrisk: srDomainFinding.srrisk, + + spgrpcd: srDomainFinding.spgrpcd, + srgrpnam: srDomainFinding.srgrpnam, + srgrpdos: srDomainFinding.srgrpdos, + srsex: srDomainFinding.srsex, + + srstdy: srDomainFinding.srstdy, + srstphse: srDomainFinding.srstphse, + srobstdy: srDomainFinding.srobstdy, + srendy: srDomainFinding.srendy, + + srenphse: srDomainFinding.srenphse, + srobendy: srDomainFinding.srobendy, + srdomain: srDomainFinding.srdomain, + srspec: srDomainFinding.srspec, + + srtstcd: srDomainFinding.srtstcd, + srfndg: srDomainFinding.srfndg, + srores: srDomainFinding.srores, + srobsv: srDomainFinding.srobsv, + + srobsq: srDomainFinding.srobsq, + srsev: srDomainFinding.srsev, + srpcnt: srDomainFinding.srpcnt, + srsigf: srDomainFinding.srsigf, + + srtrtef: srDomainFinding.srpcnt, + srcomnt: srDomainFinding.srsigf, + + export: srDomainFinding.export, + status: srDomainFinding.status, + srDomainId: srDomainFinding.srDomainId, + findingId: srDomainFinding.findingId, }) - - data_relevant_sentences.push({ - id: annotation.id, - text : annotation.text, - //findings: findings, - srDomainFindings: srDomainFindings_2 - }); }); - this.tableData = data_relevant_sentences; - this.drawTable(this); }); + data_relevant_sentences.push({ + id: annotation.id, + text: annotation.text, + srDomainFindings: srDomainFindings_2 + }); + }); + this.tableData = data_relevant_sentences; + this.drawTable(this); } private drawTable(pretoxSentencesTab): void { @@ -146,7 +112,7 @@ export class PretoxsentencesTabulatorComponent implements OnInit { data: this.tableData, height: this.height, persistentLayout: false, - layout:"fitColumns", + layout: "fitColumns", persistentSort: false, pagination: true, selectable: false, diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index 39eba66..e77cb85 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -169,66 +169,61 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } getDocument(): void { - const id = this.document.documentId; - this.documentService.getDocument(id) - .subscribe(document => { - this.document = document; - var srDomainFindingsGlobal = []; - //relevant sentence table - document.relevantSentences.forEach(annotation => { - var findings = []; - annotation.findings.forEach(find => { - var srDomainFindings = []; - find.srDomainFindings.forEach(srDomainFinding => { - srDomainFindings.push({ - studyid: srDomainFinding.studyid, - domain: srDomainFinding.domain, - srseq: srDomainFinding.srseq, - srrisk: srDomainFinding.srrisk, - - spgrpcd: srDomainFinding.spgrpcd, - srgrpnam: srDomainFinding.srgrpnam, - srgrpdos: srDomainFinding.srgrpdos, - srsex: srDomainFinding.srsex, - - srstdy: srDomainFinding.srstdy, - srstphse: srDomainFinding.srstphse, - srobstdy: srDomainFinding.srobstdy, - srendy: srDomainFinding.srendy, - - srenphse: srDomainFinding.srenphse, - srobendy: srDomainFinding.srobendy, - srdomain: srDomainFinding.srdomain, - srspec: srDomainFinding.srspec, - - srtstcd: srDomainFinding.srtstcd, - srfndg: srDomainFinding.srfndg, - srores: srDomainFinding.srores, - srobsv: srDomainFinding.srobsv, - - srobsq: srDomainFinding.srobsq, - srsev: srDomainFinding.srsev, - srpcnt: srDomainFinding.srpcnt, - srsigf: srDomainFinding.srsigf, - - srtrtef: srDomainFinding.srtrtef, - srcomnt: srDomainFinding.srsigf, - - export: srDomainFinding.export, - status: srDomainFinding.status, - srDomainId: srDomainFinding.srDomainId, - findingId: srDomainFinding.findingId, + var srDomainFindingsGlobal = []; + //relevant sentence table + this.document.relevantSentences.forEach(annotation => { + var findings = []; + annotation.findings.forEach(find => { + var srDomainFindings = []; + find.srDomainFindings.forEach(srDomainFinding => { + srDomainFindings.push({ + studyid: srDomainFinding.studyid, + domain: srDomainFinding.domain, + srseq: srDomainFinding.srseq, + srrisk: srDomainFinding.srrisk, + + spgrpcd: srDomainFinding.spgrpcd, + srgrpnam: srDomainFinding.srgrpnam, + srgrpdos: srDomainFinding.srgrpdos, + srsex: srDomainFinding.srsex, + + srstdy: srDomainFinding.srstdy, + srstphse: srDomainFinding.srstphse, + srobstdy: srDomainFinding.srobstdy, + srendy: srDomainFinding.srendy, + + srenphse: srDomainFinding.srenphse, + srobendy: srDomainFinding.srobendy, + srdomain: srDomainFinding.srdomain, + srspec: srDomainFinding.srspec, + + srtstcd: srDomainFinding.srtstcd, + srfndg: srDomainFinding.srfndg, + srores: srDomainFinding.srores, + srobsv: srDomainFinding.srobsv, + + srobsq: srDomainFinding.srobsq, + srsev: srDomainFinding.srsev, + srpcnt: srDomainFinding.srpcnt, + srsigf: srDomainFinding.srsigf, + + srtrtef: srDomainFinding.srtrtef, + srcomnt: srDomainFinding.srsigf, + + export: srDomainFinding.export, + status: srDomainFinding.status, + srDomainId: srDomainFinding.srDomainId, + findingId: srDomainFinding.findingId, - }); - }); - - srDomainFindingsGlobal = srDomainFindingsGlobal.concat(srDomainFindings); }); }); - this.tableData = srDomainFindingsGlobal; - this.originalData = cloneDeep(srDomainFindingsGlobal); - this.drawTable(this); + + srDomainFindingsGlobal = srDomainFindingsGlobal.concat(srDomainFindings); }); + }); + this.tableData = srDomainFindingsGlobal; + this.originalData = cloneDeep(srDomainFindingsGlobal); + this.drawTable(this); } addFinding() { -- GitLab From 1a52944184f8a782f34272cd540b5e8091ed60c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Wed, 31 Aug 2022 17:00:14 +0200 Subject: [PATCH 12/17] Get document data directly from document component --- .../document-detail.component.ts | 27 ++----- .../history-tracking.component.ts | 4 +- .../pretoxsentences-tabulator.component.ts | 74 ++----------------- .../srdomaintemplate-tabulator.component.ts | 70 ++---------------- 4 files changed, 25 insertions(+), 150 deletions(-) diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index 7e08105..176c610 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -239,7 +239,7 @@ export class DocumentDetailComponent implements OnInit { annotation.findings.forEach(find => { var srDomainFindings = []; find.srDomainFindings.forEach(srDomainFinding => { - srDomainFindings.push({ + const currentFinding = ({ studyid: srDomainFinding.studyid, domain: srDomainFinding.domain, srseq: srDomainFinding.srseq, @@ -276,27 +276,14 @@ export class DocumentDetailComponent implements OnInit { export: srDomainFinding.export, srDomainId: srDomainFinding.srDomainId, - findingId: srDomainFinding.findingId + findingId: srDomainFinding.findingId, + status: srDomainFinding.status }); - }); - findings.push({ - id: find.findingId, - finding: find.finding != null ? find.finding.value : '', - study_testcd: find.study_testcd != null ? find.study_testcd.value : '', - manifestation_finding: find.manifestation_finding != null ? find.manifestation_finding.value : '', - study_domain: find.study_domain != null ? find.study_domain.value : '', - specimen: find.specimen != null ? find.specimen.value : '', - sex: find.sex != null ? find.sex.value : '', - dose: find.dose != null ? find.dose.value : '', - group: find.group != null ? find.group.value : '', - is_trf: find.is_treatment_related != null ? find.is_treatment_related.value : '', - export: find.export, - status: find.status, - selected: false, - srDomainFindings: srDomainFindings + findings.push(currentFinding); + srDomainFindings.push(currentFinding); }); - + srDomainFindingsGlobal = srDomainFindingsGlobal.concat(srDomainFindings); }); @@ -511,7 +498,7 @@ export class DocumentDetailComponent implements OnInit { } onActivate(componentReference) { - componentReference.activation(this.document); + componentReference.activation(this); if (componentReference.rowClickEventFinding != undefined) { componentReference.rowClickEventFinding.subscribe((data) => { diff --git a/src/app/history-tracking/history-tracking.component.ts b/src/app/history-tracking/history-tracking.component.ts index d16d73d..c32905d 100644 --- a/src/app/history-tracking/history-tracking.component.ts +++ b/src/app/history-tracking/history-tracking.component.ts @@ -23,8 +23,8 @@ export class HistoryTrackingComponent implements OnInit { } - activation(data){ - this.documentTracking = data; + activation(parentComponent){ + this.documentTracking = parentComponent.document; } getTracking(): void { diff --git a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts index c790051..5e053ba 100644 --- a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts +++ b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts @@ -17,6 +17,7 @@ export class PretoxsentencesTabulatorComponent implements OnInit { //@Input() columnNames: any[] = []; tableData: any[] = []; + sentence_data: any[] = []; @Input() document: Document; @Input() height = '100%'; //@Input() height = '600px'; @@ -35,75 +36,16 @@ export class PretoxsentencesTabulatorComponent implements OnInit { } ngOnInit(): void { - this.getDocument(); - //this.drawTable(this); - } - - activation(data) { - this.document = data; - } - - ngOnChanges(changes: SimpleChanges): void { + this.tableData = this.sentence_data; this.drawTable(this); } - getDocument(): void { - var data_relevant_sentences = []; - //relevant sentence table - this.document.relevantSentences.forEach(annotation => { - var srDomainFindings_2 = []; - annotation.findings.forEach(find => { - find.srDomainFindings.forEach(srDomainFinding => { - srDomainFindings_2.push({ - studyid: srDomainFinding.studyid, - domain: srDomainFinding.domain, - srseq: srDomainFinding.srseq, - srrisk: srDomainFinding.srrisk, - - spgrpcd: srDomainFinding.spgrpcd, - srgrpnam: srDomainFinding.srgrpnam, - srgrpdos: srDomainFinding.srgrpdos, - srsex: srDomainFinding.srsex, - - srstdy: srDomainFinding.srstdy, - srstphse: srDomainFinding.srstphse, - srobstdy: srDomainFinding.srobstdy, - srendy: srDomainFinding.srendy, - - srenphse: srDomainFinding.srenphse, - srobendy: srDomainFinding.srobendy, - srdomain: srDomainFinding.srdomain, - srspec: srDomainFinding.srspec, + activation(parentComponent){ + this.document = parentComponent.document; + this.sentence_data = parentComponent.tableDataPretoxSentences; + } - srtstcd: srDomainFinding.srtstcd, - srfndg: srDomainFinding.srfndg, - srores: srDomainFinding.srores, - srobsv: srDomainFinding.srobsv, - - srobsq: srDomainFinding.srobsq, - srsev: srDomainFinding.srsev, - srpcnt: srDomainFinding.srpcnt, - srsigf: srDomainFinding.srsigf, - - srtrtef: srDomainFinding.srpcnt, - srcomnt: srDomainFinding.srsigf, - - export: srDomainFinding.export, - status: srDomainFinding.status, - srDomainId: srDomainFinding.srDomainId, - findingId: srDomainFinding.findingId, - }) - }); - }); - - data_relevant_sentences.push({ - id: annotation.id, - text: annotation.text, - srDomainFindings: srDomainFindings_2 - }); - }); - - this.tableData = data_relevant_sentences; + ngOnChanges(changes: SimpleChanges): void { this.drawTable(this); } @@ -190,7 +132,7 @@ export class PretoxsentencesTabulatorComponent implements OnInit { var subTable = new Tabulator(tableEl, { //layout: 'fitDataFill', layout: "fitColumns", - data: row.getData().srDomainFindings, + data: row.getData().findings, columns: [ diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index e77cb85..e003422 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -17,6 +17,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { tableData: any[] = []; table: Tabulator; originalData: any[] = []; + finding_data: any[] = []; @Input() document: Document; @Input() height = '100%'; @@ -42,16 +43,19 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }; ngOnInit(): void { - this.getDocument(); + this.tableData = this.finding_data; + this.originalData = cloneDeep(this.finding_data); + this.drawTable(this); this.enableAddFindingEvent.emit(true); this.sharedService.addFindingEvent.subscribe(() => { this.addFinding(); }); } - activation(data) { - this.document = data; - } + activation(parentComponent){ + this.document = parentComponent.document; + this.finding_data= parentComponent.tableDataSRDomainTemplate; + } editCheck(cell) { return cell.getRow().getData().inEdition == true; @@ -168,64 +172,6 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { cell.getRow().update({ srtstcd: "" }) } - getDocument(): void { - var srDomainFindingsGlobal = []; - //relevant sentence table - this.document.relevantSentences.forEach(annotation => { - var findings = []; - annotation.findings.forEach(find => { - var srDomainFindings = []; - find.srDomainFindings.forEach(srDomainFinding => { - srDomainFindings.push({ - studyid: srDomainFinding.studyid, - domain: srDomainFinding.domain, - srseq: srDomainFinding.srseq, - srrisk: srDomainFinding.srrisk, - - spgrpcd: srDomainFinding.spgrpcd, - srgrpnam: srDomainFinding.srgrpnam, - srgrpdos: srDomainFinding.srgrpdos, - srsex: srDomainFinding.srsex, - - srstdy: srDomainFinding.srstdy, - srstphse: srDomainFinding.srstphse, - srobstdy: srDomainFinding.srobstdy, - srendy: srDomainFinding.srendy, - - srenphse: srDomainFinding.srenphse, - srobendy: srDomainFinding.srobendy, - srdomain: srDomainFinding.srdomain, - srspec: srDomainFinding.srspec, - - srtstcd: srDomainFinding.srtstcd, - srfndg: srDomainFinding.srfndg, - srores: srDomainFinding.srores, - srobsv: srDomainFinding.srobsv, - - srobsq: srDomainFinding.srobsq, - srsev: srDomainFinding.srsev, - srpcnt: srDomainFinding.srpcnt, - srsigf: srDomainFinding.srsigf, - - srtrtef: srDomainFinding.srtrtef, - srcomnt: srDomainFinding.srsigf, - - export: srDomainFinding.export, - status: srDomainFinding.status, - srDomainId: srDomainFinding.srDomainId, - findingId: srDomainFinding.findingId, - - }); - }); - - srDomainFindingsGlobal = srDomainFindingsGlobal.concat(srDomainFindings); - }); - }); - this.tableData = srDomainFindingsGlobal; - this.originalData = cloneDeep(srDomainFindingsGlobal); - this.drawTable(this); - } - addFinding() { const findingId = this.table.getDataCount() + 1; const emptyFinding = { -- GitLab From cff499ce555017f216c494c12f1d6c7dd87320e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Fri, 2 Sep 2022 12:10:45 +0200 Subject: [PATCH 13/17] Show added findings in tab and configure button --- .../document-detail.component.ts | 17 +++++------ src/app/model/document.ts | 2 +- src/app/model/srdomainfindingstatus.ts | 6 ++++ src/app/services/document.service.ts | 6 ++-- .../srdomaintemplate-tabulator.component.ts | 29 ++++++++++--------- 5 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 src/app/model/srdomainfindingstatus.ts diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index 176c610..a97a267 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, ViewChild, ElementRef, ViewEncapsulation, AfterViewInit, AfterContentInit, EventEmitter, Output } from '@angular/core'; +import { Component, OnInit, Input, ViewChild, ElementRef, ViewEncapsulation } from '@angular/core'; import { Document } from '../model/document'; import { ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; @@ -9,15 +9,13 @@ import { Finding } from '../model/finding'; import { Annotation } from '../model/annotation'; import { environment } from './../../environments/environment'; - -import { MatToolbarModule } from '@angular/material/toolbar'; import { Router } from '@angular/router'; import { CdisSendCtService } from '../services/cdis-send-ct.service'; +import { Status } from '../model/srdomainfindingstatus'; //brat declare var head: any; declare var Util: any; -declare var Visualizer: any; var displaySpanComment = function (evt, target, spanId, spanType, mods, spanText, commentText, commentType, normalizations) { var left = evt.clientX + "px"; @@ -232,8 +230,6 @@ export class DocumentDetailComponent implements OnInit { this.setNextStatus(this.document.status); var data_relevant_sentences = []; var srDomainFindingsGlobal = []; - - //relevant sentence table document.relevantSentences.forEach(annotation => { var findings = []; annotation.findings.forEach(find => { @@ -255,7 +251,6 @@ export class DocumentDetailComponent implements OnInit { srobstdy: srDomainFinding.srobstdy, srendy: srDomainFinding.srendy, - srenphse: srDomainFinding.srenphse, srobendy: srDomainFinding.srobendy, srdomain: srDomainFinding.srdomain, @@ -294,6 +289,10 @@ export class DocumentDetailComponent implements OnInit { }); }); + this.document.srdomainfindings.forEach(newFinding => { + srDomainFindingsGlobal.push(newFinding); + }); + this.tableDataPretoxSentences = data_relevant_sentences; this.tableDataSRDomainTemplate = srDomainFindingsGlobal; }); @@ -434,8 +433,8 @@ export class DocumentDetailComponent implements OnInit { updateFinding(data) { const id = +this.route.snapshot.paramMap.get('id'); - if (data.isNew) { - this.documentService.addFinding(id, data); + if (data.status == Status.ADDED) { + this.documentService.addFinding(id, data).subscribe(_ => {}); } else { this.documentService.updateFinding(id, data) .subscribe(text => { diff --git a/src/app/model/document.ts b/src/app/model/document.ts index dddaa5c..fb507d1 100644 --- a/src/app/model/document.ts +++ b/src/app/model/document.ts @@ -9,6 +9,6 @@ export class Document { status: string; statusColor: string = 'warning'; textWithAnnotations: string; - findings: SRDomainFinding[]; + srdomainfindings: SRDomainFinding[]; relevantSentences: Annotation[]; } diff --git a/src/app/model/srdomainfindingstatus.ts b/src/app/model/srdomainfindingstatus.ts new file mode 100644 index 0000000..85adb54 --- /dev/null +++ b/src/app/model/srdomainfindingstatus.ts @@ -0,0 +1,6 @@ +export enum Status { + NON_CURATED = "non_curated", + REJECTED = "rejected", + ACCEPTED = "accepted", + ADDED = "added" +} \ No newline at end of file diff --git a/src/app/services/document.service.ts b/src/app/services/document.service.ts index a4fc903..422a521 100644 --- a/src/app/services/document.service.ts +++ b/src/app/services/document.service.ts @@ -10,6 +10,7 @@ import { Report } from '../model/report'; import { environment } from '../../environments/environment'; import { DocumentTracking } from '../model/document-tracking'; import { FindingSR } from '../model/findingsr'; +import { SRDomainFinding } from '../model/srdomainfinding'; const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }) }; @@ -141,7 +142,7 @@ export class DocumentService { } /** Update Finding */ - updateFinding(id: number, finding: FindingSR): any { + updateFinding(id: number, finding: SRDomainFinding): any { const url = `${this.documentsUrl}${id}/srfinding/update/`; return this.http.put(url, finding).pipe( tap(_ => this.log(`updateFinding`)), @@ -160,8 +161,7 @@ export class DocumentService { } - /** Update Finding */ - addFinding(id: number, finding: FindingSR): any { + addFinding(id: number, finding: SRDomainFinding): any { const url = `${this.documentsUrl}${id}/srfinding/add/`; return this.http.put(url, finding).pipe( tap(_ => this.log(`addFinding`)), diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index e003422..2e132b4 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -52,6 +52,10 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }); } + ngOnDestroy() { + this.enableAddFindingEvent.emit(false); + } + activation(parentComponent){ this.document = parentComponent.document; this.finding_data= parentComponent.tableDataSRDomainTemplate; @@ -174,13 +178,14 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { addFinding() { const findingId = this.table.getDataCount() + 1; + // Use srdomain object const emptyFinding = { - studyid: "", + studyid: this.document.name, domain: "", srseq: "", srrisk: "", spgrpcd: "", - grplbl: "", + srgrpnam: "", srgrpdos: "", srsex: "", srstdy: "", @@ -204,7 +209,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { export: "", srDomainId: findingId, findingId: findingId, - isNew: true + status: "added" }; this.tableData.push(emptyFinding); @@ -224,7 +229,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.isNew != true) { + if (data.status != "added") { if (data.status == "accepted") { data.status = "rejected"; cell.getElement().innerHTML = '
'; @@ -241,11 +246,9 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); - if (data.isNew) { + if (data.status == "added") { return '
'; - } - - if (data.status == "accepted") { + } else if (data.status == "accepted") { return '
'; } else if (data.status == "rejected") { return '
'; @@ -258,7 +261,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.isNew != true) { + if (data.status != "added") { if (data.export == undefined || data.export == true) { data.export = false; cell.getElement().innerHTML = '
'; @@ -272,7 +275,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); - if (data.isNew) { + if (data.status == "added") { return '
'; } @@ -286,7 +289,7 @@ 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().isNew != true && cell.getRow().getData().selected != true) { + if (cell.getRow().getData().status != "added" && cell.getRow().getData().selected != true) { cell.getRow().getData().selected = true; cell.getRow().getElement().className = "tabulator-row evidence-selected"; pretoxSRDomainTemplateTab.rowClickEventSRDomainTemplateEvidence.emit(cell.getData()); @@ -296,7 +299,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } }, formatter: function (cell, formatterParams, onRendered) { - if (cell.getRow().getData().isNew) { + if (cell.getRow().getData().status == "added") { return '
'; } @@ -403,6 +406,6 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }); document.getElementById('my-tabular-table-srdomaintemplate').appendChild(this.tab); - this.table.redraw(true); + //this.table.redraw(true); } } -- GitLab From ff23c002ace4244e460a157a2dba86e0b9cb9733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Mon, 5 Sep 2022 09:49:50 +0200 Subject: [PATCH 14/17] Replace strings with constants --- .../srdomaintemplate-tabulator.component.ts | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index 2e132b4..6ebd838 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -6,6 +6,7 @@ import { DocumentService } from '../services/document.service'; import { Document } from '../model/document'; import { cloneDeep } from 'lodash'; import { SharedService } from '../shared.service'; +import { Status } from '../model/srdomainfindingstatus'; @Component({ selector: 'app-srdomaintemplate-tabulator', @@ -209,7 +210,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { export: "", srDomainId: findingId, findingId: findingId, - status: "added" + status: Status.ADDED }; this.tableData.push(emptyFinding); @@ -217,6 +218,10 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } private drawTable(pretoxSRDomainTemplateTab): void { + const addedStatus = Status.ADDED; + const acceptedStatus = Status.ACCEPTED; + const rejectedStatus = Status.REJECTED + const nonCuratedStatus = Status.NON_CURATED; this.table = new Tabulator(this.tab, { layout: 'fitColumns', pagination: true, @@ -229,15 +234,15 @@ 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 != "added") { - if (data.status == "accepted") { - data.status = "rejected"; + if (data.status != addedStatus) { + if (data.status == acceptedStatus) { + data.status = rejectedStatus; cell.getElement().innerHTML = '
'; - } else if (data.status == "rejected") { - data.status = "non_curated"; + } else if (data.status == rejectedStatus) { + data.status = nonCuratedStatus; cell.getElement().innerHTML = '
'; } else { - data.status = "accepted"; + data.status = acceptedStatus; cell.getElement().innerHTML = '
'; } @@ -246,11 +251,11 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); - if (data.status == "added") { + if (data.status == addedStatus) { return '
'; - } else if (data.status == "accepted") { + } else if (data.status == acceptedStatus) { return '
'; - } else if (data.status == "rejected") { + } else if (data.status == rejectedStatus) { return '
'; } else { return '
'; @@ -261,7 +266,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 != "added") { + if (data.status != addedStatus) { if (data.export == undefined || data.export == true) { data.export = false; cell.getElement().innerHTML = '
'; @@ -275,7 +280,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }, formatter: function (cell, formatterParams, onRendered) { var data = cell.getRow().getData(); - if (data.status == "added") { + if (data.status == addedStatus) { return '
'; } @@ -289,7 +294,7 @@ 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 != "added" && cell.getRow().getData().selected != true) { + if (cell.getRow().getData().status != addedStatus && cell.getRow().getData().selected != true) { cell.getRow().getData().selected = true; cell.getRow().getElement().className = "tabulator-row evidence-selected"; pretoxSRDomainTemplateTab.rowClickEventSRDomainTemplateEvidence.emit(cell.getData()); @@ -299,7 +304,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } }, formatter: function (cell, formatterParams, onRendered) { - if (cell.getRow().getData().status == "added") { + if (cell.getRow().getData().status == addedStatus) { return '
'; } -- GitLab From 9b69bde5a08d81d92e337ec0989bb5edf0180a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Mon, 5 Sep 2022 09:54:44 +0200 Subject: [PATCH 15/17] Minor refactor --- .../srdomaintemplate-tabulator.component.ts | 44 ++++--------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index 6ebd838..c0b3229 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -7,6 +7,7 @@ import { Document } from '../model/document'; import { cloneDeep } from 'lodash'; import { SharedService } from '../shared.service'; import { Status } from '../model/srdomainfindingstatus'; +import { SRDomainFinding } from '../model/srdomainfinding'; @Component({ selector: 'app-srdomaintemplate-tabulator', @@ -180,41 +181,14 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { addFinding() { const findingId = this.table.getDataCount() + 1; // Use srdomain object - const emptyFinding = { - studyid: this.document.name, - domain: "", - srseq: "", - srrisk: "", - spgrpcd: "", - srgrpnam: "", - srgrpdos: "", - srsex: "", - srstdy: "", - srstphse: "", - srobstdy: "", - srendy: "", - srenphse: "", - srobendy: "", - srdomain: "", - srspec: "", - srtstcd: "", - srfndg: "", - srores: "", - srobsv: "", - srobsq: "", - srsev: "", - srpcnt: "", - srsigf: "", - srtrtef: "", - srcomnt: "", - export: "", - srDomainId: findingId, - findingId: findingId, - status: Status.ADDED - }; - - this.tableData.push(emptyFinding); - this.table.addRow(emptyFinding); + const newFinding = new SRDomainFinding(); + newFinding.studyid = this.document.name; + newFinding.srDomainId = findingId; + newFinding.findingId = findingId; + newFinding.status = Status.ADDED; + + this.tableData.push(newFinding); + this.table.addRow(newFinding); } private drawTable(pretoxSRDomainTemplateTab): void { -- GitLab From 722abf254b9a6372e72a72b4934b6b6bb4345a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Mon, 5 Sep 2022 10:20:48 +0200 Subject: [PATCH 16/17] Remove comment --- .../srdomaintemplate-tabulator.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index c0b3229..c6aba4c 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -180,7 +180,6 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { addFinding() { const findingId = this.table.getDataCount() + 1; - // Use srdomain object const newFinding = new SRDomainFinding(); newFinding.studyid = this.document.name; newFinding.srDomainId = findingId; -- GitLab From ee33b32552d812d55545ba73ccc4b5f7cac6e979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20D=C3=ADaz=20Roussel?= Date: Mon, 5 Sep 2022 11:36:28 +0200 Subject: [PATCH 17/17] Change event service name --- src/app/document-detail/document-detail.component.ts | 6 +++--- src/app/{shared.service.ts => services/event.service.ts} | 2 +- .../srdomaintemplate-tabulator.component.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/app/{shared.service.ts => services/event.service.ts} (85%) diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index a97a267..aadab3b 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -3,7 +3,7 @@ import { Document } from '../model/document'; import { ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; import { DocumentService } from '../services/document.service'; -import { SharedService } from '../shared.service'; +import { EventService } from '../services/event.service'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { Finding } from '../model/finding'; import { Annotation } from '../model/annotation'; @@ -77,7 +77,7 @@ export class DocumentDetailComponent implements OnInit { static FINISHED = 'FINISHED'; // tslint:disable-next-line: max-line-length - constructor(private router: Router, private route: ActivatedRoute, private documentService: DocumentService, private cdiscSendCTService: CdisSendCtService, private location: Location, private sanitizer: DomSanitizer, private sharedService: SharedService) { + constructor(private router: Router, private route: ActivatedRoute, private documentService: DocumentService, private cdiscSendCTService: CdisSendCtService, private location: Location, private sanitizer: DomSanitizer, private eventService: EventService) { const bratLocation = environment.bratUrl; this.loadBratVisualizer(); @@ -493,7 +493,7 @@ export class DocumentDetailComponent implements OnInit { } addFinding() { - this.sharedService.addFindingEvent.emit(); + this.eventService.addFindingEvent.emit(); } onActivate(componentReference) { diff --git a/src/app/shared.service.ts b/src/app/services/event.service.ts similarity index 85% rename from src/app/shared.service.ts rename to src/app/services/event.service.ts index 6524c69..4b80dd0 100644 --- a/src/app/shared.service.ts +++ b/src/app/services/event.service.ts @@ -3,7 +3,7 @@ import { EventEmitter, Injectable } from "@angular/core"; @Injectable({ providedIn: 'root' }) -export class SharedService { +export class EventService { addFindingEvent: EventEmitter = new EventEmitter(); diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index c6aba4c..fbea754 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute } from '@angular/router'; import { DocumentService } from '../services/document.service'; import { Document } from '../model/document'; import { cloneDeep } from 'lodash'; -import { SharedService } from '../shared.service'; +import { EventService } from '../services/event.service'; import { Status } from '../model/srdomainfindingstatus'; import { SRDomainFinding } from '../model/srdomainfinding'; @@ -33,7 +33,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { tab = document.createElement('div'); - constructor(private route: ActivatedRoute, private documentService: DocumentService, private cdiscSendCTService: CdisSendCtService, private sharedService: SharedService) { } + constructor(private route: ActivatedRoute, private documentService: DocumentService, private cdiscSendCTService: CdisSendCtService, private eventService: EventService) { } ellipsisFormatter(cell, formatterParams, onRendered) { onRendered(function () { @@ -49,7 +49,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { this.originalData = cloneDeep(this.finding_data); this.drawTable(this); this.enableAddFindingEvent.emit(true); - this.sharedService.addFindingEvent.subscribe(() => { + this.eventService.addFindingEvent.subscribe(() => { this.addFinding(); }); } -- GitLab