diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor new file mode 100644 index 0000000000..c36620f195 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor @@ -0,0 +1,21 @@ +@typeparam TItem +@using Blazorise + +@if (ParentActions.Type == ActionType.Dropdown) +{ + if (IsVisible && Primary == false) + { + @Text + } +} +else +{ + if (IsVisible) + { + + @Text + + } +} diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs new file mode 100644 index 0000000000..8dc4dcb5a0 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs @@ -0,0 +1,33 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace Volo.Abp.BlazoriseUI.Components +{ + public partial class EntityAction : ComponentBase + { + [Parameter] + public bool IsVisible { get; set; } + [Parameter] + public string Text { get; set; } + + [Parameter] + public bool Primary { get; set; } + + [Parameter] + public EventCallback Clicked { get; set; } + + [CascadingParameter] + public EntityActions ParentActions { get; set; } + + protected override void OnInitialized() + { + base.OnInitialized(); + ParentActions.AddAction(this); + } + + protected virtual async Task ActionClickedAsync() + { + await Clicked.InvokeAsync(ParentActions.Entity); + } + } +} diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor new file mode 100644 index 0000000000..b5afcdbadf --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor @@ -0,0 +1,30 @@ +@typeparam TItem + + @if (Type == ActionType.Dropdown) + { + + @if (HasPrimaryAction) + { + + @PrimaryAction.Text + + + } + else + { + + @ToggleText + + } + + @ChildContent + + + } + else + { + @ChildContent + } + \ No newline at end of file diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs new file mode 100644 index 0000000000..d24c7125a7 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using System.Linq; +using Blazorise; +using Microsoft.AspNetCore.Components; + +namespace Volo.Abp.BlazoriseUI.Components +{ + public partial class EntityActions : ComponentBase + { + protected List> Actions = new List>(); + protected bool HasPrimaryAction => Actions.Any(t => t.Primary); + protected EntityAction 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; } + + [Parameter] + public string ToggleText { get; set; } + + [Parameter] + public TItem Entity { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + + internal void AddAction(EntityAction action) + { + Actions.Add(action); + StateHasChanged(); + } + } + + public enum ActionType + { + Dropdown, + Button + } +}