@@ -4,24 +4,25 @@ import canonicalTitleMap from './canonicalTitleMap';
44/* Utils */
55const stripNullType = ( type ) => {
66 if ( Array . isArray ( type ) && type . length == 2 ) {
7- if ( type [ 0 ] === 'null' )
7+ if ( type [ 0 ] === 'null' ) {
88 return type [ 1 ] ;
9- if ( type [ 1 ] === 'null' )
9+ } ;
10+ if ( type [ 1 ] === 'null' ) {
1011 return type [ 0 ] ;
11- }
12+ } ;
13+ } ;
1214 return type ;
1315} ;
1416
1517//Creates an default titleMap list from an enum, i.e. a list of strings.
1618const enumToTitleMap = ( enm ) => {
1719 const titleMap = [ ] ; //canonical titleMap format is a list.
1820 enm . forEach ( ( name ) => {
19- titleMap . push ( { name, value : name } ) ;
21+ titleMap . push ( { name, value : name } ) ;
2022 } ) ;
2123 return titleMap ;
2224} ;
2325
24-
2526/**
2627 * Creates a default form definition from a schema.
2728 */
@@ -83,8 +84,7 @@ export function stdFormObj(name, schema, options) {
8384 f . ngModelOptions = f . ngModelOptions || { } ;
8485
8586 return f ;
86- }
87-
87+ } ;
8888
8989/*** Schema types to form type mappings, with defaults ***/
9090export function text ( name , schema , options ) {
@@ -162,7 +162,7 @@ export function fieldset(name, schema, options, defaultFormDef) {
162162 f . items = [ ] ;
163163 options . lookup [ stringify ( options . path ) ] = f ;
164164
165- console . log ( 'fieldset' , f , schema )
165+ console . log ( 'fieldset' , f , schema ) ;
166166 //recurse down into properties
167167 if ( schema . properties ) {
168168 Object . keys ( schema . properties ) . forEach ( ( key ) => {
@@ -207,13 +207,15 @@ export function array(name, schema, options, defaultFormDef) {
207207 const arrPath = options . path . slice ( ) ;
208208 arrPath . push ( '' ) ;
209209
210- f . items = [ defaultFormDef ( name , schema . items , {
211- path : arrPath ,
212- required : required || false ,
213- lookup : options . lookup ,
214- ignore : options . ignore ,
215- global : options . global
216- } ) ] ;
210+ f . items = [
211+ defaultFormDef ( name , schema . items , {
212+ path : arrPath ,
213+ required : required || false ,
214+ lookup : options . lookup ,
215+ ignore : options . ignore ,
216+ global : options . global
217+ } )
218+ ] ;
217219
218220 return f ;
219221 }
@@ -223,14 +225,15 @@ export function createDefaults() {
223225 //First sorted by schema type then a list.
224226 //Order has importance. First handler returning an form snippet will be used.
225227 return {
226- string : [ select , text ] ,
227- object : [ fieldset ] ,
228- number : [ number ] ,
229- integer : [ integer ] ,
230- boolean : [ checkbox ] , defaultForm
228+ string : [ select , text ] ,
229+ object : [ fieldset ] ,
230+ number : [ number ] ,
231+ integer : [ integer ] ,
232+ boolean : [ checkbox ] ,
233+ array : [ array ] ,
234+ defaultForm : defaultForm
231235 } ;
232- }
233-
236+ } ;
234237
235238/**
236239 * Create form defaults from schema
@@ -246,7 +249,7 @@ export function defaultForm(schema, defaultSchemaTypes, ignore, globalOptions) {
246249 if ( ignore [ key ] !== true ) {
247250 const required = schema . required && schema . required . indexOf ( key ) !== - 1 ;
248251 const def = defaultFormDefinition ( defaultSchemaTypes , key , schema . properties [ key ] , {
249- path : [ key ] , // Path to this property in bracket notation.
252+ path : [ key ] , // Path to this property in bracket notation.
250253 lookup : lookup , // Extra map to register with. Optimization for merger.
251254 ignore : ignore , // The ignore list of paths (sans root level name)
252255 required : required , // Is it required? (v4 json schema style)
@@ -261,5 +264,5 @@ export function defaultForm(schema, defaultSchemaTypes, ignore, globalOptions) {
261264 } else {
262265 throw new Error ( 'Not implemented. Only type "object" allowed at root level of schema.' ) ;
263266 }
264- return { form : form , lookup : lookup } ;
267+ return { form : form , lookup : lookup } ;
265268}
0 commit comments