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

Modified FormItemStatics to use NumericTextControl.

Changeset 7b1badb1185b

Parent 86d8132c79d7

by Profile picture of William GrossWilliam Gross

Changes to one file · Browse files at 7b1badb1185b Showing diff from parent 86d8132c79d7 Diff from another changeset...

 
104
105
106
 
 
 
 
 
 
 
 
 
 
 
 
 
107
108
109
 
165
166
167
168
169
 
 
170
171
172
173
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
 
745
746
747
748
 
 
749
750
751
 
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
178
179
180
 
 
181
182
183
184
 
 
 
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
 
 
 
 
 
 
221
222
223
 
779
780
781
 
782
783
784
785
786
@@ -104,6 +104,19 @@
  dv =>   "{0}.ToUrlControl( allowEmpty, setup: controlSetup, value: value, maxLength: {1}, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"   .FormatWith( dv, field.Size?.ToString() ?? "null" ) ); + writeFormItemGetter( + writer, + field, + "NumericTextControl", + getAllowEmptyParameter( false ).ToCollection(), + false, + new CSharpParameter( "NumericTextControlSetup", "controlSetup", defaultValue: "null" ).ToCollection(), + "string", + new CSharpParameter( "int?", "minLength", defaultValue: "null" ).ToCollection(), + true, + dv => + "{0}.ToNumericTextControl( allowEmpty, setup: controlSetup, value: value, minLength: minLength, maxLength: {1}, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )" + .FormatWith( dv, field.Size?.ToString() ?? "null" ) );   writeFormItemGetters(   writer,   field, @@ -165,25 +178,46 @@
  }     private static void writeNumericFormItemGetters( TextWriter writer, ModificationField field ) { - if( field.TypeIs( typeof( int ) ) ) { - writeNumberAsTextFormItemGetters( + if( field.TypeIs( typeof( int ) ) || field.TypeIs( typeof( long ) ) ) + writeFormItemGetter(   writer,   field, - "int?", - new[] { new CSharpParameter( "int", "min", "int.MinValue" ), new CSharpParameter( "int", "max", "int.MaxValue" ) }, - "validator.GetInt( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), min, max )" ); + "TextControl", + Enumerable.Empty<CSharpParameter>(), + false, + new CSharpParameter( "NumericTextControlSetup", "controlSetup", defaultValue: "null" ).ToCollection(), + "SpecifiedValue<{0}>".FormatWith( field.NullableTypeName ), + new CSharpParameter( field.NullableTypeName, "minValue", "null" ).ToCollection() + .Append( new CSharpParameter( field.NullableTypeName, "maxValue", "null" ) ), + true, + dv => + "{0}.ToTextControl( setup: controlSetup, value: value, minValue: minValue, maxValue: maxValue, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )" + .FormatWith( dv ) ); + if( field.TypeIs( typeof( int? ) ) || field.TypeIs( typeof( long? ) ) ) + writeFormItemGetter( + writer, + field, + "TextControl", + Enumerable.Empty<CSharpParameter>(), + false, + new CSharpParameter( "NumericTextControlSetup", "controlSetup", defaultValue: "null" ).ToCollection(), + "SpecifiedValue<{0}>".FormatWith( field.NullableTypeName ), + getAllowEmptyParameter( true ) + .ToCollection() + .Append( new CSharpParameter( field.NullableTypeName, "minValue", "null" ) ) + .Append( new CSharpParameter( field.NullableTypeName, "maxValue", "null" ) ), + true, + dv => + "{0}.ToTextControl( setup: controlSetup, value: value, allowEmpty: allowEmpty, minValue: minValue, maxValue: maxValue, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )" + .FormatWith( dv ) ); + + if( field.TypeIs( typeof( int ) ) ) {   writeNumberAsSelectListFormItemGetters( writer, field );   writeDurationFormItemGetter( writer, field );   writeHtmlAndFileFormItemGetters( writer, field, "int?" );   writeFileCollectionFormItemGetters( writer, field, "int" );   }   if( field.TypeIs( typeof( int? ) ) ) { - writeNumberAsTextFormItemGetters( - writer, - field, - "int?", - new[] { getAllowEmptyParameter( true ), new CSharpParameter( "int", "min", "int.MinValue" ), new CSharpParameter( "int", "max", "int.MaxValue" ) }, - "validator.GetNullableInt( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty, min: min, max: max )" );   writeNumberAsSelectListFormItemGetters( writer, field );   writeDurationFormItemGetter( writer, field );   writeHtmlAndFileFormItemGetters( writer, field, "int?" ); @@ -745,7 +779,8 @@
  var statements = new[]   {   "if( validationPredicate != null && !validationPredicate() ) return;", - ( includeValidationMethodReturnValue ? fieldPropertyName + " = " : "" ) + "validationMethod( control, postBackValues, labelAndSubject, validator );", + ( includeValidationMethodReturnValue ? fieldPropertyName + " = " : "" ) + + "validationMethod( control, postBackValues, labelAndSubject, validator );",   "if( validator.ErrorsOccurred && validationErrorNotifier != null ) validationErrorNotifier();",   "if( !validator.ErrorsOccurred && additionalValidationMethod != null ) additionalValidationMethod( labelAndSubject, validator );"   };