Ewl » Canonical The canonical version of EWL Read More
Clone URL:  
Pushed to 2 repositories · View In Graph Contained in tip and canonical

Added checkbox and radio button support to FormItemStatics.

Changeset f2a10e3c3401

Parent cb77a27c698b

by Profile picture of William GrossWilliam Gross

Changes to one file · Browse files at f2a10e3c3401 Showing diff from parent cb77a27c698b Diff from another changeset...

 
14
15
16
 
17
18
19
 
272
273
274
275
 
276
277
278
 
298
299
300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
302
303
 
368
369
370
371
 
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
 
402
403
404
 
14
15
16
17
18
19
20
 
273
274
275
 
276
277
278
279
 
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
 
430
431
432
 
433
434
435
436
437
438
439
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
440
441
442
443
@@ -14,6 +14,7 @@
  writeStringFormItemGetters( writer, field );   writer.WriteLine( "#pragma warning disable CS0618" ); // remove when EwfCheckBox and BlockCheckBox are gone   writeNumericFormItemGetters( writer, field ); + writeCheckboxFormItemGetters( writer, field );   writeBoolFormItemGetters( writer, field );   writer.WriteLine( "#pragma warning restore CS0618" ); // remove when EwfCheckBox and BlockCheckBox are gone   writeDateFormItemGetters( writer, field ); @@ -272,7 +273,7 @@
    if( field.TypeIs( typeof( decimal ) ) ) {   writeNumberAsSelectListFormItemGetters( writer, field ); - writeCheckBoxFormItemGetters( writer, field, "decimal" ); + writeLegacyCheckBoxFormItemGetters( writer, field, "decimal" );   writeDurationFormItemGetter( writer, field );   writeHtmlAndFileFormItemGetters( writer, field, "decimal?" );   writeFileCollectionFormItemGetters( writer, field, "decimal" ); @@ -298,6 +299,67 @@
  .FormatWith( minStep ) );   }   + private static void writeCheckboxFormItemGetters( TextWriter writer, ModificationField field ) { + if( !field.TypeIs( typeof( bool ) ) && !field.TypeIs( typeof( decimal ) ) ) + return; + + // checkboxes + writeFormItemGetter( + writer, + field, + "Checkbox", + new CSharpParameter[ 0 ], + true, + new[] { new CSharpParameter( "CheckboxSetup", "checkboxSetup", "null" ) }, + field.NullableTypeName, + new CSharpParameter[ 0 ], + true, + dv => + "{0}.ToCheckbox( label, setup: checkboxSetup, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: formItemLabel )" + .FormatWith( dv ) ); + writeFormItemGetter( + writer, + field, + "FlowCheckbox", + new CSharpParameter[ 0 ], + true, + new[] { new CSharpParameter( "FlowCheckboxSetup", "checkboxSetup", "null" ) }, + field.NullableTypeName, + new CSharpParameter[ 0 ], + true, + dv => + "{0}.ToFlowCheckbox( label, setup: checkboxSetup, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: formItemLabel )" + .FormatWith( dv ) ); + + // radio buttons + writeFormItemGetter( + writer, + field, + "RadioButton", + new CSharpParameter( "RadioButtonGroup", "group" ).ToCollection(), + true, + new[] { new CSharpParameter( "RadioButtonSetup", "radioButtonSetup", "null" ) }, + field.NullableTypeName, + new CSharpParameter[ 0 ], + true, + dv => + "{0}.ToRadioButton( group, label, setup: radioButtonSetup, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: formItemLabel )" + .FormatWith( dv ) ); + writeFormItemGetter( + writer, + field, + "FlowRadioButton", + new CSharpParameter( "RadioButtonGroup", "group" ).ToCollection(), + true, + new[] { new CSharpParameter( "FlowRadioButtonSetup", "radioButtonSetup", "null" ) }, + field.NullableTypeName, + new CSharpParameter[ 0 ], + true, + dv => + "{0}.ToFlowRadioButton( group, label, setup: radioButtonSetup, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: formItemLabel )" + .FormatWith( dv ) ); + } +   private static void writeFileCollectionFormItemGetters( TextWriter writer, ModificationField field, string valueParamTypeName ) {   writeFormItemGetters(   writer, @@ -368,37 +430,14 @@
    private static void writeBoolFormItemGetters( TextWriter writer, ModificationField field ) {   if( field.TypeIs( typeof( bool ) ) ) { - writeCheckBoxFormItemGetters( writer, field, "bool" ); + writeLegacyCheckBoxFormItemGetters( writer, field, "bool" );   writeNumberAsSelectListFormItemGetters( writer, field );   }   if( field.TypeIs( typeof( bool? ) ) )   writeNumberAsSelectListFormItemGetters( writer, field );   }   - private static void writeCheckBoxFormItemGetters( TextWriter writer, ModificationField field, string valueParamTypeName ) { - var fieldIsDecimal = valueParamTypeName == "decimal"; - var valueParamDefaultValue = fieldIsDecimal ? false.BooleanToDecimal().ToString() : "false"; - var toBoolSuffix = fieldIsDecimal ? ".DecimalToBoolean()" : ""; - var fromBoolSuffix = fieldIsDecimal ? ".BooleanToDecimal()" : ""; - - writeFormItemGetters( - writer, - field, - "EwfCheckBox", - "CheckBox", - valueParamTypeName, - valueParamDefaultValue, - new CSharpParameter[ 0 ], - new CSharpParameter[ 0 ], - new[] - { - new CSharpParameter( "bool", "putLabelOnCheckBox", "true" ), new CSharpParameter( "FormAction", "action", "null" ), - new CSharpParameter( "bool", "autoPostBack", "false" ) - }, - new CSharpParameter[ 0 ], - "new EwfCheckBox( v.Value" + toBoolSuffix + ", label: putLabelOnCheckBox ? ls : \"\", action: action ) { AutoPostBack = autoPostBack }", - "control.IsCheckedInPostBack( postBackValues )" + fromBoolSuffix, - "( putLabelOnCheckBox ? \"\" : (FormItemLabel)null )" ); + private static void writeLegacyCheckBoxFormItemGetters( TextWriter writer, ModificationField field, string valueParamTypeName ) {   writeFormItemGetter(   writer,   field,