@@ -135,6 +135,7 @@ if (typeof brutusin === "undefined") {
135135 var initialValue ;
136136 var inputCounter = 0 ;
137137 var formId = "BrutusinForms#" + BrutusinForms . instances . length ;
138+ //console.log(schema);
138139 populateSchemaMap ( "$" , schema ) ;
139140
140141 validateDepencyMapIsAcyclic ( ) ;
@@ -192,7 +193,10 @@ if (typeof brutusin === "undefined") {
192193 }
193194 }
194195 }
195- input . selectedIndex = selectedIndex ;
196+ if ( s . enum . length == 1 )
197+ input . selectedIndex = 1 ;
198+ else
199+ input . selectedIndex = selectedIndex ;
196200 } else {
197201 input = document . createElement ( "input" ) ;
198202 if ( s . type === "integer" || s . type === "number" ) {
@@ -343,6 +347,7 @@ if (typeof brutusin === "undefined") {
343347 var option = document . createElement ( "option" ) ;
344348 var propId = id + "." + i ;
345349 var ss = getSchema ( propId ) ;
350+ //console.log(s,i,id,ss);
346351 var textNode = document . createTextNode ( ss . title ) ;
347352 option . value = s . oneOf [ i ] ;
348353 appendChild ( option , textNode , s ) ;
@@ -761,12 +766,23 @@ if (typeof brutusin === "undefined") {
761766 function populateSchemaMap ( name , schema ) {
762767 var pseudoSchema = createPseudoSchema ( schema ) ;
763768 schemaMap [ name ] = pseudoSchema ;
764- if ( schema . type === "object" ) {
769+
770+ if ( schema . hasOwnProperty ( "oneOf" ) ) {
771+ pseudoSchema . oneOf = new Array ( ) ;
772+ pseudoSchema . type = "oneOf" ;
773+ for ( var i in schema . oneOf ) {
774+ //console.log(schema.oneOf[i]);
775+ var childProp = name + "." + i ;
776+ pseudoSchema . oneOf [ i ] = childProp ;
777+ populateSchemaMap ( childProp , schema . oneOf [ i ] ) ;
778+ }
779+ } else if ( schema . type === "object" ) {
765780 if ( schema . properties ) {
766781 pseudoSchema . properties = new Object ( ) ;
767- for ( var prop in schema . properties ) {
782+ for ( var prop in schema . properties ) {
768783 var childProp = name + "." + prop ;
769784 pseudoSchema . properties [ prop ] = childProp ;
785+ console . log ( prop , childProp , schema ) ;
770786 populateSchemaMap ( childProp , schema . properties [ prop ] ) ;
771787 }
772788 }
@@ -782,16 +798,7 @@ if (typeof brutusin === "undefined") {
782798 } else if ( schema . type === "array" ) {
783799 pseudoSchema . items = name + "[#]" ;
784800 populateSchemaMap ( pseudoSchema . items , schema . items ) ;
785- } else if ( schema . hasOwnProperty ( "oneOf" ) ) {
786- pseudoSchema . oneOf = new Array ( ) ;
787- pseudoSchema . type = "oneOf" ;
788- for ( var i in schema . oneOf ) {
789- //console.log(schema.oneOf[i]);
790- var childProp = name + "." + i ;
791- pseudoSchema . oneOf [ i ] = childProp ;
792- populateSchemaMap ( childProp , schema . oneOf [ i ] ) ;
793- }
794- }
801+ }
795802 if ( schema . hasOwnProperty ( "dependsOn" ) ) {
796803 if ( schema . dependsOn === null ) {
797804 schema . dependsOn = [ "$" ] ;
0 commit comments