@@ -315,7 +315,34 @@ if (typeof brutusin === "undefined") {
315315 input . onchange ( ) ;
316316 appendChild ( container , input , s ) ;
317317 } ;
318+ renderers [ "oneOf" ] = function ( container , id , parentObject , propertyProvider , value ) {
319+ var schemaId = getSchemaId ( id ) ;
320+ var s = getSchema ( schemaId ) ;
321+ var input = document . createElement ( "select" ) ;
322+ var display = document . createElement ( "div" ) ;
323+ display . innerHTML = "selected object goes here" ;
324+ var selectedIndex = 0 ;
325+ input . type = "select" ;
326+ input . schema = schemaId ;
327+ var noption = document . createElement ( "option" ) ;
328+ noption . value = null ;
329+ appendChild ( input , noption , s ) ;
330+ for ( var i = 0 ; i < s . oneOf . length ; i ++ ) {
331+ var option = document . createElement ( "option" ) ;
332+ var propId = id + "." + i ;
333+ var ss = getSchema ( propId ) ;
334+ var textNode = document . createTextNode ( ss . title ) ;
335+ option . value = s . oneOf [ i ] ;
336+ appendChild ( option , textNode , s ) ;
337+ appendChild ( input , option , s ) ;
338+ }
339+ input . onchange = function ( ) {
340+ render ( null , display , id + "." + ( input . selectedIndex - 1 ) , parentObject , propertyProvider , value ) ;
341+ }
342+ appendChild ( container , input , s ) ;
343+ appendChild ( container , display , s ) ;
318344
345+ }
319346 renderers [ "object" ] = function ( container , id , parentObject , propertyProvider , value ) {
320347
321348 function createStaticPropertyProvider ( propname ) {
@@ -486,7 +513,7 @@ if (typeof brutusin === "undefined") {
486513 appendChild ( container , table , s ) ;
487514 }
488515 } ;
489-
516+ // end of object renderer
490517 renderers [ "array" ] = function ( container , id , parentObject , propertyProvider , value ) {
491518 function addItem ( current , table , id , value ) {
492519 var schemaId = getSchemaId ( id ) ;
@@ -574,7 +601,7 @@ if (typeof brutusin === "undefined") {
574601 }
575602 appendChild ( container , div , s ) ;
576603 } ;
577-
604+ // end of array render
578605 /**
579606 * Renders the form inside the the container, with the specified data preloaded
580607 * @param {type } c container
@@ -736,7 +763,16 @@ if (typeof brutusin === "undefined") {
736763 } else if ( schema . type === "array" ) {
737764 pseudoSchema . items = name + "[#]" ;
738765 populateSchemaMap ( pseudoSchema . items , schema . items ) ;
739- }
766+ } else if ( schema . hasOwnProperty ( "oneOf" ) ) {
767+ pseudoSchema . oneOf = new Array ( ) ;
768+ pseudoSchema . type = "oneOf" ;
769+ for ( var i in schema . oneOf ) {
770+ console . log ( schema . oneOf [ i ] ) ;
771+ var childProp = name + "." + i ;
772+ pseudoSchema . oneOf [ i ] = childProp ;
773+ populateSchemaMap ( childProp , schema . oneOf [ i ] ) ;
774+ }
775+ }
740776 if ( schema . hasOwnProperty ( "dependsOn" ) ) {
741777 if ( schema . dependsOn === null ) {
742778 schema . dependsOn = [ "$" ] ;
@@ -824,6 +860,7 @@ if (typeof brutusin === "undefined") {
824860 }
825861
826862 function render ( titleContainer , container , id , parentObject , propertyProvider , value ) {
863+ console . log ( id ) ;
827864 var schemaId = getSchemaId ( id ) ;
828865 var s = getSchema ( schemaId ) ;
829866 renderInfoMap [ schemaId ] = new Object ( ) ;
@@ -834,6 +871,7 @@ if (typeof brutusin === "undefined") {
834871 renderInfoMap [ schemaId ] . value = value ;
835872 clear ( titleContainer ) ;
836873 clear ( container ) ;
874+ console . log ( s . type , id , s ) ;
837875 var r = renderers [ s . type ] ;
838876 if ( r && ! s . dependsOn ) {
839877 if ( s . title ) {
0 commit comments