Browse Source

Merge pull request #6069 from abpframework/cotur/crudpagebase

Replace Id parameter with object at OpenEditModalAsync in AbpCrudPageBase
pull/6074/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
70baf81344
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      docs/en/Tutorials/Part-3.md
  2. 2
      docs/en/Tutorials/Part-5.md
  3. 6
      framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
  4. 2
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor
  5. 2
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor
  6. 6
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs
  7. 4
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor
  8. 6
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs

6
docs/en/Tutorials/Part-3.md

@ -1264,7 +1264,7 @@ Open the `Books.razor` and add the following `DataGridColumn` section inside the
@L["Actions"] @L["Actions"]
</DropdownToggle> </DropdownToggle>
<DropdownMenu> <DropdownMenu>
<DropdownItem Clicked="() => OpenEditModalAsync(context.Id)"> <DropdownItem Clicked="() => OpenEditModalAsync(context)">
@L["Edit"] @L["Edit"]
</DropdownItem> </DropdownItem>
</DropdownMenu> </DropdownMenu>
@ -1273,7 +1273,7 @@ Open the `Books.razor` and add the following `DataGridColumn` section inside the
</DataGridColumn> </DataGridColumn>
```` ````
* `OpenEditModalAsync` is defined in the base class which takes the `Id` of the entity (book) to edit. * `OpenEditModalAsync` is defined in the base class which takes the entity (book) to edit.
This adds an "Actions" dropdown to all the books inside the `DataGrid` with an `Edit` action: This adds an "Actions" dropdown to all the books inside the `DataGrid` with an `Edit` action:
@ -1419,7 +1419,7 @@ Here the complete code to create the book management CRUD page, that has been de
@L["Actions"] @L["Actions"]
</DropdownToggle> </DropdownToggle>
<DropdownMenu> <DropdownMenu>
<DropdownItem Clicked="() => OpenEditModalAsync(context.Id)"> <DropdownItem Clicked="() => OpenEditModalAsync(context)">
@L["Edit"] @L["Edit"]
</DropdownItem> </DropdownItem>
<DropdownItem Clicked="() => DeleteEntityAsync(context)"> <DropdownItem Clicked="() => DeleteEntityAsync(context)">

2
docs/en/Tutorials/Part-5.md

@ -523,7 +523,7 @@ As similar to the *New Book* button, we can use `if` blocks to conditionally sho
````xml ````xml
@if (canEditBook) @if (canEditBook)
{ {
<DropdownItem Clicked="() => OpenEditModalAsync(context.Id)"> <DropdownItem Clicked="() => OpenEditModalAsync(context)">
@L["Edit"] @L["Edit"]
</DropdownItem> </DropdownItem>
} }

6
framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs

