Skip to content

Commit a9448ac

Browse files
chore: updated data dictionary config #4464
1 parent 58cc9eb commit a9448ac

File tree

3 files changed

+73
-4
lines changed

3 files changed

+73
-4
lines changed

app/config/utils.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { SelectCategoryValue } from "@databiosphere/findable-ui/lib/common/entities";
1+
import {
2+
Attribute,
3+
AttributeValue,
4+
DataDictionaryColumnDef,
5+
SelectCategoryValue,
6+
} from "@databiosphere/findable-ui/lib/common/entities";
7+
import { CellContext, ColumnDef } from "@tanstack/react-table";
8+
import { BasicCell } from "@databiosphere/findable-ui/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell";
9+
import { GridTrackSize } from "@databiosphere/findable-ui/lib/config/entities";
210

311
/**
412
* Returns select category value with formatted label.
@@ -15,3 +23,29 @@ export function mapSelectCategoryValue(
1523
};
1624
};
1725
}
26+
27+
/**
28+
* Returns an array of column defs, built from column def configurations, to
29+
* use when displaying the data dictionary.
30+
* @param columnDefConfigs - Array of column def configurations.
31+
* @returns Array of column defs.
32+
*/
33+
export function buildColumnDefs(
34+
columnDefConfigs: DataDictionaryColumnDef[]
35+
): ColumnDef<Attribute, AttributeValue>[] {
36+
return columnDefConfigs.map((columnDefConfig) => {
37+
const {
38+
attributeDisplayName: header,
39+
attributeSlotName: key,
40+
width,
41+
} = columnDefConfig;
42+
return {
43+
accessorFn: (row) => row[key as keyof Attribute],
44+
cell: (props: CellContext<Attribute, AttributeValue>) =>
45+
BasicCell({ ...props }),
46+
header: `${header}`,
47+
id: key,
48+
meta: { width: width as GridTrackSize },
49+
};
50+
});
51+
}

site-config/anvil-cmg/dev/config.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { APIEndpoints } from "@databiosphere/findable-ui/lib/apis/azul/common/en
22
import { SystemStatusBindResponseFn } from "@databiosphere/findable-ui/lib/config/entities";
33
import { CATALOG_DEFAULT } from "../../../app/apis/azul/anvil-cmg/common/constants";
44
import * as C from "../../../app/components/index";
5-
import { mapSelectCategoryValue } from "../../../app/config/utils";
5+
import {
6+
buildColumnDefs,
7+
mapSelectCategoryValue,
8+
} from "../../../app/config/utils";
69
import { bindSystemStatusResponse } from "../../../app/viewModelBuilders/azul/common/systemStatusMapper/systemStatusMapper";
710
import { FLATTEN, GIT_HUB_REPO_URL } from "../../common/constants";
811
import { SiteConfig } from "../../common/entities";
@@ -18,7 +21,8 @@ import { donorsEntityConfig } from "./index/donorsEntityConfig";
1821
import { filesEntityConfig } from "./index/filesEntityConfig";
1922
import { summary } from "./index/summary";
2023
import { floating } from "./layout/floating";
21-
// import dataDictionary from "./dataDictionary/data-dictionary.json";
24+
import dataDictionary from "./dataDictionary/data-dictionary.json";
25+
import columnDefs from "./dataDictionary/column-defs.json";
2226

2327
// Template constants
2428
const APP_TITLE = "AnVIL Data Explorer";
@@ -129,7 +133,12 @@ export function makeConfig(
129133
key: "anvil-cmg",
130134
},
131135
contentDir: "anvil-cmg",
132-
// dataDictionary,
136+
dataDictionaries: [
137+
{
138+
columnDefs: buildColumnDefs(columnDefs),
139+
dataDictionary,
140+
},
141+
],
133142
dataSource: {
134143
defaultListParams: {
135144
size: "25",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[
2+
{
3+
"attributeDisplayName": "Label",
4+
"attributeSlotName": "label",
5+
"width": {
6+
"max": "1fr",
7+
"min": "200px"
8+
}
9+
},
10+
{
11+
"attributeDisplayName": "Description",
12+
"attributeSlotName": "description",
13+
"width": {
14+
"max": "2fr",
15+
"min": "480px"
16+
}
17+
},
18+
{
19+
"attributeDisplayName": "Key",
20+
"attributeSlotName": "key",
21+
"width": {
22+
"max": "1fr",
23+
"min": "180px"
24+
}
25+
}
26+
]

0 commit comments

Comments
 (0)