diff --git a/report_cards_structure/CompoundReportCardGenerator.js b/report_cards_structure/CompoundReportCardGenerator.js index a0c4e9ed13f5dbd710c80ea6c8a8fa979b1ef9b7..d86aac2b09b10b6b7c5e41df5d39ec6c31621cc2 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 }, }