Skip to content

Commit

Permalink
Merge pull request #858 from NeurodataWithoutBorders/fix-complex-vali…
Browse files Browse the repository at this point in the history
…dation-while-maintaining-timezone-awareness

Fix Validation with Timezone Awareness
  • Loading branch information
CodyCBakerPhD authored Jun 13, 2024
2 parents 360a3b2 + 4840168 commit da0926c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ export class GuidedMetadataPage extends ManagedPage {

delete results.__generated; // Ignore generated results. NOTE: See if this fails

const pageThis = this;

// Create the form
const form = new JSONSchemaForm({
identifier: instanceId,
Expand Down Expand Up @@ -333,7 +335,10 @@ export class GuidedMetadataPage extends ManagedPage {

onUpdate: () => (this.unsavedUpdates = "conversions"),

validateOnChange: (...args) => validateOnChange.call(this, ...args),
validateOnChange: function (...args) {
this.timezone = pageThis.workflow?.timezone.value; // Set the timezone for the form
return validateOnChange.call(this, ...args);
},
onlyRequired: false,
onStatusChange: (state) => this.manager.updateState(`sub-${subject}/ses-${session}`, state),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class GuidedSubjectsPage extends Page {
connectedCallback() {
super.connectedCallback();

const pageThis = this;
const schema = preprocessMetadataSchema(undefined, true).properties.Subject;

const modal = (this.#globalModal = createGlobalFormModal.call(this, {
Expand All @@ -110,7 +111,8 @@ export class GuidedSubjectsPage extends Page {
validateEmptyValues: null,
schema,
formProps: {
validateOnChange: (localPath, parent, path) => {
validateOnChange: function (localPath, parent, path) {
this.timezone = pageThis.workflow?.timezone?.value;
return validateOnChange.call(this, localPath, parent, ["Subject", ...path]);
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/electron/frontend/core/validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function validateOnChange(name, parent, path, value) {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
timezone: this.workflow?.timezone?.value,
timezone: this.timezone,
parent: copy,
function_name: resolvedFunctionName,
}),
Expand Down

0 comments on commit da0926c

Please sign in to comment.