Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Cleanup Name #437

Merged
merged 4 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions schemas/json/dandi/upload.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"cleanup": {
"type": "boolean",
"title": "Delete Local Files After Upload",
"default": false
}
},
Expand Down
16 changes: 11 additions & 5 deletions src/renderer/src/stories/JSONSchemaForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ export class JSONSchemaForm extends LitElement {
return true;
};

#get = (path, object = this.resolved) => {
#get = (path, object = this.resolved, omitted = []) => {
// path = path.slice(this.base.length); // Correct for base path
return path.reduce((acc, curr) => (acc = acc[curr]), object);
return path.reduce((acc, curr) => (acc = acc[curr] ?? acc?.[omitted.find((str) => acc[str])]?.[curr]), object);
};

#checkRequiredAfterChange = async (localPath) => {
Expand All @@ -375,7 +375,7 @@ export class JSONSchemaForm extends LitElement {
if (indexOf !== -1) path = path.slice(indexOf + 1);
}

const resolved = this.#get(path, schema);
const resolved = this.#get(path, schema, ["properties"]);
if (resolved["$ref"]) return this.getSchema(resolved["$ref"].split("/").slice(1)); // NOTE: This assumes reference to the root of the schema

return resolved;
Expand Down Expand Up @@ -432,7 +432,7 @@ export class JSONSchemaForm extends LitElement {
? "conditional"
: ""}"
>
<label class="guided--form-label">${header(name)}</label>
<label class="guided--form-label">${info.title ?? header(name)}</label>
${interactiveInput}
<div class="errors"></div>
<div class="warnings"></div>
Expand Down Expand Up @@ -619,7 +619,13 @@ export class JSONSchemaForm extends LitElement {
} else {
// For non-links, throw a basic requirement error if the property is required
if (!errors.length && isRequired && !parent[name]) {
errors.push({ message: `${name} is a required property.`, type: "error", missing: true }); // Throw at least a basic error if the property is required
const schema = this.getSchema(localPath);
console.log(schema);
errors.push({
message: `${schema.title ?? header(name)} is a required property.`,
type: "error",
missing: true,
}); // Throw at least a basic error if the property is required
}
}

Expand Down
Loading