Skip to content

feat(resetfidlds): 重置属性为初始状态#2795

Open
ChiZng wants to merge 5 commits into
alibaba:developfrom
ChiZng:feat/reset-attribute
Open

feat(resetfidlds): 重置属性为初始状态#2795
ChiZng wants to merge 5 commits into
alibaba:developfrom
ChiZng:feat/reset-attribute

Conversation

@ChiZng

@ChiZng ChiZng commented Dec 25, 2023

Copy link
Copy Markdown
Contributor

类似于supportVariableGlobally,支持在init时设置supportResetFieldsGlobally,开启全局配置。组件属性setter后会有一个重置按钮,将属性重置为初始状态。
在物料props中设置supportResetFields,来开启当前属性是否支持展示重置按钮.

例如:antd按钮的尺寸中设置

image

demo项目init时开启全局

image

最终在浏览器中展示

image

Comment thread docs/docs/api/configOptions.md Outdated
focusNodeSelector?: (rootNode: IPublicModelNode) => Node;
```

#### supportResetFieldsGlobally - 设置所有属性支持重置

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

supportResetFieldsGlobally 改成 supportResetGlobally

Comment thread docs/docs/api/configOptions.md Outdated

#### supportResetFieldsGlobally - 设置所有属性支持重置
`@type {boolean}` `@default {false}`
设置所有属性支持重置, 开启后组件属性setter后会有一个重置按钮,将属性重置为初始状态。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里重置的概念可以再描述的清晰一点,我会奇怪,它充值成默认值,还是什么值?比如,没有打开设置器面板的时候,可能是一个值,打开设置器面板之后又是另外的值。

Comment thread docs/docs/specs/material-spec.md Outdated
| name | 属性名 | String | type = 'field' 生效 |
| defaultValue | 默认值 | Any(视字段类型而定) | type = 'field' 生效 |
| supportVariable | 是否支持配置变量 | Boolean | type = 'field' 生效 |
| supportResetFields | 是否支持配置重置属性 | Boolean | type = 'field' 生效 |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

supportResetFields => supportReset

}
resetIconClickHandler() {
const { children } = this.props;
if (children && (children as any).props) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里去掉 as any,换成合适的 TS 表达式

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里看看能不能从其它地方获取默认值。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

改父组件让initialValue和children一样传下来,而不是从children中拿这样?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个能力应该参考 supportVariableGlobally 的逻辑,首先新增一个 ResetSetter、再在 settings-pane 里面支持。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

新增一个ResetSetter确实比较好,没增加到ext中是考虑到之前ext项目pr处理的比较慢更新的不频繁

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

我新增一个ResetSetter吧

<div key="body" ref={(shell) => { this.body = shell; }} className="lc-field-body">
{children}
</div>
{display !== 'block' && resetValue && <Title className="lc-reseticon" title={{ tip: '重置属性', icon: <ResetIcon fill="#8f9bb3" /> }} onClick={() => this.resetIconClickHandler()} />}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里的 tip: '重置属性' 需要支持国际化,参考同文件的 intl('Attribute: ')。

这里的样式需要使用 css 变量。参考:https://lowcode-engine.cn/site/docs/guide/expand/editor/theme

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里还有个问题,display !== 'block' && resetValue 这两个条件没有写到描述里面

其中 resetValue 不存在的情况下,reset 的行为,是不是应该将值删除。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

resetValue在上层处理了,物料中的supportReset的优先级设置比supportResetGlobally优先级高
image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

css只加了一个cursor: pointer就不用使用变量了吧 😊

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里的样式变量,主要是颜色。

@liujuping

Copy link
Copy Markdown
Collaborator

image

icon 建议换成类似这样的。

@ChiZng

ChiZng commented Dec 30, 2023

Copy link
Copy Markdown
Contributor Author
}
}
}
.lc-reseticon {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里的类名在哪使用的?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

这个忘记删除了,,, 😰

@ChiZng

ChiZng commented Feb 26, 2024

Copy link
Copy Markdown
Contributor Author

改完了,看看还有别的问题吗,忘记在这里评论更新信息了 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants