Commit 318b396a authored by Iker Hurtado's avatar Iker Hurtado
Browse files

Search by Material name last improvements

parent e03e48df
This diff is collapsed.
......@@ -38,7 +38,7 @@ let SwitchComponent = require('../common/SwitchComponent.js');
// local utility functions
function getTagHtml(tag, isFormula){
return `<span class="search-label" data-el="${tag}" >
<img src="img/${isFormula ? 'info' : 'tag'}.svg" height="16px" class="remove-label"
<img src="img/tag.svg" height="16px" class="remove-label"
style="vertical-align: bottom"/>
${isFormula ? util.getSubscriptedFormula(tag) : tag}
<img src="img/cross.svg" height="6px" class="remove-label"
......@@ -219,10 +219,15 @@ class NewSearchMod {
}else{
let searchExpressionQuery;
//************** Material name or complex search expression
//if (this.queryTypes[i] === 'MN'){
// Search by Material name
if (this.queryTypes[0] === 'MN'){
//queryObj.push(this._getESSimpleMatch('material_name', item));
let rootQueryObj = { 'bool' : {} };
rootQueryObj.bool.must = [];
rootQueryObj.bool.must.push( this._getESSimpleMatch('material_name', this.searchQuery[0]) );
this.materialList.initSearch( rootQueryObj );
}else{ // Search by complex search expression
if (this.element.querySelector('#allow-other-elements').checked)
searchExpressionQuery = this._getESQueryFromSearchQuery_otherElements(
......@@ -238,6 +243,7 @@ class NewSearchMod {
this.element.querySelector('.add-box').style.display = 'none';
}
}
});
......@@ -608,6 +614,7 @@ class NewSearchMod {
removeElementORFormulaInSearchQuery(item){
//console.log(" removeElementORFormulaInSearchQuery item: ",item, this.searchQuery.indexOf(item));
let isMaterialName = (this.queryTypes[0] === 'MN');
// Travese the array removing the item and the bool operator related
let itemIndex = this.searchQuery.indexOf(item);
if (itemIndex >= 0){
......@@ -643,18 +650,19 @@ class NewSearchMod {
if (util.ELEMENTS.indexOf(item) >= 0){ // It's an element (being removed)
this.elementTable.deselectElement(item);
if (this.queryTypes.indexOf('E') < 0){ // It's the last element
//this.addFormulaButton.disabled = false;
this.addMatNameButton.disabled = false;
}
}else{ // It's other than element (formula, material name ¿or prop???)
if (this.queryTypes.length === 0){
if (isMaterialName){
this.addElementButton.disabled = false;
this.formulaBox.disable(false);
this.materialNameBox.disable(false);
// Added ¿?
this.addFormulaButton.disabled = false;
this.formulaBox.disable(false);
}else{ // element or formula
this.addMatNameButton.disabled = false;
}
this.materialNameBox.disable(false);
}
//console.log(" final searchQuery: ",this.searchQuery);
......
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