Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery (or any web tool) Nested Expression Builder

I would like to add a feature to a web app I am developing to allow the user to create rules with an expression builder. Such as the one used in Magento (picture in link below).

http://i.stack.imgur.com/ZWgcG.png

enter image description here

I want to allows them to be able to create the expressions or if statements using column names from a table in a Database, then be able to do comparisons and what not. The expression built in the user interface would then evaluate to code that would be evaluated by a PHP script or Javascript or Perl

I searched the web for things like this that are javascript (ajax) based. I figures there has to be a module or something out on the internet somewhere for jQuery or something similar, but I haven't been able to find anything. I am also not quite sure what something like this is called besides "Expression Builder". If there is something like this out there it would save me a lot of time compared to writing it from scratch.

like image 847
Marc Avatar asked Aug 11 '11 19:08

Marc


2 Answers

In Mac OS X terms it is called a “predicate editor”, and can be found in Mail.app and iTunes. I had need for one a while ago, and scoured the web from end to end without finding one. I ended up building my own using jQuery, and it looks like this (text is in norwegian, sorry):

Javascript predicat editor

Sadly this is used in an internal project and the source code is not available as it is very application-specific. There is a need for a free component like this though, so if I get around to it I will try to clean this up and release it.

like image 169
arnemart Avatar answered Sep 21 '22 03:09

arnemart


This here should be exactly what you're looking for?

  • Demo: https://github.com/chrisjpowers/business-rules
  • Code: https://github.com/chrisjpowers/business-rules
like image 21
floriank Avatar answered Sep 23 '22 03:09

floriank