Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CodeBeam.MudExtensions.UnitTests/Components/RenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,12 @@ public void TextFieldExtendedPageRenderTest()
var comp = Context.RenderComponent<TextFieldExtendedPage>();
comp.Markup.Should().NotBeNullOrEmpty();
}

[Test]
public void TransferListPageRenderTest()
{
var comp = Context.RenderComponent<TransferListPage>();
comp.Markup.Should().NotBeNullOrEmpty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@
<CascadingValue Value="@this" IsFixed="true">
@if (MultiSelection && SelectAll && SelectAllPosition == SelectAllPosition.BeforeSearchBox && ParentList == null)
{
<MudListItemExtended T="T" IsFunctional="true" Icon="@SelectAllCheckBoxIcon" IconColor="@Color" Text="@SelectAllText" OverrideMultiSelectionComponent="MultiSelectionComponent.None" OnClick="@(() => SelectAllItems(_allSelected))" OnClickHandlerPreventDefault="true" Dense="@Dense" Class="mb-2" />
<MudDivider />
@if (SelectAllTemplate != null)
{
<div class="mud-ripple" @onclick="@(() => SelectAllItems(_allSelected))" tabindex="-1">
@SelectAllTemplate
</div>
}
else
{
<MudListItemExtended T="T" IsFunctional="true" Icon="@SelectAllCheckBoxIcon" IconColor="@Color" Text="@SelectAllText" OverrideMultiSelectionComponent="MultiSelectionComponent.None" OnClick="@(() => SelectAllItems(_allSelected))" OnClickHandlerPreventDefault="true" Dense="@Dense" Class="mb-2" />
<MudDivider />
}
}

@if (ItemCollection != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using MudExtensions.Enums;
using MudExtensions.Services;
using static MudBlazor.CategoryTypes;
using static MudBlazor.Colors;

namespace MudExtensions
{
Expand Down Expand Up @@ -82,6 +83,13 @@ public partial class MudListExtended<T> : MudComponentBase, IDisposable
[Category(CategoryTypes.FormComponent.ListBehavior)]
public RenderFragment<MudListItemExtended<T>> ItemDisabledTemplate { get; set; }

/// <summary>
/// Optional presentation template for select all item
/// </summary>
[Parameter]
[Category(CategoryTypes.FormComponent.ListBehavior)]
public RenderFragment SelectAllTemplate { get; set; }

[Parameter]
[Category(CategoryTypes.List.Behavior)]
public DefaultConverter<T> Converter { get; set; } = new DefaultConverter<T>();
Expand Down Expand Up @@ -372,7 +380,7 @@ protected void HandleCentralValueCommander(string changedValueType, bool updateS
}
else if (changedValueType == "MultiSelectionOff")
{
SelectedValue = SelectedValues.FirstOrDefault();
SelectedValue = SelectedValues == null ? default(T) : SelectedValues.FirstOrDefault();
var items = CollectAllMudListItems(true);
SelectedValues = SelectedValue == null ? null : new HashSet<T>(_comparer) { SelectedValue };
UpdateSelectedItem();
Expand Down Expand Up @@ -1313,6 +1321,20 @@ protected ICollection<T> GetSearchedItems()
return ItemCollection.Where(x => Converter.Set(x).Contains(_searchString, StringComparison.CurrentCultureIgnoreCase)).ToList();
}

public async Task ForceUpdate()
{
//if (!MultiSelection)
//{
// SelectedValues = new HashSet<T>(_comparer) { SelectedValue };
//}
//else
//{
// await SelectedValuesChanged.InvokeAsync(new HashSet<T>(SelectedValues, _comparer));
//}
await Task.Delay(1);
UpdateSelectedStyles();
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@using MudBlazor
@using MudExtensions.Enums

<div tabindex="0" @attributes="UserAttributes" id="@ItemId" class="@Classname" @onclick="@(((MudListExtended?.Clickable == true || NestedList != null) && IsFunctional == false) ? OnClickHandler : OnlyOnClick)" @onclick:stopPropagation="true" style="@Style">
<div tabindex="0" @attributes="UserAttributes" id="@ItemId" class="@Classname" @onclick="@(((MudListExtended?.Clickable == true || NestedList != null) && IsFunctional == false) ? OnClickHandler : OnlyOnClick)" @onclick:stopPropagation="@OnClickStopPropagation" style="@Style">

@if (MudListExtended?.ItemDisabledTemplate != null && Disabled == true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ public bool Disabled
[Category(CategoryTypes.List.Appearance)]
public bool Inset { get; set; }

/// <summary>
/// If true, stop propagation on click. Default is true.
/// </summary>
[Parameter]
[Category(CategoryTypes.List.Appearance)]
public bool OnClickStopPropagation { get; set; } = true;

private bool? _dense;
/// <summary>
/// If true, compact vertical padding will be used.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@namespace MudExtensions
@inherits MudComponentBase
@typeparam T
@using MudExtensions.Enums

<MudStack Class="@Class" Style="@Style" Row="!Vertical" Spacing="Spacing">
<MudListExtended @ref="_startList" Class="@StartClassname" Style="@StartStylename" T="T" ItemCollection="@StartCollection" Disabled="Disabled" Clickable="true" MultiSelection="@MultiSelection" SelectAll="@MultiSelection" MultiSelectionComponent="@MultiSelectionComponent" MaxItems="@MaxItems" Color="@Color">
<SelectAllTemplate>
@if (SelectAllType == SelectAllType.SelectAllItem)
{
<MudListItemExtended T="T" IsFunctional="true" Text="@SelectAllText" SecondaryText="@($"{(_startList == null ? 0 : _startList.SelectedValues == null ? 0 : _startList.SelectedValues.Count())} / {StartCollection.Count}")" OnClickStopPropagation="false" />
}
</SelectAllTemplate>
</MudListExtended>
<div class="@($"{(Vertical ? "d-flex" : "d-flex flex-column")} gap-{ButtonSpacing} align-center justify-center")">
@if (SelectAllType == SelectAllType.Buttons)
{
<MudIconButton Icon="@(Vertical ? Icons.Material.Filled.KeyboardDoubleArrowDown : Icons.Material.Filled.KeyboardDoubleArrowRight)" Disabled="Disabled" Color="@Color" Variant="@ButtonVariant" OnClick="@(() => TransferAll(true))" />
}
<MudIconButton Icon="@(Vertical ? Icons.Material.Filled.KeyboardArrowDown : Icons.Material.Filled.KeyboardArrowRight)" Disabled="Disabled" Color="@Color" Variant="@ButtonVariant" OnClick="@(() => Transfer(true))" />
<MudIconButton Icon="@(Vertical ? Icons.Material.Filled.KeyboardArrowUp : Icons.Material.Filled.KeyboardArrowLeft)" Disabled="Disabled" Color="@Color" Variant="@ButtonVariant" OnClick="@(() => Transfer(false))" />
@if (SelectAllType == SelectAllType.Buttons)
{
<MudIconButton Icon="@(Vertical ? Icons.Material.Filled.KeyboardDoubleArrowUp : Icons.Material.Filled.KeyboardDoubleArrowLeft)" Disabled="Disabled" Color="@Color" Variant="@ButtonVariant" OnClick="@(() => TransferAll(false))" />
}
</div>
<MudListExtended @ref="_endList" Class="@EndClassname" Style="@EndStylename" T="T" ItemCollection="@EndCollection" Disabled="Disabled" Clickable="true" MultiSelection="@MultiSelection" SelectAll="@MultiSelection" MultiSelectionComponent="@MultiSelectionComponent" MaxItems="@MaxItems" Color="@Color">
<SelectAllTemplate>
@if (SelectAllType == SelectAllType.SelectAllItem)
{
<MudListItemExtended T="T" IsFunctional="true" Text="@SelectAllText" SecondaryText="@($"{(_endList == null ? 0 : _endList.SelectedValues == null ? 0 : _endList.SelectedValues.Count())} / {EndCollection.Count}")" OnClickStopPropagation="false" />
}
</SelectAllTemplate>
</MudListExtended>
</MudStack>
Loading