📝 (StringListInput.py): update parameter name from "param" to "input_value" to improve clarity and consistency
📝 (StringListOutput.py): update parameter name from "param" to "input_value" to improve clarity and consistency 📝 (index.tsx): add InputListComponent to handle StringListInput and StringListOutput components in IOFieldView 📝 (index.tsx): update InputListComponent props to include value, onChange, disabled, and playgroundDisabled 📝 (index.tsx): update IOFieldView to render InputListComponent for StringListInput and StringListOutput components
This commit is contained in:
parent
aa3ea07c6a
commit
1df3fe7ad6
5 changed files with 49 additions and 11 deletions
|
|
@ -7,7 +7,7 @@ class StringListInput(CustomComponent):
|
||||||
display_name = "String List Input"
|
display_name = "String List Input"
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {"param": {"display_name": "String List Input", "field_type": "str", "list": True}}
|
return {"input_value": {"display_name": "String List Input", "field_type": "str", "list": True}}
|
||||||
|
|
||||||
def build(self, param: list) -> Record:
|
def build(self, input_value: list) -> Record:
|
||||||
return Record(data=param)
|
return Record(data=input_value)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class StringListOutput(CustomComponent):
|
||||||
display_name = "String List Output"
|
display_name = "String List Output"
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {"param": {"display_name": "String List Output", "field_type": "str", "list": True}}
|
return {"input_value": {"display_name": "String List Output", "field_type": "str", "list": True}}
|
||||||
|
|
||||||
def build(self, param: list) -> Record:
|
def build(self, input_value: list) -> Record:
|
||||||
return Record(data=param)
|
return Record(data=input_value)
|
||||||
|
|
@ -12,6 +12,7 @@ export default function InputListComponent({
|
||||||
disabled,
|
disabled,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
componentName,
|
componentName,
|
||||||
|
playgroundDisabled,
|
||||||
}: InputListComponentType): JSX.Element {
|
}: InputListComponentType): JSX.Element {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (disabled && value.length > 0 && value[0] !== "") {
|
if (disabled && value.length > 0 && value[0] !== "") {
|
||||||
|
|
@ -24,7 +25,7 @@ export default function InputListComponent({
|
||||||
value = [value];
|
value = [value];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!value.length) value = [""];
|
if (!value?.length) value = [""];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -37,7 +38,7 @@ export default function InputListComponent({
|
||||||
return (
|
return (
|
||||||
<div key={idx} className="flex w-full gap-3">
|
<div key={idx} className="flex w-full gap-3">
|
||||||
<Input
|
<Input
|
||||||
disabled={disabled}
|
disabled={disabled || playgroundDisabled}
|
||||||
type="text"
|
type="text"
|
||||||
value={singleValue}
|
value={singleValue}
|
||||||
className={editNode ? "input-edit-node" : ""}
|
className={editNode ? "input-edit-node" : ""}
|
||||||
|
|
@ -64,6 +65,7 @@ export default function InputListComponent({
|
||||||
editNode ? "-edit" : ""
|
editNode ? "-edit" : ""
|
||||||
}_${componentName}-` + idx
|
}_${componentName}-` + idx
|
||||||
}
|
}
|
||||||
|
disabled={disabled || playgroundDisabled}
|
||||||
>
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="Plus"
|
name="Plus"
|
||||||
|
|
@ -82,10 +84,15 @@ export default function InputListComponent({
|
||||||
newInputList.splice(idx, 1);
|
newInputList.splice(idx, 1);
|
||||||
onChange(newInputList);
|
onChange(newInputList);
|
||||||
}}
|
}}
|
||||||
|
disabled={disabled || playgroundDisabled}
|
||||||
>
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="X"
|
name="X"
|
||||||
className="h-4 w-4 hover:text-status-red"
|
className={`h-4 w-4 ${
|
||||||
|
disabled || playgroundDisabled
|
||||||
|
? ""
|
||||||
|
: "hover:text-accent-foreground"
|
||||||
|
}`}
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { cloneDeep } from "lodash";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ImageViewer from "../../../../components/ImageViewer";
|
import ImageViewer from "../../../../components/ImageViewer";
|
||||||
import CsvOutputComponent from "../../../../components/csvOutputComponent";
|
import CsvOutputComponent from "../../../../components/csvOutputComponent";
|
||||||
|
import InputListComponent from "../../../../components/inputListComponent";
|
||||||
import PdfViewer from "../../../../components/pdfViewer";
|
import PdfViewer from "../../../../components/pdfViewer";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
|
|
@ -121,7 +122,21 @@ export default function IOFieldView({
|
||||||
);
|
);
|
||||||
|
|
||||||
case "StringListInput":
|
case "StringListInput":
|
||||||
return <>diusahjduisahudsa</>;
|
return (
|
||||||
|
<>
|
||||||
|
<InputListComponent
|
||||||
|
value={node.data.node!.template["input_value"]?.value}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (node) {
|
||||||
|
let newNode = cloneDeep(node);
|
||||||
|
newNode.data.node!.template["input_value"].value = e;
|
||||||
|
setNode(node.id, newNode);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
disabled={false}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
|
|
@ -249,7 +264,22 @@ export default function IOFieldView({
|
||||||
);
|
);
|
||||||
|
|
||||||
case "StringListOutput":
|
case "StringListOutput":
|
||||||
return <>diusahjduisahudsa</>;
|
return (
|
||||||
|
<>
|
||||||
|
<InputListComponent
|
||||||
|
value={node.data.node!.template["input_value"]?.value}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (node) {
|
||||||
|
let newNode = cloneDeep(node);
|
||||||
|
newNode.data.node!.template["input_value"].value = e;
|
||||||
|
setNode(node.id, newNode);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
playgroundDisabled
|
||||||
|
disabled={false}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ export type InputListComponentType = {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
editNode?: boolean;
|
editNode?: boolean;
|
||||||
componentName?: string;
|
componentName?: string;
|
||||||
|
playgroundDisabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type InputGlobalComponentType = {
|
export type InputGlobalComponentType = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue