Skip to content

Commit

Permalink
Merge pull request #524 from NeurodataWithoutBorders/delete-global-pages
Browse files Browse the repository at this point in the history
Remove Global Pages
  • Loading branch information
CodyCBakerPhD authored Nov 22, 2023
2 parents 1cceeb3 + 244053b commit 40b081c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/renderer/src/stories/pages/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class Page extends LitElement {
Object.assign(element.style, {
textAlign: "left",
display: "block",
})
});

const progressBar = new ProgressBar();
elements.progress = progressBar;
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/stories/pages/guided-mode/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export function resolveGlobalOverrides(subject, globalState) {
delete subjectMetadataCopy.sessions; // Remove extra key from metadata

const overrides = structuredClone(globalState.project ?? {}); // Copy project-wide metadata
merge(subjectMetadataCopy, overrides.Subject);

merge(subjectMetadataCopy, overrides.Subject ?? (overrides.Subject = {})); // Ensure Subject exists

return overrides;
}
Expand Down
12 changes: 5 additions & 7 deletions src/renderer/src/stories/pages/guided-mode/options/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ export const openProgressSwal = (options, callback) => {
};

export const run = async (url, payload, options = {}) => {
let internalSwal;

let internalSwal

if (options.swal === false) {}
else if (!options.swal || options.swal === true) {

if (options.swal === false) {
} else if (!options.swal || options.swal === true) {
if (!("showCancelButton" in options)) {
options.showCancelButton = true;
options.customClass = { actions: "swal-conversion-actions" };
Expand All @@ -40,12 +38,12 @@ export const run = async (url, payload, options = {}) => {
signal: cancelController.signal,
};

const popup = internalSwal = await openProgressSwal(options, (result) => {
const popup = (internalSwal = await openProgressSwal(options, (result) => {
if (!result.isConfirmed) cancelController.abort();
}).then(async (swal) => {
if (options.onOpen) await options.onOpen(swal);
return swal;
});
}));

const element = popup.getHtmlContainer();
const actions = popup.getActions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,12 @@ export class GuidedNewDatasetPage extends Page {
};

updateForm = () => {
let projectGlobalState = this.info.globalState.project;
if (!projectGlobalState) projectGlobalState = this.info.globalState.project = {};

// Properly clone the schema to produce multiple pages from the project metadata schema
const schema = { ...projectMetadataSchema };
schema.properties = { ...schema.properties };

this.state = merge(global.data.output_locations, structuredClone(this.info.globalState.project));

const pages = schemaToPages.call(this, globalSchema, ["project"], { validateEmptyValues: false }, (info) => {
info.title = `${info.label} Global Metadata`;
return info;
});

pages.forEach((page) => {
page.header = {
subtitle: `Enter any ${page.info.label}-level metadata that can serve as the common default across each experiment session`,
};
this.addPage(page.info.label, page);
});

this.form = new JSONSchemaForm({
schema,
results: this.state,
Expand Down

0 comments on commit 40b081c

Please sign in to comment.