From 994e2626b8eaf18ddbf0d57bc827b241e0d2d083 Mon Sep 17 00:00:00 2001 From: Becky Reamy Date: Fri, 10 May 2024 15:02:44 -0400 Subject: [PATCH] IP-431: Make new summary section to collapse information --- src/components/Packages/MetadataModal.js | 3 +- src/components/Packages/MetadataRenderer.js | 36 +++++++++++++++++---- src/components/Packages/PackageList.js | 11 ------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/components/Packages/MetadataModal.js b/src/components/Packages/MetadataModal.js index f95a1cc5..446d27ab 100755 --- a/src/components/Packages/MetadataModal.js +++ b/src/components/Packages/MetadataModal.js @@ -17,7 +17,7 @@ class MetadataModal extends Component { isRemoteDataLoaded() { return this.props.dtds && this.props.uploadPackage && this.props.dtds[this.props.uploadPackage.version]; } - + render() { if(!this.isRemoteDataLoaded()) { return
; @@ -54,6 +54,7 @@ class MetadataModal extends Component {

ID: {this.props.uploadPackage._id}

{standardSection} + {summarizedFields} {remainingSections} diff --git a/src/components/Packages/MetadataRenderer.js b/src/components/Packages/MetadataRenderer.js index 531ec37b..93380bc2 100755 --- a/src/components/Packages/MetadataRenderer.js +++ b/src/components/Packages/MetadataRenderer.js @@ -6,30 +6,54 @@ import { getIEFriendlyDate } from '../../helpers/timezoneUtil'; const { TreeNode } = Tree; export class MetadataRenderer { + + collapseSummarySections = (fields) => { + let fieldsSeen = []; + let list = []; + fields.forEach((field) => { + if (!fieldsSeen.includes(field.summarize.label)) { + fieldsSeen.push(field.summarize.label); + list.push(field); + } + }); + return list; + } renderSection = (section, metadata) => { let header = section.sectionHeader; let fields = section.fields; + let summaryFields = fields.filter(function(field){ + return field.summarize !== undefined; + }); + let summarySections = this.collapseSummarySections(summaryFields); return ( { fields.map((fieldJson) => this.renderField(fieldJson, metadata)) } + { summarySections.map((fieldJson) => this.renderSummaryFields(fieldJson, metadata))} ); + } + + renderSummaryFields = (fieldJson, packageInfo) => { + let fieldLabel = fieldJson.summarize.label; + let value = packageInfo[fieldJson.summarize.field]; + let summaryField = fieldLabel + ": " + value; + return +} renderField = (fieldJson, packageInfo) => { if (fieldJson.type === "Submitter Information") { let name= packageInfo.submitter.firstName + " " + packageInfo.submitter.lastName; let nameField = "Submitter: " + name; - let institutionField = "Site Name: " + packageInfo.siteName; return ( - - - - + ); + } else if (fieldJson.summarize !== undefined) { + let field = fieldJson.summarize.label + ": " + packageInfo[fieldJson.summarize.site]; + return } else { - if (fieldJson.fieldName ==="siteName") { + if (fieldJson.displayInSummary !== undefined && fieldJson.displayInSummary === false) { return ""; } let fieldValue = packageInfo[fieldJson.fieldName] === undefined ? "" : packageInfo[fieldJson.fieldName]; diff --git a/src/components/Packages/PackageList.js b/src/components/Packages/PackageList.js index 13fb31c1..561b77e4 100755 --- a/src/components/Packages/PackageList.js +++ b/src/components/Packages/PackageList.js @@ -36,21 +36,10 @@ class PackageList extends Component { async componentDidUpdate(prevProps, prevState, snapShot) { if (this.props !== prevProps) { - console.log("inside of component did update if statement") - console.log("filtering props") - console.log(this.props.filtering) - console.log("prevProps filtering props") - console.log(prevProps.filtering) if (this.props.filtering !== prevProps.filtering) { console.log("in nested if statement in side of component did update") this.setState({packages: applyFilters(this.props.filtering.filters, this.state.unfilteredPackages, this.props.filtering.packageTypes)}); } - console.log("filters") - console.log(this.props.filtering.filters) - console.log("unfiltered packages: ") - console.log(this.state.unfilteredPackages) - console.log("package Types") - console.log(this.props.filtering.packageTypes) if (this.props.refreshPackages) { await this.getPackages(); this.props.setRefreshPackages(false)