@ -300,15 +300,15 @@ namespace Volo.Abp.BlazoriseUI
return Task.CompletedTask; return Task.CompletedTask;
} }
protected virtual async Task OpenEditModalAsync(TKey id) protected virtual async Task OpenEditModalAsync(TListViewModel entity)
{ {
EditValidationsRef?.ClearAll(); EditValidationsRef?.ClearAll();
await CheckUpdatePolicyAsync(); await CheckUpdatePolicyAsync();
var entityDto = await AppService.GetAsync(id); var entityDto = await AppService.GetAsync(entity.Id);
EditingEntityId = id; EditingEntityId = entity.Id;
EditingEntity = MapToEditingEntity(entityDto); EditingEntity = MapToEditingEntity(entityDto);
await InvokeAsync(() => StateHasChanged()); await InvokeAsync(() => StateHasChanged());

2
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor

@ -37,7 +37,7 @@
<EntityActions TItem="IdentityRoleDto" EntityActionsColumn="@EntityActionsColumn"> <EntityActions TItem="IdentityRoleDto" EntityActionsColumn="@EntityActionsColumn">
<EntityAction TItem="IdentityRoleDto" <EntityAction TItem="IdentityRoleDto"
RequiredPolicy="@UpdatePolicyName" RequiredPolicy="@UpdatePolicyName"
Clicked="() => OpenEditModalAsync(context.Id)" Clicked="() => OpenEditModalAsync(context)"
Text="@L["Edit"]"></EntityAction> Text="@L["Edit"]"></EntityAction>
<EntityAction TItem="IdentityRoleDto" <EntityAction TItem="IdentityRoleDto"
RequiredPolicy="@ManagePermissionsPolicyName" RequiredPolicy="@ManagePermissionsPolicyName"

2
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor

@ -36,7 +36,7 @@
<EntityActions TItem="IdentityUserDto" EntityActionsColumn="@EntityActionsColumn"> <EntityActions TItem="IdentityUserDto" EntityActionsColumn="@EntityActionsColumn">
<EntityAction TItem="IdentityUserDto" <EntityAction TItem="IdentityUserDto"
RequiredPolicy="@UpdatePolicyName" RequiredPolicy="@UpdatePolicyName"
Clicked="() => OpenEditModalAsync(context.Id)" Clicked="() => OpenEditModalAsync(context)"
Text="@L["Edit"]" /> Text="@L["Edit"]" />
<EntityAction TItem="IdentityUserDto" <EntityAction TItem="IdentityUserDto"
RequiredPolicy="@ManagePermissionsPolicyName" RequiredPolicy="@ManagePermissionsPolicyName"

6
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs

@ -69,11 +69,11 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
return base.OnCreatingEntityAsync(); return base.OnCreatingEntityAsync();
} }
protected async override Task OpenEditModalAsync(Guid id) protected async override Task OpenEditModalAsync(IdentityUserDto entity)
{ {
EditModalSelectedTab = DefaultSelectedTab; EditModalSelectedTab = DefaultSelectedTab;
var userRoleNames = (await AppService.GetRolesAsync(id)).Items.Select(r => r.Name).ToList(); var userRoleNames = (await AppService.GetRolesAsync(entity.Id)).Items.Select(r => r.Name).ToList();
EditUserRoles = Roles.Select(x => new AssignedRoleViewModel EditUserRoles = Roles.Select(x => new AssignedRoleViewModel
{ {
@ -81,7 +81,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
IsAssigned = userRoleNames.Contains(x.Name) IsAssigned = userRoleNames.Contains(x.Name)
}).ToArray(); }).ToArray();
await base.OpenEditModalAsync(id); await base.OpenEditModalAsync(entity);
} }
protected override Task OnUpdatingEntityAsync() protected override Task OnUpdatingEntityAsync()

4
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor

@ -34,11 +34,11 @@
<EntityActions TItem="TenantDto" EntityActionsColumn="@EntityActionsColumn"> <EntityActions TItem="TenantDto" EntityActionsColumn="@EntityActionsColumn">
<EntityAction TItem="TenantDto" <EntityAction TItem="TenantDto"
RequiredPolicy="@UpdatePolicyName" RequiredPolicy="@UpdatePolicyName"
Clicked="() => OpenEditModalAsync(context.Id)" Clicked="() => OpenEditModalAsync(context)"
Text="@L["Edit"]"></EntityAction> Text="@L["Edit"]"></EntityAction>
<EntityAction TItem="TenantDto" <EntityAction TItem="TenantDto"
RequiredPolicy="@ManageConnectionStringsPolicyName" RequiredPolicy="@ManageConnectionStringsPolicyName"
Clicked="() => OpenEditConnectionStringModalAsync(context.Id)" Clicked="() => OpenEditConnectionStringModalAsync(context)"
Text="@L["ConnectionStrings"]"></EntityAction> Text="@L["ConnectionStrings"]"></EntityAction>
<EntityAction TItem="TenantDto" <EntityAction TItem="TenantDto"
RequiredPolicy="@ManageFeaturesPolicyName" RequiredPolicy="@ManageFeaturesPolicyName"

6
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs

@ -47,15 +47,15 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement
HasManageFeaturesPermission = await AuthorizationService.IsGrantedAsync(ManageFeaturesPolicyName); HasManageFeaturesPermission = await AuthorizationService.IsGrantedAsync(ManageFeaturesPolicyName);
} }
protected virtual async Task OpenEditConnectionStringModalAsync(Guid id) protected virtual async Task OpenEditConnectionStringModalAsync(TenantDto entity)
{ {
ManageConnectionStringValidations.ClearAll(); ManageConnectionStringValidations.ClearAll();
var tenantConnectionString = await AppService.GetDefaultConnectionStringAsync(id); var tenantConnectionString = await AppService.GetDefaultConnectionStringAsync(entity.Id);
TenantInfo = new TenantInfoModel TenantInfo = new TenantInfoModel
{ {
Id = id, Id = entity.Id,
DefaultConnectionString = tenantConnectionString, DefaultConnectionString = tenantConnectionString,
UseSharedDatabase = tenantConnectionString.IsNullOrWhiteSpace() UseSharedDatabase = tenantConnectionString.IsNullOrWhiteSpace()
}; };

Loading…
Cancel
Save