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

Libpitt/1638 dataset type hierarchy #1641

Open
wants to merge 4 commits 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
2 changes: 1 addition & 1 deletion src/components/custom/TableResultsEntities.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function TableResultsEntities({children, filters, onRowClicked, currentColumns,
name: 'Dataset Type',
id: 'dataset_type',
selector: row => {
let val = raw(row.dataset_type)
let val = raw(row.dataset_type_hierarchy)?.second_level || raw(row.dataset_type)
if (val) {
return Array.isArray(val) ? getUBKGFullName(val[0]) : val
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {useContext, useEffect, useState} from 'react'
import PropTypes from 'prop-types'
import SenNetAccordion from "../../layout/SenNetAccordion";
import {getCreationActionRelationName} from "../../js/functions";
import {getCreationActionRelationName, getDatasetTypeDisplay} from "../../js/functions";
import Tab from 'react-bootstrap/Tab';
import Tabs from 'react-bootstrap/Tabs';
import DataTable from "react-data-table-component";
Expand Down Expand Up @@ -36,7 +36,7 @@ function CreationActionRelationship({ entity, data }) {
},
{
name: 'Dataset Type',
selector: row => row.dataset_type,
selector: row => getDatasetTypeDisplay(row),
sortable: true,
},
{
Expand Down
4 changes: 4 additions & 0 deletions src/components/custom/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ const normalizedNames = {
"frozen in liquid nitrogen": "Frozen in Liquid Nitrogen",
}

export const getDatasetTypeDisplay = (data) => {
return data.dataset_type_hierarchy?.second_level || data.display_subtype || data.dataset_type
}

function getNormalizedName(term) {
if (term && normalizedNames.hasOwnProperty(term.toLowerCase())) {
return normalizedNames[term.toLowerCase()]
Expand Down
11 changes: 9 additions & 2 deletions src/components/custom/layout/entity/ViewHeaderBadges.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import AppContext from "@/context/AppContext";
import Link from "next/link";
import PropTypes from "prop-types";
import { Fragment, useContext } from "react";
import { displayBodyHeader, eq, getStatusColor, getStatusDefinition, getUBKGFullName } from "../../js/functions";
import {
getDatasetTypeDisplay,
displayBodyHeader,
eq,
getStatusColor,
getStatusDefinition,
getUBKGFullName
} from "../../js/functions";

function ViewHeaderBadges({data, uniqueHeader, uniqueHeaderUrl, isMetadataHeader, hasWritePrivilege}) {
const {cache} = useContext(AppContext)
Expand Down Expand Up @@ -54,7 +61,7 @@ function ViewHeaderBadges({data, uniqueHeader, uniqueHeaderUrl, isMetadataHeader
) : (
<h5 className={"title_badge"}>
<span className="badge bg-secondary me-2">
{getUBKGFullName(data.dataset_type)}
{getUBKGFullName(getDatasetTypeDisplay(data))}
</span>
</h5>
)
Expand Down
5 changes: 3 additions & 2 deletions src/config/search/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export const SEARCH_ENTITIES = {
dataset_type: {
label: 'Dataset Type',
type: 'value',
field: 'dataset_type.keyword',
field: 'dataset_type_hierarchy.second_level.keyword',
isExpanded: false,
filterType: 'any',
isFilterable: false,
groupBy: 'dataset_type_hierarchy.keyword',
groupBy: 'dataset_type_hierarchy.first_level.keyword',
groupAll: true,
},
'sources.source_type': {
Expand Down Expand Up @@ -247,6 +247,7 @@ export const SEARCH_ENTITIES = {
'organ',
'title',
'description',
'dataset_type_hierarchy'
]
},
initialState: {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/dataset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import dynamic from "next/dynamic";
import React, {useContext, useEffect, useState} from "react";
import log from "loglevel";
import {
getDatasetTypeDisplay,
datasetIs,
fetchDataCite,
getCreationActionRelationName,
Expand Down Expand Up @@ -227,9 +228,9 @@ function ViewDataset() {
<SidebarBtn/>

<EntityViewHeader data={data}
uniqueHeader={data.display_subtype || data.dataset_type}
uniqueHeader={getDatasetTypeDisplay(data)}
entity={cache.entities.dataset.toLowerCase()}
hasWritePrivilege={hasWritePrivilege}/>
hasWritePrivilege={hasWritePrivilege || false}/>

<div className="row">
<div className="col-12">
Expand Down