Skip to content

Complex Operators with custom inputs (eg modulo) #284

Open
@ascyltos

Description

@ascyltos

I am looking for a way to implement a modulo operator, but I am not sure what might be the way to do so.

When selecting the modulo op the resulting rule should display something like this (please ignore the first and last select, the image is taken from the current implementation):

image

The idea is to model operations like:

field % value = 5
field % value > 10
....

I've been able to add the modulo operator but all the fields are now shown as inputs for numbers:

(function() {

  var QueryBuilder = jQuery.fn.queryBuilder,
      operators = QueryBuilder.defaults('operators'),
      operatorsAsArray = Object.keys(operators).map(function (key) {return operators[key]});

  operatorsAsArray.push({
    type: 'modulo',
    nb_inputs: 3,
    apply_to: ['number']
  });

  QueryBuilder.defaults({operators: operatorsAsArray});
})();

image

Is there a way to specify custom inputs or a template for an operator?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions