|
|
|
@ -227,10 +227,17 @@ namespace Volo.Abp.BlazoriseUI
|
|
|
|
|
|
|
|
|
|
protected virtual async Task GetEntitiesAsync()
|
|
|
|
|
{
|
|
|
|
|
await UpdateGetListInputAsync();
|
|
|
|
|
var result = await AppService.GetListAsync(GetListInput);
|
|
|
|
|
Entities = MapToListViewModel(result.Items);
|
|
|
|
|
TotalCount = (int?)result.TotalCount;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await UpdateGetListInputAsync();
|
|
|
|
|
var result = await AppService.GetListAsync(GetListInput);
|
|
|
|
|
Entities = MapToListViewModel(result.Items);
|
|
|
|
|
TotalCount = (int?)result.TotalCount;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await HandleErrorAsync(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IReadOnlyList<TListViewModel> MapToListViewModel(IReadOnlyList<TGetListOutputDto> dtos)
|
|
|
|
@ -287,20 +294,26 @@ namespace Volo.Abp.BlazoriseUI
|
|
|
|
|
|
|
|
|
|
protected virtual async Task OpenCreateModalAsync()
|
|
|
|
|
{
|
|
|
|
|
CreateValidationsRef?.ClearAll();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CreateValidationsRef?.ClearAll();
|
|
|
|
|
|
|
|
|
|
await CheckCreatePolicyAsync();
|
|
|
|
|
await CheckCreatePolicyAsync();
|
|
|
|
|
|
|
|
|
|
NewEntity = new TCreateViewModel();
|
|
|
|
|
NewEntity = new TCreateViewModel();
|
|
|
|
|
|
|
|
|
|
// Mapper will not notify Blazor that binded values are changed
|
|
|
|
|
// so we need to notify it manually by calling StateHasChanged
|
|
|
|
|
await InvokeAsync(() =>
|
|
|
|
|
// Mapper will not notify Blazor that binded values are changed
|
|
|
|
|
// so we need to notify it manually by calling StateHasChanged
|
|
|
|
|
await InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
CreateModal?.Show();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
|
|
|
|
|
CreateModal?.Show();
|
|
|
|
|
});
|
|
|
|
|
await HandleErrorAsync(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual Task CloseCreateModalAsync()
|
|
|
|
@ -310,21 +323,27 @@ namespace Volo.Abp.BlazoriseUI
|
|
|
|
|
|
|
|
|
|
protected virtual async Task OpenEditModalAsync(TListViewModel entity)
|
|
|
|
|
{
|
|
|
|
|
EditValidationsRef?.ClearAll();
|
|
|
|
|
|
|
|
|
|
await CheckUpdatePolicyAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
EditValidationsRef?.ClearAll();
|
|
|
|
|
|
|
|
|
|
await CheckUpdatePolicyAsync();
|
|
|
|
|
|
|
|
|
|
var entityDto = await AppService.GetAsync(entity.Id);
|
|
|
|
|
var entityDto = await AppService.GetAsync(entity.Id);
|
|
|
|
|
|
|
|
|
|
EditingEntityId = entity.Id;
|
|
|
|
|
EditingEntity = MapToEditingEntity(entityDto);
|
|
|
|
|
EditingEntityId = entity.Id;
|
|
|
|
|
EditingEntity = MapToEditingEntity(entityDto);
|
|
|
|
|
|
|
|
|
|
await InvokeAsync(() =>
|
|
|
|
|
await InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
EditModal?.Show();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
|
|
|
|
|
EditModal?.Show();
|
|
|
|
|
});
|
|
|
|
|
await HandleErrorAsync(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual TUpdateViewModel MapToEditingEntity(TGetOutputDto entityDto)
|
|
|
|
@ -360,15 +379,22 @@ namespace Volo.Abp.BlazoriseUI
|
|
|
|
|
|
|
|
|
|
protected virtual async Task CreateEntityAsync()
|
|
|
|
|
{
|
|
|
|
|
if (CreateValidationsRef?.ValidateAll() ?? true)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await OnCreatingEntityAsync();
|
|
|
|
|
if (CreateValidationsRef?.ValidateAll() ?? true)
|
|
|
|
|
{
|
|
|
|
|
await OnCreatingEntityAsync();
|
|
|
|
|
|
|
|
|
|
await CheckCreatePolicyAsync();
|
|
|
|
|
var createInput = MapToCreateInput(NewEntity);
|
|
|
|
|
await AppService.CreateAsync(createInput);
|
|
|
|
|
await CheckCreatePolicyAsync();
|
|
|
|
|
var createInput = MapToCreateInput(NewEntity);
|
|
|
|
|
await AppService.CreateAsync(createInput);
|
|
|
|
|
|
|
|
|
|
await OnCreatedEntityAsync();
|
|
|
|
|
await OnCreatedEntityAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await HandleErrorAsync(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -386,15 +412,22 @@ namespace Volo.Abp.BlazoriseUI
|
|
|
|
|
|
|
|
|
|
protected virtual async Task UpdateEntityAsync()
|
|
|
|
|
{
|
|
|
|
|
if (EditValidationsRef?.ValidateAll() ?? true)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await OnUpdatingEntityAsync();
|
|
|
|
|
if (EditValidationsRef?.ValidateAll() ?? true)
|
|
|
|
|
{
|
|
|
|
|
await OnUpdatingEntityAsync();
|
|
|
|
|
|
|
|
|
|
await CheckUpdatePolicyAsync();
|
|
|
|
|
var updateInput = MapToUpdateInput(EditingEntity);
|
|
|
|
|
await AppService.UpdateAsync(EditingEntityId, updateInput);
|
|
|
|
|
await CheckUpdatePolicyAsync();
|
|
|
|
|
var updateInput = MapToUpdateInput(EditingEntity);
|
|
|
|
|
await AppService.UpdateAsync(EditingEntityId, updateInput);
|
|
|
|
|
|
|
|
|
|
await OnUpdatedEntityAsync();
|
|
|
|
|
await OnUpdatedEntityAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await HandleErrorAsync(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -421,7 +454,7 @@ namespace Volo.Abp.BlazoriseUI
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await ShowError(ex);
|
|
|
|
|
await HandleErrorAsync(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|