Split grid rendering into seperate editor views

This commit is contained in:
per ploug
2014-07-31 14:44:43 +02:00
parent 9957bbfb5d
commit 4e1214085e
8 changed files with 109 additions and 70 deletions

View File

@@ -0,0 +1,3 @@
@model dynamic
@using Umbraco.Web.Templates
@Html.Raw(Model.value)

View 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>
}

View 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>
}
}

View File

@@ -0,0 +1,4 @@
@model dynamic
@using Umbraco.Web.Templates
@Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString()))

View File

@@ -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>
}

View File

@@ -0,0 +1 @@

View 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>
}

View File

@@ -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>