Browse Source

Merge pull request #11331 from abpframework/liangshiwei/entityaction

Enhanced EntityAction
pull/11332/head
maliming 4 years ago
committed by GitHub
parent
commit
f129afd2a1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs
  2. 24
      framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor
  3. 7
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor
  4. 5
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs
  5. 7
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor
  6. 5
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs

1
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs

@ -12,6 +12,7 @@ public class EntityAction : IEquatable<EntityAction>
public object Color { get; set; } public object Color { get; set; }
public string Icon { get; set; } public string Icon { get; set; }
public Func<object, bool> Visible { get; set; } public Func<object, bool> Visible { get; set; }
public bool Disabled { get; set; }
public bool Equals(EntityAction other) public bool Equals(EntityAction other)
{ {
return string.Equals(Text, other?.Text, StringComparison.OrdinalIgnoreCase); return string.Equals(Text, other?.Text, StringComparison.OrdinalIgnoreCase);

24
framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor

@ -44,7 +44,8 @@
Clicked="async () => await action.Clicked(context)" Clicked="async () => await action.Clicked(context)"
ConfirmationMessage="() => action.ConfirmationMessage.Invoke(context)" ConfirmationMessage="() => action.ConfirmationMessage.Invoke(context)"
Visible="@(action.Visible != null ? action.Visible(context) : true)" Visible="@(action.Visible != null ? action.Visible(context) : true)"
Text="@action.Text"> Text="@action.Text"
Disabled="@action.Disabled">
</EntityAction> </EntityAction>
} }
else else
@ -54,7 +55,8 @@
Color="@(action.Color != null ? (Blazorise.Color) action.Color : Blazorise.Color.None)" Color="@(action.Color != null ? (Blazorise.Color) action.Color : Blazorise.Color.None)"
Icon="@action.Icon" Icon="@action.Icon"
Visible="@(action.Visible != null ? action.Visible(context) : true)" Visible="@(action.Visible != null ? action.Visible(context) : true)"
Text="@action.Text"> Text="@action.Text"
Disabled="@action.Disabled">
</EntityAction> </EntityAction>
} }
} }
@ -78,18 +80,18 @@
{ {
@if (column.ValueConverter == null) @if (column.ValueConverter == null)
{ {
<DataGridColumn TItem="TItem" <DataGridColumn TItem="TItem"
Field="@column.Data" Field="@column.Data"
Caption="@column.Title" Caption="@column.Title"
Sortable="@column.Sortable" Sortable="@column.Sortable"
DisplayFormat="@column.DisplayFormat" DisplayFormat="@column.DisplayFormat"
DisplayFormatProvider="@column.DisplayFormatProvider"/> DisplayFormatProvider="@column.DisplayFormatProvider"/>
} }
else else
{ {
<DataGridColumn TItem="TItem" <DataGridColumn TItem="TItem"
Field="@column.Data" Field="@column.Data"
Caption="@column.Title" Caption="@column.Title"
Sortable="@column.Sortable"> Sortable="@column.Sortable">
<DisplayTemplate> <DisplayTemplate>
@(GetConvertedFieldValue(context, column)) @(GetConvertedFieldValue(context, column))
@ -143,4 +145,4 @@
} }
} }
</DataGridColumns> </DataGridColumns>
</DataGrid> </DataGrid>

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

@ -6,14 +6,15 @@
{ {
if (Primary == false) if (Primary == false)
{ {
<DropdownItem Clicked="@ActionClickedAsync">@Text</DropdownItem> <DropdownItem Clicked="@ActionClickedAsync" Disabled=@Disabled>@Text</DropdownItem>
} }
} }
else else
{ {
<Button Block="true" <Button Block="true"
Color="@Color" Color="@Color"
Clicked="@ActionClickedAsync"> Clicked="@ActionClickedAsync"
Disabled=@Disabled>
@if(!string.IsNullOrEmpty(Icon)) @if(!string.IsNullOrEmpty(Icon))
{ {
<Icon Name="@Icon"/> <Icon Name="@Icon"/>
@ -21,4 +22,4 @@
@Text @Text
</Button> </Button>
} }
} }

5
framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs

@ -12,6 +12,9 @@ public partial class EntityAction<TItem> : ComponentBase
[Parameter] [Parameter]
public bool Visible { get; set; } = true; public bool Visible { get; set; } = true;
[Parameter]
public bool Disabled { get; set; } = false;
internal bool HasPermission { get; set; } = true; internal bool HasPermission { get; set; } = true;
[Parameter] [Parameter]
@ -45,7 +48,7 @@ public partial class EntityAction<TItem> : ComponentBase
[Inject] [Inject]
protected IUiMessageService UiMessageService { get; set; } protected IUiMessageService UiMessageService { get; set; }
protected override async Task OnInitializedAsync() protected async override Task OnInitializedAsync()
{ {
await base.OnInitializedAsync(); await base.OnInitializedAsync();
await SetDefaultValuesAsync(); await SetDefaultValuesAsync();

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

@ -2,12 +2,13 @@
<CascadingValue Value="this" IsFixed="true"> <CascadingValue Value="this" IsFixed="true">
@if ( Type == ActionType.Dropdown ) @if ( Type == ActionType.Dropdown )
{ {
<Dropdown> <Dropdown Disabled=@Disabled>
@if ( HasPrimaryAction ) @if ( HasPrimaryAction )
{ {
<Button Block="true" <Button Block="true"
Color="@PrimaryAction.Color" Color="@PrimaryAction.Color"
Clicked="async ()=> await PrimaryAction.ActionClickedAsync()"> Clicked="async ()=> await PrimaryAction.ActionClickedAsync()"
Disabled=@PrimaryAction.Disabled>
@PrimaryAction.Text @PrimaryAction.Text
</Button> </Button>
<DropdownToggle Color="@ToggleColor" Split="true" /> <DropdownToggle Color="@ToggleColor" Split="true" />
@ -27,4 +28,4 @@
{ {
@ChildContent @ChildContent
} }
</CascadingValue> </CascadingValue>

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

@ -29,6 +29,9 @@ public partial class EntityActions<TItem> : ComponentBase
[Parameter] [Parameter]
public ActionType Type { get; set; } = ActionType.Dropdown; public ActionType Type { get; set; } = ActionType.Dropdown;
[Parameter]
public bool Disabled { get; set; } = false;
[CascadingParameter] [CascadingParameter]
public DataGridEntityActionsColumn<TItem> ParentEntityActionsColumn { get; set; } public DataGridEntityActionsColumn<TItem> ParentEntityActionsColumn { get; set; }
@ -46,7 +49,7 @@ public partial class EntityActions<TItem> : ComponentBase
ToggleText = UiLocalizer["Actions"]; ToggleText = UiLocalizer["Actions"];
} }
protected override async Task OnAfterRenderAsync(bool firstRender) protected async override Task OnAfterRenderAsync(bool firstRender)
{ {
if (firstRender) if (firstRender)
{ {

Loading…
Cancel
Save