mistic100 / jQuery-QueryBuilder

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

Invert plugin and custom operators (`operatorOpposites ` and `conditionOpposites` update defaults) #972

Open Guilouf opened 1 year ago

Guilouf commented 1 year ago

I see here in the doc https://querybuilder.js.org/plugins.html#invert that i need to update operatorOpposites and conditionOpposites in order to my customs operators

The plugin uses the operatorOpposites and conditionOpposites builder options to map each condition/operator to its invert. You must update it if you add new operators and conditions.

Right, but how do i update these ? I tried something like

  $('#builder-basic').queryBuilder.defaults({
    operatorOpposites: {
       'equal': 'not_equal',
  }}
  )

but it have no effects. Am i supposed to directly modify the plugin source code ??

mistic100 commented 1 year ago

Like other options of the builder provided at init

$('#builder-basic').queryBuilder({
   plugins: {
       invert: null,
   },
   operatorOpposites: {
       'equal': 'not_equal',
   }
});

(no idea why this was done here and not in the plugin's options...)

BTW here is the default config (yours will be merged with it)
https://github.com/mistic100/jQuery-QueryBuilder/blob/dev/src/plugins/invert/plugin.js#L65-L91