From 2a8d1c9295c60bb4de10b2bb9470f79b4df640f4 Mon Sep 17 00:00:00 2001 From: David Mendez <dmendez@ebi.ac.uk> Date: Wed, 17 Aug 2022 16:03:38 +0100 Subject: [PATCH] Report card structure: improve way of determining if sections are included --- .../CompoundReportCardGenerator.js | 202 ++++++------------ 1 file changed, 65 insertions(+), 137 deletions(-) diff --git a/report_cards_structure/CompoundReportCardGenerator.js b/report_cards_structure/CompoundReportCardGenerator.js index a0c4e9e..d86aac2 100644 --- a/report_cards_structure/CompoundReportCardGenerator.js +++ b/report_cards_structure/CompoundReportCardGenerator.js @@ -15,150 +15,78 @@ const methods = { isChemicalProbe, isNegativeControl ) { - if (isChemicalProbe) { - return { - title: prefName, - entityName: EntityNames.EubopenCompound.singularEntityName, - sections: [ - { - id: 'Summary', - title: 'Summary', - component: Summary, - index: 0, - }, - { - id: 'ProbeMechanism', - title: 'Mechanism of Action', - component: ProbeMechanism, - index: 1, - }, - { - id: 'ControlStructuresAndUse', - title: 'Negative Controls', - component: ControlStructuresAndUse, - index: 2, - }, - { - id: 'ProbeProfile', - title: 'Activity Profile', - component: ProbeProfile, - index: 3, - }, - { - id: 'CellViabilityAndHealthData', - title: 'Cell Viability And Health Data', - component: CellViabilityAndHealthData, - index: 4, - }, - { - id: 'CalculatedProperties', - title: 'Calculated Properties', - component: CalculatedProperties, - componentParams: { - entityID: EntityNames.EubopenCompound.entityID, - }, + const basePageStructure = [ + { + id: 'Summary', + title: 'Summary', + component: Summary, + include: true, + }, + { + id: 'ProbeMechanism', + title: 'Mechanism of Action', + component: ProbeMechanism, + include: true, + }, + { + id: 'ControlStructuresAndUse', + title: 'Negative Controls', + component: ControlStructuresAndUse, + include: isChemicalProbe, + }, + { + id: 'ProbesForThisCompound', + title: 'Related Probes', + component: ProbesForThisCompound, + include: isNegativeControl, + }, - index: 5, - }, - { - id: 'CrystalStructures', - title: 'PBD Ligand Codes', - component: CompoundCrystalStructures, - index: 6, - }, - ], - } + { + id: 'ProbeProfile', + title: 'Activity Profile', + component: ProbeProfile, + include: true, + }, + { + id: 'CellViabilityAndHealthData', + title: 'Cell Viability And Health Data', + component: CellViabilityAndHealthData, + include: true, + }, + { + id: 'CalculatedProperties', + title: 'Calculated Properties', + component: CalculatedProperties, + componentParams: { + entityID: EntityNames.EubopenCompound.entityID, + }, + include: true, + }, + { + id: 'CrystalStructures', + title: 'PBD Ligand Codes', + component: CompoundCrystalStructures, + include: true, + }, + ] + + const finalPageStructure = { + title: prefName, + entityName: EntityNames.EubopenCompound.singularEntityName, + sections: [], } - if (isNegativeControl) { - return { - title: prefName, - entityName: EntityNames.EubopenCompound.singularEntityName, - sections: [ - { - id: 'Summary', - title: 'Summary', - component: Summary, - index: 0, - }, - { - id: 'ProbeMechanism', - title: 'Mechanism of Action', - component: ProbeMechanism, - index: 1, - }, - { - id: 'ProbesForThisCompound', - title: 'Related Probes', - component: ProbesForThisCompound, - index: 2, - }, - { - id: 'ProbeProfile', - title: 'Activity Profile', - component: ProbeProfile, - index: 3, - }, - { - id: 'CalculatedProperties', - title: 'Calculated Properties', - component: CalculatedProperties, - componentParams: { - entityID: EntityNames.EubopenCompound.entityID, - }, + let index = 0 - index: 4, - }, - { - id: 'CrystalStructures', - title: 'PBD Ligand Codes', - component: CompoundCrystalStructures, - index: 5, - }, - ], + for (const section of basePageStructure) { + if (section.include) { + section.index = index + finalPageStructure.sections.push(section) + index++ } } - return { - title: prefName, - entityName: EntityNames.EubopenCompound.singularEntityName, - sections: [ - { - id: 'Summary', - title: 'Summary', - component: Summary, - index: 0, - }, - { - id: 'ProbeMechanism', - title: 'Mechanism of Action', - component: ProbeMechanism, - index: 1, - }, - { - id: 'ProbeProfile', - title: 'Activity Profile', - component: ProbeProfile, - index: 2, - }, - { - id: 'CalculatedProperties', - title: 'Calculated Properties', - component: CalculatedProperties, - componentParams: { - entityID: EntityNames.EubopenCompound.entityID, - }, - - index: 3, - }, - { - id: 'CrystalStructures', - title: 'PBD Ligand Codes', - component: CompoundCrystalStructures, - index: 4, - }, - ], - } + return finalPageStructure }, } -- GitLab