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

Improved checkbox test page.

Changeset e204134fcd88

Parent 7826d4ed4520

by Profile picture of William GrossWilliam Gross

Changes to one file · Browse files at e204134fcd88 Showing diff from parent 7826d4ed4520 Diff from another changeset...

 
 
 
 
1
2
 
 
3
4
5
6
7
8
9
10
11
 
 
 
 
 
 
 
12
13
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
16
 
 
1
2
3
4
 
5
6
7
8
9
10
11
 
 
 
 
12
13
14
15
16
17
18
19
20
 
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 
@@ -1,16 +1,85 @@
+using System; +using System.Collections.Generic; +using System.Linq;  using EnterpriseWebLibrary.EnterpriseWebFramework; -using EnterpriseWebLibrary.EnterpriseWebFramework.Controls; +using EnterpriseWebLibrary.WebSessionState; +using Humanizer;    namespace EnterpriseWebLibrary.WebSite.TestPages {   partial class Checkboxes: EwfPage {   protected override void loadData() {   ph.AddControlsReturnThis( - ControlStack.CreateWithControls( - true, - new Checkbox( false, label: "Checkbox".ToComponents() ).ToFormItem().ToControl(), - new FlowCheckbox( false, "Flow checkbox".ToComponents() ).ToFormItem().ToControl() ) ); + FormState.ExecuteWithDataModificationsAndDefaultAction( + PostBack.CreateFull().ToCollection(), + () => { + var table = FormItemBlock.CreateFormItemTable( formItems: getControls().Select( ( getter, i ) => getter( ( i + 1 ).ToString() ) ) ); + table.IncludeButtonWithThisText = "Submit"; + return table; + } ) );   }   - public override bool IsAutoDataUpdater => true; + private IReadOnlyCollection<Func<string, FormItem>> getControls() => + new[] + { + getCheckbox( "Standard", null ), id => { + var pb = PostBack.CreateIntermediate( null, id: id ); + return FormState.ExecuteWithDataModificationsAndDefaultAction( + FormState.Current.DataModifications.Append( pb ), + () => getCheckbox( "Separate value-changed action", CheckboxSetup.Create( valueChangedAction: new PostBackFormAction( pb ) ) )( id ) ); + }, + new Func<Func<string, FormItem>>( + () => { + var pmv = new PageModificationValue<bool>(); + return getCheckbox( "Page modification", CheckboxSetup.Create( pageModificationValue: pmv ), pageModificationValue: pmv ); + } )(), + getCheckbox( "Read-only", CheckboxSetup.CreateReadOnly() ), getFlowCheckbox( "Flow", null ), + getFlowCheckbox( "Flow with highlighting", FlowCheckboxSetup.Create( highlightedWhenChecked: true ) ), + getFlowCheckbox( + "Flow with nested content", + FlowCheckboxSetup.Create( + nestedContentGetter: () => new Paragraph( + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin id vestibulum neque. Suspendisse vel sem ac nunc condimentum tempus eget quis nunc. Morbi mattis elementum cursus. Integer eros mi, porttitor vitae orci eget, facilisis pretium diam. Aenean et nisi leo. Aenean nibh ligula, suscipit sit amet nulla ac, faucibus suscipit ipsum. Nunc quis faucibus ex." + .ToComponents() ).ToCollection() ) ), + getFlowCheckbox( + "Flow with nested content always displayed", + FlowCheckboxSetup.Create( + 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 ) ) + }; + + private Func<string, FormItem> getCheckbox( string label, CheckboxSetup setup, PageModificationValue<bool> pageModificationValue = null ) => + id => new Checkbox( + false, + "Lorem ipsum dolor sit amet".ToComponents(), + setup: setup, + validationMethod: ( postBackValue, validator ) => AddStatusMessage( + StatusMessageType.Info, + "{0}: {1}".FormatWith( id, postBackValue.Value.ToString() ) ) ).ToFormItem( + label: "{0}. {1}".FormatWith( id, label ) + .ToComponents() + .Concat( + pageModificationValue != null + ? new LineBreak().ToCollection<PhrasingComponent>() + .Append( + new SideComments( + "Value: ".ToComponents() + .Concat( + pageModificationValue.ToGenericPhrasingContainer( + v => v.ToString(), + valueExpression => "{0} ? 'True' : 'False'".FormatWith( valueExpression ) ) ) + .Materialize() ) ) + : Enumerable.Empty<PhrasingComponent>() ) + .Materialize() ); + + private Func<string, FormItem> getFlowCheckbox( string label, FlowCheckboxSetup setup ) => + id => new FlowCheckbox( + false, + "Lorem ipsum dolor sit amet".ToComponents(), + setup: setup, + validationMethod: ( postBackValue, validator ) => AddStatusMessage( + StatusMessageType.Info, + "{0}: {1}".FormatWith( id, postBackValue.Value.ToString() ) ) ).ToFormItem( label: "{0}. {1}".FormatWith( id, label ).ToComponents() );   }  } \ No newline at end of file