diff --git a/dist/expression-builder.js b/dist/expression-builder.js index d6c2b10..e0c06e0 100644 --- a/dist/expression-builder.js +++ b/dist/expression-builder.js @@ -1,4 +1,4 @@ -angular.module('expression-builder', []) +angular.module('expression-builder', ['ui.bootstrap']) .controller('ExpressionBuilderController', function($scope){ @@ -19,6 +19,18 @@ angular.module('expression-builder', []) $scope.removeAt=function(idx){ $scope.conditions.splice(idx,1); } + + $scope.getLeftOperands=function($viewValue){ + return ($scope.leftOperandProvider) + ? $scope.leftOperandProvider($viewValue) + : []; + } + + $scope.getRightOperands=function($viewValue){ + return ($scope.rightOperandProvider) + ? $scope.rightOperandProvider($viewValue) + : []; + } }) .directive('expressionBuilder', function($compile){ @@ -30,7 +42,9 @@ angular.module('expression-builder', []) scope: { conditions: '=', booleanOperators: '=?', - comparisonOperators: '=?' + comparisonOperators: '=?', + leftOperandProvider: '&', + rightOperandProvider: '&' }, compile: function (element) { var contents = element.contents().remove(); @@ -46,12 +60,19 @@ angular.module('expression-builder', []) }); if(scope.booleanOperators === undefined) - scope.booleanOperators = ['AND', 'OR', 'AND NOT', 'XOR']; + scope.booleanOperators = ['AND', 'OR', 'XOR']; if(scope.comparisonOperators === undefined) scope.comparisonOperators = ['=', '<>', '<', '<=', '>', '>=']; + + if(scope.leftOperandProvider) + scope.leftOperandProvider = scope.leftOperandProvider() + + if(scope.rightOperandProvider) + scope.rightOperandProvider = scope.rightOperandProvider() }; } }; }) -angular.module("expression-builder").run(["$templateCache", function($templateCache) {$templateCache.put("templates/expressionbuilder.html","
");}]); \ No newline at end of file + +angular.module("expression-builder").run(["$templateCache", function($templateCache) {$templateCache.put("templates/expressionbuilder.html","
");}]); \ No newline at end of file diff --git a/dist/expression-builder.min.js b/dist/expression-builder.min.js index cf1dd10..4fc3176 100644 --- a/dist/expression-builder.min.js +++ b/dist/expression-builder.min.js @@ -1 +1 @@ -angular.module("expression-builder",[]).controller("ExpressionBuilderController",["$scope",function(o){o.addCondition=function(){o.conditions.push({})},o.addGroup=function(){o.conditions.push({conditions:[]})},o.remove=function(n){var i=o.conditions.indexOf(n);o.removeAt(i)},o.removeAt=function(n){o.conditions.splice(n,1)}}]).directive("expressionBuilder",["$compile",function(o){return{restrict:"EA",controller:"ExpressionBuilderController",templateUrl:"templates/expressionbuilder.html",scope:{conditions:"=",booleanOperators:"=?",comparisonOperators:"=?"},compile:function(n){var i,e=n.contents().remove();return function(n,t){angular.isUndefined(i)&&(i=o(e)),i(n,function(o){t.append(o)}),void 0===n.booleanOperators&&(n.booleanOperators=["AND","OR","AND NOT","XOR"]),void 0===n.comparisonOperators&&(n.comparisonOperators=["=","<>","<","<=",">",">="])}}}}]),angular.module("expression-builder").run(["$templateCache",function(o){o.put("templates/expressionbuilder.html",'
')}]); \ No newline at end of file +angular.module("expression-builder",["ui.bootstrap"]).controller("ExpressionBuilderController",["$scope",function(o){o.addCondition=function(){o.conditions.push({})},o.addGroup=function(){o.conditions.push({conditions:[]})},o.remove=function(e){var n=o.conditions.indexOf(e);o.removeAt(n)},o.removeAt=function(e){o.conditions.splice(e,1)},o.getLeftOperands=function(e){return o.leftOperandProvider?o.leftOperandProvider(e):[]},o.getRightOperands=function(e){return o.rightOperandProvider?o.rightOperandProvider(e):[]}}]).directive("expressionBuilder",["$compile",function(o){return{restrict:"EA",controller:"ExpressionBuilderController",templateUrl:"templates/expressionbuilder.html",scope:{conditions:"=",booleanOperators:"=?",comparisonOperators:"=?",leftOperandProvider:"&",rightOperandProvider:"&"},compile:function(e){var n,r=e.contents().remove();return function(e,i){angular.isUndefined(n)&&(n=o(r)),n(e,function(o){i.append(o)}),void 0===e.booleanOperators&&(e.booleanOperators=["AND","OR","XOR"]),void 0===e.comparisonOperators&&(e.comparisonOperators=["=","<>","<","<=",">",">="]),e.leftOperandProvider&&(e.leftOperandProvider=e.leftOperandProvider()),e.rightOperandProvider&&(e.rightOperandProvider=e.rightOperandProvider())}}}}]),angular.module("expression-builder").run(["$templateCache",function(o){o.put("templates/expressionbuilder.html",'
')}]); \ No newline at end of file