diff --git a/.gitignore b/.gitignore index 26eca7a67..e6bac7841 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules coverage bower_components +./idea diff --git a/dist/bootstrap-decorator.min.js b/dist/bootstrap-decorator.min.js index 5b0864afa..1eea29c36 100644 --- a/dist/bootstrap-decorator.min.js +++ b/dist/bootstrap-decorator.min.js @@ -1 +1 @@ -angular.module("schemaForm").run(["$templateCache",function(e){e.put("directives/decorators/bootstrap/actions-trcl.html",'
'),e.put("directives/decorators/bootstrap/actions.html",'
'),e.put("directives/decorators/bootstrap/array.html",'

{{ form.title }}

'),e.put("directives/decorators/bootstrap/checkbox.html",'
'),e.put("directives/decorators/bootstrap/checkboxes.html",'
'),e.put("directives/decorators/bootstrap/default.html",'
'),e.put("directives/decorators/bootstrap/fieldset-trcl.html",'
{{ form.title }}
'),e.put("directives/decorators/bootstrap/fieldset.html",'
{{ form.title }}
'),e.put("directives/decorators/bootstrap/help.html",'
'),e.put("directives/decorators/bootstrap/radio-buttons.html",'
'),e.put("directives/decorators/bootstrap/radios-inline.html",'
'),e.put("directives/decorators/bootstrap/radios.html",'
'),e.put("directives/decorators/bootstrap/readonly.html",'
'),e.put("directives/decorators/bootstrap/section.html",'
'),e.put("directives/decorators/bootstrap/select.html",'
'),e.put("directives/decorators/bootstrap/submit.html",'
'),e.put("directives/decorators/bootstrap/tabarray.html",'
'),e.put("directives/decorators/bootstrap/tabs.html",'
'),e.put("directives/decorators/bootstrap/textarea.html",'
{{ (hasError() && errorMessage(schemaError())) || form.description}}
')}]),angular.module("schemaForm").config(["schemaFormDecoratorsProvider",function(e){var t="directives/decorators/bootstrap/";e.createDecorator("bootstrapDecorator",{textarea:t+"textarea.html",fieldset:t+"fieldset.html",array:t+"array.html",tabarray:t+"tabarray.html",tabs:t+"tabs.html",section:t+"section.html",conditional:t+"section.html",actions:t+"actions.html",select:t+"select.html",checkbox:t+"checkbox.html",checkboxes:t+"checkboxes.html",number:t+"default.html",password:t+"default.html",submit:t+"submit.html",button:t+"submit.html",radios:t+"radios.html","radios-inline":t+"radios-inline.html",radiobuttons:t+"radio-buttons.html",help:t+"help.html","default":t+"default.html"},[]),e.createDirectives({textarea:t+"textarea.html",select:t+"select.html",checkbox:t+"checkbox.html",checkboxes:t+"checkboxes.html",number:t+"default.html",submit:t+"submit.html",button:t+"submit.html",text:t+"default.html",date:t+"default.html",password:t+"default.html",datepicker:t+"datepicker.html",input:t+"default.html",radios:t+"radios.html","radios-inline":t+"radios-inline.html",radiobuttons:t+"radio-buttons.html"})}]).directive("sfFieldset",function(){return{transclude:!0,scope:!0,templateUrl:"directives/decorators/bootstrap/fieldset-trcl.html",link:function(e,t,r){e.title=e.$eval(r.title)}}}); \ No newline at end of file +angular.module("schemaForm").run(["$templateCache",function(e){e.put("directives/decorators/bootstrap/actions-trcl.html",'
'),e.put("directives/decorators/bootstrap/actions.html",'
'),e.put("directives/decorators/bootstrap/array.html",'

{{ form.title }}

'),e.put("directives/decorators/bootstrap/checkbox.html",'
'),e.put("directives/decorators/bootstrap/checkboxes.html",'
'),e.put("directives/decorators/bootstrap/default.html",'
'),e.put("directives/decorators/bootstrap/fieldset-trcl.html",'
{{ form.title }}
'),e.put("directives/decorators/bootstrap/fieldset.html",'
{{ form.title }}
'),e.put("directives/decorators/bootstrap/help.html",'
'),e.put("directives/decorators/bootstrap/radio-buttons.html",'
'),e.put("directives/decorators/bootstrap/radios-inline.html",'
'),e.put("directives/decorators/bootstrap/radios.html",'
'),e.put("directives/decorators/bootstrap/readonly.html",'
'),e.put("directives/decorators/bootstrap/section.html",'
'),e.put("directives/decorators/bootstrap/select.html",'
'),e.put("directives/decorators/bootstrap/submit.html",'
'),e.put("directives/decorators/bootstrap/tabarray.html",'
'),e.put("directives/decorators/bootstrap/tabs.html",'
'),e.put("directives/decorators/bootstrap/textarea.html",'
{{ (hasError() && errorMessage(schemaError())) || form.description}}
')}]),angular.module("schemaForm").config(["schemaFormDecoratorsProvider",function(e){var t="directives/decorators/bootstrap/";e.createDecorator("bootstrapDecorator",{textarea:t+"textarea.html",fieldset:t+"fieldset.html",array:t+"array.html",tabarray:t+"tabarray.html",tabs:t+"tabs.html",section:t+"section.html",conditional:t+"section.html",actions:t+"actions.html",select:t+"select.html",checkbox:t+"checkbox.html",checkboxes:t+"checkboxes.html",number:t+"default.html",password:t+"default.html",submit:t+"submit.html",button:t+"submit.html",radios:t+"radios.html","radios-inline":t+"radios-inline.html",radiobuttons:t+"radio-buttons.html",help:t+"help.html","default":t+"default.html"},[]),e.createDirectives({textarea:t+"textarea.html",select:t+"select.html",checkbox:t+"checkbox.html",checkboxes:t+"checkboxes.html",number:t+"default.html",submit:t+"submit.html",button:t+"submit.html",text:t+"default.html",date:t+"default.html",password:t+"default.html",datepicker:t+"datepicker.html",input:t+"default.html",radios:t+"radios.html","radios-inline":t+"radios-inline.html",radiobuttons:t+"radio-buttons.html"})}]).directive("sfFieldset",function(){return{transclude:!0,scope:!0,templateUrl:"directives/decorators/bootstrap/fieldset-trcl.html",link:function(e,t,o){e.title=e.$eval(o.title)}}}); \ No newline at end of file diff --git a/dist/schema-form.js b/dist/schema-form.js index 0eb8b88f2..c27afba3a 100644 --- a/dist/schema-form.js +++ b/dist/schema-form.js @@ -155,6 +155,11 @@ angular.module('schemaForm').provider('schemaFormDecorators', return directive.mappings['default']; }; + + var lookupForKey = function (key) { + return 'model' + (key[0] !== '[' ? '.' : '') + key; + }; + var createDirective = function(name) { $compileProvider.directive(name, ['$parse', '$compile', '$http', '$templateCache', function($parse, $compile, $http, $templateCache) { @@ -226,6 +231,67 @@ angular.module('schemaForm').provider('schemaFormDecorators', } }; + var evalExpression = function (expression) { + angular.forEach(scope.form.dependencies, function (key) { + expression = expression.replace(key, lookupForKey(key)); + }); + + return scope.$eval(expression); + }; + + + var resetModelValue = function () { + if (scope.ngModel) { + scope.ngModel.$setViewValue(undefined); + scope.ngModel.$render(); + scope.ngModel.$setPristine(); + } + }; + + scope.showCondition = function () { + var expressionString = scope.form.expression; + if (angular.isUndefined(expressionString)) { + return true; + } + + var show = evalExpression(expressionString); + + if (angular.isDefined(scope.form.required)) { + scope.form.required = show; + scope.form.schema.required = show; + } + + + if (scope.form.key && !show) { + resetModelValue(); + } + + return show; + + }; + + + scope.disabledElement = function () { + var expressionString = scope.form.disabledExpression; + + if (angular.isUndefined(expressionString)) { + return false; + } + + var disabled = evalExpression(expressionString); + + if (angular.isDefined(scope.form.required)) { + scope.form.required = !disabled; + scope.form.schema.required = !disabled; + } + + if (disabled) { + resetModelValue(); + } + return disabled; + }; + + /** * Evaluate an expression, i.e. scope.$eval * but do it in sfSchemas parent scope sf-schema directive is used @@ -1024,8 +1090,8 @@ angular.module('schemaForm').directive('sfArray', ['sfSelect', 'schemaForm', 'sf var len = list.length; var copy = scope.copyWithIndex(len); schemaForm.traverseForm(copy, function(part) { - if (part.key && angular.isDefined(part['default'])) { - sfSelect(part.key, scope.model, part['default']); + if (part.key && part.schema && angular.isDefined(part.schema['default'])) { + sfSelect(part.key, scope.model, part.schema['default']); } }); diff --git a/dist/schema-form.min.js b/dist/schema-form.min.js index 5d0b85fc1..52d1229b4 100644 --- a/dist/schema-form.min.js +++ b/dist/schema-form.min.js @@ -1 +1 @@ -var deps=["ObjectPath"];try{angular.module("ngSanitize"),deps.push("ngSanitize")}catch(e){}try{angular.module("ui.sortable"),deps.push("ui.sortable")}catch(e){}try{angular.module("angularSpectrumColorpicker"),deps.push("angularSpectrumColorpicker")}catch(e){}angular.module("schemaForm",deps),angular.module("schemaForm").provider("sfPath",["ObjectPathProvider",function(e){var r={parse:e.parse};r.stringify=1===angular.version.major&&angular.version.minor<3?function(e){return Array.isArray(e)?e.join("."):e.toString()}:e.stringify,r.normalize=function(e,t){return r.stringify(Array.isArray(e)?e:r.parse(e),t)},this.parse=r.parse,this.stringify=r.stringify,this.normalize=r.normalize,this.$get=function(){return r}}]),angular.module("schemaForm").factory("sfSelect",["sfPath",function(e){var r=/^\d+$/;return function(t,a,n){a||(a=this);var i="string"==typeof t?e.parse(t):t;if("undefined"!=typeof n&&1===i.length)return a[i[0]]=n,a;"undefined"!=typeof n&&"undefined"==typeof a[i[0]]&&(a[i[0]]=i.length>2&&r.test(i[1])?[]:{});for(var o=a[i[0]],u=1;u',link:function(e,t,a){var n={items:"c",titleMap:"c",schema:"c"},i={type:r},o=!0;angular.forEach(a,function(r,t){if("$"!==t[0]&&0!==t.indexOf("ng")&&"sfField"!==t){var u=function(r){angular.isDefined(r)&&r!==i[t]&&(i[t]=r,o&&i.type&&(i.key||angular.isUndefined(a.key))&&(e.form=i,o=!1))};"model"===t?e.$watch(r,function(r){r&&e.model!==r&&(e.model=r)}):"c"===n[t]?e.$watchCollection(r,u):a.$observe(t,u)}})}}})};this.createDecorator=function(e,r,n){a[e]={mappings:r||{},rules:n||[]},a[t]||(t=e),i(e)},this.createDirective=o,this.createDirectives=function(e){angular.forEach(e,function(e,r){o(r,e)})},this.directive=function(e){return e=e||t,a[e]},this.addMapping=function(e,r,t){a[e]&&(a[e].mappings[r]=t)},this.$get=function(){return{directive:function(e){return a[e]},defaultDecorator:t}},i("sfDecorator")}]),angular.module("schemaForm").provider("schemaForm",["sfPathProvider",function(e){var r=function(e){var r=[];return e.forEach(function(e){r.push({name:e,value:e})}),r},t=function(e,r){if(!angular.isArray(e)){var t=[];return r?angular.forEach(r,function(r){t.push({name:e[r],value:r})}):angular.forEach(e,function(e,r){t.push({name:e,value:r})}),t}return e},a=function(e,r,t){var a=d[r.type];if(a)for(var n,i=0;i1&&(c={type:"section",items:i.items.map(function(e){return e.ngModelOptions=i.ngModelOptions,e.readonly=i.readonly,e})})}if(n.copyWithIndex=function(e){if(!l[e]&&c){var t=angular.copy(c);t.arrayIndex=e,r.traverseForm(t,a(e)),l[e]=t}return l[e]},n.appendToArray=function(){var t=o.length,a=n.copyWithIndex(t);if(r.traverseForm(a,function(r){r.key&&angular.isDefined(r["default"])&&e(r.key,n.model,r["default"])}),t===o.length){var u,l=e("schema.items.type",i);"object"===l?u={}:"array"===l&&(u=[]),o.push(u)}return n.validateArray&&n.validateArray(),o},n.deleteFromArray=function(e){return o.splice(e,1),n.validateArray&&n.validateArray(),o},i.titleMap||i.startEmpty===!0||0!==o.length||n.appendToArray(),i.titleMap&&i.titleMap.length>0){n.titleMapValues=[];var f=function(e){n.titleMapValues=[],e=e||[],i.titleMap.forEach(function(r){n.titleMapValues.push(-1!==e.indexOf(r.value))})};f(n.modelArray),n.$watchCollection("modelArray",f),n.$watchCollection("titleMapValues",function(e){if(e){for(var r=n.modelArray;r.length>0;)r.shift();i.titleMap.forEach(function(t,a){e[a]&&r.push(t.value)})}})}if(u){var m;n.validateArray=function(){var e=t.validate(i,n.modelArray.length>0?n.modelArray:void 0);e.valid!==!1||!e.error||""!==e.error.dataPath&&e.error.dataPath!=="/"+i.key[i.key.length-1]?u.$setValidity("schema",!0):(u.$setViewValue(n.modelArray),m=e.error,u.$setValidity("schema",!1))},n.$on("schemaFormValidate",n.validateArray),n.hasSuccess=function(){return u.$valid&&!u.$pristine},n.hasError=function(){return u.$invalid},n.schemaError=function(){return m}}s()})}}}]),angular.module("schemaForm").directive("sfChanged",function(){return{require:"ngModel",restrict:"AC",scope:!1,link:function(e,r,t,a){var n=e.$eval(t.sfChanged);n&&n.onChange&&a.$viewChangeListeners.push(function(){angular.isFunction(n.onChange)?n.onChange(a.$modelValue,n):e.evalExpr(n.onChange,{modelValue:a.$modelValue,form:n})})}}}),angular.module("schemaForm").directive("sfSchema",["$compile","schemaForm","schemaFormDecorators","sfSelect",function(e,r,t,a){var n=/[A-Z]/g,i=function(e,r){return r=r||"_",e.replace(n,function(e,t){return(t?r:"")+e.toLowerCase()})};return{scope:{schema:"=sfSchema",initialForm:"=sfForm",model:"=sfModel",options:"=sfOptions"},controller:["$scope",function(e){this.evalInParentScope=function(r,t){return e.$parent.$eval(r,t)}}],replace:!1,restrict:"A",transclude:!0,require:"?form",link:function(n,o,u,l,s){n.formCtrl=l;var c={};s(n,function(e){if(e.addClass("schema-form-ignore"),o.prepend(e),o[0].querySelectorAll){var r=o[0].querySelectorAll("[ng-model]");if(r)for(var t=0;t0){f.schema=l,f.form=s;var m=r.merge(l,s,c,n.options),d=document.createDocumentFragment();n.schemaForm={form:m,schema:l},o.children(":not(.schema-form-ignore)").remove(),angular.forEach(m,function(e,r){var a=document.createElement(u.sfDecorator||i(t.defaultDecorator,"-"));a.setAttribute("form","schemaForm.form["+r+"]");var n;try{n=o[0].querySelector('*[sf-insert-field="'+e.key+'"]')}catch(l){n=null}n?(n.innerHTML="",n.appendChild(a)):d.appendChild(a)}),o[0].appendChild(d),e(o.children())(n),r.traverseSchema(l,function(e,r){if(angular.isDefined(e["default"])){var t=a(r,n.model);angular.isUndefined(t)&&a(r,n.model,e["default"])}})}})}}}]),angular.module("schemaForm").directive("schemaValidate",["sfValidator",function(e){return{restrict:"A",scope:!1,priority:1e3,require:"ngModel",link:function(r,t,a,n){r.ngModel=n;var i=null,o=function(){return u||(u=r.$eval(a.schemaValidate)),u},u=o();n.$validators?n.$validators.schema=function(r){var t=e.validate(o(),r);return i=t.error,t.valid}:n.$parsers.push(function(r){if(u=o(),!u)return r;var t=e.validate(u,r);return t.valid?(n.$setValidity("schema",!0),r):(n.$setValidity("schema",!1),void(i=t.error))}),r.$on("schemaFormValidate",function(){n.$validate?(n.$validate(),n.$invalid&&(n.$dirty=!0,n.$pristine=!1)):n.$setViewValue(n.$viewValue)}),r.hasSuccess=function(){return n.$valid&&(!n.$pristine||!n.$isEmpty(n.$modelValue))},r.hasError=function(){return n.$invalid&&!n.$pristine},r.schemaError=function(){return i}}}}]); \ No newline at end of file +var deps=["ObjectPath"];try{angular.module("ngSanitize"),deps.push("ngSanitize")}catch(e){}try{angular.module("ui.sortable"),deps.push("ui.sortable")}catch(e){}try{angular.module("angularSpectrumColorpicker"),deps.push("angularSpectrumColorpicker")}catch(e){}angular.module("schemaForm",deps),angular.module("schemaForm").provider("sfPath",["ObjectPathProvider",function(e){var r={parse:e.parse};r.stringify=1===angular.version.major&&angular.version.minor<3?function(e){return Array.isArray(e)?e.join("."):e.toString()}:e.stringify,r.normalize=function(e,t){return r.stringify(Array.isArray(e)?e:r.parse(e),t)},this.parse=r.parse,this.stringify=r.stringify,this.normalize=r.normalize,this.$get=function(){return r}}]),angular.module("schemaForm").factory("sfSelect",["sfPath",function(e){var r=/^\d+$/;return function(t,n,a){n||(n=this);var i="string"==typeof t?e.parse(t):t;if("undefined"!=typeof a&&1===i.length)return n[i[0]]=a,n;"undefined"!=typeof a&&"undefined"==typeof n[i[0]]&&(n[i[0]]=i.length>2&&r.test(i[1])?[]:{});for(var o=n[i[0]],u=1;u',link:function(e,t,n){var a={items:"c",titleMap:"c",schema:"c"},i={type:r},o=!0;angular.forEach(n,function(r,t){if("$"!==t[0]&&0!==t.indexOf("ng")&&"sfField"!==t){var u=function(r){angular.isDefined(r)&&r!==i[t]&&(i[t]=r,o&&i.type&&(i.key||angular.isUndefined(n.key))&&(e.form=i,o=!1))};"model"===t?e.$watch(r,function(r){r&&e.model!==r&&(e.model=r)}):"c"===a[t]?e.$watchCollection(r,u):n.$observe(t,u)}})}}})};this.createDecorator=function(e,r,a){n[e]={mappings:r||{},rules:a||[]},n[t]||(t=e),o(e)},this.createDirective=u,this.createDirectives=function(e){angular.forEach(e,function(e,r){u(r,e)})},this.directive=function(e){return e=e||t,n[e]},this.addMapping=function(e,r,t){n[e]&&(n[e].mappings[r]=t)},this.$get=function(){return{directive:function(e){return n[e]},defaultDecorator:t}},o("sfDecorator")}]),angular.module("schemaForm").provider("schemaForm",["sfPathProvider",function(e){var r=function(e){var r=[];return e.forEach(function(e){r.push({name:e,value:e})}),r},t=function(e,r){if(!angular.isArray(e)){var t=[];return r?angular.forEach(r,function(r){t.push({name:e[r],value:r})}):angular.forEach(e,function(e,r){t.push({name:e,value:r})}),t}return e},n=function(e,r,t){var n=d[r.type];if(n)for(var a,i=0;i1&&(c={type:"section",items:i.items.map(function(e){return e.ngModelOptions=i.ngModelOptions,e.readonly=i.readonly,e})})}if(a.copyWithIndex=function(e){if(!l[e]&&c){var t=angular.copy(c);t.arrayIndex=e,r.traverseForm(t,n(e)),l[e]=t}return l[e]},a.appendToArray=function(){var t=o.length,n=a.copyWithIndex(t);if(r.traverseForm(n,function(r){r.key&&r.schema&&angular.isDefined(r.schema["default"])&&e(r.key,a.model,r.schema["default"])}),t===o.length){var u,l=e("schema.items.type",i);"object"===l?u={}:"array"===l&&(u=[]),o.push(u)}return a.validateArray&&a.validateArray(),o},a.deleteFromArray=function(e){return o.splice(e,1),a.validateArray&&a.validateArray(),o},i.titleMap||i.startEmpty===!0||0!==o.length||a.appendToArray(),i.titleMap&&i.titleMap.length>0){a.titleMapValues=[];var f=function(e){a.titleMapValues=[],e=e||[],i.titleMap.forEach(function(r){a.titleMapValues.push(-1!==e.indexOf(r.value))})};f(a.modelArray),a.$watchCollection("modelArray",f),a.$watchCollection("titleMapValues",function(e){if(e){for(var r=a.modelArray;r.length>0;)r.shift();i.titleMap.forEach(function(t,n){e[n]&&r.push(t.value)})}})}if(u){var m;a.validateArray=function(){var e=t.validate(i,a.modelArray.length>0?a.modelArray:void 0);e.valid!==!1||!e.error||""!==e.error.dataPath&&e.error.dataPath!=="/"+i.key[i.key.length-1]?u.$setValidity("schema",!0):(u.$setViewValue(a.modelArray),m=e.error,u.$setValidity("schema",!1))},a.$on("schemaFormValidate",a.validateArray),a.hasSuccess=function(){return u.$valid&&!u.$pristine},a.hasError=function(){return u.$invalid},a.schemaError=function(){return m}}s()})}}}]),angular.module("schemaForm").directive("sfChanged",function(){return{require:"ngModel",restrict:"AC",scope:!1,link:function(e,r,t,n){var a=e.$eval(t.sfChanged);a&&a.onChange&&n.$viewChangeListeners.push(function(){angular.isFunction(a.onChange)?a.onChange(n.$modelValue,a):e.evalExpr(a.onChange,{modelValue:n.$modelValue,form:a})})}}}),angular.module("schemaForm").directive("sfSchema",["$compile","schemaForm","schemaFormDecorators","sfSelect",function(e,r,t,n){var a=/[A-Z]/g,i=function(e,r){return r=r||"_",e.replace(a,function(e,t){return(t?r:"")+e.toLowerCase()})};return{scope:{schema:"=sfSchema",initialForm:"=sfForm",model:"=sfModel",options:"=sfOptions"},controller:["$scope",function(e){this.evalInParentScope=function(r,t){return e.$parent.$eval(r,t)}}],replace:!1,restrict:"A",transclude:!0,require:"?form",link:function(a,o,u,l,s){a.formCtrl=l;var c={};s(a,function(e){if(e.addClass("schema-form-ignore"),o.prepend(e),o[0].querySelectorAll){var r=o[0].querySelectorAll("[ng-model]");if(r)for(var t=0;t0){f.schema=l,f.form=s;var m=r.merge(l,s,c,a.options),d=document.createDocumentFragment();a.schemaForm={form:m,schema:l},o.children(":not(.schema-form-ignore)").remove(),angular.forEach(m,function(e,r){var n=document.createElement(u.sfDecorator||i(t.defaultDecorator,"-"));n.setAttribute("form","schemaForm.form["+r+"]");var a;try{a=o[0].querySelector('*[sf-insert-field="'+e.key+'"]')}catch(l){a=null}a?(a.innerHTML="",a.appendChild(n)):d.appendChild(n)}),o[0].appendChild(d),e(o.children())(a),r.traverseSchema(l,function(e,r){if(angular.isDefined(e["default"])){var t=n(r,a.model);angular.isUndefined(t)&&n(r,a.model,e["default"])}})}})}}}]),angular.module("schemaForm").directive("schemaValidate",["sfValidator",function(e){return{restrict:"A",scope:!1,priority:1e3,require:"ngModel",link:function(r,t,n,a){r.ngModel=a;var i=null,o=function(){return u||(u=r.$eval(n.schemaValidate)),u},u=o();a.$validators?a.$validators.schema=function(r){var t=e.validate(o(),r);return i=t.error,t.valid}:a.$parsers.push(function(r){if(u=o(),!u)return r;var t=e.validate(u,r);return t.valid?(a.$setValidity("schema",!0),r):(a.$setValidity("schema",!1),void(i=t.error))}),r.$on("schemaFormValidate",function(){a.$validate?(a.$validate(),a.$invalid&&(a.$dirty=!0,a.$pristine=!1)):a.$setViewValue(a.$viewValue)}),r.hasSuccess=function(){return a.$valid&&(!a.$pristine||!a.$isEmpty(a.$modelValue))},r.hasError=function(){return a.$invalid&&!a.$pristine},r.schemaError=function(){return i}}}}]); \ No newline at end of file diff --git a/examples/data/simple.json b/examples/data/simple.json index 42526df80..bcf568a3c 100644 --- a/examples/data/simple.json +++ b/examples/data/simple.json @@ -28,7 +28,10 @@ { "key": "comment", "type": "textarea", - "placeholder": "Make a comment" + "placeholder": "Make a comment", + "dependencies": ["name", "email"], + "expression": "name === 'secret'", + "disabledExpression": "email === 'test@test.com'" }, { "type": "submit", diff --git a/gulp/tasks/test.js b/gulp/tasks/test.js new file mode 100644 index 000000000..56bacacc5 --- /dev/null +++ b/gulp/tasks/test.js @@ -0,0 +1,27 @@ +var gulp = require('gulp'), + karma = require('gulp-karma'); + +gulp.task('test', function() { + return gulp.src([ + 'bower_components/jquery/dist/jquery.min.js', + 'test/lib/angular.js', + 'test/lib/angular-mocks.js', + 'bower_components/tv4/tv4.js', + 'bower_components/objectpath/lib/ObjectPath.js', + 'src/module.js', + 'src/sfPath.js', + 'src/services/*.js', + 'src/directives/*.js', + 'src/directives/decorators/bootstrap/*.js', + 'src/**/*.html', + 'test/services/schema-form-test.js', + 'test/services/decorators-test.js', + 'test/directives/schema-form-test.js']) + .pipe(karma({ + configFile: 'karma.conf.js', + action: 'run' + })) + .on('error', function(err) { + throw err; + }); +}); diff --git a/package.json b/package.json index 4921ebcd3..4df131a05 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "gulp-angular-templatecache": "^1.2.1", "gulp-concat": "^2.2.0", "gulp-jscs": "^1.1.0", + "gulp-karma": "0.0.4", "gulp-minify-html": "^0.1.1", "gulp-uglify": "^0.2.1", "karma": "^0.12.0", diff --git a/src/directives/decorators/bootstrap/actions.html b/src/directives/decorators/bootstrap/actions.html index 905101435..a00c7bd9b 100644 --- a/src/directives/decorators/bootstrap/actions.html +++ b/src/directives/decorators/bootstrap/actions.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/directives/decorators/bootstrap/checkbox.html b/src/directives/decorators/bootstrap/checkbox.html index 09ba38326..6a75c1b26 100644 --- a/src/directives/decorators/bootstrap/checkbox.html +++ b/src/directives/decorators/bootstrap/checkbox.html @@ -1,4 +1,4 @@ -
+