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

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

ChiZng
Copy link
Contributor

@ChiZng ChiZng commented Dec 25, 2023

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

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

image

demo项目init时开启全局

image

最终在浏览器中展示

image

@@ -115,7 +115,9 @@ config.set('enableCondition', false)
```typescript
focusNodeSelector?: (rootNode: IPublicModelNode) => Node;
```

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

Choose a reason for hiding this comment

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

supportResetFieldsGlobally 改成 supportResetGlobally


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

Choose a reason for hiding this comment

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

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

@@ -833,6 +833,7 @@ props 数组下对象字段描述:
| name | 属性名 | String | type = 'field' 生效 |
| defaultValue | 默认值 | Any(视字段类型而定) | type = 'field' 生效 |
| supportVariable | 是否支持配置变量 | Boolean | type = 'field' 生效 |
| supportResetFields | 是否支持配置重置属性 | Boolean | type = 'field' 生效 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

supportResetFields => supportReset

@@ -142,14 +144,22 @@ export class Field extends Component<FieldProps> {
const { editor, name, title, meta } = this.props;
editor?.eventBus.emit('setting.setter.field.click', { name, title, meta, event });
}
resetIconClickHandler() {
const { children } = this.props;
if (children && (children as any).props) {
Copy link
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
Collaborator

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.

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

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

Choose a reason for hiding this comment

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

我新增一个ResetSetter吧

@@ -185,6 +195,7 @@ export class Field extends Component<FieldProps> {
<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
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
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
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
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
Collaborator

Choose a reason for hiding this comment

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

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

@liujuping
Copy link
Collaborator

image

icon 建议换成类似这样的。

@ChiZng
Copy link
Contributor Author

ChiZng commented Dec 30, 2023

ext仓库的pr alibaba/lowcode-engine-ext#77

@@ -121,4 +121,7 @@
}
}
}
.lc-reseticon {
Copy link
Collaborator

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.

这个忘记删除了,,, 😰

@ChiZng
Copy link
Contributor Author

ChiZng commented Feb 26, 2024

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

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.

None yet

2 participants