diff --git a/www/src/models/index.ts b/www/src/models/index.ts index 2e5a5b7..52f16aa 100644 --- a/www/src/models/index.ts +++ b/www/src/models/index.ts @@ -68,7 +68,11 @@ export function useStores(): IStore { export type { Property, DataType } from "./ontology/Property"; export type { SMEdge, SMNode } from "./sm/SMGraph"; export type { Table, TableRow } from "./table"; -export type { TransformationResult, Transformation } from "./transformation"; +export type { + TransformationResult, + Transformation, + DraftCreateTransformation, +} from "./transformation"; export { ProjectStore, TableStore, diff --git a/www/src/models/transformation/TransformationStore.ts b/www/src/models/transformation/TransformationStore.ts index adc1d41..ab5e639 100644 --- a/www/src/models/transformation/TransformationStore.ts +++ b/www/src/models/transformation/TransformationStore.ts @@ -9,21 +9,30 @@ export interface Transformation extends Record { tableId: number; datapath: string[]; code: string | undefined; + onError: string; outputpath: string[] | undefined; +} + +export interface DraftCreateTransformation extends Transformation { tolerance: number; rows: number; } -export class TransformationStore extends SimpleCRUDStore< +export class TransformationStore extends CRUDStore< number, - Transformation + Omit & { draftID: string }, + DraftCreateTransformation & { + markSaved(): void; + toModel(): DraftCreateTransformation | undefined; + }, + DraftCreateTransformation > { constructor() { super(`${SERVER}/api/transformation`, undefined, false); } async testTransformation( - payload: Transformation + payload: DraftCreateTransformation ): Promise { let resp: any = await axios .post(`${SERVER}/api/transformation/test`, { diff --git a/www/src/pages/table/forms/TransformationForm.tsx b/www/src/pages/table/forms/TransformationForm.tsx index 773d607..2464e94 100644 --- a/www/src/pages/table/forms/TransformationForm.tsx +++ b/www/src/pages/table/forms/TransformationForm.tsx @@ -18,7 +18,7 @@ import Editor from "@monaco-editor/react"; import { TransformationResult, useStores, - Transformation, + DraftCreateTransformation, Table as TableModel, } from "../../../models"; @@ -83,12 +83,13 @@ export const TransformationForm = observer( ]; const onExecute = async () => { - const transformationPayload: Transformation = { + const transformationPayload: DraftCreateTransformation = { id: -1, tableId: table.id, type: form.getFieldValue("type"), code: form.getFieldValue("code"), mode: "restrictedpython", + onError: form.getFieldValue("onerror"), datapath: form.getFieldValue("datapath"), outputpath: form.getFieldValue("outputpath"), tolerance: form.getFieldValue("tolerance"),