Skip to content
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

Merged

Conversation

MillanWangGadget
Copy link
Contributor

@MillanWangGadget MillanWangGadget commented Sep 24, 2024

  • UPDATE
    • Updated AutoForm HasManyThrough fields so that no inputs are shown.
    • They would previously show a hasMany field for the join model, which corresponds to the API, but was confusing in an AutoForm context
    • Adding support for hasManyThrough inputs will come in a follow up

@MillanWangGadget MillanWangGadget force-pushed the mill/RMN-106_hideHasManyThroughJoinModelHasMany branch 2 times, most recently from 0537e9e to ef4f8a1 Compare September 24, 2024 16:40
@@ -355,6 +390,7 @@ export const filterAutoFormFieldList = (
fields: FieldMetadata[] | undefined,
options?: { include?: string[]; exclude?: string[]; isUpsertAction?: boolean }
): FieldMetadata[] => {
console.log("fields :", fields);
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@@ -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 ||
Copy link
Contributor

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));

Copy link
Contributor Author

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

@MillanWangGadget MillanWangGadget force-pushed the mill/RMN-106_hideHasManyThroughJoinModelHasMany branch 2 times, most recently from 76fa62d to 9106438 Compare September 24, 2024 18:30
@MillanWangGadget MillanWangGadget force-pushed the mill/RMN-106_hideHasManyThroughJoinModelHasMany branch from 9106438 to 6b96215 Compare September 24, 2024 18:37
@MillanWangGadget MillanWangGadget merged commit 577a5b9 into main Sep 24, 2024
9 checks passed
@MillanWangGadget MillanWangGadget deleted the mill/RMN-106_hideHasManyThroughJoinModelHasMany branch September 24, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants