-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: develop
Are you sure you want to change the base?
Conversation
docs/docs/api/configOptions.md
Outdated
@@ -115,7 +115,9 @@ config.set('enableCondition', false) | |||
```typescript | |||
focusNodeSelector?: (rootNode: IPublicModelNode) => Node; | |||
``` | |||
|
|||
#### supportResetFieldsGlobally - 设置所有属性支持重置 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supportResetFieldsGlobally 改成 supportResetGlobally
docs/docs/api/configOptions.md
Outdated
|
||
#### supportResetFieldsGlobally - 设置所有属性支持重置 | ||
`@type {boolean}` `@default {false}` | ||
设置所有属性支持重置, 开启后组件属性setter后会有一个重置按钮,将属性重置为初始状态。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里重置的概念可以再描述的清晰一点,我会奇怪,它充值成默认值,还是什么值?比如,没有打开设置器面板的时候,可能是一个值,打开设置器面板之后又是另外的值。
docs/docs/specs/material-spec.md
Outdated
@@ -833,6 +833,7 @@ props 数组下对象字段描述: | |||
| name | 属性名 | String | type = 'field' 生效 | | |||
| defaultValue | 默认值 | Any(视字段类型而定) | type = 'field' 生效 | | |||
| supportVariable | 是否支持配置变量 | Boolean | type = 'field' 生效 | | |||
| supportResetFields | 是否支持配置重置属性 | Boolean | type = 'field' 生效 | |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里去掉 as any,换成合适的 TS 表达式
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里看看能不能从其它地方获取默认值。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改父组件让initialValue和children一样传下来,而不是从children中拿这样?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个能力应该参考 supportVariableGlobally 的逻辑,首先新增一个 ResetSetter、再在 settings-pane 里面支持。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新增一个ResetSetter确实比较好,没增加到ext中是考虑到之前ext项目pr处理的比较慢更新的不频繁
There was a problem hiding this comment.
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()} />} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 的行为,是不是应该将值删除。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
css只加了一个cursor: pointer
就不用使用变量了吧 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的样式变量,主要是颜色。
ext仓库的pr alibaba/lowcode-engine-ext#77 |
@@ -121,4 +121,7 @@ | |||
} | |||
} | |||
} | |||
.lc-reseticon { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的类名在哪使用的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个忘记删除了,,, 😰
改完了,看看还有别的问题吗,忘记在这里评论更新信息了 😂 |
类似于
supportVariableGlobally
,支持在init时设置supportResetFieldsGlobally
,开启全局配置。组件属性setter后会有一个重置按钮,将属性重置为初始状态。在物料props中设置
supportResetFields
,来开启当前属性是否支持展示重置按钮.例如:antd按钮的尺寸中设置
demo项目init时开启全局
最终在浏览器中展示