Skip to content

Commit

Permalink
updating to add exampleDownloadFields
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Nov 27, 2023
1 parent 860dc2f commit 4210da5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/ove/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teselagen/ove",
"version": "0.3.59",
"version": "0.3.60",
"main": "./src/index.js",
"exports": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teselagen/ui",
"version": "0.3.50",
"version": "0.3.51",
"main": "./src/index.js",
"exports": {
".": {
Expand Down
16 changes: 12 additions & 4 deletions packages/ui/src/FormComponents/Uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,11 @@ function UploaderInner({
];

const mainExampleData = {};
const mainSchema = a.validateAgainstSchema.fields.map(f => {
const fieldsToUse = [
...validateAgainstSchema.fields,
...a.exampleDownloadFields
];
const mainSchema = fieldsToUse.map(f => {
mainExampleData[f.displayName || f.path] =
f.example || f.defaultValue;
return {
Expand All @@ -309,7 +313,7 @@ function UploaderInner({
};
});
const b = await writeXlsxFile(
[[mainExampleData], a.validateAgainstSchema.fields, helperText],
[[mainExampleData], fieldsToUse, helperText],
{
headerStyle: {
fontWeight: "bold"
Expand All @@ -328,13 +332,17 @@ function UploaderInner({
description: "Download Example CSV File",
exampleFile: () => {
const rows = [];
const schemaToUse = [
...a.validateAgainstSchema.fields,
...a.validateAgainstSchema.exampleDownloadFields
];
rows.push(
a.validateAgainstSchema.fields.map(f => {
schemaToUse.map(f => {
return `${f.displayName || f.path}`;
})
);
rows.push(
a.validateAgainstSchema.fields.map(f => {
schemaToUse.map(f => {
return `${f.example || f.defaultValue || ""}`;
})
);
Expand Down

0 comments on commit 4210da5

Please sign in to comment.