forked from CodeBeamOrg/CodeBeam.MudBlazor.Extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransferListTest.razor
More file actions
68 lines (62 loc) · 4.11 KB
/
TransferListTest.razor
File metadata and controls
68 lines (62 loc) · 4.11 KB
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
@namespace MudExtensions.UnitTests.TestComponents
@using MudBlazor.Extensions
<MudGrid>
<MudItem xs="12" sm="8" Class="d-flex flex-column align-center justify-center">
<MudTransferList @ref="_transferList" T="string" @bind-StartCollection="_startCollection" @bind-EndCollection="_endCollection" Vertical="_vertical" Color="_color"
StyleListCommon="background-color: var(--mud-palette-background-gray); width: 200px" MultiSelection="_multiSelection" MaxItems="_maxItems" SelectAllType="_selectAllType"
PreventTransfer="@(new Func<bool, bool>(CheckTransfer))" OrderFunc="@(_orderOnTransfer == false ? null : new Func<ICollection<string>, ICollection<string>>(OrderMethod))" ButtonVariant="_buttonVariant"
AllowDoubleClick="_allowDoubleClick" SearchBoxStart="_searchboxStart" SearchBoxEnd="_searchboxEnd"
StartTitle="@_startTitle" EndTitle="@_endTitle" />
</MudItem>
<MudItem xs="12" sm="4">
<MudStack Spacing="4">
<MudText><b>Start Collection:</b> @string.Join(", ", _startCollection ?? new List<string>())</MudText>
<MudText><b>End Collection:</b> @string.Join(", ", _endCollection ?? new List<string>())</MudText>
<MudSwitchM3 @bind-Value="_vertical" Label="Vertical" Color="Color.Secondary" />
<MudSwitchM3 @bind-Value="_multiSelection" Label="MultiSelection" Color="Color.Secondary" />
<MudSwitchM3 @bind-Value="_preventTurkeyTransfer" Label="Prevent Transfer If Turkey Selected" Color="Color.Secondary" />
<MudSwitchM3 @bind-Value="_orderOnTransfer" Label="Order on Transfer" Color="Color.Secondary" />
<MudSwitchM3 @bind-Value="_allowDoubleClick" Label="Allow Double Click" Color="Color.Secondary" />
<MudSwitchM3 @bind-Value="_searchboxStart" Label="SearchBox Start" Color="Color.Secondary" />
<MudSwitchM3 @bind-Value="_searchboxEnd" Label="SearchBox End" Color="Color.Secondary" />
<MudNumericField @bind-Value="_maxItems" Clearable="true" Label="MaxItems" Variant="Variant.Outlined" Margin="Margin.Dense" />
<MudSelectExtended @bind-Value="_selectAllType" ItemCollection="@(Enum.GetValues<SelectAllType>())" Label="SelectAll Type" Variant="Variant.Outlined" Margin="Margin.Dense" Dense="true" />
<MudSelectExtended @bind-Value="_color" ItemCollection="@(Enum.GetValues<Color>())" Label="Color" Variant="Variant.Outlined" Margin="Margin.Dense" Dense="true" />
<MudSelectExtended @bind-Value="_buttonVariant" ItemCollection="@(Enum.GetValues<Variant>())" Label="Button Variant" Variant="Variant.Outlined" Margin="Margin.Dense" Dense="true" />
<MudTextFieldExtended @bind-Value="_startTitle" Label="Start Title" Variant="Variant.Outlined" Immediate="true" />
<MudTextFieldExtended @bind-Value="_endTitle" Label="End Title" Variant="Variant.Outlined" Immediate="true" />
</MudStack>
</MudItem>
</MudGrid>
@code{
MudTransferList<string> _transferList = new();
ICollection<string> _startCollection = new List<string>() { "Sweden", "Hungary", "Turkey", "England", "Egypt" };
ICollection<string> _endCollection = new List<string>() { "Brazil", "China", "Germany", "USA", "South Africa" };
bool _vertical;
bool _multiSelection;
bool _preventTurkeyTransfer;
bool _orderOnTransfer;
bool _allowDoubleClick;
bool _searchboxStart;
bool _searchboxEnd;
int? _maxItems;
SelectAllType _selectAllType = SelectAllType.Buttons;
Color _color = Color.Primary;
Variant _buttonVariant = Variant.Text;
string _startTitle = "Country Group 1";
string _endTitle = "Country Group 2";
private bool CheckTransfer(bool startToEnd)
{
var valuesStart = _transferList.GetStartListSelectedValues();
var valuesEnd = _transferList.GetEndListSelectedValues();
if (_preventTurkeyTransfer == true && (valuesStart?.Contains("Turkey") == true || valuesEnd?.Contains("Turkey") == true))
{
return true;
}
return false;
}
private ICollection<string> OrderMethod(ICollection<string> e)
{
return e.Order().ToList();
}
}