Some work on the Containers front end. Creating a default page size site setting for containers.

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-09 16:00:51 -08:00
parent 9bf3368b25
commit 48f803b082
9 changed files with 88 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Containers.Models;
using Orchard.Data;
@@ -21,8 +22,12 @@ namespace Orchard.Core.Containers.Drivers {
}
public class ContainerPartHandler : ContentHandler {
public ContainerPartHandler(IRepository<ContainerPartRecord> repository) {
public ContainerPartHandler(IRepository<ContainerPartRecord> repository, IOrchardServices orchardServices) {
Filters.Add(StorageFilter.For(repository));
OnInitializing<ContainerPart>((context, part) => {
var containerSiteSettings = orchardServices.WorkContext.CurrentSite.As<ContainerSettingsPart>().Record;
part.Record.PageSize = containerSiteSettings.DefaultPageSize;
});
}
}
}

View File

@@ -0,0 +1,35 @@
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Containers.Models;
using Orchard.Data;
using Orchard.Localization;
namespace Orchard.Core.Containers.Drivers {
public class ContainerSettingsPartDriver : ContentPartDriver<ContainerSettingsPart> {
public ContainerSettingsPartDriver() {
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
protected override string Prefix { get { return "ContainerSettings"; } }
protected override DriverResult Editor(ContainerSettingsPart part, dynamic shapeHelper) {
return ContentShape("Parts_Container_SiteSettings",
() => shapeHelper.EditorTemplate(TemplateName: "Container.SiteSettings", Model: part.Record, Prefix: Prefix));
}
protected override DriverResult Editor(ContainerSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
updater.TryUpdateModel(part.Record, Prefix, null, null);
return Editor(part, shapeHelper);
}
}
public class ContainerSettingsPartHandler : ContentHandler {
public ContainerSettingsPartHandler(IRepository<ContainerSettingsPartRecord> repository) {
Filters.Add(new ActivatingFilter<ContainerSettingsPart>("Site"));
Filters.Add(StorageFilter.For(repository));
}
}
}

View File

@@ -1,5 +1,4 @@
using System;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;
@@ -14,6 +13,11 @@ namespace Orchard.Core.Containers {
.Column<string>("OrderByProperty")
.Column<int>("OrderByDirection"));
SchemaBuilder.CreateTable("ContainerSettingsPartRecord", table => table
.ContentPartRecord()
.Column<int>("DefaultPageSize", column => column.WithDefault(10))
);
ContentDefinitionManager.AlterPartDefinition("ContainerPart", builder => builder.Attachable());
ContentDefinitionManager.AlterPartDefinition("ContainablePart", builder => builder.Attachable());

View File

@@ -0,0 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Core.Containers.Models {
public class ContainerSettingsPart : ContentPart<ContainerSettingsPartRecord> {
}
}

View File

@@ -0,0 +1,11 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Containers.Models {
public class ContainerSettingsPartRecord : ContentPartRecord {
private int _defaultPageSize = 10;
public virtual int DefaultPageSize {
get { return _defaultPageSize; }
set { _defaultPageSize = value; }
}
}
}

View File

@@ -1,4 +1,5 @@
<Placement>
<Place Parts_Containable_Edit="Content:before.3"/>
<Place Parts_Container_Edit="Content:5"/>
<Place Parts_Containable_Edit="Content:before.3"/>
<Place Parts_Container_Edit="Content:5"/>
<Place Parts_Container_SiteSettings="Content:10"/>
</Placement>

View File

@@ -0,0 +1,11 @@
@model Orchard.Core.Containers.Models.ContainerSettingsPartRecord
@using Orchard.Core.Containers.Models;
<fieldset>
<legend>@T("Content Container")</legend>
<div>
<label for="@ViewData.TemplateInfo.GetFullHtmlFieldId("DefaultPageSize")">@T("Default page size")</label>
@Html.EditorFor(m => m.DefaultPageSize)
@Html.ValidationMessageFor(m => m.DefaultPageSize)
</div>
</fieldset>

View File

@@ -1,15 +1,15 @@
@model Orchard.Core.Containers.Models.ContainerPart
<fieldset>
@Html.LabelFor(m => m.Record.PageSize, T("Page Size"))
@Html.TextBoxFor(m => m.Record.PageSize)
</fieldset>
<fieldset>
@Html.LabelFor(m => m.Record.Paginated, T("Paginated"))
@Html.TextBoxFor(m => m.Record.Paginated)
</fieldset>
<fieldset>
@Html.LabelFor(m => m.Record.PageSize, T("PageSize"))
@Html.TextBoxFor(m => m.Record.PageSize)
</fieldset>
<fieldset>
@Html.LabelFor(m => m.Record.OrderByProperty, T("OrderByProperty"))
@Html.TextBoxFor(m => m.Record.OrderByProperty)

View File

@@ -75,6 +75,9 @@
<Compile Include="Common\Drivers\TextFieldDriver.cs" />
<Compile Include="Containers\ContainersPathConstraint.cs" />
<Compile Include="Containers\Migrations.cs" />
<Compile Include="Containers\Drivers\ContainerSettingsPartDriver.cs" />
<Compile Include="Containers\Models\ContainerSettingsPart.cs" />
<Compile Include="Containers\Models\ContainerSettingsPartRecord.cs" />
<Compile Include="Containers\Models\ContainablePart.cs" />
<Compile Include="Containers\Models\ContainerPart.cs" />
<Compile Include="Common\Shapes.cs" />
@@ -395,6 +398,7 @@
<Content Include="Containers\Views\EditorTemplates\Containable.cshtml" />
<Content Include="Containers\Views\EditorTemplates\Container.cshtml" />
<Content Include="Containers\Views\Item\Display.cshtml" />
<Content Include="Containers\Views\EditorTemplates\Container.SiteSettings.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />