From 43957cbfae4523d954569f2b85eb7997bafd7b78 Mon Sep 17 00:00:00 2001 From: Ignacio del Valle Alles Date: Tue, 27 Dec 2016 11:18:16 +0100 Subject: [PATCH] fix #48 --- dist/js/brutusin-json-forms.js | 4 ++-- dist/js/brutusin-json-forms.min.js | 2 +- src/js/brutusin-json-forms.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/js/brutusin-json-forms.js b/dist/js/brutusin-json-forms.js index 89c0164..a23cee2 100644 --- a/dist/js/brutusin-json-forms.js +++ b/dist/js/brutusin-json-forms.js @@ -360,7 +360,7 @@ if (typeof brutusin === "undefined") { option.value = s.oneOf[i]; appendChild(option, textNode, s); appendChild(input, option, s); - if (value === undefined) + if (value === undefined || value === null) continue; if (s.readOnly) input.disabled = true; @@ -606,7 +606,7 @@ if (typeof brutusin === "undefined") { appendChild(div, addButton, s); if (value) { for (var p in value) { - if (s.properties.hasOwnProperty(p)) { + if (s.properties && s.properties.hasOwnProperty(p)) { continue; } if (usedProps.indexOf(p) !== -1) { diff --git a/dist/js/brutusin-json-forms.min.js b/dist/js/brutusin-json-forms.min.js index c4b8f6f..bece051 100644 --- a/dist/js/brutusin-json-forms.min.js +++ b/dist/js/brutusin-json-forms.min.js @@ -1 +1 @@ -if("undefined"==typeof brutusin)window.brutusin=new Object;else if("object"!=typeof brutusin)throw"brutusin global variable already exists";!function(){String.prototype.startsWith||(String.prototype.startsWith=function(e,t){return t=t||0,this.indexOf(e,t)===t}),String.prototype.endsWith||(String.prototype.endsWith=function(e,t){var r=this.toString();(void 0===t||t>r.length)&&(t=r.length),t-=e.length;var n=r.indexOf(e,t);return-1!==n&&n===t}),String.prototype.includes||(String.prototype.includes=function(){"use strict";return-1!==String.prototype.indexOf.apply(this,arguments)}),String.prototype.format||(String.prototype.format=function(){for(var e=this,t=0;t0)throw"Error parsing expression '"+e+"': Multiple tokens found inside a bracket";o+=u,i++}else r[r.length]=u;if(s===n.length-1&&a)throw"Error parsing expression '"+e+"': Unbalanced [ found"}this.exp=e,this.queue=r,this.visit=function(e,t){function r(e,n,a,i,o){if(null!=a){var s=n.shift();if("$"===s){e="$";var s=n.shift()}if(s)if(Array.isArray(a)){if(!s.startsWith("["))throw"Node '"+e+"' is of type array";var u=s.substring(1,s.length-1);if(u.equals("#"))for(var l=0;lp)throw"Element '"+u+"' of node '"+e+"' is lower than zero";var d=a[p];r(e+s,n.slice(0),d,a,p)}}else{if("object"!=typeof a)throw"boolean"==typeof a||"number"==typeof a||"string"==typeof a?"Node is leaf but still are tokens remaining: "+s:"Node type '"+typeof a+"' not supported for index field '"+e+"'";if("[*]"===s)for(var c in a){var d=a[c];r(e+s,n.slice(0),d,a,c),r(e+'["'+c+'"]',n.slice(0),d,a,c)}else{var d;if(s.startsWith("[")){var u=s.substring(1,s.length-1);if(!u.startsWith('"')&&!u.startsWith("'"))throw"Element '"+u+"' of node '"+e+"' must be a string expression or wilcard '*'";u=u.substring(1,u.length()-1),e+=s,d=a[u]}else e=e.length>0?e+"."+s:s,d=a[s];r(e,n,d,a,s)}}else t(a,i,o)}}r(this.exp,this.queue,e)}}var SCHEMA_ANY={type:"any"},obj=new Object,schemaMap=new Object,dependencyMap=new Object,renderInfoMap=new Object,container,data,error,initialValue,inputCounter=0,root=schema,formId="BrutusinForms#"+BrutusinForms.instances.length;populateSchemaMap("$",schema),validateDepencyMapIsAcyclic();var renderers=new Object;return renderers.integer=function(e,t,r,n,a){renderers.string(e,t,r,n,a)},renderers.number=function(e,t,r,n,a){renderers.string(e,t,r,n,a)},renderers.any=function(e,t,r,n,a){renderers.string(e,t,r,n,a)},renderers.string=function(e,t,r,n,a){var i,o=getSchemaId(t),s=getSchema(o);if("any"===s.type)i=document.createElement("textarea"),a&&(i.value=JSON.stringify(a,null,4),s.readOnly&&(i.disabled=!0));else if(s.media)i=document.createElement("input"),i.type="file",appendChild(i,u,s);else if(s["enum"]){if(i=document.createElement("select"),!s.required){var u=document.createElement("option"),l=document.createTextNode("");u.value="",appendChild(u,l,s),appendChild(i,u,s)}for(var d=0,p=0;pe.length))return BrutusinForms.messages.minLength.format(s.minLength);if(s.maxLength&&e&&s.maxLength=s.maximum)return BrutusinForms.messages.exclusiveMaximum.format(s.maximum);if(!s.exclusiveMaximum&&e>s.maximum)return BrutusinForms.messages.maximum.format(s.maximum)}if(s.hasOwnProperty("minimum")){if(s.exclusiveMinimum&&e<=s.minimum)return BrutusinForms.messages.exclusiveMinimum.format(s.minimum);if(!s.exclusiveMinimum&&eu.maxProperties?BrutusinForms.messages.maxProperties.format(u.maxProperties):void 0}),C.description&&(E.title=C.description),appendChild(E,document.createTextNode("Add "+O),u),appendChild(P,E,u),a)for(var S in a)if(!u.properties.hasOwnProperty(S)){var V=RegExp(O);-1!==S.search(V)&&-1===x.indexOf(S)&&(o(l,d,t+"["+O+"]",S,a[S]),x.push(S))}appendChild(w,P,u)}if(u.additionalProperties){var I=getSchema(u.additionalProperties),E=document.createElement("button");if(E.setAttribute("type","button"),E.onclick=function(){o(l,d,t+"[*]",void 0)},(u.maxProperties||u.minProperties)&&(E.getValidationError=function(){return u.minProperties&&c+d.rows.lengthu.maxProperties?BrutusinForms.messages.maxProperties.format(u.maxProperties):void 0}),I.description&&(E.title=I.description),appendChild(E,document.createTextNode("Add"),u),appendChild(w,E,u),a)for(var S in a)u.properties.hasOwnProperty(S)||-1===x.indexOf(S)&&o(l,d,t+'["'+m+'"]',S,a[S],void 0)}appendChild(e,w,u)}else appendChild(e,d,u)},renderers.array=function(e,t,r,n,a){function i(e,t,r,n,a){var i=getSchemaId(r),o=getSchema(i),s=document.createElement("tbody"),u=document.createElement("tr");u.className="item";var l=document.createElement("td");l.className="item-index";var d=document.createElement("td");d.className="item-action";var p=document.createElement("td");p.className="item-value";var c=document.createElement("button");c.setAttribute("type","button"),c.className="remove",a===!0&&(c.disabled=!0),appendChild(c,document.createTextNode("x"),o);var m=function(){for(var e=0;ep.rows.length?BrutusinForms.messages.minItems.format(s.minItems):s.maxItems&&s.maxItemsr.length)&&(t=r.length),t-=e.length;var n=r.indexOf(e,t);return-1!==n&&n===t}),String.prototype.includes||(String.prototype.includes=function(){"use strict";return-1!==String.prototype.indexOf.apply(this,arguments)}),String.prototype.format||(String.prototype.format=function(){for(var e=this,t=0;t0)throw"Error parsing expression '"+e+"': Multiple tokens found inside a bracket";o+=u,i++}else r[r.length]=u;if(s===n.length-1&&a)throw"Error parsing expression '"+e+"': Unbalanced [ found"}this.exp=e,this.queue=r,this.visit=function(e,t){function r(e,n,a,i,o){if(null!=a){var s=n.shift();if("$"===s){e="$";var s=n.shift()}if(s)if(Array.isArray(a)){if(!s.startsWith("["))throw"Node '"+e+"' is of type array";var u=s.substring(1,s.length-1);if(u.equals("#"))for(var l=0;lp)throw"Element '"+u+"' of node '"+e+"' is lower than zero";var d=a[p];r(e+s,n.slice(0),d,a,p)}}else{if("object"!=typeof a)throw"boolean"==typeof a||"number"==typeof a||"string"==typeof a?"Node is leaf but still are tokens remaining: "+s:"Node type '"+typeof a+"' not supported for index field '"+e+"'";if("[*]"===s)for(var c in a){var d=a[c];r(e+s,n.slice(0),d,a,c),r(e+'["'+c+'"]',n.slice(0),d,a,c)}else{var d;if(s.startsWith("[")){var u=s.substring(1,s.length-1);if(!u.startsWith('"')&&!u.startsWith("'"))throw"Element '"+u+"' of node '"+e+"' must be a string expression or wilcard '*'";u=u.substring(1,u.length()-1),e+=s,d=a[u]}else e=e.length>0?e+"."+s:s,d=a[s];r(e,n,d,a,s)}}else t(a,i,o)}}r(this.exp,this.queue,e)}}var SCHEMA_ANY={type:"any"},obj=new Object,schemaMap=new Object,dependencyMap=new Object,renderInfoMap=new Object,container,data,error,initialValue,inputCounter=0,root=schema,formId="BrutusinForms#"+BrutusinForms.instances.length;populateSchemaMap("$",schema),validateDepencyMapIsAcyclic();var renderers=new Object;return renderers.integer=function(e,t,r,n,a){renderers.string(e,t,r,n,a)},renderers.number=function(e,t,r,n,a){renderers.string(e,t,r,n,a)},renderers.any=function(e,t,r,n,a){renderers.string(e,t,r,n,a)},renderers.string=function(e,t,r,n,a){var i,o=getSchemaId(t),s=getSchema(o);if("any"===s.type)i=document.createElement("textarea"),a&&(i.value=JSON.stringify(a,null,4),s.readOnly&&(i.disabled=!0));else if(s.media)i=document.createElement("input"),i.type="file",appendChild(i,u,s);else if(s["enum"]){if(i=document.createElement("select"),!s.required){var u=document.createElement("option"),l=document.createTextNode("");u.value="",appendChild(u,l,s),appendChild(i,u,s)}for(var d=0,p=0;pe.length))return BrutusinForms.messages.minLength.format(s.minLength);if(s.maxLength&&e&&s.maxLength=s.maximum)return BrutusinForms.messages.exclusiveMaximum.format(s.maximum);if(!s.exclusiveMaximum&&e>s.maximum)return BrutusinForms.messages.maximum.format(s.maximum)}if(s.hasOwnProperty("minimum")){if(s.exclusiveMinimum&&e<=s.minimum)return BrutusinForms.messages.exclusiveMinimum.format(s.minimum);if(!s.exclusiveMinimum&&eu.maxProperties?BrutusinForms.messages.maxProperties.format(u.maxProperties):void 0}),C.description&&(E.title=C.description),appendChild(E,document.createTextNode("Add "+O),u),appendChild(P,E,u),a)for(var S in a)if(!u.properties.hasOwnProperty(S)){var V=RegExp(O);-1!==S.search(V)&&-1===x.indexOf(S)&&(o(l,d,t+"["+O+"]",S,a[S]),x.push(S))}appendChild(w,P,u)}if(u.additionalProperties){var I=getSchema(u.additionalProperties),E=document.createElement("button");if(E.setAttribute("type","button"),E.onclick=function(){o(l,d,t+"[*]",void 0)},(u.maxProperties||u.minProperties)&&(E.getValidationError=function(){return u.minProperties&&c+d.rows.lengthu.maxProperties?BrutusinForms.messages.maxProperties.format(u.maxProperties):void 0}),I.description&&(E.title=I.description),appendChild(E,document.createTextNode("Add"),u),appendChild(w,E,u),a)for(var S in a)u.properties&&u.properties.hasOwnProperty(S)||-1===x.indexOf(S)&&o(l,d,t+'["'+m+'"]',S,a[S],void 0)}appendChild(e,w,u)}else appendChild(e,d,u)},renderers.array=function(e,t,r,n,a){function i(e,t,r,n,a){var i=getSchemaId(r),o=getSchema(i),s=document.createElement("tbody"),u=document.createElement("tr");u.className="item";var l=document.createElement("td");l.className="item-index";var d=document.createElement("td");d.className="item-action";var p=document.createElement("td");p.className="item-value";var c=document.createElement("button");c.setAttribute("type","button"),c.className="remove",a===!0&&(c.disabled=!0),appendChild(c,document.createTextNode("x"),o);var m=function(){for(var e=0;ep.rows.length?BrutusinForms.messages.minItems.format(s.minItems):s.maxItems&&s.maxItems