Add registry element data view
This commit is contained in:
28
Hcs.WebApp/Components/Dialogs/ViewRegistryElement.razor
Normal file
28
Hcs.WebApp/Components/Dialogs/ViewRegistryElement.razor
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user