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

Search by Material name last improvements

parent e03e48df
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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,24 +219,30 @@ 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));
if (this.element.querySelector('#allow-other-elements').checked)
searchExpressionQuery = this._getESQueryFromSearchQuery_otherElements(
this.searchQuery, this.queryTypes);
// Regular case: search containing only the elements in the search expression
else searchExpressionQuery =
this._getESQueryFromSearchQuery(this.searchQuery, this.queryTypes);
this.materialList.initSearch(
this._addFiltersInSearchQuery( this.filterPanel.getValues(),
searchExpressionQuery));
//util.setBrowserHashPath('search','results');
this.element.querySelector('.add-box').style.display = 'none';
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(
this.searchQuery, this.queryTypes);
// Regular case: search containing only the elements in the search expression
else searchExpressionQuery =
this._getESQueryFromSearchQuery(this.searchQuery, this.queryTypes);
this.materialList.initSearch(
this._addFiltersInSearchQuery( this.filterPanel.getValues(),
searchExpressionQuery));
//util.setBrowserHashPath('search','results');
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;
}
if (this.queryTypes.length === 0){
if (isMaterialName){
this.addElementButton.disabled = false;
this.addFormulaButton.disabled = false;
this.formulaBox.disable(false);
}else{ // element or formula
this.addMatNameButton.disabled = false;
}
}else{ // It's other than element (formula, material name ¿or prop???)
this.addElementButton.disabled = false;
this.formulaBox.disable(false);
this.materialNameBox.disable(false);
// Added ¿?
this.addFormulaButton.disabled = false;
this.addMatNameButton.disabled = 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