Skip to content

Commit 76ff7c8

Browse files
authored
TransferList Support Complex Types and Splitter Bar Style (#148)
1 parent ae3efdd commit 76ff7c8

File tree

8 files changed

+57
-9
lines changed

8 files changed

+57
-9
lines changed

CodeBeam.MudBlazor.Extensions/Components/TransferList/MudTransferList.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@using MudExtensions.Enums
55

66
<MudStack Class="@Class" Style="@Style" Row="!Vertical" Spacing="Spacing">
7-
<MudListExtended @ref="_startList" Class="@StartClassname" Style="@StartStylename" OnDoubleClick="DoubleClick" T="T" ItemCollection="@StartCollection" Disabled="Disabled" Clickable="true" MultiSelection="@MultiSelection" SelectAll="@MultiSelection" MultiSelectionComponent="@MultiSelectionComponent" MaxItems="@MaxItems" Color="@Color">
7+
<MudListExtended @ref="_startList" Class="@StartClassname" Style="@StartStylename" OnDoubleClick="DoubleClick" T="T" ItemCollection="@StartCollection" Disabled="Disabled" Clickable="true" MultiSelection="@MultiSelection" SelectAll="@MultiSelection" MultiSelectionComponent="@MultiSelectionComponent" MaxItems="@MaxItems" Color="@Color" ToStringFunc="ToStringFunc">
88
<SelectAllTemplate>
99
@if (SelectAllType == SelectAllType.SelectAllItem)
1010
{
@@ -24,7 +24,7 @@
2424
<MudIconButton Icon="@(Vertical ? Icons.Material.Filled.KeyboardDoubleArrowUp : Icons.Material.Filled.KeyboardDoubleArrowLeft)" Disabled="Disabled" Color="@Color" Variant="@ButtonVariant" OnClick="@(() => TransferAll(false))" />
2525
}
2626
</div>
27-
<MudListExtended @ref="_endList" Class="@EndClassname" Style="@EndStylename" OnDoubleClick="DoubleClick" T="T" ItemCollection="@EndCollection" Disabled="Disabled" Clickable="true" MultiSelection="@MultiSelection" SelectAll="@MultiSelection" MultiSelectionComponent="@MultiSelectionComponent" MaxItems="@MaxItems" Color="@Color">
27+
<MudListExtended @ref="_endList" Class="@EndClassname" Style="@EndStylename" OnDoubleClick="DoubleClick" T="T" ItemCollection="@EndCollection" Disabled="Disabled" Clickable="true" MultiSelection="@MultiSelection" SelectAll="@MultiSelection" MultiSelectionComponent="@MultiSelectionComponent" MaxItems="@MaxItems" Color="@Color" ToStringFunc="ToStringFunc">
2828
<SelectAllTemplate>
2929
@if (SelectAllType == SelectAllType.SelectAllItem)
3030
{

CodeBeam.MudBlazor.Extensions/Components/TransferList/MudTransferList.razor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public partial class MudTransferList<T> : MudComponentBase
5454
[Parameter]
5555
public EventCallback<ICollection<T>> EndCollectionChanged { get; set; }
5656

57+
[Parameter]
58+
[Category(CategoryTypes.FormComponent.ListBehavior)]
59+
public Func<T, string> ToStringFunc { get; set; }
60+
5761
/// <summary>
5862
/// Fires before transfer process start. Useful to backup items or prevent transfer.
5963
/// </summary>

CodeBeam.MudBlazor.Extensions/Styles/Components/_splitter.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
}
5454

5555
.mud-splitter-thumb-disabled ::-webkit-slider-thumb {
56-
cursor: not-allowed !important;
56+
cursor: default !important;
5757
}
5858

5959
.mud-splitter-thumb ::-moz-range-thumb {
@@ -70,5 +70,5 @@
7070
}
7171

7272
.mud-splitter-thumb-disabled ::-moz-range-thumb {
73-
cursor: not-allowed !important;
73+
cursor: default !important;
7474
}

CodeBeam.MudBlazor.Extensions/Styles/MudExtensions.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
cursor: ew-resize !important; }
218218

219219
.mud-splitter-thumb-disabled ::-webkit-slider-thumb {
220-
cursor: not-allowed !important; }
220+
cursor: default !important; }
221221

222222
.mud-splitter-thumb ::-moz-range-thumb {
223223
visibility: visible !important;
@@ -232,7 +232,7 @@
232232
cursor: ew-resize !important; }
233233

234234
.mud-splitter-thumb-disabled ::-moz-range-thumb {
235-
cursor: not-allowed !important; }
235+
cursor: default !important; }
236236

237237
.mud-stepper-header {
238238
min-height: 62px;

CodeBeam.MudBlazor.Extensions/Styles/MudExtensions.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodeBeam.MudBlazor.Extensions/wwwroot/MudExtensions.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ComponentViewer.Docs/Pages/Components/TransferListPage.razor

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
<TransferListExampleIntro />
77
</ExampleCard>
88

9-
<ExampleCard ExampleName="TransferListExample1" Title="Usage" Description="">
9+
<ExampleCard ExampleName="TransferListExample1" Title="Usage" Description="The basics of the transferlist.">
1010
<TransferListExample1 />
1111
</ExampleCard>
12+
13+
<ExampleCard ExampleName="TransferListExample2" Title="Complex Types" Description="">
14+
<TransferListExample2 />
15+
</ExampleCard>
1216
</ExamplePage>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@using MudBlazor.Extensions
2+
3+
<MudGrid>
4+
<MudItem xs="12" sm="8" Class="d-flex flex-column align-center justify-center">
5+
<MudTransferList @ref="_transferList" T="ComplexTypes" @bind-StartCollection="_startCollection" @bind-EndCollection="_endCollection" Color="Color.Primary"
6+
StyleListCommon="background-color: var(--mud-palette-background-grey); width: 200px" AllowDoubleClick="true" ToStringFunc="@(e => e?.Name + " " + e?.SurName)" />
7+
</MudItem>
8+
9+
<MudItem xs="12" sm="4">
10+
<MudStack Spacing="4">
11+
12+
</MudStack>
13+
</MudItem>
14+
</MudGrid>
15+
16+
@code{
17+
MudTransferList<ComplexTypes> _transferList;
18+
19+
ICollection<ComplexTypes> _startCollection = new List<ComplexTypes>()
20+
{
21+
new ComplexTypes() { Name = "Harry", SurName = "Potter" },
22+
new ComplexTypes() { Name = "Hermione", SurName = "Granger" },
23+
new ComplexTypes() { Name = "Ron", SurName = "Weasley" },
24+
new ComplexTypes() { Name = "Neville", SurName = "Longbottom" },
25+
};
26+
27+
ICollection<ComplexTypes> _endCollection = new List<ComplexTypes>()
28+
{
29+
new ComplexTypes() { Name = "Draco", SurName = "Malfoy" },
30+
new ComplexTypes() { Name = "Seamus", SurName = "Finnigan" },
31+
new ComplexTypes() { Name = "Sirius", SurName = "Black" },
32+
new ComplexTypes() { Name = "Cho", SurName = "Chang" },
33+
};
34+
35+
public class ComplexTypes
36+
{
37+
public string Name { get; set; }
38+
public string SurName { get; set; }
39+
}
40+
}

0 commit comments

Comments
 (0)