diff --git a/src/electron/frontend/core/components/DateTimeSelector.js b/src/electron/frontend/core/components/DateTimeSelector.js index 11c302e49..c8f58d6d6 100644 --- a/src/electron/frontend/core/components/DateTimeSelector.js +++ b/src/electron/frontend/core/components/DateTimeSelector.js @@ -2,15 +2,8 @@ import { LitElement, css } from "lit"; import { getTimezoneOffset, formatTimezoneOffset } from "../../../../schemas/timezone.schema"; // Function to format the GMT offset -export function extractISOString( - date = new Date(), - { - offset = false, - timezone = undefined - } = {} -) { - - if (typeof date === 'string') date = new Date() +export function extractISOString(date = new Date(), { offset = false, timezone = undefined } = {}) { + if (typeof date === "string") date = new Date(); // Extract the GMT offset const offsetMs = getTimezoneOffset(date, timezone); diff --git a/src/electron/frontend/core/components/JSONSchemaForm.js b/src/electron/frontend/core/components/JSONSchemaForm.js index 8feef732b..c50f91ab3 100644 --- a/src/electron/frontend/core/components/JSONSchemaForm.js +++ b/src/electron/frontend/core/components/JSONSchemaForm.js @@ -17,8 +17,7 @@ import { successHue, warningHue, errorHue } from "./globals"; import { Button } from "./Button"; import { extractISOString } from "./DateTimeSelector"; import { timezoneProperties } from "../../../../schemas/timezone.schema"; -const timezonePropertyPaths = timezoneProperties.map(arr => arr.join('.')) - +const timezonePropertyPaths = timezoneProperties.map((arr) => arr.join(".")); const encode = (str) => { try { @@ -252,7 +251,7 @@ export class JSONSchemaForm extends LitElement { dialogOptions: { type: Object, reflect: false }, globals: { type: Object, reflect: false }, validateEmptyValues: { type: Boolean, reflect: true }, - timezone: { type: String, reflect: true} + timezone: { type: String, reflect: true }, }; } @@ -285,7 +284,7 @@ export class JSONSchemaForm extends LitElement { this.results = (props.base ? structuredClone(props.results) : props.results) ?? {}; // Deep clone results in nested forms this.globals = props.globals ?? {}; - this.timezone = props.timezone ?? undefined + this.timezone = props.timezone ?? undefined; this.ignore = props.ignore ?? {}; this.required = props.required ?? {}; @@ -705,7 +704,7 @@ export class JSONSchemaForm extends LitElement { pattern: propertyType === "pattern" ? name : propertyType ?? undefined, renderTable: this.renderTable, renderCustomHTML: this.renderCustomHTML, - showLabel: !("title" in info && !info.title) + showLabel: !("title" in info && !info.title), }); this.inputs[localPath.join("-")] = interactiveInput; @@ -911,20 +910,16 @@ export class JSONSchemaForm extends LitElement { let value = parent[name]; - const { timezone } = this + const { timezone } = this; // Validate with timezone awareness - const isTimezoneProperty = timezonePropertyPaths.includes(externalPath.join('.')) + const isTimezoneProperty = timezonePropertyPaths.includes(externalPath.join(".")); if (timezone && isTimezoneProperty) { - value = extractISOString( - value, - { - offset: true, - timezone - } - ) + value = extractISOString(value, { + offset: true, + timezone, + }); } - const skipValidation = this.validateEmptyValues === null && value === undefined; @@ -933,7 +928,6 @@ export class JSONSchemaForm extends LitElement { // Run validation functions const jsonSchemaErrors = validateArgs.length === 2 ? this.validateSchema(...validateArgs, name) : []; - const valid = skipValidation ? true : await this.validateOnChange(name, parent, pathToValidate, value); if (valid === null) return null; // Skip validation / data change if the value is null diff --git a/src/electron/frontend/core/components/Main.js b/src/electron/frontend/core/components/Main.js index 74465691a..8421ffebe 100644 --- a/src/electron/frontend/core/components/Main.js +++ b/src/electron/frontend/core/components/Main.js @@ -77,12 +77,11 @@ export class Main extends LitElement { const workflowConfig = page.workflow ?? (page.workflow = {}); const workflowValues = page.info.globalState?.project?.workflow ?? {}; - Object.entries(workflowValues).forEach(([ key, value ]) => { - - const config = workflowConfig[key] ?? (workflowConfig[key] = {}) + Object.entries(workflowValues).forEach(([key, value]) => { + const config = workflowConfig[key] ?? (workflowConfig[key] = {}); config.value = value; - const { elements } = config + const { elements } = config; if (elements) { if (value) elements.forEach((el) => el.removeAttribute("hidden")); else elements.forEach((el) => el.setAttribute("hidden", true)); diff --git a/src/electron/frontend/core/components/pages/Page.js b/src/electron/frontend/core/components/pages/Page.js index c488a7e27..cf87eb04f 100644 --- a/src/electron/frontend/core/components/pages/Page.js +++ b/src/electron/frontend/core/components/pages/Page.js @@ -162,7 +162,6 @@ export class Page extends LitElement { const fileConfiguration = []; try { - for (let info of toRun) { const { subject, session, globalState = this.info.globalState } = info; const file = `sub-${subject}/sub-${subject}_ses-${session}.nwb`; @@ -174,21 +173,18 @@ export class Page extends LitElement { const sourceDataCopy = structuredClone(sessionResults.source_data); // Resolve the correct session info from all of the metadata for this conversion - const metadata = resolveMetadata(subject, session, globalState) + const metadata = resolveMetadata(subject, session, globalState); // Add timezone information to relevant metadata - timezoneProperties.forEach(path => { - const name = path.slice(-1)[0] - const pathTo = path.slice(0, -1) - const parent = pathTo.reduce((acc, key) => acc[key], metadata) - parent[name] = extractISOString( - parent[name], - { - offset: true, - timezone: this.workflow.timezone - } - ) - }) + timezoneProperties.forEach((path) => { + const name = path.slice(-1)[0]; + const pathTo = path.slice(0, -1); + const parent = pathTo.reduce((acc, key) => acc[key], metadata); + parent[name] = extractISOString(parent[name], { + offset: true, + timezone: this.workflow.timezone, + }); + }); const sessionInfo = { ...sessionResults, @@ -205,7 +201,7 @@ export class Page extends LitElement { ...conversionOptions, // Any additional conversion options override the defaults interfaces: globalState.interfaces, - alignment + alignment, }; fileConfiguration.push(payload); @@ -242,10 +238,7 @@ export class Page extends LitElement { const subRef = results[subject] ?? (results[subject] = {}); subRef[session] = info; }); - - } - - finally { + } finally { await closeProgressPopup(); } diff --git a/src/electron/frontend/core/components/pages/guided-mode/data/GuidedMetadata.js b/src/electron/frontend/core/components/pages/guided-mode/data/GuidedMetadata.js index b1cdd48ba..eb99fa1b2 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/data/GuidedMetadata.js +++ b/src/electron/frontend/core/components/pages/guided-mode/data/GuidedMetadata.js @@ -279,7 +279,6 @@ export class GuidedMetadataPage extends ManagedPage { delete results.__generated; // Ignore generated results. NOTE: See if this fails - // Create the form const form = new JSONSchemaForm({ identifier: instanceId,