diff --git a/js/search/search_form_criteria.js b/js/search/search_form_criteria.js index 13fa5ab18..3967a3e9f 100644 --- a/js/search/search_form_criteria.js +++ b/js/search/search_form_criteria.js @@ -20,6 +20,7 @@ $(function() 'label': '', 'allowed_values': null, 'is_null_allowed': false, + 'has_index': false, }, // Available operators. They can be extended or restricted by derivated widgets (see this._initOperators() for more informations) 'available_operators': { @@ -61,9 +62,14 @@ $(function() // Init properties (complexe type properties would be static if not initialized with a simple type variable...) this.operators = {}; + + // Choose the default operator + this._initChooseDefaultOperator(); + // Init operators this._initOperators(); + // Link search form handler this.handler = this.element.closest('.search_form_handler'); @@ -95,7 +101,14 @@ $(function() this._super( key, value ); }, - + _initChooseDefaultOperator: function() { + //if the class has an index, in order to maximize the performance, we force the default operator to "equal" + if (this.options.field.has_index && typeof this.options.available_operators['='] == 'object') + { + this.options.operator = '='; + this.options.available_operators['='].rank = -1;//we want it to be the first displayed + } + }, // Protected methods // - Init operators by cleaning up available operators and ordering them. // Note: A null operator or an operator with a rank "false" will be removed. @@ -104,6 +117,8 @@ $(function() // Reset operators this.operators = {}; + + // Cancel empty/not_empty operators if field can't be null if(this.options.field.is_null_allowed === false) { diff --git a/js/search/search_form_handler.js b/js/search/search_form_handler.js index 84884b6d6..98644614f 100644 --- a/js/search/search_form_handler.js +++ b/js/search/search_form_handler.js @@ -811,7 +811,8 @@ $(function() label: oFieldDef.label, class: oFieldDef.class, class_alias: oFieldDef.class_alias, - code: oFieldDef.code, + code: oFieldDef.code, + has_index: oFieldDef.has_index, target_class: oFieldDef.target_class, widget: oFieldDef.widget, allowed_values: oFieldDef.allowed_values,