I created a custom plugin for Jquery Querybuilder but it only works if I edit the Rule's structure from the file querybuilder-standalone itself.
The plugin I've created adds a button like the one from the plugin not-group inside each rule. The function of this plugin is to transform an input like this 'field = "value"' into this 'UPPER( field ) = "VALUE"'. The problem with this solution is that, in order to reuse this query I need to modify the structure of the Rule itself in the query-builder. The edits I would need to make are the following:
You can find the original code at line 2242 of the file query-builder.standalone.js
if (model.filter) {
model.filter.to_upper = item.to_upper; /* <---This is the line I added myself */
model.operator = self.getOperatorByType(item.operator, !options.allow_invalid);
if (!model.operator) {
model.operator = self.getOperators(model.filter)[0];
}
}
And this:
Original code between line 6215 and 6232
var id = self.getSQLFieldID(field, value);
//The following line us the code I need
var to_upper = data.to_upper;
/**
* Modifies the rule generated from the SQL expression
* @event changer:sqlToRule
* @memberof module:plugins.SqlSupport
* @param {object} rule
* @param {object} AST
* @returns {object}
*/
var rule = self.change('sqlToRule', {
id: id,
field: field,
operator: opVal.op,
value: opVal.val,
//The following line us the code I need
to_upper: to_upper
}, data);
'to_upper' is a property I set to false by default and to true when its related button it's clicked.
How could I do this without adding these code to query-builder itself?