Skip to content

Commit

Permalink
customfields: allow hidding section name
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Romero Caatro committed Aug 1, 2024
1 parent a3cdae1 commit dab23e8
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/lib/forms/widgets/custom_fields/CustomFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -77,16 +78,26 @@ export class CustomFields extends Component {
return (
<>
{sections &&
sections.map(({ fields, paths, ...sectionConfig }) => (
<AccordionField
key={sectionConfig.section}
includesPaths={paths}
label={sectionConfig.section}
active
>
{fields}
</AccordionField>
))}
sections.map((section) => {
const {
fields,
paths,
displaySection,
section: sectionName = "",
} = section;
return displaySection ? (
<AccordionField
key={`section-${sectionName}`}
includesPaths={paths}
label={sectionName}
active
>
{fields}
</AccordionField>
) : (
<Container key="custom-fields-section">{fields}</Container>
);
})}
{discoverFieldsSections && discoverFieldsSections.length > 0 && (
<DiscoverFieldsSection
templateLoaders={templateLoaders}
Expand All @@ -103,6 +114,7 @@ CustomFields.propTypes = {
config: PropTypes.arrayOf(
PropTypes.shape({
section: PropTypes.string.isRequired,
displaySection: PropTypes.bool,
fields: PropTypes.arrayOf(
PropTypes.shape({
field: PropTypes.string.isRequired,
Expand Down

0 comments on commit dab23e8

Please sign in to comment.