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

Pass index, canAdd, length of array to ArrayFieldItemTemplate #3315

Closed
epicfaace opened this issue Dec 26, 2022 · 2 comments · Fixed by #3325
Closed

Pass index, canAdd, length of array to ArrayFieldItemTemplate #3315

epicfaace opened this issue Dec 26, 2022 · 2 comments · Fixed by #3325
Labels
awaiting response p1 Important to fix soon

Comments

@epicfaace
Copy link
Member

No description provided.

@epicfaace epicfaace changed the title Pass onDropIndexClick, index, whether item is the last one to AddButton Pass onDropIndexClick, index, whether item is the last one to ArrayFieldItemTemplate Dec 26, 2022
@github-actions github-actions bot added the needs triage Initial label given, to be assigned correct labels and assigned label Dec 26, 2022
@epicfaace epicfaace changed the title Pass onDropIndexClick, index, whether item is the last one to ArrayFieldItemTemplate Pass onDropIndexClick, index, canAdd to ArrayFieldItemTemplate Dec 26, 2022
@epicfaace epicfaace changed the title Pass onDropIndexClick, index, canAdd to ArrayFieldItemTemplate Pass index, canAdd to ArrayFieldItemTemplate Dec 26, 2022
@epicfaace epicfaace changed the title Pass index, canAdd to ArrayFieldItemTemplate Pass index, canAdd, length of array to ArrayFieldItemTemplate Dec 26, 2022
@heath-freenome
Copy link
Member

heath-freenome commented Dec 28, 2022

@epicfaace we are already passing index to the ArrayFieldTemplateItemType. canAdd is actually being passed as a prop to the ArrayFieldTemplate so I'm not sure why it is needed for the ArrayFieldTemplateItemType. This way the whole array field has a single Add button. Are you imagining a use where each item might, instead have an add button? I can definitely see a use for adding totalItems to the ArrayFieldTemplateItemType (so I will).

@heath-freenome heath-freenome added p1 Important to fix soon awaiting response and removed needs triage Initial label given, to be assigned correct labels and assigned labels Dec 28, 2022
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Dec 28, 2022
fixes: rjsf-team#3302, rjsf-team#3314, rjsf-team#3315, rjsf-team#3316 and rjsf-team#3317

- In `@rjsf/antd`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/bootstrap-4`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
  - Also, remove the one off tests for `AddButton` and `CheckboxWidget` since they are duplicated elsewhere
- In `@rjsf/chakra-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/core`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also, passed `registry` into the `SubmitButton` inside of the `Form` as part of this fix
  - Updated `ArrayField` to pass the new `totalItems` prop to the `ArrayFieldItemTemplate` instances
    - Also refactored the near duplicate logic for `onAddClick` and `onAddIndexClick` into a new `_handleAddClick()` function
- In `@rjsf/fluent-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/material-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/mui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/semantic-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also fixed the `CheckboxWidget` missing label issue
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/utils`, updated the `SubmitButtonProps` and `IconButtonProps` to add required `registry` prop
  - Updated the `ArrayFieldTemplateItemType` to add the new `totalItems` prop
- Updated the `custom-templates.md` file to add documentation for the new props added to the types
- Updated the `CHANGELOG.md` file accordingly
heath-freenome added a commit that referenced this issue Dec 28, 2022
fixes: #3302, #3314, #3315, #3316 and #3317

- In `@rjsf/antd`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/bootstrap-4`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
  - Also, remove the one off tests for `AddButton` and `CheckboxWidget` since they are duplicated elsewhere
- In `@rjsf/chakra-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/core`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also, passed `registry` into the `SubmitButton` inside of the `Form` as part of this fix
  - Updated `ArrayField` to pass the new `totalItems` prop to the `ArrayFieldItemTemplate` instances
    - Also refactored the near duplicate logic for `onAddClick` and `onAddIndexClick` into a new `_handleAddClick()` function
- In `@rjsf/fluent-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/material-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/mui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/semantic-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also fixed the `CheckboxWidget` missing label issue
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/utils`, updated the `SubmitButtonProps` and `IconButtonProps` to add required `registry` prop
  - Updated the `ArrayFieldTemplateItemType` to add the new `totalItems` prop
- Updated the `custom-templates.md` file to add documentation for the new props added to the types
- Updated the `CHANGELOG.md` file accordingly
@epicfaace
Copy link
Member Author

Are you imagining a use where each item might, instead have an add button?

