Skip to content

Commit

Permalink
Added columns support from the table in scope
Browse files Browse the repository at this point in the history
  • Loading branch information
punith300i committed Oct 30, 2023
1 parent f847567 commit 86440a3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion www/src/pages/table/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const MenuBar = observer(
},
openAddEdgeForm: () => openForm({ type: "edge", sm }),
openTransformationFrom: () =>
openForm({ type: "transformation", tableId: tableId }),
openForm({ type: "transformation", table: table }),
predict: () => {
assistantService.predict(table).then(() => {
tableRef.current?.reload();
Expand Down
30 changes: 17 additions & 13 deletions www/src/pages/table/forms/TransformationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ import {
TransformationResult,
useStores,
Transformation,
Table as TableModel,
} from "../../../models";

const styles = {};

export interface TransformationFormProps {
type: string;
tableId: number;
table: TableModel;
}

export const TransformationForm = withStyles(styles)(
observer(
({
classes,
tableId,
table,
}: TransformationFormProps & WithStyles<typeof styles>) => {
const onDone = () => Modal.destroyAll();
const actionRef = useRef<ActionType>();
Expand All @@ -56,7 +56,6 @@ export const TransformationForm = withStyles(styles)(
) {
return (
<>
{" "}
{
<Tag color={"volcano"}>
<pre>{transformed_value}</pre>
Expand All @@ -74,7 +73,7 @@ export const TransformationForm = withStyles(styles)(
const onExecute = async () => {
const transformationPayload: Transformation = {
id: -1,
tableId: tableId,
tableId: table.id,
type: form.getFieldValue("type"),
code: form.getFieldValue("code"),
mode: "restrictedpython",
Expand Down Expand Up @@ -115,7 +114,11 @@ export const TransformationForm = withStyles(styles)(
style={{
width: "100%",
}}
placeholder="Please select"
placeholder="Please select columns"
options={table.columns.map((column) => ({
label: column,
value: column,
}))}
/>
</Form.Item>
</Col>
Expand All @@ -132,7 +135,11 @@ export const TransformationForm = withStyles(styles)(
style={{
width: "100%",
}}
placeholder="Please select"
options={table.columns.map((column) => ({
label: column,
value: column,
}))}
placeholder="Please select columns"
/>
</Form.Item>
</Col>
Expand All @@ -157,24 +164,21 @@ export const TransformationForm = withStyles(styles)(
type="primary"
onClick={onExecute}
>
{" "}
Execute{" "}
Execute
</Button>
</Form.Item>
</Col>
<Col span={2} flex="auto">
<Form.Item>
<Button style={{ width: "100%" }} type="primary">
{" "}
Save{" "}
Save
</Button>
</Form.Item>
</Col>
<Col span={2} flex="auto">
<Form.Item>
<Button style={{ width: "100%" }} type="primary">
{" "}
Reset{" "}
Reset
</Button>
</Form.Item>
</Col>
Expand Down
9 changes: 4 additions & 5 deletions www/src/pages/table/forms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TransformationForm,
TransformationFormProps,
} from "./TransformationForm";
import { Table } from "../../../models";

interface TypedEdgeFormProps extends EdgeFormProps {
type: "edge";
Expand All @@ -16,8 +17,8 @@ interface TypedNodeFormProps extends NodeFormProps {

interface TypedTransformationFormProps extends TransformationFormProps {
type: "transformation";
transformationId?: number;
tableId: number;
id?: number;
table: Table;
}

export function openForm(
Expand All @@ -38,9 +39,7 @@ export function openForm(
case "transformation":
content = <TransformationForm {...args} />;
title =
args.transformationId === undefined
? "Add Transformation"
: "Update Transformation";
args.id === undefined ? "Add Transformation" : "Update Transformation";
break;
}

Expand Down

0 comments on commit 86440a3

Please sign in to comment.