-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a7a1d1
commit 95e9d1f
Showing
5 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ node_modules | |
*~ | ||
.idea | ||
npm-debug.log | ||
build | ||
dist | ||
#build | ||
#dist | ||
bower_components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.bool-op { | ||
margin-top:10px; | ||
margin-bottom:10px; | ||
} | ||
|
||
.condition-builder { | ||
margin:10px; | ||
} | ||
|
||
.condition-group { | ||
border: 1px solid #ccc; | ||
border-radius:5px; | ||
padding:10px | ||
} | ||
|
||
.condition-group-button-row { | ||
margin-top:10px | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
angular.module('expression-builder', []) | ||
|
||
.controller('ExpressionBuilderController', function($scope){ | ||
|
||
$scope.addCondition=function(){ | ||
$scope.conditions.push({}); | ||
} | ||
|
||
$scope.addGroup=function(){ | ||
$scope.conditions.push({conditions:[]}); | ||
} | ||
|
||
$scope.remove=function(c){ | ||
var idx = $scope.conditions.indexOf(c); | ||
|
||
$scope.removeAt(idx); | ||
} | ||
|
||
$scope.removeAt=function(idx){ | ||
$scope.conditions.splice(idx,1); | ||
} | ||
}) | ||
|
||
.directive('expressionBuilder', function($compile){ | ||
|
||
return { | ||
restrict:'EA', | ||
controller:'ExpressionBuilderController', | ||
templateUrl: 'templates/expressionbuilder.html', | ||
scope: { | ||
conditions: '=', | ||
booleanOperators: '=?', | ||
comparisonOperators: '=?' | ||
}, | ||
compile: function (element) { | ||
var contents = element.contents().remove(); | ||
var contentsLinker; | ||
|
||
return function (scope, iElement) { | ||
if (angular.isUndefined(contentsLinker)) { | ||
contentsLinker = $compile(contents); | ||
} | ||
|
||
contentsLinker(scope, function (clonedElement) { | ||
iElement.append(clonedElement); | ||
}); | ||
|
||
if(scope.booleanOperators === undefined) | ||
scope.booleanOperators = ['AND', 'OR', 'AND NOT', 'XOR']; | ||
|
||
if(scope.comparisonOperators === undefined) | ||
scope.comparisonOperators = ['=', '<>', '<', '<=', '>', '>=']; | ||
}; | ||
} | ||
}; | ||
}) | ||
angular.module("expression-builder").run(["$templateCache", function($templateCache) {$templateCache.put("templates/expressionbuilder.html","<div class=condition-builder><div ng-repeat=\"c in conditions\"><div ng-if=\"$index != 0\" class=\"form-inline bool-op\"><select class=\"form-control input-sm\" ng-options=\"o as o for o in booleanOperators\" ng-model=c.bool></select></div><div ng-if=c.conditions class=condition-group><div class=pull-right><button class=\"btn btn-danger btn-sm\" ng-click=removeAt($index)>×</button></div><expression-builder conditions=c.conditions boolean-operators=booleanOperators comparison-operators=comparisonOperators></expression-builder></div><div ng-if=!c.conditions class=form-inline><div class=form-group-sm><input class=form-control ng-model=c.field placeholder=Field><select class=form-control ng-model=c.comparison ng-options=\"o as o for o in comparisonOperators\"></select><input class=form-control ng-model=c.value placeholder=value> <button class=\"btn btn-danger btn-sm\" ng-click=removeAt($index)>×</button></div></div></div><div class=condition-group-button-row><button class=\"btn btn-success btn-sm\" ng-click=addCondition()>Add Condition</button> <button class=\"btn btn-success btn-sm\" ng-click=addGroup()>Add Group</button></div></div>");}]); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.