Add checkbox handel func

This commit is contained in:
2022-03-05 11:37:35 +08:00
parent ca3a19f5b0
commit 86c840443c
8 changed files with 120 additions and 10 deletions
+4
View File
@@ -4,4 +4,8 @@ div.object-list-color-value {
margin-left: 3px;
border-radius: 1000px;
width: 3px;
}
div.object-list {
min-height: 100%;
}
+33 -1
View File
@@ -2,6 +2,7 @@ import { Component, ReactNode } from "react";
import { DetailsList } from "@Component/DetailsList/DetailsList";
import { useStatus, IMixinStatusProps } from "@Context/Status";
import { Localization } from "@Component/Localization/Localization";
import { ObjectID } from "@Model/Renderer";
import "./ObjectList.scss";
@useStatus
@@ -14,12 +15,14 @@ class ObjectList extends Component<IMixinStatusProps> {
public componentDidMount(){
if (this.props.status) {
this.props.status.model.on("objectChange", this.handelChange);
this.props.status.on("focusObjectChange", this.handelChange);
}
}
public componentWillUnmount(){
if (this.props.status) {
this.props.status.model.off("objectChange", this.handelChange);
this.props.status.off("focusObjectChange", this.handelChange);
}
}
@@ -34,15 +37,44 @@ class ObjectList extends Component<IMixinStatusProps> {
}
return <DetailsList
className="object-list"
items={objList.concat([]).map((object => {
return {
key: object.id.toString(),
name: object.displayName,
color: object.color,
display: object.display,
update: object.update
update: object.update,
select: this.props.status ?
this.props.status.focusObject.has(object.id.toString()) ||
this.props.status.focusObject.has(object.id) :
false
}
}))}
clickLine={(item) => {
if (this.props.status) {
this.props.status.setFocusObject(new Set<ObjectID>().add(item.key));
}
}}
checkBox={(item) => {
if (this.props.status) {
if (
this.props.status.focusObject.has(item.key.toString()) ||
this.props.status.focusObject.has(item.key)
) {
this.props.status.focusObject.delete(item.key);
this.props.status.focusObject.delete(item.key.toString());
this.props.status.setFocusObject(this.props.status.focusObject);
} else {
this.props.status.setFocusObject(this.props.status.focusObject.add(item.key));
}
}
}}
click={() => {
if (this.props.status) {
this.props.status.setFocusObject(new Set<ObjectID>());
}
}}
columns={[
{
key: "color",
+1 -1
View File
@@ -28,7 +28,7 @@ class RenderView extends Component<IMixinStatusProps & IMixinSettingProps> {
public componentDidMount() {
let div = this.rootEle.current;
console.log(div, div?.childNodes, this.props.status, this.props.status?.renderer.dom)
// console.log(div, div?.childNodes, this.props.status, this.props.status?.renderer.dom)
if (div && (!div.childNodes || div.childNodes.length <= 0) && this.props.status) {
div.appendChild(this.props.status.renderer.dom);
}