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

Reimplemented CheckboxList and ChangeBasedCheckboxList to use new checkboxes.

Changeset 7cbbff7af3b3

Parent 13f37cf98382

by Profile picture of William GrossWilliam Gross

Changes to 16 files · Browse files at 7cbbff7af3b3 Showing diff from parent 13f37cf98382 Diff from another changeset...

Change 1 of 1 Show Entire File Core/​Core.csproj Stacked
 
405
406
407
 
408
409
410
 
405
406
407
408
409
410
411
@@ -405,6 +405,7 @@
  <Compile Include="EnterpriseWebFramework\Form Controls\Imprecise Number Control\ImpreciseNumberControlSetup.cs" />   <Compile Include="EnterpriseWebFramework\Form Controls\Lists\Checkbox Lists\ChangeBasedCheckboxList.cs" />   <Compile Include="EnterpriseWebFramework\Form Controls\Lists\Checkbox Lists\CheckboxList.cs" /> + <Compile Include="EnterpriseWebFramework\Form Controls\Lists\Checkbox Lists\CheckboxListSetup.cs" />   <Compile Include="EnterpriseWebFramework\Form Controls\Lists\Free-Form Radio List\FreeFormRadioList.cs" />   <Compile Include="EnterpriseWebFramework\Form Controls\Lists\Free-Form Radio List\FreeFormRadioListSetup.cs" />   <Compile Include="EnterpriseWebFramework\Form Controls\Lists\List Items\ChangeBasedListItem.cs" />
 
