Add setting to hide Container editor

This commit is contained in:
Sebastien Ros
2015-09-16 15:25:09 -07:00
parent f3595881fe
commit 9e9e19c439
4 changed files with 18 additions and 1 deletions

View File

@@ -88,6 +88,10 @@ namespace Orchard.Core.Containers.Drivers {
protected override DriverResult Editor(ContainerPart part, IUpdateModel updater, dynamic shapeHelper) {
return ContentShape("Parts_Container_Edit", () => {
if(!part.ContainerSettings.DisplayContainerEditor) {
return null;
}
var containables = !part.ContainerSettings.RestrictItemContentTypes ? _containerService.GetContainableTypes().ToList() : new List<ContentTypeDefinition>(0);
var model = new ContainerViewModel {
AdminMenuPosition = part.AdminMenuPosition,

View File

@@ -48,6 +48,10 @@ namespace Orchard.Core.Containers.Settings {
}
public class ContainerTypePartSettings {
public ContainerTypePartSettings() {
DisplayContainerEditor = true;
}
public bool? ItemsShownDefault { get; set; }
public int? PageSizeDefault { get; set; }
public bool? PaginatedDefault { get; set; }
@@ -55,6 +59,7 @@ namespace Orchard.Core.Containers.Settings {
public bool RestrictItemContentTypes { get; set; }
public bool? EnablePositioning { get; set; }
public string AdminListViewName { get; set; }
public bool DisplayContainerEditor { get; set; }
}
public class ContainerSettingsHooks : ContentDefinitionEditorEventsBase {
@@ -93,7 +98,8 @@ namespace Orchard.Core.Containers.Settings {
EnablePositioning = model.EnablePositioning,
AdminListViewName = model.AdminListViewName,
AvailableItemContentTypes = _containerService.GetContainableTypes().ToList(),
ListViewProviders = _listViewService.Providers.ToList()
ListViewProviders = _listViewService.Providers.ToList(),
DisplayContainerEditor = model.DisplayContainerEditor
};
yield return DefinitionTemplate(viewModel);
@@ -122,6 +128,7 @@ namespace Orchard.Core.Containers.Settings {
builder.WithSetting("ContainerTypePartSettings.RestrictItemContentTypes", viewModel.RestrictItemContentTypes.ToString());
builder.WithSetting("ContainerTypePartSettings.EnablePositioning", viewModel.EnablePositioning.ToString());
builder.WithSetting("ContainerTypePartSettings.AdminListViewName", viewModel.AdminListViewName);
builder.WithSetting("ContainerTypePartSettings.DisplayContainerEditor", viewModel.DisplayContainerEditor.ToString());
yield return DefinitionTemplate(viewModel);
}

View File

@@ -16,5 +16,6 @@ namespace Orchard.Core.Containers.ViewModels {
[UIHint("ListViewPicker")]
public string AdminListViewName { get; set; }
public bool DisplayContainerEditor { get; set; }
}
}

View File

@@ -2,6 +2,11 @@
@{
Script.Require("ShapesBase");
}
<fieldset>
@Html.CheckBoxFor(m => m.DisplayContainerEditor)
@Html.LabelFor(m => m.DisplayContainerEditor, @T("Display settings editor").ToString(), new { @class = "forcheckbox" })
<span class="hint">@T("When checked, users can change the settings for each content item.")</span>
</fieldset>
<fieldset>
<label for="@Html.FieldIdFor(m => m.ItemsShownDefault)">@T("Default Items Shown")</label>
@Html.EditorFor(m => m.ItemsShownDefault)