Skip to content

feat: added AnVIL data dictionary column defs #4451 #4461

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
35 changes: 34 additions & 1 deletion app/config/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { SelectCategoryValue } from "@databiosphere/findable-ui/lib/common/entities";
import {
Attribute,
AttributeValue,

Check failure on line 3 in app/config/utils.ts

View workflow job for this annotation

GitHub Actions / build

Module '"@databiosphere/findable-ui/lib/common/entities"' has no exported member 'AttributeValue'.
DataDictionaryColumnDef,

Check failure on line 4 in app/config/utils.ts

View workflow job for this annotation

GitHub Actions / build

Module '"@databiosphere/findable-ui/lib/common/entities"' has no exported member 'DataDictionaryColumnDef'.
SelectCategoryValue,
} from "@databiosphere/findable-ui/lib/common/entities";
import { CellContext, ColumnDef } from "@tanstack/react-table";
import { BasicCell } from "@databiosphere/findable-ui/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell";

/**
* Returns select category value with formatted label.
Expand All @@ -15,3 +22,29 @@
};
};
}

/**
* Returns an array of column defs, built from column def configurations, to
* use when displaying the data dictionary.
* @param columnDefConfigs - Array of column def configurations.
* @returns Array of column defs.
*/
export function buildColumnDefs(
columnDefConfigs: DataDictionaryColumnDef[]
): ColumnDef<Attribute, AttributeValue>[] {
return columnDefConfigs.map((columnDefConfig) => {
const {
attributeDisplayName: header,
attributeSlotName: key,
width: { max, min },
} = columnDefConfig;
return {
accessorFn: (row) => row[key as keyof Attribute],
cell: (props: CellContext<Attribute, AttributeValue>) =>
BasicCell({ ...props }),
header: `${header}`,
id: key,
meta: { width: { max, min } },
};
});
}
13 changes: 11 additions & 2 deletions site-config/anvil-cmg/dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import { SystemStatusBindResponseFn } from "@databiosphere/findable-ui/lib/config/entities";
import { CATALOG_DEFAULT } from "../../../app/apis/azul/anvil-cmg/common/constants";
import * as C from "../../../app/components/index";
import { mapSelectCategoryValue } from "../../../app/config/utils";
import {
buildColumnDefs,
mapSelectCategoryValue,
} from "../../../app/config/utils";
import { bindSystemStatusResponse } from "../../../app/viewModelBuilders/azul/common/systemStatusMapper/systemStatusMapper";
import { FLATTEN, GIT_HUB_REPO_URL } from "../../common/constants";
import { SiteConfig } from "../../common/entities";
Expand All @@ -19,6 +22,7 @@
import { summary } from "./index/summary";
import { floating } from "./layout/floating";
import dataDictionary from "./dataDictionary/data-dictionary.json";
import columnDefs from "./dataDictionary/column-defs.json";

// Template constants
const APP_TITLE = "AnVIL Data Explorer";
Expand Down Expand Up @@ -126,7 +130,12 @@
key: "anvil-cmg",
},
contentDir: "anvil-cmg",
dataDictionary,
dataDictionaries: [

Check failure on line 133 in site-config/anvil-cmg/dev/config.ts

View workflow job for this annotation

GitHub Actions / build

Object literal may only specify known properties, but 'dataDictionaries' does not exist in type 'SiteConfig'. Did you mean to write 'dataDictionary'?
{
columnDefs: buildColumnDefs(columnDefs),
dataDictionary,
},
],
dataSource: {
defaultListParams: {
size: "25",
Expand Down
26 changes: 26 additions & 0 deletions site-config/anvil-cmg/dev/dataDictionary/column-defs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"attributeDisplayName": "Label",
"attributeSlotName": "label",
"width": {
"max": "1fr",
"min": "200px"
}
},
{
"attributeDisplayName": "Description",
"attributeSlotName": "description",
"width": {
"max": "2fr",
"min": "480px"
}
},
{
"attributeDisplayName": "Key",
"attributeSlotName": "key",
"width": {
"max": "1fr",
"min": "180px"
}
}
]
Loading