Skip to content

Commit

Permalink
Merge pull request #31 from Exabyte-io/feat/SOF-6379
Browse files Browse the repository at this point in the history
SOF-6379: Update templates for PointsPathFormDataProvider
  • Loading branch information
unsigned6 authored Feb 23, 2023
2 parents 2a116e3 + 1db2a50 commit c8811c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"prettier": "^2.7.1"
},
"peerDependencies": {
"@exabyte-io/made.js": "*",
"@exabyte-io/ade.js": "*",
"@exabyte-io/ide.js": "*",
"@exabyte-io/mode.js": "*",
Expand Down
12 changes: 11 additions & 1 deletion src/context/providers/PointsGridFormDataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class PointsGridFormDataProvider extends mix(JSONSchemaFormDataProvider).
return {
...vector,
items: {
type: "number",
type: this.isUsingJinjaVariables ? "string" : "number",
default: defaultValue,
},
};
Expand Down Expand Up @@ -154,7 +154,17 @@ export class PointsGridFormDataProvider extends mix(JSONSchemaFormDataProvider).
return grid.dimensions.reduce((a, b) => a * b) * nAtoms;
}

static _canTransform(data) {
return (
(data.preferKPPRA && data.KPPRA) ||
(!data.preferKPPRA && data.dimensions.every((d) => typeof d === "number"))
);
}

transformData(data) {
if (!this.constructor._canTransform(data)) {
return data;
}
// 1. check if KPPRA is preferred
if (data.preferKPPRA) {
// 2. KPPRA is preferred => recalculate grid; NOTE: `data.KPPRA` is undefined at first
Expand Down
4 changes: 2 additions & 2 deletions src/context/providers/PointsPathFormDataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class PointsPathFormDataProvider extends mix(JSONSchemaFormDataProvider).
};
}

get fields() {
get templates() {
const hasRequiredFn = typeof this.material.getBrillouinZoneImageComponent === "function";
if (!hasRequiredFn) {
console.log(
Expand All @@ -92,7 +92,7 @@ export class PointsPathFormDataProvider extends mix(JSONSchemaFormDataProvider).
}
return {
// eslint-disable-next-line no-unused-vars
TitleField: ({ title, required }) =>
TitleFieldTemplate: ({ title, required }) =>
this.material.getBrillouinZoneImageComponent(title),
};
}
Expand Down

0 comments on commit c8811c1

Please sign in to comment.