Incremental work on placeable content.

This commit is contained in:
Sipke Schoorstra
2015-09-04 12:42:08 +01:00
parent de3d205ca9
commit dfce6deaf1
10 changed files with 52 additions and 30 deletions

View File

@@ -5,5 +5,9 @@ namespace Orchard.Layouts.Helpers {
public static ContentPartDefinitionBuilder Placeable(this ContentPartDefinitionBuilder builder, bool placeable = true) {
return builder.WithSetting("ContentPartLayoutSettings.Placeable", placeable.ToString());
}
public static ContentTypeDefinitionBuilder Placeable(this ContentTypeDefinitionBuilder builder, bool placeable = true) {
return builder.WithSetting("ContentTypeLayoutSettings.Placeable", placeable.ToString());
}
}
}

View File

@@ -85,7 +85,6 @@
<Content Include="Images\illustration.jpg" />
<Content Include="Images\logo.svg" />
<Content Include="Placement.info" />
<Content Include="Scripts\contentpart-layouts-settings.js" />
<Content Include="Scripts\DemoConfig.js" />
<Content Include="Scripts\DemoData.js" />
<Content Include="Scripts\element-browser.js" />
@@ -394,6 +393,8 @@
<Compile Include="Services\LayoutModelMapper.cs" />
<Compile Include="Services\ElementSerializer.cs" />
<Compile Include="Services\ObjectStore.cs" />
<Compile Include="Settings\ContentTypeLayoutSettingsHooks.cs" />
<Compile Include="Settings\ContentTypeLayoutSettings.cs" />
<Compile Include="Signals.cs" />
<Compile Include="Tokens\ElementTokens.cs" />
<Compile Include="ViewModels\BreadcrumbsEditorViewModel.cs" />
@@ -430,9 +431,9 @@
<Compile Include="Services\ContentFieldDisplay.cs" />
<Compile Include="Services\IContentFieldDisplay.cs" />
<Compile Include="Settings\ContentPartLayoutSettings.cs" />
<Compile Include="Settings\LayoutSettingsHooks.cs" />
<Compile Include="Settings\LayoutTypePartSettingsHooks.cs" />
<Compile Include="Settings\LayoutTypePartSettings.cs" />
<Compile Include="Settings\ContentPartSettingsHooks.cs" />
<Compile Include="Settings\ContentPartLayoutSettingsHooks.cs" />
<Compile Include="ViewModels\BlueprintsIndexViewModel.cs" />
<Compile Include="ViewModels\ContentItemEditorViewModel.cs" />
<Compile Include="ViewModels\EditElementBlueprintViewModel.cs" />
@@ -598,6 +599,9 @@
<ItemGroup>
<Content Include="Views\Elements\Widget.Design.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\DefinitionTemplates\ContentTypeLayoutSettings.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -1,19 +0,0 @@
(function ($) {
var placeable = $("input[name=\"ContentPartLayoutSettings.Placeable\"]");
$(placeable).on("change", function (e) {
syncEnableEditorInput();
});
$(function () {
syncEnableEditorInput();
});
var syncEnableEditorInput = function () {
var enableEditorDialog = $("input[name=\"ContentPartLayoutSettings.EnableEditorDialog\"]");
var isPlaceable = placeable.is(":checked");
enableEditorDialog.prop("disabled", !isPlaceable);
};
})(jQuery);

View File

@@ -1,7 +1,7 @@
namespace Orchard.Layouts.Settings {
public class ContentPartLayoutSettings {
/// <summary>
/// This setting is used to configure a part to be placeable on a layout.
/// This setting is used to configure a content part to be placeable on a layout.
/// </summary>
public bool Placeable { get; set; }
}

View File

@@ -7,7 +7,7 @@ using Orchard.ContentManagement.ViewModels;
using Orchard.Layouts.Helpers;
namespace Orchard.Layouts.Settings {
public class ContentPartSettingsHooks : ContentDefinitionEditorEventsBase {
public class ContentPartLayoutSettingsHooks : ContentDefinitionEditorEventsBase {
public override IEnumerable<TemplateViewModel> PartEditor(ContentPartDefinition definition) {
var model = definition.Settings.GetModel<ContentPartLayoutSettings>();

View File

@@ -0,0 +1,8 @@
namespace Orchard.Layouts.Settings {
public class ContentTypeLayoutSettings {
/// <summary>
/// This setting is used to configure a content type to be placeable on a layout.
/// </summary>
public bool Placeable { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.ViewModels;
using Orchard.Layouts.Helpers;
namespace Orchard.Layouts.Settings {
public class ContentTypeLayoutSettingsHooks : ContentDefinitionEditorEventsBase {
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) {
var model = definition.Settings.GetModel<ContentTypeLayoutSettings>();
yield return DefinitionTemplate(model);
}
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
var model = new ContentTypeLayoutSettings();
updateModel.TryUpdateModel(model, "ContentTypeLayoutSettings", null, null);
builder.Placeable(model.Placeable);
yield return DefinitionTemplate(model);
}
}
}

View File

@@ -8,11 +8,11 @@ using Orchard.ContentManagement.ViewModels;
using Orchard.Layouts.Services;
namespace Orchard.Layouts.Settings {
public class LayoutSettingsHooks : ContentDefinitionEditorEventsBase {
public class LayoutTypePartSettingsHooks : ContentDefinitionEditorEventsBase {
private readonly ILayoutSerializer _serializer;
private readonly ILayoutManager _layoutManager;
public LayoutSettingsHooks(ILayoutSerializer serializer, ILayoutManager layoutManager) {
public LayoutTypePartSettingsHooks(ILayoutSerializer serializer, ILayoutManager layoutManager) {
_serializer = serializer;
_layoutManager = layoutManager;
}

View File

@@ -1,8 +1,4 @@
@model Orchard.Layouts.Settings.ContentPartLayoutSettings
@{
Script.Require("jQuery");
Script.Include("contentpart-layouts-settings.js");
}
<fieldset>
@Html.CheckBoxFor(m => m.Placeable)
<label for="@Html.FieldIdFor(m => m.Placeable)" class="forcheckbox">@T("Placeable")</label>

View File

@@ -0,0 +1,6 @@
@model Orchard.Layouts.Settings.ContentTypeLayoutSettings
<fieldset>
@Html.CheckBoxFor(m => m.Placeable)
<label for="@Html.FieldIdFor(m => m.Placeable)" class="forcheckbox">@T("Placeable")</label>
<span class="hint">@T("Check to allow this type to be placeable on a layout.")</span>
</fieldset>