Fix group details can focus deleted behavior

This commit is contained in:
MrKBear 2022-04-04 20:37:01 +08:00
parent c10dd6e882
commit 8607dcd3da
5 changed files with 35 additions and 0 deletions

View File

@ -112,5 +112,6 @@ const EN_US = {
"Panel.Info.Label.Details.Error.Unspecified": "Label object not specified",
"Panel.Info.Label.List.Error.Nodata": "There are no labels in the model, click the button to create",
"Panel.Info.Behavior.Details.Error.Not.Behavior": "Please specify a behavior first to view the details",
"Panel.Info.Behavior.Details.Behavior.Props": "{behavior} parameter",
}
export default EN_US;

View File

@ -112,5 +112,6 @@ const ZH_CN = {
"Panel.Info.Label.Details.Error.Unspecified": "未指定标签对象",
"Panel.Info.Label.List.Error.Nodata": "模型中没有标签,点击按钮以创建",
"Panel.Info.Behavior.Details.Error.Not.Behavior": "请先指定一个行为以查看详情",
"Panel.Info.Behavior.Details.Behavior.Props": "{behavior}参数",
}
export default ZH_CN;

View File

@ -4,6 +4,8 @@ import { Behavior } from "@Model/Behavior";
import { Message } from "@Component/Message/Message";
import { AttrInput } from "@Component/AttrInput/AttrInput";
import { ColorInput } from "@Component/ColorInput/ColorInput";
import { TogglesInput } from "@Component/TogglesInput/TogglesInput";
import { ConfirmPopup } from "@Component/ConfirmPopup/ConfirmPopup";
import "./BehaviorDetails.scss";
interface IBehaviorDetailsProps {}
@ -31,6 +33,34 @@ class BehaviorDetails extends Component<IBehaviorDetailsProps & IMixinStatusProp
}}
/>
<TogglesInput
keyI18n="Common.Attr.Key.Delete" red
onIconName="delete" offIconName="delete"
valueChange={() => {
if (this.props.status) {
const status = this.props.status;
status.popup.showPopup(ConfirmPopup, {
infoI18n: "Popup.Delete.Behavior.Confirm",
titleI18N: "Popup.Action.Objects.Confirm.Title",
yesI18n: "Popup.Action.Objects.Confirm.Delete",
red: "yes",
yes: () => {
status.model.deleteBehavior(behavior);
status.setBehaviorObject();
}
})
}
}}
/>
<Message
isTitle
i18nKey="Panel.Info.Behavior.Details.Behavior.Props"
options={{
behavior: behavior.getTerms(behavior.behaviorName)
}}
/>
</>;
}

View File

@ -63,6 +63,7 @@ class BehaviorList extends Component<IBehaviorListProps & IMixinStatusProps & IM
red: "yes",
yes: () => {
status.model.deleteBehavior(behavior);
status.setBehaviorObject();
}
})
}

View File

@ -121,9 +121,11 @@ class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps & IM
behavior={group.behaviors}
focusBehavior={this.props.status?.focusBehavior}
click={(behavior) => {
if (behavior.isDeleted()) return;
this.props.status?.setBehaviorObject(behavior);
}}
action={(behavior) => {
if (behavior.isDeleted()) return;
this.props.status?.setBehaviorObject(behavior);
setTimeout(() => {
this.props.setting?.layout.focus("BehaviorDetails");