Skip to content

Commit

Permalink
0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
futurechan committed Mar 7, 2015
1 parent 9a7a1d1 commit 95e9d1f
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ node_modules
*~
.idea
npm-debug.log
build
dist
#build
#dist
bower_components
18 changes: 18 additions & 0 deletions dist/expression-builder.css
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
}
57 changes: 57 additions & 0 deletions dist/expression-builder.js
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)>&times;</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)>&times;</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>");}]);
1 change: 1 addition & 0 deletions dist/expression-builder.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/expression-builder.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 95e9d1f

Please sign in to comment.