添加过的事件禁用

Change-Id: Ica47534ee092cf4fd5f8d17b73bc456c28d29348
This commit is contained in:
pianruijie 2022-08-22 16:48:11 +08:00
parent 3282287beb
commit 3e8c095493

View File

@ -150,13 +150,12 @@ export class EventControl extends React.Component<
return Object.keys(onEvent).length ? onEvent : {}; return Object.keys(onEvent).length ? onEvent : {};
} }
addEvent(event: RendererPluginEvent) { addEvent(event: RendererPluginEvent, disabled: boolean) {
const {onChange} = this.props; const {onChange} = this.props;
let onEvent = { let onEvent = {
...this.state.onEvent ...this.state.onEvent
}; };
if (disabled) {
if (onEvent[`${event.eventName}`]) {
return; return;
} }
onEvent[`${event.eventName}`] = { onEvent[`${event.eventName}`] = {
@ -628,7 +627,6 @@ export class EventControl extends React.Component<
const enventSnapshot = cloneDeep(onEvent); const enventSnapshot = cloneDeep(onEvent);
const {showOldEntry} = this.props; const {showOldEntry} = this.props;
const eventKeys = Object.keys(enventSnapshot); const eventKeys = Object.keys(enventSnapshot);
return ( return (
<div className="ae-event-control"> <div className="ae-event-control">
<header <header
@ -647,9 +645,12 @@ export class EventControl extends React.Component<
closeOnClick: true, closeOnClick: true,
buttons: events.map(item => ({ buttons: events.map(item => ({
type: 'button', type: 'button',
disabledTip: '您已添加该事件',
tooltipPlacement: 'left',
disabled: Object.keys(onEvent).includes(item.eventName),
actionType: '', actionType: '',
label: item.eventLabel, label: item.eventLabel,
onClick: this.addEvent.bind(this, item) onClick: this.addEvent.bind(this, item, Object.keys(onEvent).includes(item.eventName))
})) }))
})} })}
</header> </header>