Add all group all range build in label
This commit is contained in:
parent
a91143f6c0
commit
1b9c47f688
@ -13,7 +13,7 @@ import "./ObjectPicker.scss";
|
|||||||
type IObjectType = Label | Group | Range | CtrlObject;
|
type IObjectType = Label | Group | Range | CtrlObject;
|
||||||
|
|
||||||
interface IObjectPickerProps extends ITextFieldProps {
|
interface IObjectPickerProps extends ITextFieldProps {
|
||||||
type: Array<"L" | "G" | "R">;
|
type: string;
|
||||||
value?: IObjectType;
|
value?: IObjectType;
|
||||||
valueChange?: (value: IObjectType) => any;
|
valueChange?: (value: IObjectType) => any;
|
||||||
cleanValue?: () => any;
|
cleanValue?: () => any;
|
||||||
@ -28,17 +28,23 @@ class ObjectPicker extends Component<IObjectPickerProps & IMixinStatusProps, IOb
|
|||||||
|
|
||||||
private getAllOption() {
|
private getAllOption() {
|
||||||
let option: Array<IObjectType> = [];
|
let option: Array<IObjectType> = [];
|
||||||
if (this.props.status) {
|
if (!this.props.status) return option;
|
||||||
|
|
||||||
for (let i = 0; i < this.props.type.length; i++) {
|
if (this.props.type.includes("L")) {
|
||||||
|
|
||||||
if (this.props.type[i] === "L") {
|
|
||||||
for (let j = 0; j < this.props.status.model.labelPool.length; j++) {
|
for (let j = 0; j < this.props.status.model.labelPool.length; j++) {
|
||||||
option.push(this.props.status.model.labelPool[j]);
|
option.push(this.props.status.model.labelPool[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.props.type.includes("R")) {
|
||||||
|
option.push(this.props.status.model.allRangeLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.type[i] === "R") {
|
if (this.props.type.includes("G")) {
|
||||||
|
option.push(this.props.status.model.allGroupLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.props.type.includes("R")) {
|
||||||
for (let j = 0; j < this.props.status.model.objectPool.length; j++) {
|
for (let j = 0; j < this.props.status.model.objectPool.length; j++) {
|
||||||
if (this.props.status.model.objectPool[j] instanceof Range) {
|
if (this.props.status.model.objectPool[j] instanceof Range) {
|
||||||
option.push(this.props.status.model.objectPool[j]);
|
option.push(this.props.status.model.objectPool[j]);
|
||||||
@ -46,15 +52,14 @@ class ObjectPicker extends Component<IObjectPickerProps & IMixinStatusProps, IOb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.type[i] === "G") {
|
if (this.props.type.includes("G")) {
|
||||||
for (let j = 0; j < this.props.status.model.objectPool.length; j++) {
|
for (let j = 0; j < this.props.status.model.objectPool.length; j++) {
|
||||||
if (this.props.status.model.objectPool[j] instanceof Group) {
|
if (this.props.status.model.objectPool[j] instanceof Group) {
|
||||||
option.push(this.props.status.model.objectPool[j]);
|
option.push(this.props.status.model.objectPool[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,9 +105,10 @@ class ObjectPicker extends Component<IObjectPickerProps & IMixinStatusProps, IOb
|
|||||||
isDelete = this.props.value.isDeleted();
|
isDelete = this.props.value.isDeleted();
|
||||||
} else {
|
} else {
|
||||||
disPlayInfo = {
|
disPlayInfo = {
|
||||||
name: "",
|
name: "Input.Error.Select",
|
||||||
icon: "Label",
|
icon: "Label",
|
||||||
color: "rgba(0,0,0,0)"
|
color: "transparent",
|
||||||
|
needI18n: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,9 +145,9 @@ class ObjectPicker extends Component<IObjectPickerProps & IMixinStatusProps, IOb
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
disPlayInfo.name ?
|
disPlayInfo.needI18n ?
|
||||||
<span>{disPlayInfo.name}</span> :
|
<Localization i18nKey={disPlayInfo.name as any}/> :
|
||||||
<Localization i18nKey="Input.Error.Select"/>
|
<span>{disPlayInfo.name}</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
@ -7,9 +7,15 @@ import { Range } from "@Model/Range";
|
|||||||
import { Component, ReactNode, RefObject } from "react";
|
import { Component, ReactNode, RefObject } from "react";
|
||||||
import "./PickerList.scss";
|
import "./PickerList.scss";
|
||||||
|
|
||||||
type IDisplayInfo = Record<"color" | "icon" | "name", string>;
|
|
||||||
type IPickerListItem = CtrlObject | Label | Range | Group;
|
type IPickerListItem = CtrlObject | Label | Range | Group;
|
||||||
type IDisplayItem = {
|
interface IDisplayInfo {
|
||||||
|
color: string;
|
||||||
|
icon: string;
|
||||||
|
name: string;
|
||||||
|
needI18n?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface IDisplayItem {
|
||||||
nameKey: AllI18nKeys;
|
nameKey: AllI18nKeys;
|
||||||
key: string;
|
key: string;
|
||||||
mark?: boolean;
|
mark?: boolean;
|
||||||
@ -20,6 +26,7 @@ function getObjectDisplayInfo(item: IPickerListItem): IDisplayInfo {
|
|||||||
let color: number[] = [];
|
let color: number[] = [];
|
||||||
let icon: string = "tag";
|
let icon: string = "tag";
|
||||||
let name: string = "";
|
let name: string = "";
|
||||||
|
let needI18n: boolean = false;
|
||||||
|
|
||||||
if (item instanceof Range) {
|
if (item instanceof Range) {
|
||||||
icon = "CubeShape"
|
icon = "CubeShape"
|
||||||
@ -34,15 +41,30 @@ function getObjectDisplayInfo(item: IPickerListItem): IDisplayInfo {
|
|||||||
name = item.displayName;
|
name = item.displayName;
|
||||||
}
|
}
|
||||||
if (item instanceof Label) {
|
if (item instanceof Label) {
|
||||||
|
|
||||||
|
if (item.isBuildIn) {
|
||||||
|
needI18n = true;
|
||||||
|
if (item.id === "AllRange") {
|
||||||
|
icon = "ProductList";
|
||||||
|
name = "Build.In.Label.Name.All.Range";
|
||||||
|
} else if (item.id === "AllGroup") {
|
||||||
|
icon = "SizeLegacy";
|
||||||
|
name = "Build.In.Label.Name.All.Group";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
icon = "tag";
|
icon = "tag";
|
||||||
color = item.color.concat([]);
|
color = item.color.concat([]);
|
||||||
name = item.name;
|
name = item.name;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
color: `rgb(${color[0]},${color[1]},${color[2]})`,
|
color: needI18n ? "transparent" : `rgb(${color[0]},${color[1]},${color[2]})`,
|
||||||
icon: icon,
|
icon: icon,
|
||||||
name: name
|
name: name,
|
||||||
|
needI18n: needI18n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +101,11 @@ class PickerList extends Component<IPickerListProps> {
|
|||||||
<Icon iconName={displayInfo.icon}/>
|
<Icon iconName={displayInfo.icon}/>
|
||||||
</div>
|
</div>
|
||||||
<div className="list-item-name">
|
<div className="list-item-name">
|
||||||
{displayInfo.name}
|
{
|
||||||
|
displayInfo.needI18n ?
|
||||||
|
<Localization i18nKey={displayInfo.name as any}/> :
|
||||||
|
displayInfo.name
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ const EN_US = {
|
|||||||
"Panel.Info.Label.Details.View": "Edit view label attributes",
|
"Panel.Info.Label.Details.View": "Edit view label attributes",
|
||||||
"Panel.Title.Group.Details.View": "Group",
|
"Panel.Title.Group.Details.View": "Group",
|
||||||
"Panel.Info.Group.Details.View": "Edit view group attributes",
|
"Panel.Info.Group.Details.View": "Edit view group attributes",
|
||||||
|
"Build.In.Label.Name.All.Group": "All group",
|
||||||
|
"Build.In.Label.Name.All.Range": "All range",
|
||||||
"Common.No.Data": "No Data",
|
"Common.No.Data": "No Data",
|
||||||
"Common.No.Unknown.Error": "Unknown error",
|
"Common.No.Unknown.Error": "Unknown error",
|
||||||
"Common.Attr.Title.Basic": "Basic properties",
|
"Common.Attr.Title.Basic": "Basic properties",
|
||||||
|
@ -44,6 +44,8 @@ const ZH_CN = {
|
|||||||
"Panel.Info.Label.Details.View": "编辑查看标签属性",
|
"Panel.Info.Label.Details.View": "编辑查看标签属性",
|
||||||
"Panel.Title.Group.Details.View": "群",
|
"Panel.Title.Group.Details.View": "群",
|
||||||
"Panel.Info.Group.Details.View": "编辑查看群属性",
|
"Panel.Info.Group.Details.View": "编辑查看群属性",
|
||||||
|
"Build.In.Label.Name.All.Group": "全部群",
|
||||||
|
"Build.In.Label.Name.All.Range": "全部范围",
|
||||||
"Common.No.Data": "暂无数据",
|
"Common.No.Data": "暂无数据",
|
||||||
"Common.No.Unknown.Error": "未知错误",
|
"Common.No.Unknown.Error": "未知错误",
|
||||||
"Common.Attr.Title.Basic": "基础属性",
|
"Common.Attr.Title.Basic": "基础属性",
|
||||||
|
@ -6,6 +6,11 @@ import { ObjectID } from "./Renderer";
|
|||||||
*/
|
*/
|
||||||
class Label {
|
class Label {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为内置标签
|
||||||
|
*/
|
||||||
|
public isBuildIn: boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 唯一标识符
|
* 唯一标识符
|
||||||
*/
|
*/
|
||||||
@ -54,12 +59,21 @@ class Label {
|
|||||||
*/
|
*/
|
||||||
public isDeleted(): boolean {
|
public isDeleted(): boolean {
|
||||||
if (this.deleteFlag) return true;
|
if (this.deleteFlag) return true;
|
||||||
|
if (this.isBuildIn) return false;
|
||||||
for (let i = 0; i < this.model.labelPool.length; i++) {
|
for (let i = 0; i < this.model.labelPool.length; i++) {
|
||||||
if (this.model.labelPool[i].equal(this)) return false;
|
if (this.model.labelPool[i].equal(this)) return false;
|
||||||
}
|
}
|
||||||
this.deleteFlag = true;
|
this.deleteFlag = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置为内置标签
|
||||||
|
*/
|
||||||
|
public setBuildInLabel(): this {
|
||||||
|
this.isBuildIn = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,6 +51,16 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
*/
|
*/
|
||||||
public labelPool: Label[] = [];
|
public labelPool: Label[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内置标签-全部范围标签
|
||||||
|
*/
|
||||||
|
public allRangeLabel = new Label(this, "AllRange").setBuildInLabel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内置标签-全部群标签
|
||||||
|
*/
|
||||||
|
public allGroupLabel = new Label(this, "AllGroup").setBuildInLabel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加标签
|
* 添加标签
|
||||||
*/
|
*/
|
||||||
@ -94,23 +104,21 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
/**
|
/**
|
||||||
* 通过标签获取指定类型的对象
|
* 通过标签获取指定类型的对象
|
||||||
* @param label 标签
|
* @param label 标签
|
||||||
* @param type 筛选类型
|
|
||||||
*/
|
*/
|
||||||
public getObjectByLabel(
|
public getObjectByLabel(label: Label): CtrlObject[] {
|
||||||
label: Label, type?:
|
|
||||||
(new (...p: any) => Range) |
|
|
||||||
(new (...p: any) => Group)
|
|
||||||
): CtrlObject[] {
|
|
||||||
const res: CtrlObject[] = [];
|
const res: CtrlObject[] = [];
|
||||||
for (let i = 0; i < this.objectPool.length; i++) {
|
for (let i = 0; i < this.objectPool.length; i++) {
|
||||||
if (this.objectPool[i].hasLabel(label)) {
|
|
||||||
if (type) {
|
if (label.equal(this.allGroupLabel) && this.objectPool[i] instanceof Group) {
|
||||||
if (this.objectPool[i] instanceof type) {
|
|
||||||
res.push(this.objectPool[i]);
|
res.push(this.objectPool[i]);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
else if (label.equal(this.allRangeLabel) && this.objectPool[i] instanceof Range) {
|
||||||
res.push(this.objectPool[i]);
|
res.push(this.objectPool[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (this.objectPool[i].hasLabel(label)) {
|
||||||
|
res.push(this.objectPool[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -172,7 +172,7 @@ class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps> {
|
|||||||
return <>
|
return <>
|
||||||
<ObjectPicker
|
<ObjectPicker
|
||||||
keyI18n="Common.Attr.Key.Generation.Use.Range"
|
keyI18n="Common.Attr.Key.Generation.Use.Range"
|
||||||
type={["L", "R"]}
|
type={"LR"}
|
||||||
value={group.genRange}
|
value={group.genRange}
|
||||||
valueChange={(value) => {
|
valueChange={(value) => {
|
||||||
this.props.status?.changeGroupAttrib(group.id, "genRange", value);
|
this.props.status?.changeGroupAttrib(group.id, "genRange", value);
|
||||||
|
Loading…
Reference in New Issue
Block a user