import { Component, ReactNode } from "react"; import { AttrInput } from "@Component/AttrInput/AttrInput"; import { useStatusWithEvent, IMixinStatusProps, Status } from "@Context/Status"; import { Message } from "@Component/Message/Message"; import { ObjectID } from "@Model/Renderer"; import { ColorInput } from "@Component/ColorInput/ColorInput"; import { TogglesInput } from "@Component/TogglesInput/TogglesInput"; import { LabelPicker } from "@Component/LabelPicker/LabelPicker"; import { Group, GenMod } from "@Model/Group"; import { AllI18nKeys } from "@Component/Localization/Localization"; import { ComboInput, IDisplayItem } from "@Component/ComboInput/ComboInput"; import { ObjectPicker } from "@Component/ObjectPicker/ObjectPicker"; import "./GroupDetails.scss"; interface IGroupDetailsProps {} const mapGenModToI18nKey = new Map(); mapGenModToI18nKey.set(GenMod.Point, "Common.Attr.Key.Generation.Mod.Point"); mapGenModToI18nKey.set(GenMod.Range, "Common.Attr.Key.Generation.Mod.Range"); const allOption: IDisplayItem[] = [ {nameKey: "Common.Attr.Key.Generation.Mod.Point", key: GenMod.Point}, {nameKey: "Common.Attr.Key.Generation.Mod.Range", key: GenMod.Range} ]; @useStatusWithEvent("groupAttrChange", "groupLabelChange", "focusObjectChange") class GroupDetails extends Component { private renderAttrInput( id: ObjectID, key: AllI18nKeys, val: string | number | undefined, change: (val: string, status: Status) => any, step?: number, max?: number, min?: number ) { const handelFunc = (e: string) => { if (this.props.status) { change(e, this.props.status); } } if (step) { return } else { return } } private renderFrom(group: Group) { return <> {this.renderAttrInput( group.id, "Common.Attr.Key.Display.Name", group.displayName, (val, status) => { status.changeGroupAttrib(group.id, "displayName", val); } )} { if (this.props.status) { this.props.status.changeGroupAttrib(group.id, "color", color); } }} /> {this.renderAttrInput( group.id, "Common.Attr.Key.Size", group.size, (val, status) => { status.changeGroupAttrib(group.id, "size", (val as any) / 1); }, 10, undefined, 0 )} { if (this.props.status) { this.props.status.addGroupLabel(group.id, label); } }} labelDelete={(label) => { if (this.props.status) { this.props.status.deleteGroupLabel(group.id, label); } }} /> { if (this.props.status) { this.props.status.changeGroupAttrib(group.id, "display", val); } }} /> { if (this.props.status) { this.props.status.changeGroupAttrib(group.id, "update", val); } }} /> { if (this.props.status) { this.props.status.model.deleteObject([group]); this.props.status.setFocusObject(new Set()); } }} /> { if (this.props.status) { this.props.status.changeGroupAttrib(group.id, "genMethod", value.key as any); } }} /> } public render(): ReactNode { if (this.props.status) { if (this.props.status.focusObject.size <= 0) { return ; } if (this.props.status.focusObject.size > 1) { return ; } let id: ObjectID = ""; this.props.status.focusObject.forEach((cid => id = cid)); let group = this.props.status!.model.getObjectById(id); if (group instanceof Group) { return this.renderFrom(group); } else { return ; } } return ; } } export { GroupDetails }