Add behavior list panel

This commit is contained in:
2022-03-29 17:44:48 +08:00
parent 5ff6987a4b
commit 873a2a8d0a
9 changed files with 129 additions and 1 deletions
@@ -0,0 +1,8 @@
@import "../../Component/Theme/Theme.scss";
div.behavior-list-panel-root {
width: 100%;
min-height: 100%;
padding: 10px;
box-sizing: border-box;
}
@@ -0,0 +1,77 @@
import { BehaviorList as BehaviorListComponent } from "@Component/BehaviorList/BehaviorList";
import { Component } from "react";
import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status";
import { useSetting, IMixinSettingProps } from "@Context/Setting";
import { Behavior } from "@Model/Behavior";
import { Message } from "@Component/Message/Message";
import { ConfirmPopup } from "@Component/ConfirmPopup/ConfirmPopup";
import { BehaviorPopup } from "@Component/BehaviorPopup/BehaviorPopup";
import "./BehaviorList.scss";
interface IBehaviorListProps {
}
@useSetting
@useStatusWithEvent("behaviorChange", "focusBehaviorChange")
class BehaviorList extends Component<IBehaviorListProps & IMixinStatusProps & IMixinSettingProps> {
private labelInnerClick: boolean = false;
public render() {
let behaviors: Behavior[] = [];
if (this.props.status) {
behaviors = this.props.status.model.behaviorPool.concat([]);
}
return <div
className="behavior-list-panel-root"
onClick={() => {
if (this.props.status && !this.labelInnerClick) {
this.props.status.setBehaviorObject();
}
this.labelInnerClick = false;
}}
>
{behaviors.length <=0 ?
<Message i18nKey="Panel.Info.Label.List.Error.Nodata"/> : null
}
<BehaviorListComponent
actionType="delete"
behaviors={behaviors}
focusBehaviors={
this.props.status?.focusBehavior ?
[this.props.status?.focusBehavior] : undefined
}
click={(behavior) => {
if (this.props.status) {
this.props.status.setBehaviorObject(behavior as Behavior);
}
// if (this.props.setting) {
// this.props.setting.layout.focus("LabelDetails");
// }
this.labelInnerClick = true;
}}
onAdd={() => {
this.props.status?.popup.showPopup(BehaviorPopup, {});
}}
action={(behavior) => {
if (this.props.status && behavior instanceof Behavior) {
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);
}
})
}
this.labelInnerClick = true;
}}
/>
</div>;
}
}
export { BehaviorList };
+6
View File
@@ -8,6 +8,7 @@ import { RangeDetails } from "./RangeDetails/RangeDetails";
import { LabelList } from "./LabelList/LabelList";
import { LabelDetails } from "./LabelDetails/LabelDetails";
import { GroupDetails } from "./GroupDetails/GroupDetails";
import { BehaviorList } from "./BehaviorList/BehaviorList";
interface IPanelInfo {
nameKey: string;
@@ -27,6 +28,7 @@ type PanelId = ""
| "LabelList" // 标签列表
| "LabelDetails" // 标签属性
| "GroupDetails" // 群属性
| "BehaviorList" // 行为列表
;
const PanelInfoMap = new Map<PanelId, IPanelInfo>();
@@ -54,6 +56,10 @@ PanelInfoMap.set("GroupDetails", {
nameKey: "Panel.Title.Group.Details.View", introKay: "Panel.Info.Group.Details.View",
class: GroupDetails
});
PanelInfoMap.set("BehaviorList", {
nameKey: "Panel.Title.Behavior.List.View", introKay: "Panel.Info.Behavior.List.View",
class: BehaviorList, hidePadding: true
});
function getPanelById(panelId: PanelId): ReactNode {
switch (panelId) {