|
| 1 | +@namespace MudExtensions.UnitTests.TestComponents |
| 2 | +@using MudBlazor.Extensions |
| 3 | + |
| 4 | +<MudGrid> |
| 5 | + <MudItem xs="12" sm="8" Class="d-flex flex-column align-center justify-center"> |
| 6 | + <MudTransferList @ref="_transferList" T="string" @bind-StartCollection="_startCollection" @bind-EndCollection="_endCollection" Vertical="_vertical" Color="_color" |
| 7 | + StyleListCommon="background-color: var(--mud-palette-background-gray); width: 200px" MultiSelection="_multiSelection" MaxItems="_maxItems" SelectAllType="_selectAllType" |
| 8 | + PreventTransfer="@(new Func<bool, bool>(CheckTransfer))" OrderFunc="@(_orderOnTransfer == false ? null : new Func<ICollection<string>, ICollection<string>>(OrderMethod))" ButtonVariant="_buttonVariant" |
| 9 | + AllowDoubleClick="_allowDoubleClick" SearchBoxStart="_searchboxStart" SearchBoxEnd="_searchboxEnd" |
| 10 | + StartTitle="@_startTitle" EndTitle="@_endTitle" /> |
| 11 | + </MudItem> |
| 12 | + |
| 13 | + <MudItem xs="12" sm="4"> |
| 14 | + <MudStack Spacing="4"> |
| 15 | + <MudText><b>Start Collection:</b> @string.Join(", ", _startCollection ?? new List<string>())</MudText> |
| 16 | + <MudText><b>End Collection:</b> @string.Join(", ", _endCollection ?? new List<string>())</MudText> |
| 17 | + <MudSwitchM3 @bind-Value="_vertical" Label="Vertical" Color="Color.Secondary" /> |
| 18 | + <MudSwitchM3 @bind-Value="_multiSelection" Label="MultiSelection" Color="Color.Secondary" /> |
| 19 | + <MudSwitchM3 @bind-Value="_preventTurkeyTransfer" Label="Prevent Transfer If Turkey Selected" Color="Color.Secondary" /> |
| 20 | + <MudSwitchM3 @bind-Value="_orderOnTransfer" Label="Order on Transfer" Color="Color.Secondary" /> |
| 21 | + <MudSwitchM3 @bind-Value="_allowDoubleClick" Label="Allow Double Click" Color="Color.Secondary" /> |
| 22 | + <MudSwitchM3 @bind-Value="_searchboxStart" Label="SearchBox Start" Color="Color.Secondary" /> |
| 23 | + <MudSwitchM3 @bind-Value="_searchboxEnd" Label="SearchBox End" Color="Color.Secondary" /> |
| 24 | + <MudNumericField @bind-Value="_maxItems" Clearable="true" Label="MaxItems" Variant="Variant.Outlined" Margin="Margin.Dense" /> |
| 25 | + <MudSelectExtended @bind-Value="_selectAllType" ItemCollection="@(Enum.GetValues<SelectAllType>())" Label="SelectAll Type" Variant="Variant.Outlined" Margin="Margin.Dense" Dense="true" /> |
| 26 | + <MudSelectExtended @bind-Value="_color" ItemCollection="@(Enum.GetValues<Color>())" Label="Color" Variant="Variant.Outlined" Margin="Margin.Dense" Dense="true" /> |
| 27 | + <MudSelectExtended @bind-Value="_buttonVariant" ItemCollection="@(Enum.GetValues<Variant>())" Label="Button Variant" Variant="Variant.Outlined" Margin="Margin.Dense" Dense="true" /> |
| 28 | + <MudTextFieldExtended @bind-Value="_startTitle" Label="Start Title" Variant="Variant.Outlined" Immediate="true" /> |
| 29 | + <MudTextFieldExtended @bind-Value="_endTitle" Label="End Title" Variant="Variant.Outlined" Immediate="true" /> |
| 30 | + </MudStack> |
| 31 | + </MudItem> |
| 32 | +</MudGrid> |
| 33 | + |
| 34 | +@code{ |
| 35 | + MudTransferList<string> _transferList = new(); |
| 36 | + ICollection<string> _startCollection = new List<string>() { "Sweden", "Hungary", "Turkey", "England", "Egypt" }; |
| 37 | + ICollection<string> _endCollection = new List<string>() { "Brazil", "China", "Germany", "USA", "South Africa" }; |
| 38 | + |
| 39 | + bool _vertical; |
| 40 | + bool _multiSelection; |
| 41 | + bool _preventTurkeyTransfer; |
| 42 | + bool _orderOnTransfer; |
| 43 | + bool _allowDoubleClick; |
| 44 | + bool _searchboxStart; |
| 45 | + bool _searchboxEnd; |
| 46 | + int? _maxItems; |
| 47 | + SelectAllType _selectAllType = SelectAllType.Buttons; |
| 48 | + Color _color = Color.Primary; |
| 49 | + Variant _buttonVariant = Variant.Text; |
| 50 | + string _startTitle = "Country Group 1"; |
| 51 | + string _endTitle = "Country Group 2"; |
| 52 | + |
| 53 | + private bool CheckTransfer(bool startToEnd) |
| 54 | + { |
| 55 | + var valuesStart = _transferList.GetStartListSelectedValues(); |
| 56 | + var valuesEnd = _transferList.GetEndListSelectedValues(); |
| 57 | + if (_preventTurkeyTransfer == true && (valuesStart?.Contains("Turkey") == true || valuesEnd?.Contains("Turkey") == true)) |
| 58 | + { |
| 59 | + return true; |
| 60 | + } |
| 61 | + return false; |
| 62 | + } |
| 63 | + |
| 64 | + private ICollection<string> OrderMethod(ICollection<string> e) |
| 65 | + { |
| 66 | + return e.Order().ToList(); |
| 67 | + } |
| 68 | +} |
0 commit comments