Merge pull request #7754 from Dora-boots/fix-clear-value

feat(amis-editor): timeline组件配置面板增加关联上下文配置
This commit is contained in:
hsm-lv 2023-08-10 09:44:56 +08:00 committed by GitHub
commit 19b040fc6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,7 @@ export interface TimelineItemProps extends FormControlProps {
export interface TimelineItemState {
items: Array<Partial<TimelineItem>>;
source: 'custom' | 'api';
source: 'custom' | 'api' | 'variable';
api: SchemaApi;
}
@ -54,7 +54,7 @@ export default class TimelineItemControl extends React.Component<
*
*/
@autobind
handleSourceChange(source: 'custom' | 'api') {
handleSourceChange(source: 'custom' | 'api' | 'variable') {
this.setState({source: source}, this.onChange);
}
@ -80,6 +80,11 @@ export default class TimelineItemControl extends React.Component<
data.items = items.map(item => ({...item}));
data.source = api;
}
if (source === 'variable') {
const {items, api} = this.state;
data.items = items.map(item => ({...item}));
data.source = api;
}
onBulkChange && onBulkChange(data);
}
@ -339,10 +344,14 @@ export default class TimelineItemControl extends React.Component<
{
label: '接口获取',
value: 'api'
},
{
label: '上下文变量',
value: 'variable'
}
] as Array<{
label: string;
value: 'custom' | 'api';
value: 'custom' | 'api' | 'variable';
}>
).map(item => ({
...item,
@ -562,6 +571,19 @@ export default class TimelineItemControl extends React.Component<
</div>
</div>
) : null}
{source === 'variable'
? render(
'variable',
getSchemaTpl('sourceBindControl', {
label: false,
className: 'ae-ExtendMore'
}),
{
onChange: this.handleAPIChange
}
)
: null}
{this.renderApiPanel()}
</div>
);