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

Fixed page-modification bug in imprecise number control.

Changeset b3141cffb054

Parent e58f2e76d564

by Profile picture of William GrossWilliam Gross

Changes to 2 files · Browse files at b3141cffb054 Showing diff from parent e58f2e76d564 Diff from another changeset...

 
211
212
213
214
215
216
217
 
 
 
 
 
218
219
220
 
211
212
213
 
 
 
 
214
215
216
217
218
219
220
221
@@ -211,10 +211,11 @@
  context.Id,   "setTimeout( function() { " + valueChangedAction.GetJsStatements() + " }, 0 );" )   : "", - isImprecise - ? ( (PageModificationValue<decimal>)pageModificationValue ).GetJsModificationStatements( "Number( $( this ).val() )" ) - : ( (PageModificationValue<decimal?>)pageModificationValue ).GetJsModificationStatements( "Number( $( this ).val() )" ) - .Surround( "$( '#{0}' ).change( function() {{ ".FormatWith( context.Id ), " } );" ), + ( isImprecise + ? ( (PageModificationValue<decimal>)pageModificationValue ).GetJsModificationStatements( "Number( $( this ).val() )" ) + : ( (PageModificationValue<decimal?>)pageModificationValue ).GetJsModificationStatements( "Number( $( this ).val() )" ) ).Surround( + "$( '#{0}' ).change( function() {{ ".FormatWith( context.Id ), + " } );" ),   autoCompleteStatements );     return new DisplayableElementLocalData(
 
37
38
39
 
 
 
 
 
40
41
42
 
46
47
48
 
 
 
 
 
 
 
 
49
50
51
 
78
79
80
81
 
 
 
82
83
84
 
87
88
89
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
92
93
 
 
 
 
94
95
96
 
98
99
100
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
103
 
 
37
38
39
40
41
42
43
44
45
46
47
 
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
91
92
93
 
94
95
96
97
98
99
 
102
103
104
 
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
 
 
121
122
123
124
125
126
127
 
129
130
131
 
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
 
@@ -37,6 +37,11 @@
  FormState.Current.DataModifications.Append( pb ),   () => get( "Separate value-changed action", NumberControlSetup.Create( valueChangedAction: new PostBackFormAction( pb ) ) )( id ) );   }, + new Func<Func<string, FormItem>>( + () => { + var pmv = new PageModificationValue<decimal?>(); + return get( "Page modification", NumberControlSetup.Create( pageModificationValue: pmv ), pageModificationValue: pmv ); + } )(),   get( "Read-only", NumberControlSetup.CreateReadOnly() ), getImprecise( "Imprecise", null ),   getImprecise( "Imprecise [1,2] with .25 step", null, minValue: 1, maxValue: 2, valueStep: .25m ), id => {   var pb = PostBack.CreateIntermediate( null, id: id ); @@ -46,6 +51,14 @@
  "Imprecise with separate value-changed action",   ImpreciseNumberControlSetup.Create( valueChangedAction: new PostBackFormAction( pb ) ) )( id ) );   }, + new Func<Func<string, FormItem>>( + () => { + var pmv = new PageModificationValue<decimal>(); + return getImprecise( + "Imprecise with page modification", + ImpreciseNumberControlSetup.Create( pageModificationValue: pmv ), + pageModificationValue: pmv ); + } )(),   getImprecise( "Imprecise read-only", ImpreciseNumberControlSetup.CreateReadOnly() )   };   @@ -78,7 +91,9 @@
  };     private Func<string, FormItem> - get( string label, NumberControlSetup setup, decimal? minValue = null, decimal? maxValue = null, decimal? valueStep = null ) => + get( + string label, NumberControlSetup setup, PageModificationValue<decimal?> pageModificationValue = null, decimal? minValue = null, + decimal? maxValue = null, decimal? valueStep = null ) =>   id => new NumberControl(   null,   true, @@ -87,10 +102,26 @@
  maxValue: maxValue,   valueStep: valueStep,   validationMethod: ( postBackValue, validator ) => AddStatusMessage( StatusMessageType.Info, "{0}: {1}".FormatWith( id, postBackValue ) ) ).ToFormItem( - label: "{0}. {1}".FormatWith( id, label ).ToComponents() ); + label: "{0}. {1}".FormatWith( id, label ) + .ToComponents() + .Concat( + pageModificationValue != null + ? new LineBreak().ToCollection<PhrasingComponent>() + .Append( + new SideComments( + "Value: ".ToComponents() + .Concat( + pageModificationValue.ToGenericPhrasingContainer( + v => v?.Normalize().ToString() ?? "", + valueExpression => "{0}.toString()".FormatWith( valueExpression ) ) ) + .Materialize() ) ) + : Enumerable.Empty<PhrasingComponent>() ) + .Materialize() );   - private Func<string, FormItem> getImprecise( - string label, ImpreciseNumberControlSetup setup, decimal? minValue = null, decimal? maxValue = null, decimal? valueStep = null ) => + private Func<string, FormItem> + getImprecise( + string label, ImpreciseNumberControlSetup setup, PageModificationValue<decimal> pageModificationValue = null, decimal? minValue = null, + decimal? maxValue = null, decimal? valueStep = null ) =>   id => new ImpreciseNumberControl(   .25m,   minValue ?? 0, @@ -98,6 +129,20 @@
  setup: setup,   valueStep: valueStep,   validationMethod: ( postBackValue, validator ) => AddStatusMessage( StatusMessageType.Info, "{0}: {1}".FormatWith( id, postBackValue ) ) ).ToFormItem( - label: "{0}. {1}".FormatWith( id, label ).ToComponents() ); + label: "{0}. {1}".FormatWith( id, label ) + .ToComponents() + .Concat( + pageModificationValue != null + ? new LineBreak().ToCollection<PhrasingComponent>() + .Append( + new SideComments( + "Value: ".ToComponents() + .Concat( + pageModificationValue.ToGenericPhrasingContainer( + v => v.Normalize().ToString(), + valueExpression => "{0}.toString()".FormatWith( valueExpression ) ) ) + .Materialize() ) ) + : Enumerable.Empty<PhrasingComponent>() ) + .Materialize() );   }  } \ No newline at end of file