-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from fractal-analytics-platform/jschema_integ…
…ration_with_workflow_page Integrate JSchema component within Workflow page
- Loading branch information
Showing
4 changed files
with
145 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<script> | ||
import { page } from '$app/stores'; | ||
import JSchema from '$lib/components/common/jschema/JSchema.svelte'; | ||
import StandardErrorAlert from '$lib/components/common/StandardErrorAlert.svelte'; | ||
import { updateFormEntry } from '$lib/components/workflow/task_form_utils'; | ||
const SUPPORTED_SCHEMA_VERSIONS = ['pydantic_v1']; | ||
export let workflowId = undefined; | ||
export let workflowTaskId = undefined; | ||
export let argumentsSchema = undefined; | ||
export let argumentsSchemaVersion = undefined; | ||
export let validSchema = undefined; | ||
export let args = undefined; | ||
let schemaComponent = undefined; | ||
function handleSaveChanges(newArgs) { | ||
return new Promise((resolve, reject) => { | ||
const projectId = $page.params.projectId; | ||
updateFormEntry( | ||
projectId, | ||
workflowId, | ||
workflowTaskId, | ||
newArgs, | ||
'args' | ||
).then(response => { | ||
resolve(response.args); | ||
}).catch(err => { | ||
new StandardErrorAlert({ | ||
target: document.getElementById('json-schema-validation-errors'), | ||
props: { | ||
error: err | ||
} | ||
}); | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
function handleValidationErrors(errors) { | ||
new StandardErrorAlert({ | ||
target: document.getElementById('json-schema-validation-errors'), | ||
props: { | ||
error: errors | ||
} | ||
}); | ||
} | ||
$: { | ||
if (argumentsSchemaVersion && SUPPORTED_SCHEMA_VERSIONS.includes(argumentsSchemaVersion)) { | ||
validSchema = true; | ||
} else { | ||
validSchema = false; | ||
} | ||
} | ||
</script> | ||
|
||
<div> | ||
<div id='json-schema-validation-errors'></div> | ||
<button on:click={() => { schemaComponent.resetChanges(args) }}>Reset</button> | ||
<JSchema schema={argumentsSchema} schemaData={args} {handleSaveChanges} {handleValidationErrors} | ||
bind:this={schemaComponent} /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters