Merge pull request #10512 from bjarnef/v9/feature/grid-partial-async
Render grid editor partial async
This commit is contained in:
@@ -14,7 +14,8 @@
|
||||
<div class="umb-grid">
|
||||
@if (oneColumn)
|
||||
{
|
||||
foreach (var section in Model.sections) {
|
||||
foreach (var section in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
@foreach (var row in section.rows)
|
||||
{
|
||||
@@ -22,12 +23,15 @@
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}else {
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row clearfix">
|
||||
@foreach (var s in Model.sections) {
|
||||
@foreach (var sec in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
<div class="col-md-@s.grid column">
|
||||
@foreach (var row in s.rows)
|
||||
<div class="col-md-@sec.grid column">
|
||||
@foreach (var row in sec.rows)
|
||||
{
|
||||
renderRow(row);
|
||||
}
|
||||
@@ -39,38 +43,46 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions {
|
||||
private void renderRow(dynamic row)
|
||||
@functions{
|
||||
|
||||
private async Task renderRow(dynamic row)
|
||||
{
|
||||
<div @RenderElementAttributes(row)>
|
||||
<div class="row clearfix">
|
||||
@foreach ( var area in row.areas ) {
|
||||
@foreach (var area in row.areas)
|
||||
{
|
||||
<div class="col-md-@area.grid column">
|
||||
<div @RenderElementAttributes(area)>
|
||||
@foreach (var control in area.controls) {
|
||||
if (control !=null && control.editor != null && control.editor.view != null ) {
|
||||
<text>@Html.Partial("grid/editors/base", (object)control)</text>
|
||||
@foreach (var control in area.controls)
|
||||
{
|
||||
if (control != null && control.editor != null && control.editor.view != null)
|
||||
{
|
||||
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@functions {
|
||||
@functions{
|
||||
|
||||
public static HtmlString RenderElementAttributes(dynamic contentItem)
|
||||
{
|
||||
var attrs = new List<string>();
|
||||
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;
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
<div class="umb-grid">
|
||||
@if (oneColumn)
|
||||
{
|
||||
foreach (var section in Model.sections) {
|
||||
foreach (var section in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
@foreach (var row in section.rows)
|
||||
{
|
||||
@@ -18,13 +19,16 @@
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}else {
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="container">
|
||||
<div class="row clearfix">
|
||||
@foreach (var s in Model.sections) {
|
||||
@foreach (var sec in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
<div class="col-md-@s.grid column">
|
||||
@foreach (var row in s.rows)
|
||||
<div class="col-md-@sec.grid column">
|
||||
@foreach (var row in sec.rows)
|
||||
{
|
||||
renderRow(row, false);
|
||||
}
|
||||
@@ -37,25 +41,29 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions {
|
||||
@functions{
|
||||
|
||||
private void renderRow(dynamic row, bool singleColumn)
|
||||
private async Task renderRow(dynamic row, bool singleColumn)
|
||||
{
|
||||
<div @RenderElementAttributes(row)>
|
||||
@if (singleColumn) {
|
||||
@:<div class="container">
|
||||
}
|
||||
<div class="row clearfix">
|
||||
@foreach ( var area in row.areas ) {
|
||||
@foreach (var area in row.areas)
|
||||
{
|
||||
<div class="col-md-@area.grid column">
|
||||
<div @RenderElementAttributes(area)>
|
||||
@foreach (var control in area.controls) {
|
||||
if (control !=null && control.editor != null && control.editor.view != null ) {
|
||||
<text>@Html.Partial("grid/editors/base", (object)control)</text>
|
||||
@foreach (var control in area.controls)
|
||||
{
|
||||
if (control != null && control.editor != null && control.editor.view != null)
|
||||
{
|
||||
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@if (singleColumn) {
|
||||
@:</div>
|
||||
@@ -65,23 +73,26 @@
|
||||
|
||||
}
|
||||
|
||||
@functions{
|
||||
|
||||
@functions {
|
||||
public static HtmlString RenderElementAttributes(dynamic contentItem)
|
||||
{
|
||||
var attrs = new List<string>();
|
||||
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<string>();
|
||||
foreach (JProperty property in style.Properties())
|
||||
{
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
@model dynamic
|
||||
@model dynamic
|
||||
|
||||
@try
|
||||
{
|
||||
string editor = EditorView(Model);
|
||||
<text>@await Html.PartialAsync(editor, (object)Model)</text>
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
<pre>@ex.ToString()</pre>
|
||||
}
|
||||
|
||||
@functions{
|
||||
|
||||
@functions {
|
||||
public static string EditorView(dynamic contentItem)
|
||||
{
|
||||
string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString();
|
||||
view = view.ToLower().Replace(".html", ".cshtml");
|
||||
|
||||
if (!view.Contains("/")) {
|
||||
if (!view.Contains("/"))
|
||||
{
|
||||
view = "grid/editors/" + view;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@try
|
||||
{
|
||||
string editor = EditorView(Model);
|
||||
<text>@Html.Partial(editor, (object)Model)</text>
|
||||
}
|
||||
catch (Exception ex) {
|
||||
<pre>@ex.ToString()</pre>
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
@model dynamic
|
||||
@model dynamic
|
||||
@using Umbraco.Cms.Core.Media
|
||||
@using Umbraco.Cms.Core.PropertyEditors.ValueConverters
|
||||
@inject IImageUrlGenerator ImageUrlGenerator
|
||||
@if (Model.value != null)
|
||||
{
|
||||
var url = Model.value.image;
|
||||
if(Model.editor.config != null && Model.editor.config.size != null){
|
||||
|
||||
if (Model.editor.config != null && Model.editor.config.size != null)
|
||||
{
|
||||
if (Model.value.coordinates != null)
|
||||
{
|
||||
url = ImageCropperTemplateCoreExtensions.GetCropUrl(
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
@using Umbraco.Cms.Core.Templates
|
||||
@using Umbraco.Cms.Core.Templates
|
||||
@model dynamic
|
||||
@inject HtmlLocalLinkParser HtmlLocalLinkParser;
|
||||
@inject HtmlUrlParser HtmlUrlParser;
|
||||
@inject HtmlImageSourceParser HtmlImageSourceParser;
|
||||
|
||||
@{
|
||||
|
||||
var value = HtmlLocalLinkParser.EnsureInternalLinks(Model.value.ToString());
|
||||
value = HtmlUrlParser.EnsureUrls(value);
|
||||
value = HtmlImageSourceParser.EnsureImageSources(value);
|
||||
}
|
||||
|
||||
@Html.Raw(value)
|
||||
|
||||
Reference in New Issue
Block a user