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 Jul 31, 2024
1 parent a3cdae1 commit 0c47819
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 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,22 @@ 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, section: sectionName = "" } = section;

return sectionName === "" ? (
<Container key={`section-${sectionName}`}>{fields}</Container>
) : (
<AccordionField
key={`section-${sectionName}`}
includesPaths={paths}
label={sectionName}
active
>
{fields}
</AccordionField>
);
})}
{discoverFieldsSections && discoverFieldsSections.length > 0 && (
<DiscoverFieldsSection
templateLoaders={templateLoaders}
Expand Down

0 comments on commit 0c47819

Please sign in to comment.