Skip to content

Commit

Permalink
issues with beans
Browse files Browse the repository at this point in the history
  • Loading branch information
mgubaidullin committed Sep 26, 2024
1 parent 389b732 commit e2a0969
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export function DslPropertyField(props: Props) {
}

function showCode(name: string, javaType: string) {
console.log(name, javaType)
const {property} = props;
InfrastructureAPI.onGetCustomCode?.(name, property.javaType).then(value => {
if (value === undefined) {
Expand All @@ -487,6 +488,7 @@ export function DslPropertyField(props: Props) {
const {dslLanguage} = props;
const selectOptions: SelectOptionProps[] = [];
if (beans) {
console.log(beans)
selectOptions.push(...beans.map((bean) => {
return {value: beanPrefix + bean.name, children: bean.name}
}));
Expand All @@ -497,51 +499,46 @@ export function DslPropertyField(props: Props) {
})
);
}
if (selectOptions.filter(o => o.value === value?.toString()).length === 0) {
selectOptions.push({
value: value, children: value, description: 'Custom Bean'
})
}
return (
<SelectField
id={property.name}
name={property.name}
placeholder='Select bean'
selectOptions={selectOptions}
value={value?.toString()}
onChange={(name, value) => propertyChanged(property.name, value)}
/>
// <InputGroup>
// <InputGroupItem isFill>
// <TextInput
// ref={ref}
// className="text-field" isRequired
// type="text"
// id={property.name} name={property.name}
// value={value?.toString()}
// onChange={(_, value) => {
// propertyChanged(property.name, CamelUtil.capitalizeName(value?.replace(/\s/g, '')))
// }}
// readOnlyVariant={isUriReadOnly(property) ? "default" : undefined}/>
// </InputGroupItem>
// <InputGroupItem>
// <Tooltip position="bottom-end" content={"Create Java Class"}>
// <Button isDisabled={value?.length === 0} variant="control"
// onClick={e => showCode(value, property.javaType)}>
// <PlusIcon/>
// </Button>
// </Tooltip>
// </InputGroupItem>
// {showEditor && <InputGroupItem>
// <ExpressionModalEditor name={property.name}
// customCode={customCode}
// showEditor={showEditor}
// dark={dark}
// dslLanguage={dslLanguage}
// title="Java Class"
// onClose={() => setShowEditor(false)}
// onSave={(fieldId, value1) => {
// propertyChanged(fieldId, value);
// InfrastructureAPI.onSaveCustomCode?.(value, value1);
// setShowEditor(false)
// }}/>
// </InputGroupItem>}
// </InputGroup>
<InputGroup>
<InputGroupItem isFill>
<SelectField
id={property.name}
name={property.name}
placeholder='Select bean'
selectOptions={selectOptions}
value={value?.toString()}
onChange={(name, value) => propertyChanged(property.name, value)}
/>
</InputGroupItem>
<InputGroupItem>
<Tooltip position="bottom-end" content={"Create Java Class"}>
<Button isDisabled={value?.length === 0} variant="control"
onClick={e => showCode(value, property.javaType)}>
<PlusIcon/>
</Button>
</Tooltip>
</InputGroupItem>
{showEditor && <InputGroupItem>
<ExpressionModalEditor name={property.name}
customCode={customCode}
showEditor={showEditor}
dark={dark}
dslLanguage={dslLanguage}
title="Java Class"
onClose={() => setShowEditor(false)}
onSave={(fieldId, value1) => {
propertyChanged(fieldId, value);
InfrastructureAPI.onSaveCustomCode?.(value, value1);
setShowEditor(false)
}}/>
</InputGroupItem>}
</InputGroup>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function SelectField(props: Props) {
setSelectOptions(newSelectOptions);
}, [filterValue]);

const createItemId = (value: any) => `select-typeahead-${value.replace(' ', '-')}`;
const createItemId = (value: any) => `select-typeahead-${value?.replace(' ', '-')}`;

const setActiveAndFocusedItem = (itemIndex: number) => {
setFocusedItemIndex(itemIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export function DslPropertyField(props: Props) {
}

function showCode(name: string, javaType: string) {
console.log(name, javaType)
const {property} = props;
InfrastructureAPI.onGetCustomCode?.(name, property.javaType).then(value => {
if (value === undefined) {
Expand All @@ -487,6 +488,7 @@ export function DslPropertyField(props: Props) {
const {dslLanguage} = props;
const selectOptions: SelectOptionProps[] = [];
if (beans) {
console.log(beans)
selectOptions.push(...beans.map((bean) => {
return {value: beanPrefix + bean.name, children: bean.name}
}));
Expand All @@ -497,51 +499,46 @@ export function DslPropertyField(props: Props) {
})
);
}
if (selectOptions.filter(o => o.value === value?.toString()).length === 0) {
selectOptions.push({
value: value, children: value, description: 'Custom Bean'
})
}
return (
<SelectField
id={property.name}
name={property.name}
placeholder='Select bean'
selectOptions={selectOptions}
value={value?.toString()}
onChange={(name, value) => propertyChanged(property.name, value)}
/>
// <InputGroup>
// <InputGroupItem isFill>
// <TextInput
// ref={ref}
// className="text-field" isRequired
// type="text"
// id={property.name} name={property.name}
// value={value?.toString()}
// onChange={(_, value) => {
// propertyChanged(property.name, CamelUtil.capitalizeName(value?.replace(/\s/g, '')))
// }}
// readOnlyVariant={isUriReadOnly(property) ? "default" : undefined}/>
// </InputGroupItem>
// <InputGroupItem>
// <Tooltip position="bottom-end" content={"Create Java Class"}>
// <Button isDisabled={value?.length === 0} variant="control"
// onClick={e => showCode(value, property.javaType)}>
// <PlusIcon/>
// </Button>
// </Tooltip>
// </InputGroupItem>
// {showEditor && <InputGroupItem>
// <ExpressionModalEditor name={property.name}
// customCode={customCode}
// showEditor={showEditor}
// dark={dark}
// dslLanguage={dslLanguage}
// title="Java Class"
// onClose={() => setShowEditor(false)}
// onSave={(fieldId, value1) => {
// propertyChanged(fieldId, value);
// InfrastructureAPI.onSaveCustomCode?.(value, value1);
// setShowEditor(false)
// }}/>
// </InputGroupItem>}
// </InputGroup>
<InputGroup>
<InputGroupItem isFill>
<SelectField
id={property.name}
name={property.name}
placeholder='Select bean'
selectOptions={selectOptions}
value={value?.toString()}
onChange={(name, value) => propertyChanged(property.name, value)}
/>
</InputGroupItem>
<InputGroupItem>
<Tooltip position="bottom-end" content={"Create Java Class"}>
<Button isDisabled={value?.length === 0} variant="control"
onClick={e => showCode(value, property.javaType)}>
<PlusIcon/>
</Button>
</Tooltip>
</InputGroupItem>
{showEditor && <InputGroupItem>
<ExpressionModalEditor name={property.name}
customCode={customCode}
showEditor={showEditor}
dark={dark}
dslLanguage={dslLanguage}
title="Java Class"
onClose={() => setShowEditor(false)}
onSave={(fieldId, value1) => {
propertyChanged(fieldId, value);
InfrastructureAPI.onSaveCustomCode?.(value, value1);
setShowEditor(false)
}}/>
</InputGroupItem>}
</InputGroup>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function SelectField(props: Props) {
setSelectOptions(newSelectOptions);
}, [filterValue]);

const createItemId = (value: any) => `select-typeahead-${value.replace(' ', '-')}`;
const createItemId = (value: any) => `select-typeahead-${value?.replace(' ', '-')}`;

const setActiveAndFocusedItem = (itemIndex: number) => {
setFocusedItemIndex(itemIndex);
Expand Down
85 changes: 41 additions & 44 deletions karavan-space/src/designer/property/property/DslPropertyField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export function DslPropertyField(props: Props) {
}

function showCode(name: string, javaType: string) {
console.log(name, javaType)
const {property} = props;
InfrastructureAPI.onGetCustomCode?.(name, property.javaType).then(value => {
if (value === undefined) {
Expand All @@ -487,6 +488,7 @@ export function DslPropertyField(props: Props) {
const {dslLanguage} = props;
const selectOptions: SelectOptionProps[] = [];
if (beans) {
console.log(beans)
selectOptions.push(...beans.map((bean) => {
return {value: beanPrefix + bean.name, children: bean.name}
}));
Expand All @@ -497,51 +499,46 @@ export function DslPropertyField(props: Props) {
})
);
}
if (selectOptions.filter(o => o.value === value?.toString()).length === 0) {
selectOptions.push({
value: value, children: value, description: 'Custom Bean'
})
}
return (
<SelectField
id={property.name}
name={property.name}
placeholder='Select bean'
selectOptions={selectOptions}
value={value?.toString()}
onChange={(name, value) => propertyChanged(property.name, value)}
/>
// <InputGroup>
// <InputGroupItem isFill>
// <TextInput
// ref={ref}
// className="text-field" isRequired
// type="text"
// id={property.name} name={property.name}
// value={value?.toString()}
// onChange={(_, value) => {
// propertyChanged(property.name, CamelUtil.capitalizeName(value?.replace(/\s/g, '')))
// }}
// readOnlyVariant={isUriReadOnly(property) ? "default" : undefined}/>
// </InputGroupItem>
// <InputGroupItem>
// <Tooltip position="bottom-end" content={"Create Java Class"}>
// <Button isDisabled={value?.length === 0} variant="control"
// onClick={e => showCode(value, property.javaType)}>
// <PlusIcon/>
// </Button>
// </Tooltip>
// </InputGroupItem>
// {showEditor && <InputGroupItem>
// <ExpressionModalEditor name={property.name}
// customCode={customCode}
// showEditor={showEditor}
// dark={dark}
// dslLanguage={dslLanguage}
// title="Java Class"
// onClose={() => setShowEditor(false)}
// onSave={(fieldId, value1) => {
// propertyChanged(fieldId, value);
// InfrastructureAPI.onSaveCustomCode?.(value, value1);
// setShowEditor(false)
// }}/>
// </InputGroupItem>}
// </InputGroup>
<InputGroup>
<InputGroupItem isFill>
<SelectField
id={property.name}
name={property.name}
placeholder='Select bean'
selectOptions={selectOptions}
value={value?.toString()}
onChange={(name, value) => propertyChanged(property.name, value)}
/>
</InputGroupItem>
<InputGroupItem>
<Tooltip position="bottom-end" content={"Create Java Class"}>
<Button isDisabled={value?.length === 0} variant="control"
onClick={e => showCode(value, property.javaType)}>
<PlusIcon/>
</Button>
</Tooltip>
</InputGroupItem>
{showEditor && <InputGroupItem>
<ExpressionModalEditor name={property.name}
customCode={customCode}
showEditor={showEditor}
dark={dark}
dslLanguage={dslLanguage}
title="Java Class"
onClose={() => setShowEditor(false)}
onSave={(fieldId, value1) => {
propertyChanged(fieldId, value);
InfrastructureAPI.onSaveCustomCode?.(value, value1);
setShowEditor(false)
}}/>
</InputGroupItem>}
</InputGroup>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function SelectField(props: Props) {
setSelectOptions(newSelectOptions);
}, [filterValue]);

const createItemId = (value: any) => `select-typeahead-${value.replace(' ', '-')}`;
const createItemId = (value: any) => `select-typeahead-${value?.replace(' ', '-')}`;

const setActiveAndFocusedItem = (itemIndex: number) => {
setFocusedItemIndex(itemIndex);
Expand Down

0 comments on commit e2a0969

Please sign in to comment.