From 147a45e6c5f1275da5bc792db173f8f421a594cc Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Mon, 11 Mar 2024 11:02:53 -0700 Subject: [PATCH 1/2] List Fix (#654) Co-authored-by: Ben Dichter Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- environments/environment-Linux.yml | 2 +- environments/environment-Windows.yml | 2 +- src/renderer/src/stories/List.ts | 38 +++++++++++++------ .../pages/guided-mode/data/GuidedStructure.js | 15 ++++++-- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/environments/environment-Linux.yml b/environments/environment-Linux.yml index 4ccd56d03..847abad91 100644 --- a/environments/environment-Linux.yml +++ b/environments/environment-Linux.yml @@ -17,7 +17,7 @@ dependencies: - flask == 2.3.2 - flask-cors == 4.0.0 - flask_restx == 1.1.0 - - neuroconv @ git+https://github.com/catalystneuro/neuroconv.git@try_remove_packaing_bound#neuroconv[full] + - neuroconv @ git+https://github.com/catalystneuro/neuroconv.git@main#neuroconv[full] - dandi >= 0.60.0 - pytest == 7.4.0 - pytest-cov == 4.1.0 diff --git a/environments/environment-Windows.yml b/environments/environment-Windows.yml index 84bfd2167..fc1e15850 100644 --- a/environments/environment-Windows.yml +++ b/environments/environment-Windows.yml @@ -17,7 +17,7 @@ dependencies: - flask == 2.3.2 - flask-cors === 3.0.10 - flask_restx == 1.1.0 - - neuroconv @ git+https://github.com/catalystneuro/neuroconv.git@try_remove_packaing_bound#neuroconv[full] + - neuroconv @ git+https://github.com/catalystneuro/neuroconv.git@main#neuroconv[full] - dandi >= 0.60.0 - pytest == 7.2.2 - pytest-cov == 4.1.0 diff --git a/src/renderer/src/stories/List.ts b/src/renderer/src/stories/List.ts index d33220ba3..802d98b82 100644 --- a/src/renderer/src/stories/List.ts +++ b/src/renderer/src/stories/List.ts @@ -6,7 +6,8 @@ type ListItemType = { key: string, content: string, value: any, - controls: HTMLElement[] + controls: HTMLElement[], + originalKey?: string } export interface ListProps { @@ -140,11 +141,14 @@ export class List extends LitElement { return this.items.map(item => item.value) } + #previousItems = [] #items: ListItemType[] = [] - set items(value) { - const oldList = this.#items + set items(value: ListItemType[]) { + + const oldList = this.#previousItems this.#items = value.map(item => this.transform ? this.transform(item) ?? item : item) + this.#previousItems = this.#items.map(item => ({...item})) // Clone items const oldObject = this.object this.#updateObject() @@ -205,7 +209,7 @@ export class List extends LitElement { this.items.splice(draggedIdx, 1) this.items.splice(i, 0, movedItem) - this.items = [...this.items] + this.items = this.items } @@ -225,7 +229,8 @@ export class List extends LitElement { } add = (item: ListItemType) => { - this.items = [...this.items, item] + this.items.push({ ...item }) // Update original + this.items = this.items } #removePlaceholder = () => { @@ -235,6 +240,9 @@ export class List extends LitElement { #renderListItem = (item: ListItemType, i: number) => { const { key, value, content = value } = item; + + if (!item.originalKey) item.originalKey = key + const li = document.createElement("li"); li.id = `item-${i}`; @@ -283,7 +291,7 @@ export class List extends LitElement { let i = 0; while (resolvedKey in this.object) { i++; - resolvedKey = `${originalValue}_${i}`; + resolvedKey = `${originalValue} (${i})`; } const keyEl = editableElement @@ -352,10 +360,13 @@ export class List extends LitElement { delete this.object[oKey]; this.object[newKey] = value; - if (!isUnordered) { + if (isUnordered) { + this.items[i].key = newKey + } else { this.items[i].value = newKey - this.items = [...this.items] } + this.items = this.items + } }; @@ -367,11 +378,13 @@ export class List extends LitElement { delete = (i: number) => { this.items.splice(i, 1) - this.items = [...this.items] + this.items = this.items } clear = () => { - this.items = [] + // Remove items in original list + for (let i = this.items.length - 1; i >= 0; i--) this.items.splice(i, 1) + this.items = this.items } #updateObject = () => { @@ -388,8 +401,8 @@ export class List extends LitElement { // Ensure no duplicate keys let kI = 0; while (resolvedKey in this.object) { - i++; - resolvedKey = `${key}_${kI}`; + kI++; + resolvedKey = `${key} (${kI})`; } this.object[resolvedKey] = value @@ -403,6 +416,7 @@ export class List extends LitElement { render() { + this.removeAttribute('unordered') if (this.unordered) this.setAttribute('unordered', '') diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js index 584c5f708..c5993c30e 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js @@ -84,13 +84,20 @@ export class GuidedStructurePage extends Page { }; beforeSave = async () => { - this.info.globalState.interfaces = { ...this.list.object }; + const interfaces = (this.info.globalState.interfaces = { ...this.list.object }); - // Remove extra interfaces from results + // Remove or reassign extra interfaces in results if (this.info.globalState.results) { this.mapSessions(({ info }) => { - Object.keys(info.source_data).forEach((key) => { - if (!this.info.globalState.interfaces[key]) delete info.source_data[key]; + const metadata = [info.source_data]; + metadata.forEach((results) => { + Object.keys(results).forEach((key) => { + if (!interfaces[key]) { + const renamed = this.list.items.find((item) => item.originalKey === key); + if (renamed) results[renamed.key] = results[key]; + delete results[key]; + } + }); }); }); } From ba8bcf2c534af4f5aa1e02240a796c416d847ec8 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Mon, 11 Mar 2024 11:28:37 -0700 Subject: [PATCH 2/2] Change Exit Pipeline Text (#655) Co-authored-by: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> --- src/renderer/src/stories/Main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/stories/Main.js b/src/renderer/src/stories/Main.js index 65b163c3c..a8d36d183 100644 --- a/src/renderer/src/stories/Main.js +++ b/src/renderer/src/stories/Main.js @@ -101,7 +101,7 @@ export class Main extends LitElement { footer = Object.assign( { exit: false, - next: "Complete Pipeline", + next: "Exit Pipeline", onNext: () => this.toRender.page.to("/"), }, footer && typeof footer === "object" ? footer : {}