Skip to content

Commit

Permalink
Merge pull request #1534 from sennetconsortium/libpitt/metadata-facet
Browse files Browse the repository at this point in the history
Resolve has metadata bug
  • Loading branch information
maxsibilla authored Jul 24, 2024
2 parents 1a065b6 + dce284b commit 63064a8
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/config/search/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const SEARCH_ENTITIES = {
filterType: 'any',
isFilterable: false,
},
// Used for when "Dataset/Sample" is selected to show related sources
// Used for when "Dataset/Sample" is selected to show related sources
"source.source_type": {
label: 'Source Type',
type: 'value',
Expand All @@ -104,14 +104,22 @@ export const SEARCH_ENTITIES = {
filterType: 'any',
isFilterable: false,
},
metadata: {
'metadata': {
label: 'Has Metadata',
type: 'exists',
field: 'metadata',
isExpanded: false,
filterType: 'any',
isFilterable: false,
},
'ingest_metadata.metadata': {
label: 'Has Metadata',
type: 'exists',
field: 'ingest_metadata.metadata',
isExpanded: false,
filterType: 'any',
isFilterable: false,
},
status: {
label: 'Status',
type: 'value',
Expand Down Expand Up @@ -159,21 +167,27 @@ export const SEARCH_ENTITIES = {
conditionalFacets: {
// Show 'origin_sample.organ' facet if 'Dataset' or Sample Block/Section/Suspension is selected
"origin_sample.organ": ({filters}) => {
return filters.some(
return filters.some(
(filter) =>
(filter.field === 'entity_type' && filter.values.includes('Dataset')) ||
(filter.field === 'sample_category' && (filter.values.includes('Block') ||
filter.values.includes('Section') || filter.values.includes('Suspension')))
filter.values.includes('Section') || filter.values.includes('Suspension')))
)
},
// Show 'metadata' facet if 'Sample' or Sample Block/Section/Suspension is selected
metadata: ({filters}) => {
'metadata': ({filters}) => {
return filters.some(
(filter) =>
(filter.field === 'entity_type' && filter.values.some(r=> ['Source', 'Dataset', 'Collection', 'Publication'].includes(r)) ) ||
(filter.field === 'entity_type' && filter.values.some(r=> ['Source', 'Collection', 'Publication'].includes(r)) ) ||
(filter.field === 'sample_category' && (filter.values.includes('Block') ||
filter.values.includes('Section') || filter.values.includes('Suspension')))
)
},
'ingest_metadata.metadata': ({filters}) => {
return filters.some(
(filter) =>
(filter.field === 'entity_type' && filter.values.includes('Dataset'))
)
},
// Only show 'organ' facet if 'Sample' is selected from the entity type facet
organ: FilterIsSelected('entity_type', 'Sample'),
Expand Down

0 comments on commit 63064a8

Please sign in to comment.