mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Implemented collapsible columns.
This commit is contained in:
@@ -64,7 +64,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(CheckBox element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(CheckBox element, ElementDisplayingContext context) {
|
||||
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.RuntimeValue, null);
|
||||
}
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(FormElement element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(FormElement element, ElementDisplayingContext context) {
|
||||
context.ElementShape.Metadata.Wrappers.Add("FormElement_Wrapper");
|
||||
context.ElementShape.Child.Add(New.PlaceChildContent(Source: context.ElementShape));
|
||||
|
||||
|
@@ -75,7 +75,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(EmailField element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(EmailField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.RuntimeValue, null);
|
||||
}
|
||||
}
|
||||
|
@@ -79,7 +79,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Enumeration element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Enumeration element, ElementDisplayingContext context) {
|
||||
var tokenizedOptions = _tokenizer.Replace(element.Options).ToArray();
|
||||
var typeName = element.GetType().Name;
|
||||
var displayType = context.DisplayType;
|
||||
|
@@ -128,7 +128,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Form element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Form element, ElementDisplayingContext context) {
|
||||
var controller = _currentControllerAccessor.CurrentController;
|
||||
var values = controller.FetchPostedValues(element);
|
||||
var modelState = controller.FetchModelState(element);
|
||||
|
@@ -33,7 +33,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(HiddenField element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(HiddenField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.Value, null);
|
||||
}
|
||||
}
|
||||
|
@@ -116,7 +116,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Query element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Query element, ElementDisplayingContext context) {
|
||||
var queryId = element.QueryId;
|
||||
var typeName = element.GetType().Name;
|
||||
var category = element.Category.ToSafeName();
|
||||
|
@@ -39,7 +39,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(RadioButton element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(RadioButton element, ElementDisplayingContext context) {
|
||||
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.Value, null);
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(ReCaptcha element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(ReCaptcha element, ElementDisplayingContext context) {
|
||||
var workContext = _services.WorkContext;
|
||||
var currentSite = workContext.CurrentSite;
|
||||
var settings = currentSite.As<ReCaptchaSettingsPart>();
|
||||
|
@@ -120,7 +120,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Taxonomy element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Taxonomy element, ElementDisplayingContext context) {
|
||||
var taxonomyId = element.TaxonomyId;
|
||||
var typeName = element.GetType().Name;
|
||||
var displayType = context.DisplayType;
|
||||
|
@@ -87,7 +87,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(TextArea element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(TextArea element, ElementDisplayingContext context) {
|
||||
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.RuntimeValue, null);
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(TextField element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(TextField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.RuntimeValue, null);
|
||||
}
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@
|
||||
// return Editor(context, validatorsEditor);
|
||||
// }
|
||||
|
||||
// protected override void OnDisplaying(FormElement element, ElementDisplayContext context) {
|
||||
// protected override void OnDisplaying(FormElement element, ElementDisplayingContext context) {
|
||||
// if (context.DisplayType == "Design" || element.Form == null)
|
||||
// return;
|
||||
|
||||
|
@@ -21,7 +21,7 @@ namespace Orchard.DynamicForms.Handlers {
|
||||
}
|
||||
}
|
||||
|
||||
void IElementEventHandler.Displaying(ElementDisplayContext context) {
|
||||
void IElementEventHandler.Displaying(ElementDisplayingContext context) {
|
||||
if (context.DisplayType == "Design")
|
||||
return;
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Orchard.DynamicForms.Handlers {
|
||||
context.ElementShape.ClientValidationAttributes = registrationContext.ClientAttributes;
|
||||
}
|
||||
|
||||
void IElementEventHandler.Displayed(ElementDisplayedContext context) {}
|
||||
void IFormElementEventHandler.GetElementValue(FormElement element, ReadElementValuesContext context) { }
|
||||
void IElementEventHandler.Creating(ElementCreatingContext context) {}
|
||||
void IElementEventHandler.Created(ElementCreatedContext context) {}
|
||||
|
@@ -1,6 +1,13 @@
|
||||
using Orchard.Layouts.Elements;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
|
||||
namespace Orchard.Layouts.Drivers {
|
||||
public class ColumnElementDriver : ElementDriver<Column> {}
|
||||
public class ColumnElementDriver : ElementDriver<Column> {
|
||||
protected override void OnDisplaying(Column element, ElementDisplayingContext context) {
|
||||
context.ElementShape.Width = element.Width;
|
||||
context.ElementShape.Offset = element.Offset;
|
||||
context.ElementShape.Collapsed = false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -37,7 +37,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
return Editor(context, editor);
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(ContentItem element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(ContentItem element, ElementDisplayingContext context) {
|
||||
var contentItemIds = context.Content != null ? RemoveCurrentContentItemId(element.ContentItemIds, context.Content.Id) : element.ContentItemIds;
|
||||
var displayType = element.DisplayType;
|
||||
var contentItems = GetContentItems(contentItemIds).ToArray();
|
||||
|
@@ -19,7 +19,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
_transactionManager = transactionManager;
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(ContentPart element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(ContentPart element, ElementDisplayingContext context) {
|
||||
// Content is optional context, so if it's null, we can't render the part element.
|
||||
// This typically only happens when the layout editor is used outside the context of
|
||||
// a content item and still renders the various content part elements as part of the toolbox.
|
||||
|
@@ -27,7 +27,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
return Editor(context, editor);
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Html element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Html element, ElementDisplayingContext context) {
|
||||
var text = element.Content;
|
||||
var flavor = "html";
|
||||
var processedText = ApplyHtmlFilters(text, flavor);
|
||||
|
@@ -33,7 +33,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
return Editor(context, editor);
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Image element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Image element, ElementDisplayingContext context) {
|
||||
var imageId = element.MediaId;
|
||||
var image = imageId != null ? GetImage(imageId.Value) : default(ImagePart);
|
||||
context.ElementShape.ImagePart = image;
|
||||
|
@@ -22,7 +22,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
return Editor(context, editor);
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(MarkdownElement element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(MarkdownElement element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedContent = ToHtml(element.Content);
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
return Editor(context, editor);
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(MediaItem element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(MediaItem element, ElementDisplayingContext context) {
|
||||
var contentItemIds = RemoveCurrentContentItemId(element.MediaItemIds, context.Content.Id);
|
||||
var displayType = context.DisplayType != "Design" ? element.DisplayType : "Thumbnail";
|
||||
var contentItems = GetContentItems(contentItemIds).ToArray();
|
||||
|
@@ -27,7 +27,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
return Editor(context, editor);
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Paragraph element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Paragraph element, ElementDisplayingContext context) {
|
||||
var text = element.Content;
|
||||
var flavor = "html";
|
||||
var processedText = ApplyHtmlFilters(text, flavor);
|
||||
|
@@ -53,7 +53,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Projection element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Projection element, ElementDisplayingContext context) {
|
||||
var queryId = element.QueryId;
|
||||
var layoutId = element.LayoutId;
|
||||
|
||||
|
@@ -1,7 +1,52 @@
|
||||
using Orchard.Layouts.Elements;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Layouts.Elements;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
|
||||
namespace Orchard.Layouts.Drivers {
|
||||
public class RowElementDriver : ElementDriver<Row> {
|
||||
protected override void OnDisplaying(Row element, ElementDisplayingContext context) {
|
||||
context.ElementShape.Collapsed = false;
|
||||
}
|
||||
|
||||
protected override void OnDisplayed(Row element, ElementDisplayedContext context) {
|
||||
var columnShapes = ((IEnumerable<dynamic>)context.ElementShape.Items).ToList();
|
||||
var columnIndex = 0;
|
||||
|
||||
foreach (var columnShape in columnShapes) {
|
||||
var column = (Column)columnShape.Element;
|
||||
|
||||
if (column.Collapsible == true && IsEmpty(columnShape)) {
|
||||
columnShape.Collapsed = true;
|
||||
|
||||
var sibling = GetNonCollapsedSibling(columnShapes, columnIndex);
|
||||
if (sibling != null) {
|
||||
// Increase the width of the sibling by the width of the current column.
|
||||
sibling.Width += columnShape.Width;
|
||||
//sibling.Width += GetAvailableWidth(columnShapes.Skip(columnIndex));
|
||||
}
|
||||
else {
|
||||
// The row has only one column, which is collapsed, so we hide the row entirely.
|
||||
context.ElementShape.Collapsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
++columnIndex;
|
||||
}
|
||||
}
|
||||
|
||||
private dynamic GetNonCollapsedSibling(IList<dynamic> columnShapes, int index) {
|
||||
var siblings = index == 0 ? columnShapes : columnShapes.Reverse();
|
||||
return siblings.FirstOrDefault(x => x.Collapsed == false);
|
||||
}
|
||||
|
||||
private int GetAvailableWidth(IEnumerable<dynamic> columnShapes) {
|
||||
return columnShapes.Where(x => IsEmpty(x)).Sum(x => (int) x.Width);
|
||||
}
|
||||
|
||||
private static bool IsEmpty(dynamic shape) {
|
||||
return shape.Items.Count == 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,7 +19,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
get { yield return "ShapeElement"; }
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Shape element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Shape element, ElementDisplayingContext context) {
|
||||
if (String.IsNullOrWhiteSpace(element.ShapeType))
|
||||
return;
|
||||
|
||||
|
@@ -27,7 +27,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
return Editor(context, editor);
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Text element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Text element, ElementDisplayingContext context) {
|
||||
var text = element.Content;
|
||||
var flavor = "textarea";
|
||||
var processedText = ApplyHtmlFilters(text, flavor);
|
||||
|
@@ -37,7 +37,7 @@ namespace Orchard.Layouts.Drivers {
|
||||
return Editor(context, editor);
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(VectorImage element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(VectorImage element, ElementDisplayingContext context) {
|
||||
var mediaId = element.MediaId;
|
||||
var vectorImage = mediaId != null ? GetVectorImage(mediaId.Value) : default(VectorImagePart);
|
||||
context.ElementShape.VectorImagePart = vectorImage;
|
||||
|
@@ -25,9 +25,7 @@ namespace Orchard.Layouts.Framework.Display {
|
||||
Element element,
|
||||
IContent content,
|
||||
string displayType = null,
|
||||
IUpdateModel updater = null,
|
||||
string renderEventName = null,
|
||||
string renderEventArgs = null) {
|
||||
IUpdateModel updater = null) {
|
||||
|
||||
var createShapeContext = new ElementCreatingDisplayShapeContext {
|
||||
Element = element,
|
||||
@@ -39,7 +37,7 @@ namespace Orchard.Layouts.Framework.Display {
|
||||
|
||||
var typeName = element.GetType().Name;
|
||||
var category = element.Category.ToSafeName();
|
||||
var drivers = element.Descriptor.GetDrivers();
|
||||
var drivers = element.Descriptor.GetDrivers().ToList();
|
||||
var elementShapeArguments = CreateArguments(element, content);
|
||||
var elementShape = (dynamic)_shapeFactory.Create("Element", elementShapeArguments, () => new ZoneHolding(() => _shapeFactory.Create("ElementZone")));
|
||||
|
||||
@@ -49,19 +47,19 @@ namespace Orchard.Layouts.Framework.Display {
|
||||
elementShape.Metadata.Alternates.Add(String.Format("Elements_{0}__{1}", typeName, category));
|
||||
elementShape.Metadata.Alternates.Add(String.Format("Elements_{0}_{1}__{2}", typeName, displayType, category));
|
||||
|
||||
var displayContext = new ElementDisplayContext {
|
||||
var displayingContext = new ElementDisplayingContext {
|
||||
Element = element,
|
||||
ElementShape = elementShape,
|
||||
DisplayType = displayType,
|
||||
Content = content,
|
||||
Updater = updater,
|
||||
RenderEventName = renderEventName,
|
||||
RenderEventArgs = renderEventArgs
|
||||
Updater = updater
|
||||
};
|
||||
|
||||
_elementEventHandlerHandler.Displaying(displayContext);
|
||||
InvokeDrivers(drivers, driver => driver.Displaying(displayContext));
|
||||
element.Descriptor.Display(displayContext);
|
||||
_elementEventHandlerHandler.Displaying(displayingContext);
|
||||
InvokeDrivers(drivers, driver => driver.Displaying(displayingContext));
|
||||
|
||||
if (element.Descriptor.Displaying != null)
|
||||
element.Descriptor.Displaying(displayingContext);
|
||||
|
||||
var container = element as Container;
|
||||
|
||||
@@ -75,14 +73,28 @@ namespace Orchard.Layouts.Framework.Display {
|
||||
}
|
||||
}
|
||||
|
||||
var displayedContext = new ElementDisplayedContext {
|
||||
Element = element,
|
||||
ElementShape = elementShape,
|
||||
DisplayType = displayType,
|
||||
Content = content,
|
||||
Updater = updater
|
||||
};
|
||||
|
||||
_elementEventHandlerHandler.Displayed(displayedContext);
|
||||
InvokeDrivers(drivers, driver => driver.Displayed(displayedContext));
|
||||
|
||||
if (element.Descriptor.Displayed != null)
|
||||
element.Descriptor.Displayed(displayedContext);
|
||||
|
||||
return elementShape;
|
||||
}
|
||||
|
||||
public dynamic DisplayElements(IEnumerable<Element> elements, IContent content, string displayType = null, IUpdateModel updater = null, string renderEventName = null, string renderEventArgs = null) {
|
||||
public dynamic DisplayElements(IEnumerable<Element> elements, IContent content, string displayType = null, IUpdateModel updater = null) {
|
||||
var layoutRoot = (dynamic)_shapeFactory.Create("LayoutRoot");
|
||||
|
||||
foreach (var element in elements) {
|
||||
var elementShape = DisplayElement(element, content, displayType, updater, renderEventName, renderEventArgs);
|
||||
var elementShape = DisplayElement(element, content, displayType, updater);
|
||||
layoutRoot.Add(elementShape);
|
||||
}
|
||||
|
||||
|
@@ -2,13 +2,11 @@ using Orchard.ContentManagement;
|
||||
using Orchard.Layouts.Framework.Elements;
|
||||
|
||||
namespace Orchard.Layouts.Framework.Display {
|
||||
public class ElementDisplayContext {
|
||||
public class ElementDisplayedContext {
|
||||
public IContent Content { get; set; }
|
||||
public Element Element { get; set; }
|
||||
public string DisplayType { get; set; }
|
||||
public dynamic ElementShape { get; set; }
|
||||
public IUpdateModel Updater { get; set; }
|
||||
public string RenderEventName { get; set; }
|
||||
public string RenderEventArgs { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Layouts.Framework.Elements;
|
||||
|
||||
namespace Orchard.Layouts.Framework.Display {
|
||||
public class ElementDisplayingContext {
|
||||
public IContent Content { get; set; }
|
||||
public Element Element { get; set; }
|
||||
public string DisplayType { get; set; }
|
||||
public dynamic ElementShape { get; set; }
|
||||
public IUpdateModel Updater { get; set; }
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@ using Orchard.Layouts.Framework.Elements;
|
||||
|
||||
namespace Orchard.Layouts.Framework.Display {
|
||||
public interface IElementDisplay : IDependency {
|
||||
dynamic DisplayElement(Element element, IContent content, string displayType = null, IUpdateModel updater = null, string renderEventName = null, string renderEventArgs = null);
|
||||
dynamic DisplayElements(IEnumerable<Element> elements, IContent content, string displayType = null, IUpdateModel updater = null, string renderEventName = null, string renderEventArgs = null);
|
||||
dynamic DisplayElement(Element element, IContent content, string displayType = null, IUpdateModel updater = null);
|
||||
dynamic DisplayElements(IEnumerable<Element> elements, IContent content, string displayType = null, IUpdateModel updater = null);
|
||||
}
|
||||
}
|
@@ -17,10 +17,14 @@ namespace Orchard.Layouts.Framework.Drivers {
|
||||
return OnUpdateEditor((TElement)context.Element, context);
|
||||
}
|
||||
|
||||
public void Displaying(ElementDisplayContext context) {
|
||||
public void Displaying(ElementDisplayingContext context) {
|
||||
OnDisplaying((TElement) context.Element, context);
|
||||
}
|
||||
|
||||
public void Displayed(ElementDisplayedContext context) {
|
||||
OnDisplayed((TElement)context.Element, context);
|
||||
}
|
||||
|
||||
public void LayoutSaving(ElementSavingContext context) {
|
||||
OnLayoutSaving((TElement) context.Element, context);
|
||||
}
|
||||
@@ -45,7 +49,10 @@ namespace Orchard.Layouts.Framework.Drivers {
|
||||
return OnBuildEditor(element, context);
|
||||
}
|
||||
|
||||
protected virtual void OnDisplaying(TElement element, ElementDisplayContext context) {
|
||||
protected virtual void OnDisplaying(TElement element, ElementDisplayingContext context) {
|
||||
}
|
||||
|
||||
protected virtual void OnDisplayed(TElement element, ElementDisplayedContext context) {
|
||||
}
|
||||
|
||||
protected virtual void OnLayoutSaving(TElement element, ElementSavingContext context) {
|
||||
|
@@ -6,7 +6,8 @@ namespace Orchard.Layouts.Framework.Drivers {
|
||||
int Priority { get; }
|
||||
EditorResult BuildEditor(ElementEditorContext context);
|
||||
EditorResult UpdateEditor(ElementEditorContext context);
|
||||
void Displaying(ElementDisplayContext context);
|
||||
void Displaying(ElementDisplayingContext context);
|
||||
void Displayed(ElementDisplayedContext context);
|
||||
void LayoutSaving(ElementSavingContext context);
|
||||
void Removing(ElementRemovingContext context);
|
||||
void Exporting(ExportElementContext context);
|
||||
|
@@ -15,7 +15,7 @@ namespace Orchard.Layouts.Framework.Elements {
|
||||
Category = category;
|
||||
GetDrivers = Enumerable.Empty<IElementDriver>;
|
||||
CreatingDisplay = context => { };
|
||||
Display = context => {};
|
||||
Displaying = context => {};
|
||||
Editor = context => { };
|
||||
UpdateEditor = context => { };
|
||||
StateBag = new Dictionary<string, object>();
|
||||
@@ -29,7 +29,8 @@ namespace Orchard.Layouts.Framework.Elements {
|
||||
public string TypeName { get; set; }
|
||||
public Func<IEnumerable<IElementDriver>> GetDrivers { get; set; }
|
||||
public Action<ElementCreatingDisplayShapeContext> CreatingDisplay { get; set; }
|
||||
public Action<ElementDisplayContext> Display { get; set; }
|
||||
public Action<ElementDisplayingContext> Displaying { get; set; }
|
||||
public Action<ElementDisplayedContext> Displayed { get; set; }
|
||||
public Action<ElementEditorContext> Editor { get; set; }
|
||||
public Action<ElementEditorContext> UpdateEditor { get; set; }
|
||||
public bool IsSystemElement { get; set; }
|
||||
|
@@ -424,6 +424,7 @@
|
||||
<Compile Include="Elements\ContentElement.cs" />
|
||||
<Compile Include="Elements\Shape.cs" />
|
||||
<Compile Include="Filters\TokensFilter.cs" />
|
||||
<Compile Include="Framework\Display\ElementDisplayedContext.cs" />
|
||||
<Compile Include="Framework\Drivers\ImportContentContextWrapper.cs" />
|
||||
<Compile Include="Framework\Drivers\IContentImportSession.cs" />
|
||||
<Compile Include="Framework\Drivers\ExportElementContext.cs" />
|
||||
@@ -560,7 +561,7 @@
|
||||
<Compile Include="Services\ILayoutSerializer.cs" />
|
||||
<Compile Include="Helpers\ElementDataHelper.cs" />
|
||||
<Compile Include="Models\ElementInstance.cs" />
|
||||
<Compile Include="Framework\Display\ElementDisplayContext.cs" />
|
||||
<Compile Include="Framework\Display\ElementDisplayingContext.cs" />
|
||||
<Compile Include="Elements\Column.cs" />
|
||||
<Compile Include="Services\LayoutSerializer.cs" />
|
||||
<Compile Include="Providers\SnippetElementHarvester.cs" />
|
||||
|
@@ -41,7 +41,7 @@ namespace Orchard.Layouts.Providers {
|
||||
EnableEditorDialog = false,
|
||||
IsSystemElement = false,
|
||||
CreatingDisplay = creatingDisplayContext => CreatingDisplay(creatingDisplayContext, blueprint),
|
||||
Display = displayContext => Displaying(displayContext, baseElement),
|
||||
Displaying = displayContext => Displaying(displayContext, baseElement),
|
||||
StateBag = new Dictionary<string, object> {
|
||||
{"Blueprint", true},
|
||||
{"ElementTypeName", baseElement.Descriptor.TypeName}
|
||||
@@ -62,7 +62,7 @@ namespace Orchard.Layouts.Providers {
|
||||
context.Element.Data = bluePrintState;
|
||||
}
|
||||
|
||||
private void Displaying(ElementDisplayContext context, Element element) {
|
||||
private void Displaying(ElementDisplayingContext context, Element element) {
|
||||
var drivers = _elementManager.Value.GetDrivers(element);
|
||||
|
||||
foreach (var driver in drivers) {
|
||||
|
@@ -45,7 +45,7 @@ namespace Orchard.Layouts.Providers {
|
||||
var name = String.Format("{0}.{1}", part.Name, field.Name);
|
||||
var displayName = field.DisplayName;
|
||||
yield return new ElementDescriptor(elementType, name, T(displayName), T(field.DisplayName), contentFieldElement.Category) {
|
||||
Display = displayContext => Displaying(displayContext),
|
||||
Displaying = displayContext => Displaying(displayContext),
|
||||
ToolboxIcon = "\uf1b2"
|
||||
};
|
||||
}
|
||||
@@ -68,7 +68,7 @@ namespace Orchard.Layouts.Providers {
|
||||
return fields.Where(t => blackList.All(x => t.Item2.FieldDefinition.Name != x));
|
||||
}
|
||||
|
||||
private void Displaying(ElementDisplayContext context) {
|
||||
private void Displaying(ElementDisplayingContext context) {
|
||||
var contentItem = context.Content.ContentItem;
|
||||
var typeName = context.Element.Descriptor.TypeName;
|
||||
var contentField = contentItem.GetContentField(typeName);
|
||||
|
@@ -39,7 +39,7 @@ namespace Orchard.Layouts.Providers {
|
||||
var partDescription = partSettings != null ? partSettings.Description : null;
|
||||
var description = T(!String.IsNullOrWhiteSpace(partDescription) ? partDescription : contentPart.Name);
|
||||
return new ElementDescriptor(elementType, contentPart.Name, T(contentPart.Name.CamelFriendly()), description, contentPartElement.Category) {
|
||||
Display = displayContext => Displaying(displayContext),
|
||||
Displaying = displayContext => Displaying(displayContext),
|
||||
ToolboxIcon = "\uf1b2",
|
||||
StateBag = new Dictionary<string, object> {
|
||||
{"ElementTypeName", contentPart.Name}
|
||||
@@ -60,7 +60,7 @@ namespace Orchard.Layouts.Providers {
|
||||
return parts.Where(p => p.Settings.GetModel<ContentPartLayoutSettings>().Placable);
|
||||
}
|
||||
|
||||
private void Displaying(ElementDisplayContext context) {
|
||||
private void Displaying(ElementDisplayingContext context) {
|
||||
var drivers = _elementManager.Value.GetDrivers(context.Element);
|
||||
|
||||
foreach (var driver in drivers) {
|
||||
|
@@ -49,13 +49,13 @@ namespace Orchard.Layouts.Providers {
|
||||
var elementName = GetDisplayName(shapeDescriptor.Value.BindingSource);
|
||||
var closureDescriptor = shapeDescriptor;
|
||||
yield return new ElementDescriptor(elementType, shapeType, T(elementName), T("An element that renders the {0} shape.", shapeType), snippetElement.Category) {
|
||||
Display = displayContext => Displaying(displayContext, closureDescriptor.Value),
|
||||
Displaying = displayContext => Displaying(displayContext, closureDescriptor.Value),
|
||||
ToolboxIcon = "\uf10c"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void Displaying(ElementDisplayContext context, ShapeDescriptor shapeDescriptor) {
|
||||
private void Displaying(ElementDisplayingContext context, ShapeDescriptor shapeDescriptor) {
|
||||
var shapeType = shapeDescriptor.ShapeType;
|
||||
var shape = _shapeFactory.Value.Create(shapeType);
|
||||
context.ElementShape.Snippet = shape;
|
||||
|
@@ -5,7 +5,8 @@ namespace Orchard.Layouts.Services {
|
||||
public abstract class ElementEventHandlerBase : Component, IElementEventHandler {
|
||||
public virtual void Creating(ElementCreatingContext context) { }
|
||||
public virtual void Created(ElementCreatedContext context) { }
|
||||
public virtual void Displaying(ElementDisplayContext context) { }
|
||||
public virtual void Displaying(ElementDisplayingContext context) { }
|
||||
public virtual void Displayed(ElementDisplayedContext context) { }
|
||||
public virtual void BuildEditor(ElementEditorContext context) { }
|
||||
public virtual void UpdateEditor(ElementEditorContext context) { }
|
||||
}
|
||||
|
@@ -6,7 +6,8 @@ namespace Orchard.Layouts.Services {
|
||||
public interface IElementEventHandler : IEventHandler {
|
||||
void Creating(ElementCreatingContext context);
|
||||
void Created(ElementCreatedContext context);
|
||||
void Displaying(ElementDisplayContext context);
|
||||
void Displaying(ElementDisplayingContext context);
|
||||
void Displayed(ElementDisplayedContext context);
|
||||
void BuildEditor(ElementEditorContext context);
|
||||
void UpdateEditor(ElementEditorContext context);
|
||||
}
|
||||
|
@@ -1,10 +1,8 @@
|
||||
@using Orchard.DisplayManagement.Shapes
|
||||
@using Orchard.Layouts.Elements
|
||||
@using Orchard.Layouts.Helpers
|
||||
@{
|
||||
var element = (Column) Model.Element;
|
||||
var columnSpan = element.Width;
|
||||
var columnOffset = element.Offset;
|
||||
var columnSpan = (int?)Model.Width;
|
||||
var columnOffset = (int?)Model.Offset;
|
||||
var columnOffsetCss = columnOffset > 0 ? "offset-" + columnOffset : default(string);
|
||||
var tagBuilder = TagBuilderExtensions.AddCommonElementAttributes(new OrchardTagBuilder("div"), Model);
|
||||
|
||||
@@ -12,6 +10,8 @@
|
||||
tagBuilder.AddCssClass(String.Concat("span-", columnSpan));
|
||||
tagBuilder.AddCssClass(columnOffsetCss);
|
||||
}
|
||||
@tagBuilder.StartElement
|
||||
@DisplayChildren(Model)
|
||||
@tagBuilder.EndElement
|
||||
@if (!Model.Collapsed) {
|
||||
@tagBuilder.StartElement
|
||||
@DisplayChildren(Model)
|
||||
@tagBuilder.EndElement
|
||||
}
|
@@ -4,6 +4,8 @@
|
||||
var tagBuilder = TagBuilderExtensions.AddCommonElementAttributes(new OrchardTagBuilder("div"), Model);
|
||||
tagBuilder.AddCssClass("row");
|
||||
}
|
||||
@tagBuilder.StartElement
|
||||
@DisplayChildren(Model)
|
||||
@tagBuilder.EndElement
|
||||
@if (!Model.Collapsed) {
|
||||
@tagBuilder.StartElement
|
||||
@DisplayChildren(Model)
|
||||
@tagBuilder.EndElement
|
||||
}
|
@@ -23,7 +23,11 @@ namespace Orchard.Widgets.Drivers {
|
||||
_widgetsService = widgetsService;
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Column element, ElementDisplayContext context) {
|
||||
protected override void OnDisplaying(Column element, ElementDisplayingContext context) {
|
||||
RenderWidgets(element, context);
|
||||
}
|
||||
|
||||
private void RenderWidgets(Column element, ElementDisplayingContext context) {
|
||||
var zoneName = element.ZoneName;
|
||||
|
||||
if (String.IsNullOrWhiteSpace(zoneName))
|
||||
|
Reference in New Issue
Block a user