From dab23e8b66af70cbead983b0bea58797a6fced91 Mon Sep 17 00:00:00 2001 From: Javier Romero Caatro Date: Wed, 31 Jul 2024 12:54:16 +0200 Subject: [PATCH 1/4] customfields: allow hidding section name * closes https://github.com/CERNDocumentServer/cds-rdm/issues/143 --- .../widgets/custom_fields/CustomFields.js | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/lib/forms/widgets/custom_fields/CustomFields.js b/src/lib/forms/widgets/custom_fields/CustomFields.js index afa607d6..7b6d34dc 100644 --- a/src/lib/forms/widgets/custom_fields/CustomFields.js +++ b/src/lib/forms/widgets/custom_fields/CustomFields.js @@ -10,6 +10,7 @@ import PropTypes from "prop-types"; import { DiscoverFieldsSection } from "./DiscoverFieldsSection"; import { AccordionField } from "../../AccordionField"; import { loadWidgetsFromConfig } from "../loader"; +import { Container } from "semantic-ui-react"; export class CustomFields extends Component { constructor(props) { @@ -77,16 +78,26 @@ export class CustomFields extends Component { return ( <> {sections && - sections.map(({ fields, paths, ...sectionConfig }) => ( - - {fields} - - ))} + sections.map((section) => { + const { + fields, + paths, + displaySection, + section: sectionName = "", + } = section; + return displaySection ? ( + + {fields} + + ) : ( + {fields} + ); + })} {discoverFieldsSections && discoverFieldsSections.length > 0 && ( Date: Fri, 2 Aug 2024 17:01:50 +0200 Subject: [PATCH 2/4] Update src/lib/forms/widgets/custom_fields/CustomFields.js --- src/lib/forms/widgets/custom_fields/CustomFields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/forms/widgets/custom_fields/CustomFields.js b/src/lib/forms/widgets/custom_fields/CustomFields.js index 7b6d34dc..039fb633 100644 --- a/src/lib/forms/widgets/custom_fields/CustomFields.js +++ b/src/lib/forms/widgets/custom_fields/CustomFields.js @@ -83,7 +83,7 @@ export class CustomFields extends Component { fields, paths, displaySection, - section: sectionName = "", + section: sectionName, } = section; return displaySection ? ( Date: Fri, 2 Aug 2024 17:16:44 +0200 Subject: [PATCH 3/4] chore: fix formatting --- src/lib/forms/widgets/custom_fields/CustomFields.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/lib/forms/widgets/custom_fields/CustomFields.js b/src/lib/forms/widgets/custom_fields/CustomFields.js index 039fb633..44680c8e 100644 --- a/src/lib/forms/widgets/custom_fields/CustomFields.js +++ b/src/lib/forms/widgets/custom_fields/CustomFields.js @@ -79,12 +79,7 @@ export class CustomFields extends Component { <> {sections && sections.map((section) => { - const { - fields, - paths, - displaySection, - section: sectionName, - } = section; + const { fields, paths, displaySection, section: sectionName } = section; return displaySection ? ( Date: Fri, 2 Aug 2024 17:22:49 +0200 Subject: [PATCH 4/4] custom_fields: display section by default --- src/lib/forms/widgets/custom_fields/CustomFields.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/forms/widgets/custom_fields/CustomFields.js b/src/lib/forms/widgets/custom_fields/CustomFields.js index 44680c8e..abe69417 100644 --- a/src/lib/forms/widgets/custom_fields/CustomFields.js +++ b/src/lib/forms/widgets/custom_fields/CustomFields.js @@ -79,7 +79,12 @@ export class CustomFields extends Component { <> {sections && sections.map((section) => { - const { fields, paths, displaySection, section: sectionName } = section; + const { + fields, + paths, + displaySection = true, + section: sectionName, + } = section; return displaySection ? (