feat: dropdown combobox option (#2991)
* Removed default variable as true * added combobox to dropdown * Fixed types on strRenderComponents * Added type of combobox * Created combobox option on backend * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
a9863a050e
commit
a857868b7e
7 changed files with 23 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ FIELD_FORMAT_ATTRIBUTES = [
|
||||||
"required",
|
"required",
|
||||||
"list",
|
"list",
|
||||||
"multiline",
|
"multiline",
|
||||||
|
"combobox",
|
||||||
"fileTypes",
|
"fileTypes",
|
||||||
"password",
|
"password",
|
||||||
"input_types",
|
"input_types",
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,11 @@ class MultilineMixin(BaseModel):
|
||||||
multiline: CoalesceBool = True
|
multiline: CoalesceBool = True
|
||||||
|
|
||||||
|
|
||||||
|
class ComboboxMixin(BaseModel):
|
||||||
|
combobox: CoalesceBool = False
|
||||||
|
"""Variable that defines if the user can insert custom values in the dropdown."""
|
||||||
|
|
||||||
|
|
||||||
class TableMixin(BaseModel):
|
class TableMixin(BaseModel):
|
||||||
table_schema: Optional[TableSchema | list[Column]] = None
|
table_schema: Optional[TableSchema | list[Column]] = None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ from .input_mixin import (
|
||||||
BaseInputMixin,
|
BaseInputMixin,
|
||||||
DatabaseLoadMixin,
|
DatabaseLoadMixin,
|
||||||
DropDownMixin,
|
DropDownMixin,
|
||||||
|
ComboboxMixin,
|
||||||
FieldTypes,
|
FieldTypes,
|
||||||
FileMixin,
|
FileMixin,
|
||||||
InputTraceMixin,
|
InputTraceMixin,
|
||||||
|
|
@ -292,7 +293,7 @@ class DictInput(BaseInputMixin, ListableInputMixin, InputTraceMixin):
|
||||||
value: Optional[dict] = {}
|
value: Optional[dict] = {}
|
||||||
|
|
||||||
|
|
||||||
class DropdownInput(BaseInputMixin, DropDownMixin, MetadataTraceMixin):
|
class DropdownInput(BaseInputMixin, DropDownMixin, MetadataTraceMixin, ComboboxMixin):
|
||||||
"""
|
"""
|
||||||
Represents a dropdown input field.
|
Represents a dropdown input field.
|
||||||
|
|
||||||
|
|
@ -307,6 +308,7 @@ class DropdownInput(BaseInputMixin, DropDownMixin, MetadataTraceMixin):
|
||||||
|
|
||||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.TEXT
|
field_type: Optional[SerializableFieldTypes] = FieldTypes.TEXT
|
||||||
options: list[str] = Field(default_factory=list)
|
options: list[str] = Field(default_factory=list)
|
||||||
|
combobox: CoalesceBool = False
|
||||||
|
|
||||||
|
|
||||||
class MultiselectInput(BaseInputMixin, ListableInputMixin, DropDownMixin, MetadataTraceMixin):
|
class MultiselectInput(BaseInputMixin, ListableInputMixin, DropDownMixin, MetadataTraceMixin):
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export default function Dropdown({
|
||||||
isLoading,
|
isLoading,
|
||||||
value,
|
value,
|
||||||
options,
|
options,
|
||||||
combobox = true,
|
combobox,
|
||||||
onSelect,
|
onSelect,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
id = "",
|
id = "",
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { handleOnNewValueType } from "@/CustomNodes/hooks/use-handle-new-value";
|
||||||
|
import { InputFieldType } from "@/types/api";
|
||||||
import Dropdown from "../../../dropdownComponent";
|
import Dropdown from "../../../dropdownComponent";
|
||||||
import InputGlobalComponent from "../../../inputGlobalComponent";
|
import InputGlobalComponent from "../../../inputGlobalComponent";
|
||||||
import InputListComponent from "../../../inputListComponent";
|
import InputListComponent from "../../../inputListComponent";
|
||||||
|
|
@ -12,6 +14,14 @@ export function StrRenderComponent({
|
||||||
handleOnNewValue,
|
handleOnNewValue,
|
||||||
editNode,
|
editNode,
|
||||||
id,
|
id,
|
||||||
|
}: {
|
||||||
|
templateData: Partial<InputFieldType>;
|
||||||
|
value: any;
|
||||||
|
name: string;
|
||||||
|
disabled: boolean;
|
||||||
|
handleOnNewValue: handleOnNewValueType;
|
||||||
|
editNode: boolean;
|
||||||
|
id: string;
|
||||||
}) {
|
}) {
|
||||||
const onChange = (value: any, dbValue?: boolean, skipSnapshot?: boolean) => {
|
const onChange = (value: any, dbValue?: boolean, skipSnapshot?: boolean) => {
|
||||||
handleOnNewValue({ value, load_from_db: dbValue }, { skipSnapshot });
|
handleOnNewValue({ value, load_from_db: dbValue }, { skipSnapshot });
|
||||||
|
|
@ -65,6 +75,7 @@ export function StrRenderComponent({
|
||||||
editNode={editNode}
|
editNode={editNode}
|
||||||
options={templateData.options}
|
options={templateData.options}
|
||||||
onSelect={onChange}
|
onSelect={onChange}
|
||||||
|
combobox={templateData.combobox}
|
||||||
value={value ?? "Choose an option"}
|
value={value ?? "Choose an option"}
|
||||||
id={`dropdown_${id}`}
|
id={`dropdown_${id}`}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ export type InputFieldType = {
|
||||||
real_time_refresh?: boolean;
|
real_time_refresh?: boolean;
|
||||||
refresh_button?: boolean;
|
refresh_button?: boolean;
|
||||||
refresh_button_text?: string;
|
refresh_button_text?: string;
|
||||||
|
combobox?: boolean;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ export type InputGlobalComponentType = {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
onChange: (value: string, dbValue: boolean, snapshot?: boolean) => void;
|
onChange: (value: string, dbValue: boolean, snapshot?: boolean) => void;
|
||||||
name: string;
|
name: string;
|
||||||
data: InputFieldType;
|
data: Partial<InputFieldType>;
|
||||||
editNode?: boolean;
|
editNode?: boolean;
|
||||||
playgroundDisabled?: boolean;
|
playgroundDisabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue