Add all group all range build in label
This commit is contained in:
@@ -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,33 +28,38 @@ 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.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[i] === "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") {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.props.type.includes("G")) {
|
||||
option.push(this.props.status.model.allGroupLabel);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.props.type[i] === "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]);
|
||||
}
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
icon = "tag";
|
||||
color = item.color.concat([]);
|
||||
name = item.name;
|
||||
|
||||
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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user