Commit b77a86df authored by Iker Hurtado's avatar Iker Hurtado
Browse files

Add the checkboxes that modify the search by Elements and Formula (4)

parent 706aadd4
......@@ -7815,8 +7815,12 @@
//if (this.elementTable.getAllowOtherElements())
//else
queryObj.bool.filter.push( this._getESSimpleMatch(
(this.formulaBox.getMultiplesOfFormula() ? 'formula_reduced' : 'formula'), item));
let esMatchQuery;
if (this.formulaBox.getMultiplesOfFormula())
esMatchQuery = this._getESSimpleMatch('formula_reduced', item);
else
esMatchQuery = this._getESSimpleMatch('formula', item);
queryObj.bool.filter.push(esMatchQuery);
}else if (this.queryTypes[i] === 'MN'){
queryObj.bool.filter.push(this._getESSimpleMatch('material_name', item));
......@@ -7831,8 +7835,10 @@
if (elements.length > 0){ // If there are elements (there is no formula or material name)
if (this.elementTable.getAllowOtherElements())
queryObj.bool.filter.push(this._getFieldESMatch('atom_labels', elements, true));//getAtomsESMatch(elements));
else
queryObj.bool.filter.push(this._getESSimpleMatch('atom_labels_keyword', elements.join('')));
else // Regular search, the elements inserted must be sorted for this to work
{
queryObj.bool.filter.push(this._getESSimpleMatch('atom_labels_keyword', this._sortElements(elements) )); ///elements.join('')));
}
}
///atom_labels": { "operator": "and",
......@@ -7963,6 +7969,17 @@
}
_sortElements(elements){
let numbers = [];
let elString = '';
elements.forEach( e => numbers.push(util.ELEMENTS.indexOf(e)) );
numbers.sort( (a, b) => a - b ); // atomic number-1
numbers.forEach( n => elString += util.ELEMENTS[n] );
//console.log('_sortElements ',numbers, elString);
return elString;
}
_addFiltersInSearchQuery(filterMap, queryFilterArray){
//let filters = [];
filterMap.forEach((values/*Array*/, filterName) => {
......@@ -8024,6 +8041,8 @@
}
_setTabSelectedStyles(element, value){
/*
element.style.fontWeight = (value ? 'bold' : 'normal');
......
......@@ -208,8 +208,12 @@ class NewSearchMod {
//if (this.elementTable.getAllowOtherElements())
//else
queryObj.bool.filter.push( this._getESSimpleMatch(
(this.formulaBox.getMultiplesOfFormula() ? 'formula_reduced' : 'formula'), item));
let esMatchQuery;
if (this.formulaBox.getMultiplesOfFormula())
esMatchQuery = this._getESSimpleMatch('formula_reduced', item);
else
esMatchQuery = this._getESSimpleMatch('formula', item);
queryObj.bool.filter.push(esMatchQuery);
}else if (this.queryTypes[i] === 'MN'){
queryObj.bool.filter.push(this._getESSimpleMatch('material_name', item));
......@@ -224,8 +228,10 @@ class NewSearchMod {
if (elements.length > 0){ // If there are elements (there is no formula or material name)
if (this.elementTable.getAllowOtherElements())
queryObj.bool.filter.push(this._getFieldESMatch('atom_labels', elements, true));//getAtomsESMatch(elements));
else
queryObj.bool.filter.push(this._getESSimpleMatch('atom_labels_keyword', elements.join('')));
else // Regular search, the elements inserted must be sorted for this to work
{
queryObj.bool.filter.push(this._getESSimpleMatch('atom_labels_keyword', this._sortElements(elements) )); ///elements.join('')));
}
}
///atom_labels": { "operator": "and",
......@@ -356,6 +362,17 @@ class NewSearchMod {
}
_sortElements(elements){
let numbers = [];
let elString = '';
elements.forEach( e => numbers.push(util.ELEMENTS.indexOf(e)) );
numbers.sort( (a, b) => a - b ); // atomic number-1
numbers.forEach( n => elString += util.ELEMENTS[n] );
//console.log('_sortElements ',numbers, elString);
return elString;
}
_addFiltersInSearchQuery(filterMap, queryFilterArray){
//let filters = [];
filterMap.forEach((values/*Array*/, filterName) => {
......@@ -417,6 +434,8 @@ class NewSearchMod {
}
_setTabSelectedStyles(element, value){
/*
element.style.fontWeight = (value ? 'bold' : 'normal');
......
Markdown is supported
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