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

Added radio-button-group test code.

Changeset 5ce637791e85

Parent fb210883c3c9

by Profile picture of William GrossWilliam Gross

Changes to one file · Browse files at 5ce637791e85 Showing diff from parent fb210883c3c9 Diff from another changeset...

 
1
2
3
 
 
4
 
5
6
7
 
46
47
48
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
51
52
 
81
82
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
85
 
 
1
2
3
4
5
6
7
8
9
10
 
49
50
51
 
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
97
98
99
100
101
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
 
@@ -1,7 +1,10 @@
 using System;  using System.Collections.Generic;  using System.Linq; +using System.Web.UI; +using System.Web.UI.WebControls;  using EnterpriseWebLibrary.EnterpriseWebFramework; +using EnterpriseWebLibrary.EnterpriseWebFramework.Controls;  using EnterpriseWebLibrary.WebSessionState;  using Humanizer;   @@ -46,7 +49,20 @@
  nestedContentGetter: () => new Paragraph(   "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel diam quis felis accumsan tempus. Nunc hendrerit mi in hendrerit finibus. Nullam aliquet pharetra mauris ac vehicula. Quisque vehicula imperdiet pulvinar. Morbi ullamcorper est non arcu suscipit, quis interdum ex egestas. Sed vel risus vitae nisl scelerisque pretium. Aliquam vel pretium orci, eu scelerisque felis. Morbi ac auctor lacus, sit amet congue nunc."   .ToComponents() ).ToCollection(), - nestedContentAlwaysDisplayed: true ) ) + nestedContentAlwaysDisplayed: true ) ), + getRadioGroup( "Radio group", null ), + getRadioGroup( "Radio group with no selection", null, noSelection: true ), + getRadioGroup( "Radio group with single button", null, singleButton: true ), id => { + var pb = PostBack.CreateIntermediate( null, id: id ); + return FormState.ExecuteWithDataModificationsAndDefaultAction( + FormState.Current.DataModifications.Append( pb ), + () => getRadioGroup( "Radio group with separate selection-changed action", null, selectionChangedAction: new PostBackFormAction( pb ) )( id ) ); + }, + new Func<Func<string, FormItem>>( + () => { + var pmv = new PageModificationValue<bool>(); + return getRadioGroup( "Radio group with page modification", RadioButtonSetup.Create( pageModificationValue: pmv ), pageModificationValue: pmv ); + } )()   };     private Func<string, FormItem> getCheckbox( string label, CheckboxSetup setup, PageModificationValue<bool> pageModificationValue = null ) => @@ -81,5 +97,67 @@
  validationMethod: ( postBackValue, validator ) => AddStatusMessage(   StatusMessageType.Info,   "{0}: {1}".FormatWith( id, postBackValue.Value.ToString() ) ) ).ToFormItem( label: "{0}. {1}".FormatWith( id, label ).ToComponents() ); + + private Func<string, FormItem> getRadioGroup( + string label, RadioButtonSetup setup, bool noSelection = false, bool singleButton = false, FormAction selectionChangedAction = null, + PageModificationValue<bool> pageModificationValue = null ) => + id => { + var group = new RadioButtonGroup( noSelection, disableSingleButtonDetection: singleButton, selectionChangedAction: selectionChangedAction ); + return FormItem.Create( + new PlaceHolder().AddControlsReturnThis( + "{0}. {1}".FormatWith( id, label ) + .ToComponents() + .Concat( + pageModificationValue != null + ? new LineBreak().ToCollection<PhrasingComponent>() + .Append( + new SideComments( + "First button value: ".ToComponents() + .Concat( + pageModificationValue.ToGenericPhrasingContainer( + v => v.ToString(), + valueExpression => "{0} ? 'True' : 'False'".FormatWith( valueExpression ) ) ) + .Materialize() ) ) + : Enumerable.Empty<PhrasingComponent>() ) + .GetControls() ), + ControlStack.CreateWithControls( + true, + group + .CreateRadioButton( + !noSelection, + "First".ToComponents(), + setup: setup, + validationMethod: ( postBackValue, validator ) => AddStatusMessage( + StatusMessageType.Info, + "{0}-1: {1}".FormatWith( id, postBackValue.Value.ToString() ) ) ) + .ToFormItem() + .ToControl() + .ToCollection() + .Concat( + singleButton + ? Enumerable.Empty<Control>() + : group.CreateFlowRadioButton( + false, + "Second".ToComponents(), + setup: FlowRadioButtonSetup.Create( + nestedContentGetter: () => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sit.".ToComponents() ), + validationMethod: ( postBackValue, validator ) => AddStatusMessage( + StatusMessageType.Info, + "{0}-2: {1}".FormatWith( id, postBackValue.Value.ToString() ) ) ) + .ToFormItem() + .ToControl() + .ToCollection() + .Append( + group.CreateRadioButton( + false, + "Third".ToComponents(), + setup: RadioButtonSetup.Create(), + validationMethod: ( postBackValue, validator ) => AddStatusMessage( + StatusMessageType.Info, + "{0}-3: {1}".FormatWith( id, postBackValue.Value.ToString() ) ) ) + .ToFormItem() + .ToControl() ) ) + .ToArray() ) ); + };   }  } \ No newline at end of file