Skip to content

Commit

Permalink
Merge pull request #279 from fractal-analytics-platform/278-task-argu…
Browse files Browse the repository at this point in the history
…ment-can-be-updated-once-but-not-twice

Fix bug "task argument can be updated once but not twice"
  • Loading branch information
tcompa authored Sep 5, 2023
2 parents 43c9047 + 44c81c2 commit ef47c70
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*Note: Numbers like (\#123) point to closed Pull Requests on the fractal-web repository.*

# 0.5.5

* Fix bug in `JSchema.svelte` (\#279).

# 0.5.4

Expand Down
56 changes: 27 additions & 29 deletions src/lib/components/common/jschema/JSchema.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,35 +97,33 @@
}
}
if (saveChanges === null || saveChanges === undefined) {
saveChanges = function() {
const data = schemaManager.data;
// The following is required to remove all null values from the data object
// We suppose that null values are not valid, hence we remove them
// Deep copy the data object
const toStripData = JSON.parse(JSON.stringify(data));
const strippedNullData = stripNullAndEmptyObjectsAndArrays(toStripData);
const isDataValid = validator.isValid(strippedNullData);
if (!isDataValid) {
if (handleValidationErrors !== null && handleValidationErrors !== undefined) {
handleValidationErrors(validator.getErrors());
}
console.error('Could not save changes. Data is invalid', validator.getErrors());
return;
}
if (handleSaveChanges !== null && handleSaveChanges !== undefined) {
handleSaveChanges(strippedNullData)
.then((updated_args) => {
schemaManager.data = updated_args;
schemaManager.changesSaved();
})
.catch((err) => {
console.error(err);
});
}
}
}
saveChanges = function() {
const data = schemaManager.data;
// The following is required to remove all null values from the data object
// We suppose that null values are not valid, hence we remove them
// Deep copy the data object
const toStripData = JSON.parse(JSON.stringify(data));
const strippedNullData = stripNullAndEmptyObjectsAndArrays(toStripData);
const isDataValid = validator.isValid(strippedNullData);
if (!isDataValid) {
if (handleValidationErrors !== null && handleValidationErrors !== undefined) {
handleValidationErrors(validator.getErrors());
}
console.error('Could not save changes. Data is invalid', validator.getErrors());
return;
}
if (handleSaveChanges !== null && handleSaveChanges !== undefined) {
handleSaveChanges(strippedNullData)
.then((updated_args) => {
schemaManager.data = updated_args;
schemaManager.changesSaved();
})
.catch((err) => {
console.error(err);
});
}
}
export function discardChanges(args) {
// Set schemaData to incoming args value
Expand Down
3 changes: 3 additions & 0 deletions src/lib/components/workflow/task_form_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export async function updateFormEntry(
const requestData = {};
requestData[groupName] = updatingWorkflowTaskProperties;

console.log(`In updateFormEntry, requestData is ${JSON.stringify(requestData)}`);

// Should make a PATCH request to the server to update the workflow task properties
const response = await fetch(
`/projects/${projectId}/workflows/${workflowId}/tasks/${workflowTaskId}`,
Expand All @@ -26,6 +28,7 @@ export async function updateFormEntry(
console.log('Update form entry response successful');
// Should return the updated form entry
const updatedFormEntry = await response.json();
console.log(`In updateFormEntry, updatedFormEntry is ${JSON.stringify(updatedFormEntry)}`);
return updatedFormEntry;
}

Expand Down

0 comments on commit ef47c70

Please sign in to comment.