added select
parent
b5b8480726
commit
5d1b9bec2c
|
@ -85,7 +85,8 @@
|
||||||
},
|
},
|
||||||
"select": {
|
"select": {
|
||||||
"placeholder": "Wählen Sie einen Gruppentyp",
|
"placeholder": "Wählen Sie einen Gruppentyp",
|
||||||
"machinePlaceholder": "Wählen Sie eine Maschine"
|
"machinePlaceholder": "Wählen Sie eine Maschine",
|
||||||
|
"valuePlaceholder": "Wählen Sie einen Wert"
|
||||||
},
|
},
|
||||||
"form": {
|
"form": {
|
||||||
"item": {
|
"item": {
|
||||||
|
|
|
@ -85,7 +85,8 @@
|
||||||
},
|
},
|
||||||
"select": {
|
"select": {
|
||||||
"placeholder": "Select a Group Type",
|
"placeholder": "Select a Group Type",
|
||||||
"machinePlaceholder": "Select a Machine"
|
"machinePlaceholder": "Select a Machine",
|
||||||
|
"valuePlaceholder": "Select a Value"
|
||||||
},
|
},
|
||||||
"form": {
|
"form": {
|
||||||
"item": {
|
"item": {
|
||||||
|
|
|
@ -9,9 +9,10 @@ import {
|
||||||
Select,
|
Select,
|
||||||
Space,
|
Space,
|
||||||
Tag,
|
Tag,
|
||||||
|
Typography,
|
||||||
notification,
|
notification,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import { GetUuid, myFetch } from "../../../utils";
|
import { AppStyle, Constants, GetUuid, myFetch } from "../../../utils";
|
||||||
import { InfoCircleOutlined } from "@ant-design/icons";
|
import { InfoCircleOutlined } from "@ant-design/icons";
|
||||||
import TextArea from "antd/es/input/TextArea";
|
import TextArea from "antd/es/input/TextArea";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
@ -19,6 +20,7 @@ import { useWebSocketContext } from "../../../Contexts/WebSocketContext";
|
||||||
import { useGroupTasksContext } from "../../../Contexts/GroupTasksContext";
|
import { useGroupTasksContext } from "../../../Contexts/GroupTasksContext";
|
||||||
import { SentMessagesCommands } from "../../../Handlers/WebSocketMessageHandler";
|
import { SentMessagesCommands } from "../../../Handlers/WebSocketMessageHandler";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import Paragraph from "antd/es/skeleton/Paragraph";
|
||||||
|
|
||||||
export default function GroupTypeSelectionModal({
|
export default function GroupTypeSelectionModal({
|
||||||
isOpen,
|
isOpen,
|
||||||
|
@ -80,7 +82,7 @@ export default function GroupTypeSelectionModal({
|
||||||
|
|
||||||
if (userSpecifiedGlobalInputs.length > 0) {
|
if (userSpecifiedGlobalInputs.length > 0) {
|
||||||
for (let i = 0; i < userSpecifiedGlobalInputs.length; i++) {
|
for (let i = 0; i < userSpecifiedGlobalInputs.length; i++) {
|
||||||
if (userSpecifiedGlobalInputs[i].type === "select") {
|
if (userSpecifiedGlobalInputs[i].type === "search") {
|
||||||
foundSelectInputs = foundSelectInputs + 1;
|
foundSelectInputs = foundSelectInputs + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -258,6 +260,41 @@ export default function GroupTypeSelectionModal({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function SelectComponent({ t, globalInput }) {
|
||||||
|
const groupTasksContext = useGroupTasksContext();
|
||||||
|
|
||||||
|
if (globalInput.options === null) {
|
||||||
|
return (
|
||||||
|
<Typography.Text type="danger">
|
||||||
|
Options for this input not specified in the index.json
|
||||||
|
</Typography.Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
placeholder={t(
|
||||||
|
"groupTasks.groupTypeSelectionModal.select.valuePlaceholder"
|
||||||
|
)}
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
options={globalInput.options.map((option) => {
|
||||||
|
return {
|
||||||
|
label: option,
|
||||||
|
value: option,
|
||||||
|
};
|
||||||
|
})}
|
||||||
|
onChange={(value) => {
|
||||||
|
groupTasksContext.setSelectInputs((prevState) => ({
|
||||||
|
...prevState,
|
||||||
|
[globalInput.parameterName]: {
|
||||||
|
value: value,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function SelectMachineComponent({
|
export function SelectMachineComponent({
|
||||||
t,
|
t,
|
||||||
notificationApi,
|
notificationApi,
|
||||||
|
@ -381,7 +418,13 @@ function GroupGlobalInputs({
|
||||||
const getLabel = (displayName) => {
|
const getLabel = (displayName) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{displayName}
|
{displayName === undefined || displayName === "" ? (
|
||||||
|
<Typography.Text type="danger">
|
||||||
|
DisplayName is missing
|
||||||
|
</Typography.Text>
|
||||||
|
) : (
|
||||||
|
displayName
|
||||||
|
)}
|
||||||
<Tag style={{ marginLeft: 6 }} color="purple">
|
<Tag style={{ marginLeft: 6 }} color="purple">
|
||||||
{t("groupTasks.tag.global")}
|
{t("groupTasks.tag.global")}
|
||||||
</Tag>
|
</Tag>
|
||||||
|
@ -453,7 +496,17 @@ function GroupGlobalInputs({
|
||||||
break;
|
break;
|
||||||
case "checkbox":
|
case "checkbox":
|
||||||
elements.push(
|
elements.push(
|
||||||
<Form.Item key={index} required>
|
<Form.Item
|
||||||
|
key={index}
|
||||||
|
required
|
||||||
|
style={{
|
||||||
|
marginBottom:
|
||||||
|
group.globalInputs.length > index &&
|
||||||
|
group.globalInputs[index + 1].type === "checkbox"
|
||||||
|
? 0
|
||||||
|
: 12,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id={globalInput.parameterName}
|
id={globalInput.parameterName}
|
||||||
defaultChecked={
|
defaultChecked={
|
||||||
|
@ -468,6 +521,17 @@ function GroupGlobalInputs({
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case "select":
|
||||||
|
elements.push(
|
||||||
|
<Form.Item
|
||||||
|
key={index}
|
||||||
|
label={getLabel(globalInput.displayName)}
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<SelectComponent t={t} globalInput={globalInput} />
|
||||||
|
</Form.Item>
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
notificationApi["error"]({
|
notificationApi["error"]({
|
||||||
|
|
Loading…
Reference in New Issue