626
627
628
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
630
631
 
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
@@ -626,6 +626,25 @@
  } );   }   + /// <summary> + /// Creates a checkbox list for this data value. + /// </summary> + /// <param name="dataValue"></param> + /// <param name="setup">The setup object for the checkbox list. Do not pass null.</param> + /// <param name="value"></param> + /// <param name="additionalValidationMethod"></param> + public static CheckboxList<ItemIdType> ToCheckboxList<ItemIdType>( + this DataValue<IEnumerable<ItemIdType>> dataValue, CheckboxListSetup<ItemIdType> setup, IEnumerable<ItemIdType> value = null, + Action<Validator> additionalValidationMethod = null ) { + return new CheckboxList<ItemIdType>( + setup, + value ?? dataValue.Value, + validationMethod: ( postBackValue, validator ) => { + dataValue.Value = postBackValue; + additionalValidationMethod?.Invoke( validator ); + } ); + } +   public static DateControl ToDateControl(   this DataValue<LocalDate> dataValue, DateControlSetup setup = null, SpecifiedValue<LocalDate?> value = null, LocalDate? minValue = null,   LocalDate? maxValue = null, Action<Validator> additionalValidationMethod = null ) {
 
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
86
87
88
89
90
91
92
93
94
95
96
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
 
 
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
86
87
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
@@ -1,141 +1,89 @@
 using System;  using System.Collections.Generic; +using System.Collections.Immutable;  using System.Linq; -using System.Web.UI; -using System.Web.UI.WebControls; -using EnterpriseWebLibrary.EnterpriseWebFramework.Controls;    namespace EnterpriseWebLibrary.EnterpriseWebFramework {   /// <summary> - /// A check box list that is based on changes to the selections rather than the absolute set of selected items. + /// A checkbox list that is based on changes to the selections rather than the absolute set of selected items.   /// </summary> - public static class ChangeBasedCheckBoxList { + public static class ChangeBasedCheckboxList {   /// <summary> - /// Creates a form item with a change based check box list, which is a check box list that is based on changes to the selections rather than the absolute - /// set of selected items. + /// Creates a change-based checkbox list, which is a checkbox list that is based on changes to the selections rather than the absolute set of selected + /// items.   /// </summary> - /// <typeparam name="ItemIdType"></typeparam> - /// <param name="label"></param> - /// <param name="items"></param> - /// <param name="selectedItemIds"></param> + /// <param name="items">The items in the list.</param> + /// <param name="selectedItemIds">The selected-item IDs.</param>   /// <param name="modificationMethod">A method that executes the change handlers of the items that were selected or deselected on this post back.</param> - /// <param name="caption"></param> + /// <param name="displaySetup"></param>   /// <param name="includeSelectAndDeselectAllButtons"></param> - /// <param name="numberOfColumns"></param> + /// <param name="minColumnWidth">The minimum width of each column in the list. Pass null to force a single column.</param>   /// <param name="uiSelectedItemIds"></param> - /// <param name="action"></param> - /// <param name="cellSpan"></param> - /// <param name="textAlignment"></param> + /// <param name="action">The action that will occur when the user hits Enter on any of the checkboxes. Pass null to use the current default action.</param> + /// <param name="selectionChangedAction">The action that will occur when the selection is changed. Pass null for no action.</param>   /// <param name="validationPredicate"></param> - /// <returns></returns> - public static FormItem GetFormItem<ItemIdType>( - FormItemLabel label, IEnumerable<ChangeBasedListItem<ItemIdType>> items, IEnumerable<ItemIdType> selectedItemIds, out Action modificationMethod, - string caption = "", bool includeSelectAndDeselectAllButtons = false, byte numberOfColumns = 1, IEnumerable<ItemIdType> uiSelectedItemIds = null, - FormAction action = null, int? cellSpan = null, TextAlignment textAlignment = TextAlignment.NotSpecified, Func<bool> validationPredicate = null ) { - var checkBoxList = new ChangeBasedCheckBoxList<ItemIdType>( - items, - selectedItemIds, - caption, - includeSelectAndDeselectAllButtons, - numberOfColumns, - uiSelectedItemIds ?? selectedItemIds, - action ); - modificationMethod = checkBoxList.ModifyData; - return FormItem.Create( - label, - checkBoxList, - setup: new FormItemSetup( cellSpan: cellSpan, textAlignment: textAlignment ), - validationGetter: control => new EwfValidation( - ( pbv, validator ) => { - if( validationPredicate != null && !validationPredicate() ) - return; - control.Validate( pbv ); - } ) ); + /// <param name="validationErrorNotifier"></param> + public static CheckboxList<ItemIdType> Create<ItemIdType>( + IEnumerable<ChangeBasedListItem<ItemIdType>> items, IEnumerable<ItemIdType> selectedItemIds, out Action modificationMethod, + DisplaySetup displaySetup = null, bool includeSelectAndDeselectAllButtons = false, ContentBasedLength minColumnWidth = null, + IEnumerable<ItemIdType> uiSelectedItemIds = null, FormAction action = null, FormAction selectionChangedAction = null, + Func<bool, bool> validationPredicate = null, Action validationErrorNotifier = null ) { + items = items.Materialize(); + var selectedItemIdSet = selectedItemIds.ToImmutableHashSet(); + + ImmutableHashSet<ItemIdType> selectedItemIdsInPostBack = null; + modificationMethod = () => { + if( selectedItemIdsInPostBack == null ) + return; + var changedItemIds = selectedItemIdsInPostBack.Except( selectedItemIdSet ).Union( selectedItemIdSet.Except( selectedItemIdsInPostBack ) ).ToArray(); + foreach( var i in items.Where( i => changedItemIds.Contains( i.Item.Id ) ) ) + i.ChangeHandler( selectedItemIdsInPostBack.Contains( i.Item.Id ) ); + }; + + return new CheckboxList<ItemIdType>( + CheckboxListSetup.Create( + from i in items select i.Item, + displaySetup: displaySetup, + includeSelectAndDeselectAllButtons: includeSelectAndDeselectAllButtons, + minColumnWidth: minColumnWidth, + action: action, + selectionChangedAction: selectionChangedAction, + validationPredicate: validationPredicate, + validationErrorNotifier: validationErrorNotifier ), + uiSelectedItemIds ?? selectedItemIdSet, + validationMethod: ( postBackValue, validator ) => selectedItemIdsInPostBack = postBackValue.ToImmutableHashSet() );   }     /// <summary> - /// Creates a form item with a change based check box list, which is a check box list that is based on changes to the selections rather than the absolute - /// set of selected items. + /// Creates a change-based checkbox list, which is a checkbox list that is based on changes to the selections rather than the absolute set of selected + /// items.   /// </summary> - /// <typeparam name="ItemIdType"></typeparam> - /// <param name="label"></param> - /// <param name="items"></param> + /// <param name="items">The items in the list.</param>   /// <param name="modificationMethod">A method that executes the change handlers of the items that were selected or deselected on this post back.</param> - /// <param name="caption"></param> + /// <param name="displaySetup"></param>   /// <param name="includeSelectAndDeselectAllButtons"></param> - /// <param name="numberOfColumns"></param> - /// <param name="action"></param> - /// <param name="cellSpan"></param> - /// <param name="textAlignment"></param> + /// <param name="minColumnWidth">The minimum width of each column in the list. Pass null to force a single column.</param> + /// <param name="action">The action that will occur when the user hits Enter on any of the checkboxes. Pass null to use the current default action.</param> + /// <param name="selectionChangedAction">The action that will occur when the selection is changed. Pass null for no action.</param>   /// <param name="validationPredicate"></param> - /// <returns></returns> - public static FormItem GetFormItem<ItemIdType>( - FormItemLabel label, IEnumerable<ChangeBasedListItemWithSelectionState<ItemIdType>> items, out Action modificationMethod, string caption = "", - bool includeSelectAndDeselectAllButtons = false, byte numberOfColumns = 1, FormAction action = null, int? cellSpan = null, - TextAlignment textAlignment = TextAlignment.NotSpecified, Func<bool> validationPredicate = null ) { - var itemArray = items.ToArray(); - var selectedItemIds = itemArray.Where( i => i.IsSelected ).Select( i => i.Item.Item.Id ); - var uiSelectedItemIds = itemArray.Where( i => i.IsSelectedInUi ).Select( i => i.Item.Item.Id ); - var checkBoxList = new ChangeBasedCheckBoxList<ItemIdType>( - itemArray.Select( i => i.Item ), - selectedItemIds, - caption, - includeSelectAndDeselectAllButtons, - numberOfColumns, - uiSelectedItemIds, - action ); - modificationMethod = checkBoxList.ModifyData; - return FormItem.Create( - label, - checkBoxList, - setup: new FormItemSetup( cellSpan: cellSpan, textAlignment: textAlignment ), - validationGetter: control => new EwfValidation( - ( pbv, validator ) => { - if( validationPredicate != null && !validationPredicate() ) - return; - control.Validate( pbv ); - } ) ); + /// <param name="validationErrorNotifier"></param> + public static CheckboxList<ItemIdType> Create<ItemIdType>( + IEnumerable<ChangeBasedListItemWithSelectionState<ItemIdType>> items, out Action modificationMethod, DisplaySetup displaySetup = null, + bool includeSelectAndDeselectAllButtons = false, ContentBasedLength minColumnWidth = null, FormAction action = null, + FormAction selectionChangedAction = null, Func<bool, bool> validationPredicate = null, Action validationErrorNotifier = null ) { + items = items.Materialize(); + return Create( + from i in items select i.Item, + from i in items where i.IsSelected select i.Item.Item.Id, + out modificationMethod, + displaySetup: displaySetup, + includeSelectAndDeselectAllButtons: includeSelectAndDeselectAllButtons, + minColumnWidth: minColumnWidth, + uiSelectedItemIds: from i in items where i.IsSelectedInUi select i.Item.Item.Id, + action: action, + selectionChangedAction: selectionChangedAction, + validationPredicate: validationPredicate, + validationErrorNotifier: validationErrorNotifier );   }   } - - internal sealed class ChangeBasedCheckBoxList<ItemIdType>: WebControl { - private readonly IEnumerable<ChangeBasedListItem<ItemIdType>> items; - private readonly IEnumerable<ItemIdType> selectedItemIds; - - private readonly EwfCheckBoxList<ItemIdType> checkBoxList; - private IEnumerable<ItemIdType> selectedItemIdsInPostBack; - - internal ChangeBasedCheckBoxList( - IEnumerable<ChangeBasedListItem<ItemIdType>> items, IEnumerable<ItemIdType> selectedItemIds, string caption, bool includeSelectAndDeselectAllButtons, - byte numberOfColumns, IEnumerable<ItemIdType> uiSelectedItemIds, FormAction action ) { - this.items = items.ToArray(); - this.selectedItemIds = selectedItemIds.ToArray(); - - Controls.Add( - checkBoxList = new EwfCheckBoxList<ItemIdType>( - this.items.Select( i => i.Item ), - uiSelectedItemIds, - caption: caption, - includeSelectAndDeselectAllButtons: includeSelectAndDeselectAllButtons, - numberOfColumns: numberOfColumns, - action: action ) ); - } - - internal void Validate( PostBackValueDictionary postBackValues ) { - selectedItemIdsInPostBack = checkBoxList.GetSelectedItemIdsInPostBack( postBackValues ); - } - - internal void ModifyData() { - if( selectedItemIdsInPostBack == null ) - return; - var changedItemIds = selectedItemIdsInPostBack.Except( selectedItemIds ).Union( selectedItemIds.Except( selectedItemIdsInPostBack ) ).ToArray(); - foreach( var i in items.Where( i => changedItemIds.Contains( i.Item.Id ) ) ) - i.ChangeHandler( selectedItemIdsInPostBack.Contains( i.Item.Id ) ); - } - - /// <summary> - /// Returns the tag that represents this control in HTML. - /// </summary> - protected override HtmlTextWriterTag TagKey => HtmlTextWriterTag.Div; - }  } \ No newline at end of file
 
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
 
 
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
102
103
104
105
106
107
108
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
111
112
 
@@ -1,84 +1,112 @@
 using System;  using System.Collections.Generic; +using System.Collections.Immutable;  using System.Linq; -using System.Web.UI; -using System.Web.UI.WebControls; -using EnterpriseWebLibrary.EnterpriseWebFramework.Controls; +using EnterpriseWebLibrary.InputValidation; +using Humanizer;    namespace EnterpriseWebLibrary.EnterpriseWebFramework {   // We can't nest this inside the class below because of the type parameter. - internal class CheckBoxListCssElementCreator: ControlCssElementCreator { - internal const string CssClass = "ewfStandardCheckBoxList"; + internal class CheckboxListCssElementCreator: ControlCssElementCreator { + internal static readonly ElementClass ListClass = new ElementClass( "ewfCheckboxList" ); + internal static readonly ElementClass ActionContainerClass = new ElementClass( "ewfClA" ); + internal static readonly ElementClass ContentContainerClass = new ElementClass( "ewfClC" );     IReadOnlyCollection<CssElement> ControlCssElementCreator.CreateCssElements() { - return new[] { new CssElement( "CheckBoxList", "div." + CssClass ) }; + return new[] + { + new CssElement( "CheckboxList", "div.{0}".FormatWith( ListClass.ClassName ) ), + new CssElement( "CheckboxListActionContainer", "div.{0}".FormatWith( ActionContainerClass.ClassName ) ), + new CssElement( "CheckboxListContentContainer", "div.{0}".FormatWith( ContentContainerClass.ClassName ) ) + };   }   }     /// <summary> - /// A check box list that allows multiple items to be selected. + /// A checkbox list, which allows multiple items to be selected.   /// NOTE: Consider using something like the multi select feature of http://harvesthq.github.com/chosen/ to provide a space-saving mode for this control.   /// </summary> - public sealed class EwfCheckBoxList<ItemIdType>: WebControl { - private readonly IEnumerable<SelectListItem<ItemIdType>> items; - - private readonly Dictionary<SelectListItem<ItemIdType>, BlockCheckBox> checkBoxesByItem = new Dictionary<SelectListItem<ItemIdType>, BlockCheckBox>(); + public sealed class CheckboxList<ItemIdType>: FormControl<FlowComponent> { + public FlowComponent PageComponent { get; } + public EwfValidation Validation { get; }     /// <summary> - /// Creates a check box list. + /// Creates a checkbox list.   /// </summary> - public EwfCheckBoxList( - IEnumerable<SelectListItem<ItemIdType>> items, IEnumerable<ItemIdType> selectedItemIds, string caption = "", bool includeSelectAndDeselectAllButtons = false, - byte numberOfColumns = 1, FormAction action = null ) { - this.items = items.ToArray(); - selectedItemIds = selectedItemIds.ToArray(); + /// <param name="setup">The setup object for the checkbox list. Do not pass null.</param> + /// <param name="value">The selected-item IDs.</param> + /// <param name="validationMethod">The validation method. Pass null if you’re only using this control for page modification.</param> + public CheckboxList( + CheckboxListSetup<ItemIdType> setup, IEnumerable<ItemIdType> value, Action<IReadOnlyCollection<ItemIdType>, Validator> validationMethod = null ) { + var valueSet = value.ToImmutableHashSet();   - CssClass = CssClass.ConcatenateWithSpace( CheckBoxListCssElementCreator.CssClass ); + var selectedItemIdsInPostBack = new List<ItemIdType>(); + var selectionChangedOnPostBack = false; + var checkboxes = setup.Items.Select( + i => new FlowCheckbox( + valueSet.Contains( i.Id ), + i.Label.ToComponents(), + setup: FlowCheckboxSetup.Create( highlightedWhenChecked: true, action: setup.Action, valueChangedAction: setup.SelectionChangedAction ), + validationMethod: ( postBackValue, validator ) => { + if( postBackValue.Value ) + selectedItemIdsInPostBack.Add( i.Id ); + selectionChangedOnPostBack = selectionChangedOnPostBack || postBackValue.ChangedOnPostBack; + } ) ) + .Materialize();   - var table = new DynamicTable { Caption = caption }; - if( includeSelectAndDeselectAllButtons ) { - table.AddActionLink( new ActionButtonSetup( "Select All", new CustomButton( () => string.Format( @"toggleCheckBoxes( '{0}', true )", ClientID ) ) ) ); - table.AddActionLink( new ActionButtonSetup( "Deselect All", new CustomButton( () => string.Format( @"toggleCheckBoxes( '{0}', false )", ClientID ) ) ) ); - } + var contentContainerId = new ElementId(); + PageComponent = new GenericFlowContainer( + ( setup.IncludeSelectAndDeselectAllButtons + ? new GenericFlowContainer( + new InlineList( + new EwfButton( + new StandardButtonStyle( + "Select All", + buttonSize: ButtonSize.ShrinkWrap, + icon: new ActionComponentIcon( new FontAwesomeIcon( "fa-check-square-o" ) ) ), + behavior: new CustomButtonBehavior( + () => "$( '#{0}' ).find( 'input[type=checkbox]:not(:checked)' ).click();".FormatWith( contentContainerId.Id ) ) ).ToCollection() + .ToComponentListItem() + .ToCollection() + .Append( + new EwfButton( + new StandardButtonStyle( + "Deselect All", + buttonSize: ButtonSize.ShrinkWrap, + icon: new ActionComponentIcon( new FontAwesomeIcon( "fa-square-o" ) ) ), + behavior: new CustomButtonBehavior( + () => "$( '#{0}' ).find( 'input[type=checkbox]:checked' ).click();".FormatWith( contentContainerId.Id ) ) ).ToCollection() + .ToComponentListItem() ) ).ToCollection(), + classes: CheckboxListCssElementCreator.ActionContainerClass ).ToCollection() + : Enumerable.Empty<FlowComponent>() ).Append( + new DisplayableElement( + context => { + contentContainerId.AddId( context.Id ); + return new DisplayableElementData( + null, + () => new DisplayableElementLocalData( + "div", + focusDependentData: new DisplayableElementFocusDependentData( + attributes: setup.MinColumnWidth != null + ? Tuple.Create( "style", "column-width: {0}".FormatWith( ( (CssLength)setup.MinColumnWidth ).Value ) ).ToCollection() + : null, + includeIdAttribute: true ) ), + classes: CheckboxListCssElementCreator.ContentContainerClass, + children: new RawList( from i in checkboxes select i.PageComponent.ToCollection().ToComponentListItem() ).ToCollection() ); + } ) ) + .Materialize(), + displaySetup: setup.DisplaySetup, + classes: CheckboxListCssElementCreator.ListClass );   - var itemsPerColumn = (int)Math.Ceiling( (decimal)this.items.Count() / numberOfColumns ); - var cells = new List<EwfTableCell>(); - for( byte i = 0; i < numberOfColumns; i += 1 ) { - var maxIndex = Math.Min( ( i + 1 ) * itemsPerColumn, this.items.Count() ); - var place = new PlaceHolder(); - for( var j = i * itemsPerColumn; j < maxIndex; j += 1 ) { - var item = this.items.ElementAt( j ); - var checkBox = new BlockCheckBox( - selectedItemIds.Contains( item.Id ), - item.Label.ToComponents(), - setup: new BlockCheckBoxSetup( highlightedWhenChecked: true, action: action ), - validationMethod: ( postBackValue, validator ) => {} ); - place.Controls.Add( checkBox ); - checkBoxesByItem.Add( item, checkBox ); - } - cells.Add( place ); - } - table.AddRow( cells.ToArray() ); - Controls.Add( table ); + if( validationMethod != null ) + Validation = new EwfValidation( + validator => { + if( setup.ValidationPredicate != null && !setup.ValidationPredicate( selectionChangedOnPostBack ) ) + return; + validationMethod( selectedItemIdsInPostBack, validator ); + } );   }   - /// <summary> - /// Gets the selected item IDs in the post back. - /// </summary> - public IEnumerable<ItemIdType> GetSelectedItemIdsInPostBack( PostBackValueDictionary postBackValues ) { - return items.Where( i => checkBoxesByItem[ i ].IsCheckedInPostBack( postBackValues ) ).Select( i => i.Id ).ToArray(); - } - - /// <summary> - /// Returns true if the selections changed on this post back. - /// </summary> - public bool SelectionsChangedOnPostBack( PostBackValueDictionary postBackValues ) { - return items.Any( i => checkBoxesByItem[ i ].ValueChangedOnPostBack( postBackValues ) ); - } - - /// <summary> - /// Returns the tag that represents this control in HTML. - /// </summary> - protected override HtmlTextWriterTag TagKey { get { return HtmlTextWriterTag.Div; } } + FormControlLabeler FormControl<FlowComponent>.Labeler => null;   }  } \ No newline at end of file
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
 
@@ -0,0 +1,62 @@
+using System; +using System.Collections.Generic; + +namespace EnterpriseWebLibrary.EnterpriseWebFramework { + /// <summary> + /// The configuration for a checkbox list. + /// </summary> + public static class CheckboxListSetup { + /// <summary> + /// Creates a setup object for a checkbox list. + /// </summary> + /// <param name="items">The items in the list.</param> + /// <param name="displaySetup"></param> + /// <param name="includeSelectAndDeselectAllButtons"></param> + /// <param name="minColumnWidth">The minimum width of each column in the list. Pass null to force a single column.</param> + /// <param name="action">The action that will occur when the user hits Enter on any of the checkboxes. Pass null to use the current default action.</param> + /// <param name="selectionChangedAction">The action that will occur when the selection is changed. Pass null for no action.</param> + /// <param name="validationPredicate"></param> + /// <param name="validationErrorNotifier"></param> + public static CheckboxListSetup<ItemIdType> Create<ItemIdType>( + IEnumerable<SelectListItem<ItemIdType>> items, DisplaySetup displaySetup = null, bool includeSelectAndDeselectAllButtons = false, + ContentBasedLength minColumnWidth = null, FormAction action = null, FormAction selectionChangedAction = null, Func<bool, bool> validationPredicate = null, + Action validationErrorNotifier = null ) { + return new CheckboxListSetup<ItemIdType>( + displaySetup, + includeSelectAndDeselectAllButtons, + items, + minColumnWidth, + action, + selectionChangedAction, + validationPredicate, + validationErrorNotifier ); + } + } + + /// <summary> + /// The configuration for a checkbox list. + /// </summary> + public class CheckboxListSetup<ItemIdType> { + internal readonly DisplaySetup DisplaySetup; + internal readonly bool IncludeSelectAndDeselectAllButtons; + internal readonly IReadOnlyCollection<SelectListItem<ItemIdType>> Items; + internal readonly ContentBasedLength MinColumnWidth; + internal readonly FormAction Action; + internal readonly FormAction SelectionChangedAction; + internal readonly Func<bool, bool> ValidationPredicate; + internal readonly Action ValidationErrorNotifier; + + internal CheckboxListSetup( + DisplaySetup displaySetup, bool includeSelectAndDeselectAllButtons, IEnumerable<SelectListItem<ItemIdType>> items, ContentBasedLength minColumnWidth, + FormAction action, FormAction selectionChangedAction, Func<bool, bool> validationPredicate, Action validationErrorNotifier ) { + DisplaySetup = displaySetup; + IncludeSelectAndDeselectAllButtons = includeSelectAndDeselectAllButtons; + Items = items.Materialize(); + MinColumnWidth = minColumnWidth; + Action = action; + SelectionChangedAction = selectionChangedAction; + ValidationPredicate = validationPredicate; + ValidationErrorNotifier = validationErrorNotifier; + } + } +} \ No newline at end of file
 
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
166
167
168
 
 
 
 
 
 
 
 
169
170
171
@@ -166,14 +166,6 @@
  checkBoxParentDiv.removeClass( selectedCheckBoxClass );  }   -// Toggles the given checklist boxes based on the text of the link clicked - -function toggleCheckBoxes( checklistClientId, setChecked ) { - $( '#' + checklistClientId ).find( 'input[type=checkbox]' ).prop( 'checked', setChecked ).each( function( i, checkBox ) { - changeCheckBoxColor( checkBox ); - } ); -} -  // Supports DurationControl.  /*   * jQuery plugin: fieldSelection - v0.1.0 - last change: 2006-12-16
 
53
54
55
56
 
 
 
 
57
58
59
 
53
54
55
 
56
57
58
59
60
61
62
@@ -53,7 +53,10 @@
  }     IEnumerable<ResourceInfo> AppMetaLogicFactory.CreateEwfUiCssInfos() { - return new ResourceInfo[] { new Styles.EwfUi.ColorsCss.Info(), new Styles.EwfUi.FontsCss.Info(), new Styles.EwfUi.LayoutCss.Info() }; + return new ResourceInfo[] + { + new Styles.EwfUi.ColorsCss.Info(), new Styles.EwfUi.FontsCss.Info(), new Styles.EwfUi.LayoutCss.Info(), new Styles.EwfUi.TransitionsCss.Info() + };   }     ResourceInfo AppMetaLogicFactory.CreateModernizrJavaScriptInfo() {
 
175
176
177
178
179
180
181
182
183
184
185
 
209
210
211
 
 
 
 
 
 
 
 
 
 
212
213
214
 
175
176
177
 
 
 
 
 
178
179
180
 
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
@@ -175,11 +175,6 @@
  resize: none;  }   -/* drop-down lists */ -ewfControlStackItem > ewfDropDownList, ewfTableStandardAndStandardLayoutOnlyStyles > ewfTheadAndTfootAndTbody > ewfTrAllStates > ewfThAndTd > ewfDropDownList { - width: 100%; -} -  /* checkboxes */  ewfInlineCheckBox > ewfInlineCheckBoxBox, ewfInlineCheckBox > ewfInlineCheckBoxLabel {   vertical-align: middle; @@ -209,6 +204,16 @@
  margin-bottom: 0;  }   +/* list controls */ +ewfControlStackItem > ewfDropDownList, ewfTableStandardAndStandardLayoutOnlyStyles > ewfTheadAndTfootAndTbody > ewfTrAllStates > ewfThAndTd > ewfDropDownList { + width: 100%; +} +ewfCheckboxList > ewfCheckboxListContentContainer > ewfUnorderedComponentList { + margin: 0; + padding: 0; + list-style-type: none; +} +  /* date pickers, time pickers, and date and time pickers */  ewfDateControl, ewfDateAndTimeControl {   display: flex;
 
8
9
10
11
 
12
13
14
15
16
17
 
18
19
20
 
8
9
10
 
11
12
13
14
15
16
17
18
19
20
21
@@ -8,13 +8,14 @@
 ewfSectionBoxStyleBothStates > ewfSectionHeadingContainer > ewfSectionHeading,  ewfTableStandardAndStandardExceptLayoutStyles,  ewfTableStandardAndStandardExceptLayoutStyles > tbody > ewfTrStatesWithContrast, -ewfFlowCheckboxHighlightedState > ewfCheckbox, +ewfCheckboxList,  .checkedChecklistCheckboxDiv {   background-image: linear-gradient( rgba( 0, 0, 0, .05 ), rgba( 0, 0, 0, .05 ) );  }    /* block highlighting */  ewfTableStandardAndStandardExceptLayoutStyles > ewfTheadAndTfootAndTbody > ewfTrStatesWithActionAndWithHover, +ewfFlowCheckboxHighlightedState > ewfCheckbox,  ewfUiTopTabBlock ewfUiCurrentTabActionControl,  ewfUiSideTabBlock ewfUiCurrentTabActionControl {   background-color: #81989E;
 
82
83
84
85
86
87
88
89
90
91
 
164
165
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
168
 
169
170
171
 
172
173
174
 
179
180
181
182
 
 
183
184
185
 
201
202
203
204
 
 
205
206
207
 
82
83
84
 
 
 
 
85
86
87
 
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
180
181
182
 
183
184
185
186
 
191
192
193
 
194
195
196
197
198
 
214
215
216
 
217
218
219
220
221
@@ -82,10 +82,6 @@
 .ewfControlList tr:first-child td {   padding-top: 0;  } -ewfCheckBoxList table.ewfBlockCheckBox { - padding-top: .25em; - padding-bottom: .25em; -}    /* boxes */  ewfSectionBoxStyleBothStates { @@ -164,11 +160,27 @@
  text-decoration: underline;  }   +/* list controls */ +ewfCheckboxList { + padding: .5em; +} +ewfCheckboxList > ewfCheckboxListActionContainer { + margin-bottom: .5em; + text-align: right; +} +ewfCheckboxList > ewfCheckboxListContentContainer { + margin: -.25em; + column-gap: .5em; +} +ewfCheckboxList > ewfCheckboxListContentContainer > ewfUnorderedComponentList > ewfComponentListItem > ewfFlowCheckboxAllStates > ewfCheckbox { + padding: .25em; +} +  /* block element vertical spacing */ -p, ewfSectionNormalStyleBothStates > ewfSectionContentContainer, ewfUnorderedLineList, ewfUnorderedStackList, ewfUnorderedWrappingList, ewfHtmlBlock ul, .ewfControlList, div.ewfStandardDynamicTable, ewfTableStandardAndStandardLayoutOnlyStyles, ewfCheckBoxList, div.ewfStandardFileCollectionManager, ewfMergeFieldTreeContainer, ewfMergeRowTreeContainer, ewfMergeRowTreeChildContainer, ewfControlStack, div.ewfControlList, ewfHtmlBlockEditor, ewfSectionBoxStyleBothStates, ewfFormItemBlock, ewfLabeledControl, ewfChart, ewfUiEntityBlock > *, ewfUiGlobalFootBlock, ewfHtmlBlock { +p, ewfSectionNormalStyleBothStates > ewfSectionContentContainer, ewfUnorderedLineList, ewfUnorderedStackList, ewfUnorderedWrappingList, ewfHtmlBlock ul, .ewfControlList, div.ewfStandardDynamicTable, ewfTableStandardAndStandardLayoutOnlyStyles, ewfCheckboxList, div.ewfStandardFileCollectionManager, ewfMergeFieldTreeContainer, ewfMergeRowTreeContainer, ewfMergeRowTreeChildContainer, ewfControlStack, div.ewfControlList, ewfHtmlBlockEditor, ewfSectionBoxStyleBothStates, ewfFormItemBlock, ewfLabeledControl, ewfChart, ewfUiEntityBlock > *, ewfUiGlobalFootBlock, ewfHtmlBlock {   margin-top: 1em;  } -p:first-child, ewfUnorderedLineList:first-child, ewfUnorderedStackList:first-child, ewfUnorderedWrappingList:first-child, ewfHtmlBlock ul:first-child, .ewfControlList:first-child, div.ewfStandardDynamicTable:first-child, ewfTableStandardAndStandardLayoutOnlyStyles:first-child, ewfCheckBoxList:first-child, div.ewfStandardFileCollectionManager:first-child, ewfMergeFieldTreeContainer:first-child, ewfMergeRowTreeContainer:first-child, ewfMergeRowTreeChildContainer:first-child, ewfControlStack:first-child, div.ewfControlList:first-child, ewfHtmlBlockEditor:first-child, ewfSectionBoxStyleBothStates:first-child, ewfFormItemBlock:first-child, ewfLabeledControl:first-child, ewfChart:first-child, ewfUiEntityBlock > *:first-child, ewfHtmlBlock:first-child { +p:first-child, ewfUnorderedLineList:first-child, ewfUnorderedStackList:first-child, ewfUnorderedWrappingList:first-child, ewfHtmlBlock ul:first-child, .ewfControlList:first-child, div.ewfStandardDynamicTable:first-child, ewfTableStandardAndStandardLayoutOnlyStyles:first-child, ewfCheckboxList:first-child, div.ewfStandardFileCollectionManager:first-child, ewfMergeFieldTreeContainer:first-child, ewfMergeRowTreeContainer:first-child, ewfMergeRowTreeChildContainer:first-child, ewfControlStack:first-child, div.ewfControlList:first-child, ewfHtmlBlockEditor:first-child, ewfSectionBoxStyleBothStates:first-child, ewfFormItemBlock:first-child, ewfLabeledControl:first-child, ewfChart:first-child, ewfUiEntityBlock > *:first-child, ewfHtmlBlock:first-child {   margin-top: 0;  }  ewfUiPageActionAndContentAndContentFootCell { @@ -179,7 +191,8 @@
 }    /* corner rounding */ -ewfActionControlLargeButtonStyleAllStates { +ewfActionControlLargeButtonStyleAllStates, +ewfCheckboxList {   border-radius: .5em;  }  ewfSectionBoxStyleBothStates, ewfSectionBoxStyleBothStates > ewfSectionHeadingContainer > ewfSectionHeading, @@ -201,7 +214,8 @@
  ewfSectionBoxStyleBothStates, ewfSectionBoxStyleBothStates > ewfSectionHeadingContainer > ewfSectionHeading,   ewfTableStandardAndStandardExceptLayoutStyles,   ewfTableStandardAndStandardExceptLayoutStyles > tbody:last-child > ewfTrStatesWithContrast:last-child > ewfThAndTd:first-child, - ewfTableStandardAndStandardExceptLayoutStyles > tbody:last-child > ewfTrStatesWithContrast:last-child > ewfThAndTd:last-child { + ewfTableStandardAndStandardExceptLayoutStyles > tbody:last-child > ewfTrStatesWithContrast:last-child > ewfThAndTd:last-child, + ewfCheckboxList {   border-radius: 0;   }  }
Change 1 of 1 Show Entire File Web Site/​Ewf/​Styles/​EwfUi/​Transitions.css Stacked
 
 
 
 
 
 
1
2
3
 
@@ -0,0 +1,3 @@
+ewfFlowCheckboxAllStates > ewfCheckbox { + transition: background-color 200ms; +} \ No newline at end of file
Change 1 of 1 Show Entire File Web Site/​TestPages/​CheckboxListDemo.aspx Stacked
renamed from Web Site/TestPages/CheckBoxList.aspx
 
1
 
2
3
4
 
 
1
2
3
4
@@ -1,4 +1,4 @@
-<%@ Page Language="C#" CodeBehind="CheckBoxList.aspx.cs" Inherits="EnterpriseWebLibrary.WebSite.TestPages.CheckBoxList" MasterPageFile="~/Ewf/EwfUi.master" %> +<%@ Page Language="C#" CodeBehind="CheckboxListDemo.aspx.cs" Inherits="EnterpriseWebLibrary.WebSite.TestPages.CheckboxListDemo" MasterPageFile="~/Ewf/EwfUi.master" %>    <asp:Content runat="server" ContentPlaceHolderID="contentPlace">   <asp:PlaceHolder runat="server" ID="ph" />
Change 1 of 1 Show Entire File Web Site/​TestPages/​CheckboxListDemo.aspx.cs Stacked
renamed from Web Site/TestPages/CheckBoxList.aspx.cs
 
2
3
4
5
 
 
 
 
 
6
7
8
9
10
11
 
 
 
 
 
 
 
12
13
14
 
15
16
 
 
2
3
4
 
5
6
7
8
9
10
11
 
 
 
 
12
13
14
15
16
17
18
19
20
 
21
22
23
 
@@ -2,15 +2,22 @@
 using EnterpriseWebLibrary.EnterpriseWebFramework;    namespace EnterpriseWebLibrary.WebSite.TestPages { - public partial class CheckBoxList: EwfPage { + partial class CheckboxListDemo: EwfPage { + partial class Info { + public override string ResourceName => "Checkbox List"; + } +   protected override void loadData() {   ph.AddControlsReturnThis( - new EwfCheckBoxList<int>( - from i in Enumerable.Range( 0, 20 ) select SelectListItem.Create( i, "Item " + i ), - new[] { 3, 9, 19 }, - includeSelectAndDeselectAllButtons: true ) ); + new CheckboxList<int>( + CheckboxListSetup.Create( + from i in Enumerable.Range( 1, 20 ) select SelectListItem.Create( i, "Item " + i ), + includeSelectAndDeselectAllButtons: true, + minColumnWidth: 20.ToEm() ), + new[] { 3, 9, 19 } ).ToFormItem() + .ToControl() );   }   - public override bool IsAutoDataUpdater { get { return true; } } + public override bool IsAutoDataUpdater => true;   }  } \ No newline at end of file
Change 1 of 1 Show Entire File Web Site/​TestPages/​CheckboxListDemo.aspx.designer.cs Stacked
renamed from Web Site/TestPages/CheckBoxList.aspx.designer.cs
 
10
11
12
13
 
14
15
16
 
10
11
12
 
13
14
15
16
@@ -10,7 +10,7 @@
 namespace EnterpriseWebLibrary.WebSite.TestPages {     - public partial class CheckBoxList { + public partial class CheckboxListDemo {     /// <summary>   /// ph control.
 
27
28
29
30
31
 
32
33
34
 
27
28
29
 
30
31
32
33
34
@@ -27,8 +27,8 @@
  new TextControlDemo.Info( this ),   new NumberControlDemo.Info( this ),   new Checkboxes.Info( this ), - new CheckBoxList.Info( this ),   new SelectListDemo.Info( this ), + new CheckboxListDemo.Info( this ),   new DateAndTimePickers.Info( this ) ),   new ResourceGroup(   "Other",
 
243
244
245
246
247
 
 
248
249
250
251
 
 
252
253
254
 
487
488
489
 
490
491
492
 
526
527
528
529
 
530
531
532
 
243
244
245
 
 
246
247
248
249
 
 
250
251
252
253
254
 
487
488
489
490
491
492
493
 
527
528
529
 
530
531
532
533
@@ -243,12 +243,12 @@
  <Compile Include="TestPages\Checkboxes.aspx.designer.cs">   <DependentUpon>Checkboxes.aspx</DependentUpon>   </Compile> - <Compile Include="TestPages\CheckBoxList.aspx.cs"> - <DependentUpon>CheckBoxList.aspx</DependentUpon> + <Compile Include="TestPages\CheckboxListDemo.aspx.cs"> + <DependentUpon>CheckboxListDemo.aspx</DependentUpon>   <SubType>ASPXCodeBehind</SubType>   </Compile> - <Compile Include="TestPages\CheckBoxList.aspx.designer.cs"> - <DependentUpon>CheckBoxList.aspx</DependentUpon> + <Compile Include="TestPages\CheckboxListDemo.aspx.designer.cs"> + <DependentUpon>CheckboxListDemo.aspx</DependentUpon>   </Compile>   <Compile Include="TestPages\DateAndTimePickers.aspx.cs">   <DependentUpon>DateAndTimePickers.aspx</DependentUpon> @@ -487,6 +487,7 @@
  <Content Include="Ewf\Styles\EwfUi\Colors.css" />   <Content Include="Ewf\Styles\EwfUi\Fonts.css" />   <Content Include="Ewf\Styles\EwfUi\Layout.css" /> + <Content Include="Ewf\Styles\EwfUi\Transitions.css" />   <Content Include="Ewf\ThirdParty\SpinJs\spin.min.js" />   <Content Include="Ewf\ThirdParty\TimePicker\JavaScript.js" />   <Content Include="Ewf\ThirdParty\TimePicker\Styles.css" /> @@ -526,7 +527,7 @@
  <Content Include="TestPages\BoxDemo.aspx" />   <Content Include="TestPages\Charts.aspx" />   <Content Include="TestPages\Checkboxes.aspx" /> - <Content Include="TestPages\CheckBoxList.aspx" /> + <Content Include="TestPages\CheckboxListDemo.aspx" />   <Content Include="TestPages\ColumnPrimaryTableDemo.aspx" />   <Content Include="TestPages\DateAndTimePickers.aspx" />   <Content Include="TestPages\EwfTableDemo.aspx" />