Skip to content

Commit

Permalink
Merge pull request #51 from wp-graphql/feat/sort-field-settings
Browse files Browse the repository at this point in the history
feat: sort the settings alphabetically
  • Loading branch information
jasonbahl authored Jan 11, 2024
2 parents bf22070 + ed785d5 commit 62052c3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion wp-blocks/AcfFieldTypeSettingsBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,28 @@ export function AcfFieldTypeSettingsBlock({ fieldTypeSettingsBlockFields }) {
);
}

// copy the nodes so we can sort them before returning
const settings = [...fieldTypeSettings?.nodes];

// sort by name
settings.sort((a, b) => {
let nameA = a.name.toUpperCase(); // ignore upper and lowercase
let nameB = b.name.toUpperCase(); // ignore upper and lowercase
if (nameA < nameB) {
return -1; //nameA comes first
}
if (nameA > nameB) {
return 1; // nameB comes first
}
return 0; // names must be equal
});

return (
<>
<p>Below you will find information about how various ACF field settings can impact how the field will map to the GraphQL Schema and/or modify resolution of the field when queried.</p>
<Card>
<CardHeader className="grid grid-cols-[1fr_110px] items-start space-y-2">
{fieldTypeSettings?.nodes?.map((item, index) => {
{settings?.map((item, index) => {
const { id, name, description, fieldTypeSettingsMeta } = item;
const { impactOnWpgraphql, acfFieldName } = fieldTypeSettingsMeta;

Expand Down

1 comment on commit 62052c3

@headless-platform-by-wp-engine

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the recent updates to your Atlas environment:

App Environment URL Build
acf.wpgraphql.com main https://hb…wered.com ✅ (logs)

Learn more about building on Atlas in our documentation.

Please sign in to comment.