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