mistic100 / jQuery-QueryBuilder

jQuery plugin offering an interface to create complex queries
https://querybuilder.js.org
MIT License
1.68k stars 552 forks source link

Operator selector rendering issue when there is only one operator #948

Open nemphys opened 2 years ago

nemphys commented 2 years ago

When a rule has just one operator, both a label and a select is rendered as operator selectors. This is due to the template:

QueryBuilder.templates.operatorSelect = '\ {{? it.operators.length === 1 }} \ \ {{= it.translate("operators", it.operators[0].type) }} \ \ {{?}} \ <------- having "else" here would fix the problem {{ var optgroup = null; }} \

';
akshit-arora commented 1 year ago

This is not an issue. The select dropdown should be hidden when only one operator is added.

The select element has a code class="form-control {{? it.operators.length === 1 }}hide{{?}}" that should add hide class in the select element.

Add the following CSS as mentioned in the 'No Bootstrap' page to get it working:

.query-builder .hide {
  display: none;
}