Split grid rendering into seperate editor views
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Web.Templates
|
||||
@Html.Raw(Model.value)
|
||||
17
src/Umbraco.Web.UI/Views/Partials/Grid/Editors/macro.cshtml
Normal file
17
src/Umbraco.Web.UI/Views/Partials/Grid/Editors/macro.cshtml
Normal file
@@ -0,0 +1,17 @@
|
||||
@inherits UmbracoViewPage<dynamic>
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
|
||||
@if (Model.value != null)
|
||||
{
|
||||
string macroAlias = Model.value.macroAlias.ToString();
|
||||
ViewDataDictionary parameters = new ViewDataDictionary();
|
||||
foreach (dynamic mpd in Model.value.marcoParamsDictionary)
|
||||
{
|
||||
parameters.Add(mpd.Name, mpd.Value);
|
||||
}
|
||||
|
||||
<text>
|
||||
@Umbraco.RenderMacro(macroAlias, parameters)
|
||||
</text>
|
||||
}
|
||||
13
src/Umbraco.Web.UI/Views/Partials/Grid/Editors/media.cshtml
Normal file
13
src/Umbraco.Web.UI/Views/Partials/Grid/Editors/media.cshtml
Normal file
@@ -0,0 +1,13 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
@if (Model.value != null)
|
||||
{
|
||||
<div class="thumbnail">
|
||||
<img src="@Model.value.image" alt="@Model.value.caption">
|
||||
</div>
|
||||
if (Model.value.caption != null)
|
||||
{
|
||||
<p class="caption">@Model.value.caption</p>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
@Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString()))
|
||||
@@ -0,0 +1,20 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
@if (Model.editor.config.markup != null)
|
||||
{
|
||||
string markup = Model.editor.config.markup.ToString();
|
||||
|
||||
markup = markup.Replace("#value#", Model.value.ToString());
|
||||
markup = markup.Replace("#style#", Model.editor.config.style.ToString());
|
||||
|
||||
<text>
|
||||
@Html.Raw(markup)
|
||||
</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>
|
||||
<div style="@Model.editor.config.style">@Model.value</div>
|
||||
</text>
|
||||
}
|
||||
1
src/Umbraco.Web.UI/Views/Partials/Grid/basic.cshtml
Normal file
1
src/Umbraco.Web.UI/Views/Partials/Grid/basic.cshtml
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
47
src/Umbraco.Web.UI/Views/Partials/Grid/bootstrap2.cshtml
Normal file
47
src/Umbraco.Web.UI/Views/Partials/Grid/bootstrap2.cshtml
Normal file
@@ -0,0 +1,47 @@
|
||||
@inherits UmbracoViewPage<dynamic>
|
||||
@using Umbraco.Web.Templates
|
||||
@using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
@if (Model != null && !string.IsNullOrEmpty(Model.ToString()))
|
||||
{
|
||||
var onlyOneColumn = Model.sections != null ? ((System.Collections.ICollection)Model.sections).Count : 0;
|
||||
|
||||
<div class="uSky-grid @(onlyOneColumn > 1 ? "container-fluid" : "")">
|
||||
<div class="row-fluid clearfix">
|
||||
@foreach (var s in Model.sections)
|
||||
{
|
||||
<div class="@("span" + s.grid)">
|
||||
@foreach (var row in s.rows)
|
||||
{
|
||||
<div class="gridrow_@row.uniqueId" >
|
||||
<div>
|
||||
<div class="row-fluid clearfix">
|
||||
|
||||
@foreach (var area in row.areas)
|
||||
{
|
||||
<div class="@("span" + area.grid)">
|
||||
|
||||
@foreach (var control in area.controls)
|
||||
{
|
||||
if (control != null && control.editor != null && control.editor.view != null)
|
||||
{
|
||||
|
||||
string editor = "grid/editors/" + control.editor.view.ToString();
|
||||
<text>
|
||||
@Html.Partial(editor, (object)control)
|
||||
</text>
|
||||
}
|
||||
}
|
||||
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -26,78 +26,12 @@
|
||||
if (control != null && control.editor != null && control.editor.view != null)
|
||||
{
|
||||
|
||||
string editor = control.editor.view.ToString();
|
||||
|
||||
switch (editor)
|
||||
{
|
||||
case "rte":
|
||||
<text>
|
||||
@Html.Raw(TemplateUtilities.ParseInternalLinks(control.value.ToString()))
|
||||
</text>
|
||||
break;
|
||||
case "macro":
|
||||
if (control.value != null)
|
||||
{
|
||||
string macroAlias = control.value.macroAlias.ToString();
|
||||
ViewDataDictionary parameters = new ViewDataDictionary();
|
||||
foreach (dynamic mpd in control.value.marcoParamsDictionary)
|
||||
{
|
||||
parameters.Add(mpd.Name, mpd.Value);
|
||||
}
|
||||
|
||||
<text>
|
||||
@Umbraco.RenderMacro(macroAlias, parameters)
|
||||
</text>
|
||||
}
|
||||
break;
|
||||
case "textstring":
|
||||
|
||||
if (control.editor.config.markup != null)
|
||||
{
|
||||
string markup = control.editor.config.markup.ToString();
|
||||
|
||||
markup = markup.Replace("#value#", control.value.ToString());
|
||||
markup = markup.Replace("#style#", control.editor.config.style.ToString());
|
||||
|
||||
<text>
|
||||
@Html.Raw(markup)
|
||||
</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>
|
||||
<div style="@control.editor.config.style">@control.value</div>
|
||||
</text>
|
||||
}
|
||||
|
||||
break;
|
||||
case "media":
|
||||
<text>
|
||||
@if (control.value != null)
|
||||
{
|
||||
<div class="thumbnail">
|
||||
<img src="@control.value.image">
|
||||
</div>
|
||||
if (control.value.caption != null)
|
||||
{
|
||||
<p class="caption">@control.value.caption</p>
|
||||
}
|
||||
}
|
||||
</text>
|
||||
break;
|
||||
case "embed":
|
||||
<text>
|
||||
@Html.Raw(control.value)
|
||||
</text>
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
string editor = "grid/editors/" + control.editor.view.ToString();
|
||||
<text>
|
||||
@Html.Partial(editor, (object)control)
|
||||
</text>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user