Yep that's actually my use case! I need the add and remove buttons on the same row -- currently doing it via a hacky solution but these props will make it much easier.

image

heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Dec 29, 2022
fixed: rjsf-team#3315
- Updated the `ArrayFieldTemplateItemType` to add the `canAdd` prop
- Updated `ArrayField` to pass the `canAdd` prop to the ArrayFieldItemTemplate instances
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Dec 29, 2022
fixed: rjsf-team#3315
- Updated the `ArrayFieldTemplateItemType` to add the `canAdd` prop
- Updated `ArrayField` to pass the `canAdd` prop to the ArrayFieldItemTemplate instances
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Dec 29, 2022
fixed: rjsf-team#3315
- Updated the `ArrayFieldTemplateItemType` to add the `canAdd` prop
- Updated `ArrayField` to pass the `canAdd` prop to the ArrayFieldItemTemplate instances
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit that referenced this issue Dec 30, 2022
…3325)

fixed: #3315
- Updated the `ArrayFieldTemplateItemType` to add the `canAdd` prop
- Updated `ArrayField` to pass the `canAdd` prop to the ArrayFieldItemTemplate instances
- Updated the `CHANGELOG.md` accordingly
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
fixes: rjsf-team#3302, rjsf-team#3314, rjsf-team#3315, rjsf-team#3316 and rjsf-team#3317

- In `@rjsf/antd`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/bootstrap-4`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
  - Also, remove the one off tests for `AddButton` and `CheckboxWidget` since they are duplicated elsewhere
- In `@rjsf/chakra-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/core`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also, passed `registry` into the `SubmitButton` inside of the `Form` as part of this fix
  - Updated `ArrayField` to pass the new `totalItems` prop to the `ArrayFieldItemTemplate` instances
    - Also refactored the near duplicate logic for `onAddClick` and `onAddIndexClick` into a new `_handleAddClick()` function
- In `@rjsf/fluent-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/material-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/mui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/semantic-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also fixed the `CheckboxWidget` missing label issue
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/utils`, updated the `SubmitButtonProps` and `IconButtonProps` to add required `registry` prop
  - Updated the `ArrayFieldTemplateItemType` to add the new `totalItems` prop
- Updated the `custom-templates.md` file to add documentation for the new props added to the types
- Updated the `CHANGELOG.md` file accordingly
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
…jsf-team#3325)

fixed: rjsf-team#3315
- Updated the `ArrayFieldTemplateItemType` to add the `canAdd` prop
- Updated `ArrayField` to pass the `canAdd` prop to the ArrayFieldItemTemplate instances
- Updated the `CHANGELOG.md` accordingly
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
fixes: rjsf-team#3302, rjsf-team#3314, rjsf-team#3315, rjsf-team#3316 and rjsf-team#3317

- In `@rjsf/antd`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/bootstrap-4`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
  - Also, remove the one off tests for `AddButton` and `CheckboxWidget` since they are duplicated elsewhere
- In `@rjsf/chakra-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/core`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also, passed `registry` into the `SubmitButton` inside of the `Form` as part of this fix
  - Updated `ArrayField` to pass the new `totalItems` prop to the `ArrayFieldItemTemplate` instances
    - Also refactored the near duplicate logic for `onAddClick` and `onAddIndexClick` into a new `_handleAddClick()` function
- In `@rjsf/fluent-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/material-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/mui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/semantic-ui`, pass the new `registry` prop into all of the `ButtonTemplates` usages, filtering it out when spreading props into the underlying button implementation
  - Updated `CheckboxWidget` to get the `required` state of the checkbox from the `schemaRequiresTrueValue()` utility function rather than the `required` prop
  - Also fixed the `CheckboxWidget` missing label issue
  - Also updated the `CheckboxWidget` tests to verify the label is passed correctly
- In `@rjsf/utils`, updated the `SubmitButtonProps` and `IconButtonProps` to add required `registry` prop
  - Updated the `ArrayFieldTemplateItemType` to add the new `totalItems` prop
- Updated the `custom-templates.md` file to add documentation for the new props added to the types
- Updated the `CHANGELOG.md` file accordingly
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
…jsf-team#3325)

fixed: rjsf-team#3315
- Updated the `ArrayFieldTemplateItemType` to add the `canAdd` prop
- Updated `ArrayField` to pass the `canAdd` prop to the ArrayFieldItemTemplate instances
- Updated the `CHANGELOG.md` accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response p1 Important to fix soon
Projects
None yet
2 participants