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

优化状态容器配置 & listSelect自定义label value适配 #8663

Merged
merged 3 commits into from
Nov 8, 2023

Conversation

zhangtao07
Copy link
Collaborator

@zhangtao07 zhangtao07 commented Nov 8, 2023

What

🤖 Generated by Copilot at 2c140f6

This pull request enhances the AMIS editor plugins for list controls and switch containers, and fixes some bugs related to them. It introduces a new getSubEditorVariable function to support dynamic variables based on the schema, and adds some new options and validations to the plugins. It also fixes a bug in the SwitchContainer renderer that caused the active index to be reset when the items array was empty.

🤖 Generated by Copilot at 2c140f6

We are the masters of the switch container
We create and edit with dynamic power
We resolve the variables from the scope
We fix the bugs and never lose hope

Why

How

🤖 Generated by Copilot at 2c140f6

  • Change the subEditorVariable property of the RendererInfo interface and the BasePlugin class to a function getSubEditorVariable that takes an optional schema argument and returns an array of custom variables for the sub-editor. This allows the sub-editor variables to be dynamically generated based on the schema of the host node. (link, link)
  • Update the resolveVariablesFromScope function in util.ts to use the getSubEditorVariable function of the host node info instead of the subEditorVariable property. This allows the variables to be resolved based on the schema of the host node. (link)
  • Implement the getSubEditorVariable function in the ListControlPlugin class in ListSelect.tsx to return the label and value fields of the current option based on the schema of the list select control. (link)
  • Fix a bug in the ListControlPlugin class in ListSelect.tsx where the option label was not displayed correctly when the value was an object. Use the data variable instead of the value variable in the template of the option label. (link)
  • Simplify the getDisplayField function in the ListControlPlugin class in ListSelect.tsx. Return the label field of the data or the default 'label' field. Remove the unnecessary logic for handling the source and map properties of the data, which are not relevant for the list select control. (link)
  • Add a minLength property to the items field of the schema in the SwitchContainerPlugin class in SwitchContainer.tsx. This property specifies the minimum number of items that the switch container should have. This is used to prevent deleting items below the minimum length in the sub-editor. (link)
  • Add a theme:base schema template to the theme field of the schema in the SwitchContainerPlugin class in SwitchContainer.tsx. This template provides some common theme properties for the switch container, such as collapsed and extra. (link)
  • Add a theme-cssCode type to the schema in the SwitchContainerPlugin class in SwitchContainer.tsx. This type allows the user to customize the CSS style of the switch container using a code editor. (link)
  • Import the toast function from amis in ListItemControl.tsx. This function is used to show a warning message when the user tries to delete an item below the minimum length in the sub-editor. (link)
  • Remove the unused and redundant api property of the OptionControlState interface and the OptionControl class in ListItemControl.tsx. Use the source property of the data instead. (link, link)
  • Check the minLength property of the props before deleting an item in the handleDelete function of the OptionControl class in ListItemControl.tsx. If the minimum length is greater than zero and the items length is equal or less than the minimum length, show a warning message using the toast function and return without deleting the item. This prevents deleting items below the minimum length in the sub-editor. (link)

@zhangtao07 zhangtao07 merged commit 3e1e8a6 into baidu:master Nov 8, 2023
1 of 2 checks passed
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