From 05c0d6d022fd19abfc6421824aeb7beab65fbe5d Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Fri, 27 Oct 2023 08:42:17 -0700 Subject: [PATCH 1/3] Update GetPartWrapperCssClasses and GetFieldWrapperCssClasses helpers --- .../Razor/CssOrchardHelperExtensions.cs | 28 +++++++++++-------- ...elper.cs => CssOrchardHelperExtensions.cs} | 6 +--- 2 files changed, 18 insertions(+), 16 deletions(-) rename src/OrchardCore/OrchardCore.DisplayManagement/Html/{CssOrchardHelper.cs => CssOrchardHelperExtensions.cs} (94%) diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs b/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs index 72a5690b049..d10eb65388b 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs @@ -1,15 +1,11 @@ -using System.Collections.Generic; -using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.Mvc.Utilities; - namespace OrchardCore; -public static class CssOrchardHelper +public static class CssOrchardHelperExtensions { private const string FieldWrapperPrefix = "field-wrapper"; private const string PartWrapperPrefix = "content-part-wrapper"; - - public static string GetPartWrapperCssClasses(this IOrchardHelper helper, ContentTypePartDefinition partDefinition) + + public static string GetPartWrapperCssClasses(this IOrchardHelper helper, ContentTypePartDefinition partDefinition, params string[] additionalClasses) { var items = new List() { @@ -19,17 +15,22 @@ public static string GetPartWrapperCssClasses(this IOrchardHelper helper, Conten if (partDefinition != null) { items.Add($"{PartWrapperPrefix}-{partDefinition.PartDefinition.Name.HtmlClassify()}"); - + if (partDefinition.IsNamedPart()) { items.Add($"{PartWrapperPrefix}-{partDefinition.Name.HtmlClassify()}"); } } + if (additionalClasses?.Length > 0) + { + items.AddRange(additionalClasses); + } + return helper.GetWrapperCssClasses(items.ToArray()); } - - public static string GetFieldWrapperCssClasses(this IOrchardHelper helper, ContentPartFieldDefinition fieldDefinition) + + public static string GetFieldWrapperCssClasses(this IOrchardHelper helper, ContentPartFieldDefinition fieldDefinition, params string[] additionalClasses) { var items = new List() { @@ -39,13 +40,18 @@ public static string GetFieldWrapperCssClasses(this IOrchardHelper helper, Conte if (fieldDefinition != null) { items.Add($"{FieldWrapperPrefix}-{fieldDefinition.PartDefinition.Name}-{fieldDefinition.Name}".HtmlClassify()); - + if (fieldDefinition.IsNamedPart()) { items.Add($"{FieldWrapperPrefix}-{fieldDefinition.ContentTypePartDefinition.Name}-{fieldDefinition.Name}".HtmlClassify()); } } + if (additionalClasses?.Length > 0) + { + items.AddRange(additionalClasses); + } + return helper.GetWrapperCssClasses(items.ToArray()); } } diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelper.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs similarity index 94% rename from src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelper.cs rename to src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs index 152fd88aba8..3274fc052d2 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelper.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs @@ -1,12 +1,8 @@ -using System.Collections.Generic; -using System.Linq; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using OrchardCore.DisplayManagement.Html; namespace OrchardCore; -public static class CssOrchardHelper +public static class CssOrchardHelperExtensions { public static string GetLimitedWidthWrapperCssClasses(this IOrchardHelper helper, params string[] additionalClasses) { From d9ab493ebe2a5be168e5daacc23ef155d2d61f46 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Fri, 27 Oct 2023 08:49:22 -0700 Subject: [PATCH 2/3] fix usings --- .../Razor/CssOrchardHelperExtensions.cs | 4 ++++ .../Html/CssOrchardHelperExtensions.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs b/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs index d10eb65388b..76cb3975020 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs @@ -1,3 +1,7 @@ +using System.Collections.Generic; +using OrchardCore.ContentManagement.Metadata.Models; +using OrchardCore.Mvc.Utilities; + namespace OrchardCore; public static class CssOrchardHelperExtensions diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs index 3274fc052d2..6f90331195c 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs @@ -1,3 +1,7 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using OrchardCore.DisplayManagement.Html; namespace OrchardCore; From 007c3d22cb1abef98088bd24e663fae690062e65 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Fri, 27 Oct 2023 09:04:09 -0700 Subject: [PATCH 3/3] Fix build --- .../Html/CssOrchardHelperExtensions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs index 6f90331195c..145bfc44f8e 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using OrchardCore.DisplayManagement.Html; namespace OrchardCore; @@ -74,7 +74,8 @@ public static string GetOffsetCssClasses(this IOrchardHelper helper, params stri return string.Join(' ', Combine(options.OffsetClasses, additionalClasses)); } - private static TheAdminThemeOptions GetThemeOptions(IOrchardHelper helper) => helper.HttpContext.RequestServices.GetService>().Value; + private static TheAdminThemeOptions GetThemeOptions(IOrchardHelper helper) + => helper.HttpContext.RequestServices.GetService>().Value; private static IEnumerable Combine(string optionClasses, string[] additionalClasses) {