Commit fafdb25c authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added multi search for functional names and added enc props to search.

parent 4d71fee0
......@@ -28,6 +28,30 @@ const quantitiesWithAlternativeOptions = {
}
}
// We need to treat dft. and encyclopedia. special. Usually all dft domain pieces
// are prefixed dft., but the encycloepdia is top-level and also a dft. specific
// quantity. These to functions remove and add the dft./encyclopedia. prefixes accordingly.
function getDomainOfQuantity(quantity) {
if (!quantity.includes('.')) {
return null
}
const firstSegment = quantity.split('.')[0]
if (firstSegment === 'encyclopedia') {
return 'dft'
}
return firstSegment
}
function addDomainToQuantity(shortenedQuantityName, domainKey) {
if (!searchQuantities[shortenedQuantityName]) {
shortenedQuantityName = domainKey + '.' + shortenedQuantityName
if (!searchQuantities[shortenedQuantityName]) {
shortenedQuantityName = 'encyclopedia.' + shortenedQuantityName.slice(4)
}
}
return shortenedQuantityName
}
/**
* This searchbar component shows a searchbar with autocomplete functionality. The
* searchbar also includes a status line about the current results. It uses the
......@@ -45,7 +69,7 @@ export default function SearchBar() {
return Object.keys(searchQuantities)
.map(quantity => ({
quantity: quantity,
domain: quantity.includes('.') ? quantity.split('.')[0] : null
domain: getDomainOfQuantity(quantity)
}))
.filter(option => !option.domain || option.domain === domain.key)
}, [domain.key])
......@@ -158,11 +182,8 @@ export default function SearchBar() {
const parseOption = useCallback(input => {
const [inputQuantity, inputValue] = input.split('=')
let quantity = inputQuantity
const quantity = addDomainToQuantity(inputQuantity, domain.key)
let value = inputValue
if (!searchQuantities[quantity]) {
quantity = domain.key + '.' + quantity
}
if (value && searchQuantities[quantity] && searchQuantities[quantity].many) {
value = value.split(',').map(item => item.trim())
}
......
......@@ -150,7 +150,7 @@ class DFTMetadata(MSection):
xc_functional_names = Quantity(
type=str, default=[], shape=['*'],
description='The list of libXC functional names that where used in this entry.',
a_search=Search())
a_search=Search(many_and='append'))
system = Quantity(
type=str, default='not processed',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment