From 71c65059a094ed2ada3cdc17cebcc5cb30fb193f Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Tue, 28 Jan 2025 17:54:30 -0600 Subject: [PATCH] Fix redistributable editing --- .../Components/RedistributableEditView.razor | 78 ++++++++ .../UI/Pages/Redistributables/Edit.razor | 179 ------------------ .../Redistributables/Edit/Archives.razor | 11 ++ .../Pages/Redistributables/Edit/General.razor | 133 +++++++++++++ .../Pages/Redistributables/Edit/Scripts.razor | 41 ++++ .../UI/Pages/Redistributables/Index.razor | 2 +- 6 files changed, 264 insertions(+), 180 deletions(-) create mode 100644 LANCommander.Server/UI/Pages/Redistributables/Components/RedistributableEditView.razor delete mode 100644 LANCommander.Server/UI/Pages/Redistributables/Edit.razor create mode 100644 LANCommander.Server/UI/Pages/Redistributables/Edit/Archives.razor create mode 100644 LANCommander.Server/UI/Pages/Redistributables/Edit/General.razor create mode 100644 LANCommander.Server/UI/Pages/Redistributables/Edit/Scripts.razor diff --git a/LANCommander.Server/UI/Pages/Redistributables/Components/RedistributableEditView.razor b/LANCommander.Server/UI/Pages/Redistributables/Components/RedistributableEditView.razor new file mode 100644 index 00000000..ee9256e2 --- /dev/null +++ b/LANCommander.Server/UI/Pages/Redistributables/Components/RedistributableEditView.razor @@ -0,0 +1,78 @@ +@using Microsoft.EntityFrameworkCore +@inject DatabaseServiceFactory DatabaseServiceFactory +@inject NavigationManager NavigationManager + + + + + General + + @if (Redistributable?.Id != Guid.Empty) + { + Archives + Scripts + } + + + + + + + + @if (TitleTemplate != null) + { + @TitleTemplate(Redistributable) + } + else { + @Title + } + + + + @TitleExtraTemplate?.Invoke(Redistributable) + + + + +
+ @ChildContent?.Invoke(Redistributable) +
+
+
+ +@code { + [Parameter] public Guid Id { get; set; } + [Parameter] public string Title { get; set; } + [Parameter] public RenderFragment? TitleTemplate { get; set; } + [Parameter] public RenderFragment? TitleExtraTemplate { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } + + Redistributable Redistributable { get; set; } = new(); + Guid _id; + + protected override async Task OnParametersSetAsync() + { + if (_id != Id) + { + _id = Id; + + using (var redistributableService = DatabaseServiceFactory.Create()) + { + if (_id != Guid.Empty) + Redistributable = await redistributableService + .Query(query => + { + return query + .Include(g => g.CreatedBy) + .Include(g => g.UpdatedBy); + }) + .GetAsync(_id); + else + Redistributable = new(); + } + + if (Redistributable == null) + NavigationManager.NavigateTo("/Redistributables"); + } + } +} \ No newline at end of file diff --git a/LANCommander.Server/UI/Pages/Redistributables/Edit.razor b/LANCommander.Server/UI/Pages/Redistributables/Edit.razor deleted file mode 100644 index f9fa970e..00000000 --- a/LANCommander.Server/UI/Pages/Redistributables/Edit.razor +++ /dev/null @@ -1,179 +0,0 @@ -@page "/Redistributables/{id:guid}" -@page "/Redistributables/{id:guid}/{panel}" -@page "/Redistributables/Add" -@using LANCommander.SDK.Enums -@using LANCommander.Server.Models -@using Microsoft.EntityFrameworkCore -@attribute [Authorize(Roles = RoleService.AdministratorRoleName)] -@inject DatabaseServiceFactory DatabaseServiceFactory -@inject IMessageService MessageService -@inject NavigationManager NavigationManager -@inject ILogger Logger - - - - - General - - @if (Redistributable?.Id != Guid.Empty) - { - Scripts - Archives - } - - - - - - - @if (Id == Guid.Empty) - { - Add New Redistributable - } - else - { - @Panel - } - - - - @if (Redistributable != null && Redistributable.Id != Guid.Empty) - { - Export - } - - - - - - - -
-
-
- - - - - -