Browse Source
Merge pull request #11331 from abpframework/liangshiwei/entityaction
Enhanced EntityAction
pull/11332/head
maliming
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
30 additions and
19 deletions
-
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs
-
framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor
-
framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor
-
framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs
-
framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor
-
framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs
|
|
|
@ -12,6 +12,7 @@ public class EntityAction : IEquatable<EntityAction> |
|
|
|
public object Color { get; set; } |
|
|
|
public string Icon { get; set; } |
|
|
|
public Func<object, bool> Visible { get; set; } |
|
|
|
public bool Disabled { get; set; } |
|
|
|
public bool Equals(EntityAction other) |
|
|
|
{ |
|
|
|
return string.Equals(Text, other?.Text, StringComparison.OrdinalIgnoreCase); |
|
|
|
|
|
|
|
@ -44,7 +44,8 @@ |
|
|
|
Clicked="async () => await action.Clicked(context)" |
|
|
|
ConfirmationMessage="() => action.ConfirmationMessage.Invoke(context)" |
|
|
|
Visible="@(action.Visible != null ? action.Visible(context) : true)" |
|
|
|
Text="@action.Text"> |
|
|
|
Text="@action.Text" |
|
|
|
Disabled="@action.Disabled"> |
|
|
|
</EntityAction> |
|
|
|
} |
|
|
|
else |
|
|
|
@ -54,7 +55,8 @@ |
|
|
|
Color="@(action.Color != null ? (Blazorise.Color) action.Color : Blazorise.Color.None)" |
|
|
|
Icon="@action.Icon" |
|
|
|
Visible="@(action.Visible != null ? action.Visible(context) : true)" |
|
|
|
Text="@action.Text"> |
|
|
|
Text="@action.Text" |
|
|
|
Disabled="@action.Disabled"> |
|
|
|
</EntityAction> |
|
|
|
} |
|
|
|
} |
|
|
|
@ -78,18 +80,18 @@ |
|
|
|
{ |
|
|
|
@if (column.ValueConverter == null) |
|
|
|
{ |
|
|
|
<DataGridColumn TItem="TItem" |
|
|
|
Field="@column.Data" |
|
|
|
Caption="@column.Title" |
|
|
|
Sortable="@column.Sortable" |
|
|
|
DisplayFormat="@column.DisplayFormat" |
|
|
|
<DataGridColumn TItem="TItem" |
|
|
|
Field="@column.Data" |
|
|
|
Caption="@column.Title" |
|
|
|
Sortable="@column.Sortable" |
|
|
|
DisplayFormat="@column.DisplayFormat" |
|
|
|
DisplayFormatProvider="@column.DisplayFormatProvider"/> |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
<DataGridColumn TItem="TItem" |
|
|
|
Field="@column.Data" |
|
|
|
Caption="@column.Title" |
|
|
|
<DataGridColumn TItem="TItem" |
|
|
|
Field="@column.Data" |
|
|
|
Caption="@column.Title" |
|
|
|
Sortable="@column.Sortable"> |
|
|
|
<DisplayTemplate> |
|
|
|
@(GetConvertedFieldValue(context, column)) |
|
|
|
@ -143,4 +145,4 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
</DataGridColumns> |
|
|
|
</DataGrid> |
|
|
|
</DataGrid> |
|
|
|
|
|
|
|
@ -6,14 +6,15 @@ |
|
|
|
{ |
|
|
|
if (Primary == false) |
|
|
|
{ |
|
|
|
<DropdownItem Clicked="@ActionClickedAsync">@Text</DropdownItem> |
|
|
|
<DropdownItem Clicked="@ActionClickedAsync" Disabled=@Disabled>@Text</DropdownItem> |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
<Button Block="true" |
|
|
|
Color="@Color" |
|
|
|
Clicked="@ActionClickedAsync"> |
|
|
|
Clicked="@ActionClickedAsync" |
|
|
|
Disabled=@Disabled> |
|
|
|
@if(!string.IsNullOrEmpty(Icon)) |
|
|
|
{ |
|
|
|
<Icon Name="@Icon"/> |
|
|
|
@ -21,4 +22,4 @@ |
|
|
|
@Text |
|
|
|
</Button> |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -12,6 +12,9 @@ public partial class EntityAction<TItem> : ComponentBase |
|
|
|
[Parameter] |
|
|
|
public bool Visible { get; set; } = true; |
|
|
|
|
|
|
|
[Parameter] |
|
|
|
public bool Disabled { get; set; } = false; |
|
|
|
|
|
|
|
internal bool HasPermission { get; set; } = true; |
|
|
|
|
|
|
|
[Parameter] |
|
|
|
@ -45,7 +48,7 @@ public partial class EntityAction<TItem> : ComponentBase |
|
|
|
[Inject] |
|
|
|
protected IUiMessageService UiMessageService { get; set; } |
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync() |
|
|
|
protected async override Task OnInitializedAsync() |
|
|
|
{ |
|
|
|
await base.OnInitializedAsync(); |
|
|
|
await SetDefaultValuesAsync(); |
|
|
|
|
|
|
|
@ -2,12 +2,13 @@ |
|
|
|
<CascadingValue Value="this" IsFixed="true"> |
|
|
|
@if ( Type == ActionType.Dropdown ) |
|
|
|
{ |
|
|
|
<Dropdown> |
|
|
|
<Dropdown Disabled=@Disabled> |
|
|
|
@if ( HasPrimaryAction ) |
|
|
|
{ |
|
|
|
<Button Block="true" |
|
|
|
Color="@PrimaryAction.Color" |
|
|
|
Clicked="async ()=> await PrimaryAction.ActionClickedAsync()"> |
|
|
|
Clicked="async ()=> await PrimaryAction.ActionClickedAsync()" |
|
|
|
Disabled=@PrimaryAction.Disabled> |
|
|
|
@PrimaryAction.Text |
|
|
|
</Button> |
|
|
|
<DropdownToggle Color="@ToggleColor" Split="true" /> |
|
|
|
@ -27,4 +28,4 @@ |
|
|
|
{ |
|
|
|
@ChildContent |
|
|
|
} |
|
|
|
</CascadingValue> |
|
|
|
</CascadingValue> |
|
|
|
|
|
|
|
@ -29,6 +29,9 @@ public partial class EntityActions<TItem> : ComponentBase |
|
|
|
[Parameter] |
|
|
|
public ActionType Type { get; set; } = ActionType.Dropdown; |
|
|
|
|
|
|
|
[Parameter] |
|
|
|
public bool Disabled { get; set; } = false; |
|
|
|
|
|
|
|
[CascadingParameter] |
|
|
|
public DataGridEntityActionsColumn<TItem> ParentEntityActionsColumn { get; set; } |
|
|
|
|
|
|
|
@ -46,7 +49,7 @@ public partial class EntityActions<TItem> : ComponentBase |
|
|
|
ToggleText = UiLocalizer["Actions"]; |
|
|
|
} |
|
|
|
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender) |
|
|
|
protected async override Task OnAfterRenderAsync(bool firstRender) |
|
|
|
{ |
|
|
|
if (firstRender) |
|
|
|
{ |
|
|
|
|