Skip to content

Commit

Permalink
Merge pull request #66 from Lombiq/issue/OSOE-893
Browse files Browse the repository at this point in the history
OSOE-893: Fix breaking changes and use CreateModelAsync
  • Loading branch information
sarahelsaig authored Aug 9, 2024
2 parents 197e437 + 2c4a698 commit e24d926
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
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
10 changes: 4 additions & 6 deletions Lombiq.JsonEditor/Drivers/JsonFieldDisplayDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.Extensions.Localization;
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 Down Expand Up @@ -35,15 +35,13 @@ public override IDisplayResult Edit(JsonField field, BuildFieldEditorContext con
model.PartFieldDefinition = context.PartFieldDefinition;
});

public override async Task<IDisplayResult> UpdateAsync(JsonField field, IUpdateModel updater, UpdateFieldEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(JsonField field, UpdateFieldEditorContext context)
{
var model = new EditJsonFieldViewModel();

if (!await updater.TryUpdateModelAsync(model, Prefix)) return await EditAsync(field, context);
var model = await context.CreateModelAsync<EditJsonFieldViewModel>(Prefix);

if (JsonHelpers.ValidateJsonIfNotNull(model.Value) == false)
{
updater.ModelState.AddModelError(Prefix, T["The input isn't a valid JSON entity."]);
context.Updater.ModelState.AddModelError(Prefix, T["The input isn't a valid JSON entity."]);
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions Lombiq.JsonEditor/Lombiq.JsonEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
</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.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.ContentFields" 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" />
<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.ContentFields" Version="2.0.0-preview-18300" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' != 'true'">
Expand All @@ -49,7 +49,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
6 changes: 3 additions & 3 deletions Lombiq.JsonEditor/Settings/JsonFieldSettingsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public class JsonFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriver<J

public JsonFieldSettingsDriver(IStringLocalizer<JsonFieldSettingsDriver> stringLocalizer) => T = stringLocalizer;

public override IDisplayResult Edit(ContentPartFieldDefinition model) =>
public override IDisplayResult Edit(ContentPartFieldDefinition model, BuildEditorContext context) =>
Initialize<JsonFieldSettings>($"{nameof(JsonFieldSettings)}_Edit", model.CopySettingsTo)
.PlaceInContent();

public override async Task<IDisplayResult> UpdateAsync(
ContentPartFieldDefinition model,
UpdatePartFieldEditorContext context)
{
var settings = await context.CreateModelMaybeAsync<JsonFieldSettings>(Prefix);
var settings = await context.CreateModelAsync<JsonFieldSettings>(Prefix);

try
{
Expand All @@ -40,6 +40,6 @@ public override async Task<IDisplayResult> UpdateAsync(
T["The input isn't a valid {0} object.", nameof(JsonEditorOptions)]);
}

return Edit(model);
return await EditAsync(model, context);
}
}

0 comments on commit e24d926

Please sign in to comment.