Skip to content

Commit

Permalink
Merge branch 'main' into pipeline-generation
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Jan 17, 2024
2 parents d717982 + 6ba7fc2 commit 5db8e9a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/requirements-rtd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ jsonschema==3.2.0
Jinja2<3.1
sphinx==5.1.1
pydata-sphinx-theme==0.14.1
readthedocs-sphinx-search==0.1.0rc3
readthedocs-sphinx-search==0.3.2
sphinx-copybutton==0.5.0
3 changes: 2 additions & 1 deletion src/renderer/src/stories/FileSystemSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export class FilesystemSelector extends LitElement {
const isMultipleTypes = Array.isArray(this.type);
this.setAttribute("manytypes", isMultipleTypes);
const isArray = Array.isArray(this.value);

const len = isArray ? this.value.length : 0;

if (isArray) {
Expand Down Expand Up @@ -251,7 +252,7 @@ export class FilesystemSelector extends LitElement {
>`
: ""}`}
</button>
${this.multiple && this.value.length > 1
${this.multiple && isArray && this.value.length > 1
? new List({
items: this.value.map((v) => ({ value: v })),
editable: false,
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/src/stories/JSONSchemaInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ export class JSONSchemaInput extends LitElement {
const filesystemSelectorElement = new FilesystemSelector({
type: format,
value: this.value,
onSelect: (filePath) => this.#updateData(fullPath, filePath),
onSelect: (paths) => {
const value = paths.length ? paths : undefined;
this.#updateData(fullPath, value);
},
onChange: (filePath) => validateOnChange && this.#triggerValidation(name, path),
onThrow: (...args) => this.#onThrow(...args),
dialogOptions: this.form?.dialogOptions,
Expand Down
20 changes: 12 additions & 8 deletions src/renderer/src/stories/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,10 @@ export class Search extends LitElement {
const listItemElement = document.createElement("li");
listItemElement.classList.add("option");
listItemElement.setAttribute("hidden", "");
listItemElement.setAttribute("tabindex", -1);
if (option.keywords) listItemElement.setAttribute("data-keywords", JSON.stringify(option.keywords));
listItemElement.addEventListener("click", (ev) => {
ev.stopPropagation();
listItemElement.addEventListener("click", (clickEvent) => {
clickEvent.stopPropagation();
this.#onSelect(option);
});

Expand Down Expand Up @@ -393,18 +394,21 @@ export class Search extends LitElement {
<div class="header" style=${styleMap({
...this.headerStyles,
})}>
<input placeholder="Type here to search" value=${valueToDisplay} @click=${(ev) => {
ev.stopPropagation();
<input placeholder="Type here to search" value=${valueToDisplay} @click=${(clickEvent) => {
clickEvent.stopPropagation();
if (this.listMode === "click") {
const input = ev.target.value;
const input = clickEvent.target.value;
this.#populate(input);
}
}} @input=${(ev) => {
const input = ev.target.value;
}}
@input=${(inputEvent) => {
const input = inputEvent.target.value;
this.#populate(input);
}}
@blur=${(ev) => {
@blur=${(blurEvent) => {
if (blurEvent.relatedTarget.classList.contains("option")) return;
this.submit();
}}
Expand Down
15 changes: 10 additions & 5 deletions src/renderer/src/stories/pages/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { LitElement, html } from "lit";
import { openProgressSwal, runConversion } from "./guided-mode/options/utils.js";
import { get, save } from "../../progress/index.js";
import { dismissNotification, notify } from "../../dependencies/globals.js";
import { randomizeElements, mapSessions } from "./utils.js";
import { randomizeElements, mapSessions, merge } from "./utils.js";

import { ProgressBar } from "../ProgressBar";
import { resolveResults } from "./guided-mode/data/utils.js";
import { resolveMetadata } from "./guided-mode/data/utils.js";
import Swal from "sweetalert2";

export class Page extends LitElement {
Expand Down Expand Up @@ -187,12 +187,17 @@ export class Page extends LitElement {
const { subject, session, globalState = this.info.globalState } = info;
const file = `sub-${subject}/sub-${subject}_ses-${session}.nwb`;

const { conversion_output_folder, name } = globalState.project;
const { conversion_output_folder, name, SourceData } = globalState.project;

const sessionResults = globalState.results[subject][session];

const sourceDataCopy = structuredClone(sessionResults.source_data);

// Resolve the correct session info from all of the metadata for this conversion
const sessionInfo = {
...globalState.results[subject][session],
metadata: resolveResults(subject, session, globalState),
...sessionResults,
metadata: resolveMetadata(subject, session, globalState),
source_data: merge(SourceData, sourceDataCopy),
};

const result = await runConversion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ManagedPage } from "./ManagedPage.js";
import { Modal } from "../../../Modal";

import { validateOnChange } from "../../../../validation/index.js";
import { resolveGlobalOverrides, resolveResults } from "./utils.js";
import { resolveGlobalOverrides, resolveMetadata } from "./utils.js";
import Swal from "sweetalert2";
import { SimpleTable } from "../../../SimpleTable.js";
import { onThrow } from "../../../../errors";
Expand Down Expand Up @@ -143,7 +143,7 @@ export class GuidedMetadataPage extends ManagedPage {
sortedProps.forEach((k) => (newElectrodeItemSchema[k] = ogElectrodeItemSchema[k]));
}

resolveResults(subject, session, globalState);
resolveMetadata(subject, session, globalState);

// Create the form
const form = new JSONSchemaForm({
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/stories/pages/guided-mode/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function resolveProperties(properties = {}, target, globals = {}) {
}

// Explicitly resolve the results for a particular session (from both GUIDE-defined globals and the NWB Schema)
export function resolveResults(subject, session, globalState) {
export function resolveMetadata(subject, session, globalState) {
const overrides = resolveGlobalOverrides(subject, globalState); // Unique per-subject (but not sessions)
const metadata = globalState.results[subject][session].metadata;
const results = structuredClone(metadata); // Copy the metadata results from the form
Expand Down

0 comments on commit 5db8e9a

Please sign in to comment.