-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide hasMany input on join model when using actions on models with hasManyThrough fields #651
Hide hasMany input on join model when using actions on models with hasManyThrough fields #651
Conversation
0537e9e
to
ef4f8a1
Compare
packages/react/src/metadata.tsx
Outdated
@@ -355,6 +390,7 @@ export const filterAutoFormFieldList = ( | |||
fields: FieldMetadata[] | undefined, | |||
options?: { include?: string[]; exclude?: string[]; isUpsertAction?: boolean } | |||
): FieldMetadata[] => { | |||
console.log("fields :", fields); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
packages/react/src/metadata.tsx
Outdated
@@ -408,6 +447,12 @@ const specialModelKeys = new Set(["DataModel-Shopify-Shop"]); | |||
const isAcceptedFieldType = (field: FieldMetadata) => acceptedAutoFormFieldTypes.has(field.fieldType); | |||
const isAcceptedUpsertFieldType = (field: FieldMetadata) => field.fieldType === FieldType.Id || isAcceptedFieldType(field); | |||
|
|||
const isNotJoinModelHasManyField = (field: FieldMetadata) => | |||
field.fieldType !== FieldType.HasMany || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be more clearly expressed in the positive -- isJoinModelHasManyField because some of the double negatives confused me for a second.
(field.fieldType === FieldType.HasMany &&
field.configuration.__typename === "GadgetHasManyConfig" &&
field.configuration.isJoinModelHasManyField)
...
// Remove `hasMany` fields that emerge from `hasManyThrough` fields that are not actually model fields
subset = subset.filter(field => !isJoinModelHasManyField(field));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated such that the filter works as a positive check
76fa62d
to
9106438
Compare
…sManyThrough fields
9106438
to
6b96215
Compare
hasManyThrough
inputs will come in a follow up