Skip to content

Commit

Permalink
Merge branch 'main' into fix-species-constraint-message
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Mar 11, 2024
2 parents c52cb9d + ba8bcf2 commit 2218043
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion environments/environment-Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion environments/environment-Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 26 additions & 12 deletions src/renderer/src/stories/List.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ type ListItemType = {
key: string,
content: string,
value: any,
controls: HTMLElement[]
controls: HTMLElement[],
originalKey?: string
}

export interface ListProps {
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
}


Expand All @@ -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 = () => {
Expand All @@ -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}`;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

}
};

Expand All @@ -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 = () => {
Expand All @@ -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
Expand All @@ -403,6 +416,7 @@ export class List extends LitElement {

render() {


this.removeAttribute('unordered')
if (this.unordered) this.setAttribute('unordered', '')

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/stories/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 : {}
Expand Down
15 changes: 11 additions & 4 deletions src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
});
});
});
}
Expand Down

0 comments on commit 2218043

Please sign in to comment.