Add registry element data view

This commit is contained in:
2025-11-04 17:17:53 +09:00
parent 9799086b53
commit 48cab2cde9
5 changed files with 50 additions and 4 deletions

View File

@ -0,0 +1,28 @@
@using Hcs.WebApp.Services
@using Newtonsoft.Json
@inject RegistryService RegistryService
<RadzenTextArea @bind-Value="@content" Style="width: 370px; height:500px; resize: none; display: block; margin-left: auto; margin-right: auto;" ReadOnly="true" />
@code {
string? content;
[Parameter]
public required RegistryElement RegistryElement { get; set; }
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (string.IsNullOrEmpty(RegistryElement.Json))
{
RegistryElement.Json = await RegistryService.GetRegistryElementJsonAsync(RegistryElement.Id);
}
if (!string.IsNullOrEmpty(RegistryElement.Json))
{
content = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(RegistryElement.Json!), Formatting.Indented);
}
}
}

View File

@ -109,8 +109,8 @@
"Редактирование пользователя", "Редактирование пользователя",
new Dictionary<string, object>() new Dictionary<string, object>()
{ {
{ nameof(Dialogs.EditUser.CurrentUserId), currentUserId }, { nameof(EditUser.CurrentUserId), currentUserId },
{ nameof(Dialogs.EditUser.UserWithRole), userWithRole } { nameof(EditUser.UserWithRole), userWithRole }
}, },
new DialogOptions() new DialogOptions()
{ {

View File

@ -134,7 +134,17 @@
async Task ShowElementAsync(RegistryElement registryElement) async Task ShowElementAsync(RegistryElement registryElement)
{ {
// TODO await DialogService.OpenAsync<ViewRegistryElement>(
"Просмотр записи",
new Dictionary<string, object>()
{
{ nameof(ViewRegistryElement.RegistryElement), registryElement }
},
new DialogOptions()
{
Width = "420px",
Height = "600px"
});
} }
void ChangeState(CommonPageState state) void ChangeState(CommonPageState state)

View File

@ -12,6 +12,6 @@
public string GUID { get; set; } public string GUID { get; set; }
public virtual string Json { get; set; } public virtual string? Json { get; set; } = null;
} }
} }

View File

@ -61,5 +61,13 @@ namespace Hcs.WebApp.Services
using var context = GetNewContext(); using var context = GetNewContext();
return await context.Elements.Where(x => x.RegistryId == registryId).ToListAsync(); return await context.Elements.Where(x => x.RegistryId == registryId).ToListAsync();
} }
public async Task<string?> GetRegistryElementJsonAsync(Guid registryElementId)
{
using var context = GetNewContext();
return await (from registryElement in context.Elements
where registryElement.Id == registryElementId
select registryElement.Json).FirstOrDefaultAsync();
}
} }
} }