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

load flowpart and bagpart resources by name #15954

Merged
merged 9 commits into from
May 3, 2024
28 changes: 28 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Flows/ResourceManifest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.Extensions.Options;
using OrchardCore.ResourceManagement;

namespace OrchardCore.Flows;

public class ResourceManagementOptionsConfiguration : IConfigureOptions<ResourceManagementOptions>
{
private static ResourceManifest _manifest;

static ResourceManagementOptionsConfiguration()
{
_manifest = new ResourceManifest();

_manifest
.DefineStyle("flowpart-edit")
.SetUrl( "~/OrchardCore.Flows/Styles/flows.edit.min.css", "~/OrchardCore.Flows/Styles/flows.edit.css");

_manifest
.DefineScript("flowpart-edit")
.SetDependencies("jQuery")
.SetUrl("~/OrchardCore.Flows/Scripts/flows.edit.min.js","~/OrchardCore.Flows/Scripts/flows.edit.js");
}

public void Configure(ResourceManagementOptions options)
{
options.ResourceManifests.Add(_manifest);
}
}
4 changes: 4 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Flows/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Fluid;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentTypes.Editors;
Expand All @@ -12,6 +13,7 @@
using OrchardCore.Flows.ViewModels;
using OrchardCore.Indexing;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;

namespace OrchardCore.Flows
{
Expand Down Expand Up @@ -45,6 +47,8 @@ public override void ConfigureServices(IServiceCollection services)
services.AddContentPart<FlowMetadata>();

services.AddDataMigration<Migrations>();

services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,9 @@
@if (Context.Items["BagPart.Edit"] == null)
{
Context.Items["BagPart.Edit"] = new object();
<script asp-src="~/OrchardCore.Flows/Scripts/flows.edit.min.js"
debug-src="~/OrchardCore.Flows/Scripts/flows.edit.js" at="Foot" depends-on="jQuery"></script>
<style asp-src="~/OrchardCore.Widgets/Styles/widgetslist.edit.min.css"
debug-src="~/OrchardCore.Widgets/Styles/widgetslist.edit.css"></style>
<style asp-src="~/OrchardCore.Flows/Styles/flows.edit.min.css"
debug-src="~/OrchardCore.Flows/Styles/flows.edit.css"></style>
<script asp-name="flowpart-edit" at="Foot"></script>
<script asp-name="widgetslist-edit" at="Foot"></script>
<style asp-name="flowpart-edit" at="Head"></style>
}

@* Rendered only once per type to initialize the scripts its editor will need *@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,10 @@
var contentItem = await ContentManager.NewAsync(type.Name);
await DisplayAsync(await ContentItemDisplayManager.BuildEditorAsync(contentItem, Model.Updater, true, "", Guid.NewGuid().ToString("n")));
}

<script asp-src="~/OrchardCore.Flows/Scripts/flows.edit.min.js"
debug-src="~/OrchardCore.Flows/Scripts/flows.edit.js" at="Foot" depends-on="jQuery"></script>
<style asp-src="~/OrchardCore.Widgets/Styles/widgetslist.edit.min.css"
debug-src="~/OrchardCore.Widgets/Styles/widgetslist.edit.css"></style>
<style asp-src="~/OrchardCore.Flows/Styles/flows.edit.css"
debug-src="~/OrchardCore.Flows/Styles/flows.edit.min.css"></style>

<script asp-name="flowpart-edit" at="Foot"></script>
<script asp-name="widgetslist-edit" at="Foot"></script>
<style asp-name="flowpart-edit" at="Head"></style>
}

<script at="Foot">
Expand Down
28 changes: 28 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Widgets/ResourceManifest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.Extensions.Options;
using OrchardCore.ResourceManagement;

namespace OrchardCore.Widgets;

public class ResourceManagementOptionsConfiguration : IConfigureOptions<ResourceManagementOptions>
{
private static ResourceManifest _manifest;

static ResourceManagementOptionsConfiguration()
{
_manifest = new ResourceManifest();

_manifest
.DefineStyle("widgetslist-edit")
.SetUrl( "~/OrchardCore.Widgets/Styles/widgetslist.edit.min.css", "~/OrchardCore.Widgets/Styles/widgetslist.edit.css");

_manifest
.DefineScript("widgetslist-edit")
.SetDependencies("jQuery")
.SetUrl("~/OrchardCore.Widgets/Scripts/widgetslist.edit.min.js","~/OrchardCore.Widgets/Scripts/widgetslist.edit.js");
}

public void Configure(ResourceManagementOptions options)
{
options.ResourceManifests.Add(_manifest);
}
}
3 changes: 3 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Widgets/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
using OrchardCore.Widgets.Drivers;
using OrchardCore.Widgets.Models;
using OrchardCore.Widgets.Settings;
Expand All @@ -24,6 +26,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<IContentTypePartDefinitionDisplayDriver, WidgetsListPartSettingsDisplayDriver>();
services.AddContentPart<WidgetMetadata>();
services.AddDataMigration<Migrations>();
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@
var contentItem = await ContentManager.NewAsync(type.Name);
await DisplayAsync(await ContentItemDisplayManager.BuildEditorAsync(contentItem, Model.Updater, true, "", Guid.NewGuid().ToString("n")));
}

<script asp-src="~/OrchardCore.Widgets/Scripts/widgetslist.edit.min.js"
debug-src="~/OrchardCore.Widgets/Scripts/widgetslist.edit.js" at="Foot" depends-on="jQuery"></script>
<style asp-src="~/OrchardCore.Widgets/Styles/widgetslist.edit.min.css"
debug-src="~/OrchardCore.Widgets/Styles/widgetslist.edit.css"></style>

<script asp-name="widgetslist-edit" at="Foot"></script>
<style asp-name="widgetslist-edit" at="Head"></style>
}
</div>