Browse Source

Explicitely define EntityActions Type

pull/8074/head
Mladen Macanovic 5 years ago
parent
commit
f6ef4be30a
  1. 8
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor
  2. 14
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor
  3. 28
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs

8
framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor

@ -12,10 +12,10 @@ else
{
if (IsVisible)
{
<Blazorise.Button Block="true"
Color="@Color"
Clicked="@ActionClickedAsync">
<Button Block="true"
Color="@Color"
Clicked="@ActionClickedAsync">
@Text
</Blazorise.Button>
</Button>
}
}

14
framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor

@ -1,15 +1,15 @@
@typeparam TItem
<CascadingValue Value="this">
@if (Type == ActionType.Dropdown)
<CascadingValue Value="this" IsFixed="true">
@if ( Type == ActionType.Dropdown )
{
<Dropdown>
@if (HasPrimaryAction)
@if ( HasPrimaryAction )
{
<Blazorise.Button Block="true"
Color="@PrimaryAction.Color"
Clicked="async ()=> await PrimaryAction.ActionClickedAsync()">
<Button Block="true"
Color="@PrimaryAction.Color"
Clicked="async ()=> await PrimaryAction.ActionClickedAsync()">
@PrimaryAction.Text
</Blazorise.Button>
</Button>
<DropdownToggle Color="@ToggleColor" Split="true" />
}
else

28
framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Components;
@ -12,7 +13,6 @@ namespace Volo.Abp.BlazoriseUI.Components
protected readonly List<EntityAction<TItem>> Actions = new List<EntityAction<TItem>>();
protected bool HasPrimaryAction => Actions.Any(t => t.Primary);
protected EntityAction<TItem> PrimaryAction => Actions.FirstOrDefault(t => t.Primary);
protected internal ActionType Type => Actions.Count(t => t.IsVisible) > 1 ? ActionType.Dropdown : ActionType.Button;
[Parameter]
public Color ToggleColor { get; set; } = Color.Primary;
@ -26,17 +26,18 @@ namespace Volo.Abp.BlazoriseUI.Components
[Parameter]
public DataGridEntityActionsColumn<TItem> EntityActionsColumn { get; set; }
[Parameter]
public ActionType Type { get; set; } = ActionType.Dropdown;
[CascadingParameter]
public DataGridEntityActionsColumn<TItem> ParentEntityActionsColumn { get; set; }
[Inject]
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
internal void AddAction(EntityAction<TItem> action)
{
Actions.Add(action);
if (EntityActionsColumn != null)
{
EntityActionsColumn.Displayable = Actions.Any(t => t.IsVisible);
}
InvokeAsync(StateHasChanged);
}
protected override void OnInitialized()
@ -44,5 +45,20 @@ namespace Volo.Abp.BlazoriseUI.Components
base.OnInitialized();
ToggleText = UiLocalizer["Actions"];
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
if (ParentEntityActionsColumn != null)
{
ParentEntityActionsColumn.Displayable = Actions.Any(t => t.IsVisible);
}
await InvokeAsync(StateHasChanged);
}
await base.OnAfterRenderAsync(firstRender);
}
}
}

Loading…
Cancel
Save