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 { ConfirmPopup } from "@Component/ConfirmPopup/ConfirmPopup"; 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 renderFrom(group: Group) { return <> { this.props.status?.changeGroupAttrib(group.id, "displayName", val); }} /> { this.props.status?.changeGroupAttrib(group.id, "color", color); }} /> { this.props.status?.changeGroupAttrib(group.id, "size", (val as any) / 1); }} /> { 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) { const status = this.props.status; status.popup.showPopup(ConfirmPopup, { infoI18n: "Popup.Delete.Objects.Confirm", titleI18N: "Popup.Action.Objects.Confirm.Title", yesI18n: "Popup.Action.Objects.Confirm.Delete", red: "yes", yes: () => { status.model.deleteObject([group]); status.setFocusObject(new Set()); } }) } }} /> { if (this.props.status) { this.props.status.changeGroupAttrib(group.id, "genMethod", value.key as any); } }} /> { this.props.status?.changeGroupAttrib(group.id, "genCount", (val as any) / 1); }} /> {group.genMethod === GenMod.Point ? this.renderPointGenOption(group) : null} {group.genMethod === GenMod.Range ? this.renderRangeGenOption(group) : null} { if(!group.genIndividuals()) { this.props.status?.changeGroupAttrib(group.id, "genErrorMessageShowCount", 1); } }} /> { this.props.status?.changeGroupAttrib(group.id, "killCount", (val as any) / 1); }} /> { group.killIndividuals() }} /> } private renderPointGenOption(group: Group) { return <> { group.genPoint[0] = (val as any) / 1; this.props.status?.changeGroupAttrib(group.id, "genPoint", group.genPoint); }} /> { group.genPoint[1] = (val as any) / 1; this.props.status?.changeGroupAttrib(group.id, "genPoint", group.genPoint); }} /> { group.genPoint[2] = (val as any) / 1; this.props.status?.changeGroupAttrib(group.id, "genPoint", group.genPoint); }} /> } private renderRangeGenOption(group: Group) { let isRenderErrorInfo: boolean = false; if (group.genErrorMessageShowCount > 0) { group.genErrorMessageShowCount --; if (group.genErrorMessage) { isRenderErrorInfo = true; } } else { group.genErrorMessage = undefined; } return <> { this.props.status?.changeGroupAttrib(group.id, "genRange", value); }} cleanValue={() => { this.props.status?.changeGroupAttrib(group.id, "genRange", undefined); }} /> } 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 }