Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-893: Use CreateModelAsync #72

Merged
merged 6 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Lombiq.ContentEditors.Samples.ViewModels;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;
using System.Threading.Tasks;

Expand All @@ -27,23 +27,21 @@ public override IDisplayResult Edit(SupportTicketPart part, BuildPartEditorConte
viewModel.Description = part.Description;
}).OnGroup(EditorGroups.SupportTicket.Details).Location("Content"));

public override async Task<IDisplayResult> UpdateAsync(SupportTicketPart part, IUpdateModel updater, UpdatePartEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(SupportTicketPart part, UpdatePartEditorContext context)
{
// It's a good idea to check what editor group is being updated. This way you can have different update logic
// for different editor groups and you won't update properties that aren't on the current editor group.
// for different editor groups, and you won't update properties that aren't on the current editor group.
switch (context.GroupId)
{
case EditorGroups.SupportTicket.Reporter:
var reporterViewModel = new EditSupportTicketReporterViewModel();
await updater.TryUpdateModelAsync(reporterViewModel, Prefix);
var reporterViewModel = await context.CreateModelAsync<EditSupportTicketReporterViewModel>(Prefix);

part.Name = reporterViewModel.Name;
part.Email = reporterViewModel.Email;

break;
case EditorGroups.SupportTicket.Details:
var detailsViewModel = new EditSupportTicketDetailsViewModel();
await updater.TryUpdateModelAsync(detailsViewModel, Prefix);
var detailsViewModel = await context.CreateModelAsync<EditSupportTicketDetailsViewModel>(Prefix);

part.Url = detailsViewModel.Url;
part.Description = detailsViewModel.Description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Contents" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Contents" Version="2.0.0-preview-18300" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.Tests.UI" Version="10.0.2-alpha.1.occ-245" />
<PackageReference Include="Lombiq.Tests.UI" Version="10.0.2-alpha.2.osoe-893" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions Lombiq.ContentEditors/Lombiq.ContentEditors.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.ContentFields" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.ContentManagement" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Media" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.ContentFields" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.ContentManagement" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Media" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="2.0.0-preview-18300" />
</ItemGroup>

<ItemGroup>
Expand All @@ -47,7 +47,7 @@
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.1-alpha.2.occ-245" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.1-alpha.4.osoe-893" />
<PackageReference Include="Lombiq.NodeJs.Extensions" Version="2.1.0" />
</ItemGroup>

Expand Down