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

getItemSummary receives mapProp value instead of original list value #586

Open
mattlevine32 opened this issue Aug 30, 2024 · 0 comments
Open

Comments

@mattlevine32
Copy link

Hi team, thanks for the great work on Puck - we're loving working with it. Quick one we ran into - mapProp seems to run before getItemSummary which means we can't use fields from the originally fetched object in the summary.

We want to only store an ID as a prop in JSON vs. more complex objects which is why we want to keep mapProp as just id.

Would it make sense to have getItemSummary always receive the raw item value?

  {
    label: 'Observation Panel',
    fields: {
      view: {
        type: 'select',
        options: [
          { value: 'Row', label: 'Row' },
          { value: 'Card', label: 'Card' },
        ],
      },
      observationPanelDefinitionId: {
        type: 'external',
        fetchList: fetchAvailablePanels,
        getItemSummary: (item: ObservationPanelDefinition) => item.title,
        mapProp: (item: ObservationPanelDefinition) => item.id,
        mapRow: (item: ObservationPanelDefinition) => ({title: item.title}),
        showSearch: true,
      },
    },
    defaultProps: {
      view: 'Row',
      observationPanelDefinitionId: null,
    },
    render: (props) => <BlockRenderer {...props} />,
  }
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

No branches or pull requests

1 participant