Skip to content

Commit ded56d4

Browse files
committed
changes to the get it working
1 parent b8fd1ef commit ded56d4

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

packages/react/spec/auto/form/PolarisAutoRelationshipForm.stories.jsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const ExampleAutoRelatedForm = (props) => {
2020
</Text>
2121
<PolarisAutoInput field="name" />
2222
<PolarisAutoInput field="description" />
23+
<PolarisAutoInput field="inventoryCount" />
2324
</Card>
2425

2526
<Card>
@@ -43,6 +44,7 @@ const ExampleAutoRelatedForm = (props) => {
4344
secondaryLabel="orientation"
4445
>
4546
<PolarisAutoInput field="name" />
47+
<PolarisAutoInput field="orientation" />
4648
<PolarisAutoInput field="attachment" />
4749
</PolarisAutoRelationshipForm>
4850
</Card>
@@ -70,7 +72,13 @@ export default {
7072
],
7173
};
7274

73-
export const Primary = {
75+
export const Create = {
76+
args: {
77+
action: api.widget.create,
78+
},
79+
};
80+
81+
export const Update = {
7482
args: {
7583
action: api.widget.update,
7684
findBy: "1",

packages/react/src/auto/AutoForm.ts

-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ export const useAutoForm = <
179179

180180
const { metadata, fetching: fetchingMetadata, error: metadataError } = useActionMetadata(props.action);
181181

182-
console.log("metadata", metadata);
183-
184182
validateTriggersFromMetadata(metadata);
185183

186184
// filter down the fields to render only what we want to render for this form

packages/react/src/auto/polaris/inputs/relationships/PolarisAutoRelationshipForm.tsx

+14-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ export const PolarisAutoRelationshipForm = autoInput(
3737
return <PolarisAutoBelongsToRelationshipForm pathPrefix={pathPrefix}>{props.children}</PolarisAutoBelongsToRelationshipForm>;
3838
} else if (metadata.configuration.__typename === "GadgetHasManyConfig") {
3939
return (
40-
<PolarisAutoHasManyRelationshipForm field={field} pathPrefix={pathPrefix} primaryLabel={props.primaryLabel}>
40+
<PolarisAutoHasManyRelationshipForm
41+
field={field}
42+
pathPrefix={pathPrefix}
43+
primaryLabel={props.primaryLabel}
44+
secondaryLabel={props.secondaryLabel}
45+
>
4146
{props.children}
4247
</PolarisAutoHasManyRelationshipForm>
4348
);
@@ -79,9 +84,13 @@ const PolarisAutoHasManyRelationshipForm = (props: {
7984
return (
8085
<Box borderColor="border" borderWidth="025" borderRadius="200">
8186
<BlockStack as="ul">
82-
{fields.map((field, idx) => {
87+
{fields.flatMap((field, idx) => {
8388
const record = records[idx];
8489

90+
if (!record) {
91+
return [];
92+
}
93+
8594
const primary = getRecordAsOption(record, primaryLabel);
8695
const secondary = props.secondaryLabel && getRecordLabel(record, props.secondaryLabel);
8796

@@ -110,11 +119,9 @@ const PolarisAutoHasManyRelationshipForm = (props: {
110119
<Text variant="bodyMd" fontWeight="semibold" as="h3">
111120
{primary.label}
112121
</Text>
113-
{secondary && (
114-
<Text variant="bodyMd" as="p" tone="subdued">
115-
{secondary}
116-
</Text>
117-
)}
122+
<Text variant="bodyMd" as="p" tone="subdued">
123+
{secondary ?? <span style={{ visibility: "hidden" }}>&nbsp;</span>}
124+
</Text>
118125
</BlockStack>
119126
) : (
120127
<Text variant="bodyMd" as="h3" tone="subdued">

packages/react/tsconfig.base.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"baseUrl": "./",
77
"target": "es2020",
88
"types": ["jest", "node"],
9-
"importHelpers": true
9+
"importHelpers": true,
10+
"declaration": false
1011
}
1112
}

0 commit comments

Comments
 (0)