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