🐛 fix(genericModal/index.tsx): set field_name to the first key of custom_fields object if it is an empty string
🐛 fix(genericModal/index.tsx): update template value based on field_name instead of hardcoding "template" ✨ feat(api/index.ts): add CustomFieldsType to represent custom fields in APIClassType
This commit is contained in:
parent
0024117b43
commit
f38692c9df
2 changed files with 22 additions and 3 deletions
|
|
@ -109,6 +109,13 @@ export default function GenericModal({
|
|||
|
||||
postValidatePrompt(field_name, inputValue, nodeClass!)
|
||||
.then((apiReturn) => {
|
||||
// if field_name is an empty string, then we need to set it
|
||||
// to the first key of the custom_fields object
|
||||
if (field_name === "") {
|
||||
field_name = Object.keys(
|
||||
apiReturn.data?.frontend_node?.custom_fields ?? {}
|
||||
)[0];
|
||||
}
|
||||
if (apiReturn.data) {
|
||||
let inputVariables = apiReturn.data.input_variables ?? [];
|
||||
if (inputVariables && inputVariables.length === 0) {
|
||||
|
|
@ -124,7 +131,7 @@ export default function GenericModal({
|
|||
setNodeClass!(apiReturn.data?.frontend_node);
|
||||
setModalOpen(closeModal);
|
||||
setValue(inputValue);
|
||||
apiReturn.data.frontend_node["template"]["template"]["value"] =
|
||||
apiReturn.data.frontend_node["template"][field_name]["value"] =
|
||||
inputValue;
|
||||
} else {
|
||||
setIsEdit(false);
|
||||
|
|
@ -138,7 +145,7 @@ export default function GenericModal({
|
|||
setNodeClass!(apiReturn.data?.frontend_node);
|
||||
setModalOpen(closeModal);
|
||||
setValue(inputValue);
|
||||
apiReturn.data.frontend_node["template"]["template"]["value"] =
|
||||
apiReturn.data.frontend_node["template"][field_name]["value"] =
|
||||
inputValue;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ export type APITemplateType = {
|
|||
variable: TemplateVariableType;
|
||||
[key: string]: TemplateVariableType;
|
||||
};
|
||||
|
||||
export type CustomFieldsType = {
|
||||
[key: string]: Array<string>;
|
||||
};
|
||||
|
||||
export type APIClassType = {
|
||||
base_classes: Array<string>;
|
||||
description: string;
|
||||
|
|
@ -14,10 +19,17 @@ export type APIClassType = {
|
|||
display_name: string;
|
||||
input_types?: Array<string>;
|
||||
output_types?: Array<string>;
|
||||
custom_fields?: CustomFieldsType;
|
||||
beta?: boolean;
|
||||
documentation: string;
|
||||
error?: string;
|
||||
[key: string]: Array<string> | string | APITemplateType | boolean | undefined;
|
||||
[key: string]:
|
||||
| Array<string>
|
||||
| string
|
||||
| APITemplateType
|
||||
| CustomFieldsType
|
||||
| boolean
|
||||
| undefined;
|
||||
};
|
||||
|
||||
export type TemplateVariableType = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue