From ff65a333e137882eee0636e6492fdcfdc76b5381 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 22 Jun 2021 19:33:48 +0200 Subject: [PATCH] Render grid partials async --- .../Partials/grid/bootstrap3-fluid.cshtml | 25 +++++++++----- .../Views/Partials/grid/bootstrap3.cshtml | 33 +++++++++++-------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3-fluid.cshtml b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3-fluid.cshtml index 7e349bd7f3..3b91577a03 100644 --- a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3-fluid.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3-fluid.cshtml @@ -39,38 +39,45 @@ } -@functions { - private void renderRow(dynamic row) +@functions{ + + private async Task renderRow(dynamic row) {
- @foreach ( var area in row.areas ) { + @foreach (var area in row.areas) + {
- @foreach (var control in area.controls) { - if (control !=null && control.editor != null && control.editor.view != null ) { - @Html.Partial("grid/editors/base", (object)control) + @foreach (var control in area.controls) + { + if (control != null && control.editor != null && control.editor.view != null ) { + @await Html.PartialAsync("grid/editors/base", (object)control) } }
-
} +
+ }
} } -@functions { +@functions{ + public static HtmlString RenderElementAttributes(dynamic contentItem) { var attrs = new List(); JObject cfg = contentItem.config; - if(cfg != null) + if (cfg != null) + { foreach (JProperty property in cfg.Properties()) { var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); attrs.Add(property.Name + "=\"" + propertyValue + "\""); } + } JObject style = contentItem.styles; diff --git a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3.cshtml b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3.cshtml index cf35714692..bc4b3cd6dd 100644 --- a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3.cshtml @@ -21,10 +21,10 @@ }else {
- @foreach (var s in Model.sections) { + @foreach (var sec in Model.sections) {
-
- @foreach (var row in s.rows) +
+ @foreach (var row in sec.rows) { renderRow(row, false); } @@ -37,25 +37,29 @@
} -@functions { +@functions{ - private void renderRow(dynamic row, bool singleColumn) + private async Task renderRow(dynamic row, bool singleColumn) {
@if (singleColumn) { @:
}
- @foreach ( var area in row.areas ) { + @foreach (var area in row.areas) + {
- @foreach (var control in area.controls) { - if (control !=null && control.editor != null && control.editor.view != null ) { - @Html.Partial("grid/editors/base", (object)control) + @foreach (var control in area.controls) + { + if (control != null && control.editor != null && control.editor.view != null) + { + @await Html.PartialAsync("grid/editors/base", (object)control) } }
-
} +
+ }
@if (singleColumn) { @:
@@ -65,23 +69,26 @@ } +@functions{ -@functions { public static HtmlString RenderElementAttributes(dynamic contentItem) { var attrs = new List(); JObject cfg = contentItem.config; - if(cfg != null) + if (cfg != null) + { foreach (JProperty property in cfg.Properties()) { var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); attrs.Add(property.Name + "=\"" + propertyValue + "\""); } + } JObject style = contentItem.styles; - if (style != null) { + if (style != null) + { var cssVals = new List(); foreach (JProperty property in style.Properties()) {