Implemented element rules.

This commit is contained in:
Sipke Schoorstra
2015-04-19 11:31:53 +02:00
parent 24776bf9ee
commit d5f75a242d
32 changed files with 173 additions and 58 deletions

View File

@@ -45,6 +45,7 @@ namespace Orchard.DynamicForms.Handlers {
context.ElementShape.ClientValidationAttributes = registrationContext.ClientAttributes;
}
void IElementEventHandler.CreatingDisplay(ElementCreatingDisplayShapeContext context) { }
void IElementEventHandler.Displayed(ElementDisplayedContext context) {}
void IFormElementEventHandler.GetElementValue(FormElement element, ReadElementValuesContext context) { }
void IElementEventHandler.Creating(ElementCreatingContext context) {}

View File

@@ -30,8 +30,8 @@
var LayoutEditor;
(function ($, LayoutEditor) {
LayoutEditor.Form = function (data, htmlId, htmlClass, htmlStyle, isTemplated, name, formBindingContentType, contentType, contentTypeLabel, contentTypeClass, hasEditor, children) {
LayoutEditor.Element.call(this, "Form", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Form = function (data, htmlId, htmlClass, htmlStyle, isTemplated, name, formBindingContentType, contentType, contentTypeLabel, contentTypeClass, hasEditor, rule, children) {
LayoutEditor.Element.call(this, "Form", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
var self = this;
@@ -96,6 +96,7 @@ var LayoutEditor;
value.contentTypeLabel,
value.contentTypeClass,
value.hasEditor,
value.rule,
LayoutEditor.childrenFrom(value.children));
};

View File

@@ -1 +1 @@
angular.module("LayoutEditor").directive("orcLayoutForm",["$compile","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="y";n.edit=function(){n.$root.editElement(n.element).then(function(t){t.cancel||(n.element.data=decodeURIComponent(t.element.data),n.element.name=t.elementEditorModel.name,n.element.formBindingContentType=t.elementEditorModel.formBindingContentType,n.$apply())})}}],templateUrl:i.templateUrl("Form"),replace:!0}}]);var LayoutEditor;(function(n,t){t.Form=function(i,r,u,f,e,o,s,h,c,l,a,v){var y,p;t.Element.call(this,"Form",i,r,u,f,e);t.Container.call(this,["Grid","Content"],v);y=this;this.isContainable=!0;this.dropTargetClass="layout-common-holder";this.contentType=h;this.contentTypeLabel=c;this.contentTypeClass=l;this.name=o||"Untitled";this.formBindingContentType=s;this.hasEditor=a;this.toObject=function(){var n=this.elementToObject();return n.name=this.name,n.formBindingContentType=this.formBindingContentType,n.children=this.childrenToObject(),n};p=this.getEditorObject;this.getEditorObject=function(){var t=p();return n.extend(t,{FormName:this.name,FormBindingContentType:this.formBindingContentType})};this.setChildren=function(n){this.children=n;_(this.children).each(function(n){n.parent=y;y.linkChild(n)})};this.linkChild=function(t){var i=t.getEditorObject;t.getEditorObject=function(){var t=i();return n.extend(t,{FormBindingContentType:y.formBindingContentType})}};this.setChildren(v)};t.Form.from=function(n){return new t.Form(n.data,n.htmlId,n.htmlClass,n.htmlStyle,n.isTemplated,n.name,n.formBindingContentType,n.contentType,n.contentTypeLabel,n.contentTypeClass,n.hasEditor,t.childrenFrom(n.children))};t.registerFactory("Form",function(n){return t.Form.from(n)})})(jQuery,LayoutEditor||(LayoutEditor={}));
angular.module("LayoutEditor").directive("orcLayoutForm",["$compile","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="y";n.edit=function(){n.$root.editElement(n.element).then(function(t){t.cancel||(n.element.data=decodeURIComponent(t.element.data),n.element.name=t.elementEditorModel.name,n.element.formBindingContentType=t.elementEditorModel.formBindingContentType,n.$apply())})}}],templateUrl:i.templateUrl("Form"),replace:!0}}]);var LayoutEditor;(function(n,t){t.Form=function(i,r,u,f,e,o,s,h,c,l,a,v,y){var p,w;t.Element.call(this,"Form",i,r,u,f,e,v);t.Container.call(this,["Grid","Content"],y);p=this;this.isContainable=!0;this.dropTargetClass="layout-common-holder";this.contentType=h;this.contentTypeLabel=c;this.contentTypeClass=l;this.name=o||"Untitled";this.formBindingContentType=s;this.hasEditor=a;this.toObject=function(){var n=this.elementToObject();return n.name=this.name,n.formBindingContentType=this.formBindingContentType,n.children=this.childrenToObject(),n};w=this.getEditorObject;this.getEditorObject=function(){var t=w();return n.extend(t,{FormName:this.name,FormBindingContentType:this.formBindingContentType})};this.setChildren=function(n){this.children=n;_(this.children).each(function(n){n.parent=p;p.linkChild(n)})};this.linkChild=function(t){var i=t.getEditorObject;t.getEditorObject=function(){var t=i();return n.extend(t,{FormBindingContentType:p.formBindingContentType})}};this.setChildren(y)};t.Form.from=function(n){return new t.Form(n.data,n.htmlId,n.htmlClass,n.htmlStyle,n.isTemplated,n.name,n.formBindingContentType,n.contentType,n.contentTypeLabel,n.contentTypeClass,n.hasEditor,n.rule,t.childrenFrom(n.children))};t.registerFactory("Form",function(n){return t.Form.from(n)})})(jQuery,LayoutEditor||(LayoutEditor={}));

View File

@@ -1,8 +1,8 @@
var LayoutEditor;
(function ($, LayoutEditor) {
LayoutEditor.Form = function (data, htmlId, htmlClass, htmlStyle, isTemplated, name, formBindingContentType, contentType, contentTypeLabel, contentTypeClass, hasEditor, children) {
LayoutEditor.Element.call(this, "Form", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Form = function (data, htmlId, htmlClass, htmlStyle, isTemplated, name, formBindingContentType, contentType, contentTypeLabel, contentTypeClass, hasEditor, rule, children) {
LayoutEditor.Element.call(this, "Form", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
var self = this;
@@ -67,6 +67,7 @@
value.contentTypeLabel,
value.contentTypeClass,
value.hasEditor,
value.rule,
LayoutEditor.childrenFrom(value.children));
};

View File

@@ -6,5 +6,6 @@ namespace Orchard.Layouts.Framework.Display {
public IContent Content { get; set; }
public Element Element { get; set; }
public string DisplayType { get; set; }
public bool Cancel { get; set; }
}
}

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using Orchard.ContentManagement;
using Orchard.Core.Shapes;
using Orchard.DisplayManagement;
using Orchard.Layouts.Elements;
using Orchard.Layouts.Framework.Drivers;
@@ -34,8 +33,12 @@ namespace Orchard.Layouts.Framework.Display {
Content = content,
};
_elementEventHandlerHandler.CreatingDisplay(createShapeContext);
element.Descriptor.CreatingDisplay(createShapeContext);
if (createShapeContext.Cancel)
return null;
var typeName = element.GetType().Name;
var category = element.Category.ToSafeName();
var drivers = element.Descriptor.GetDrivers().ToList();
@@ -69,11 +72,13 @@ namespace Orchard.Layouts.Framework.Display {
var childIndex = 0;
foreach (var child in container.Elements) {
var childShape = DisplayElement(child, content, displayType: displayType, updater: updater);
if (childShape != null) {
childShape.Parent = elementShape;
elementShape.Add(childShape, childIndex++.ToString());
}
}
}
}
var displayedContext = new ElementDisplayedContext {
Element = element,

View File

@@ -41,6 +41,7 @@ namespace Orchard.Layouts.Framework.Elements {
public string HtmlId { get; set; }
public string HtmlClass { get; set; }
public string HtmlStyle { get; set; }
public string Rule { get; set; }
public ElementDataDictionary ExportableData { get; set; }
public ElementDescriptor Descriptor { get; set; }
public ElementDataDictionary Data { get; set; }

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Services;
using Orchard.Widgets.Services;
namespace Orchard.Layouts.Handlers {
public class ElementRuleCoordinator : ElementEventHandlerBase {
private readonly IRuleManager _ruleManager;
private readonly Dictionary<string, bool> _evaluations = new Dictionary<string, bool>();
public ElementRuleCoordinator(IRuleManager ruleManager) {
_ruleManager = ruleManager;
}
public override void CreatingDisplay(ElementCreatingDisplayShapeContext context) {
if (context.DisplayType == "Design")
return;
if (String.IsNullOrWhiteSpace(context.Element.Rule))
return;
context.Cancel = !EvaluateRule(context.Element.Rule);
}
private bool EvaluateRule(string rule) {
if (_evaluations.ContainsKey(rule))
return _evaluations[rule];
var result = _ruleManager.Matches(rule);
_evaluations[rule] = result;
return result;
}
}
}

View File

@@ -10,7 +10,7 @@ Features:
Orchard.Layouts:
Name: Layouts
Description: Provides tools to create layouts.
Dependencies: Common, Orchard.jQuery, Orchard.Forms, Orchard.Tokens, Orchard.MediaLibrary, TinyMCE
Dependencies: Common, Orchard.jQuery, Orchard.Forms, Orchard.Tokens, Orchard.MediaLibrary, TinyMCE, Orchard.Widgets
Category: Layout
Orchard.Layouts.Snippets:
Name: Layout Snippets

View File

@@ -413,6 +413,10 @@
<Project>{6f759635-13d7-4e94-bcc9-80445d63f117}</Project>
<Name>Orchard.Tokens</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
<Project>{194d3ccc-1153-474d-8176-fde8d7d0d0bd}</Project>
<Name>Orchard.Widgets</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AdminMenu.cs" />
@@ -441,6 +445,7 @@
<Compile Include="Framework\Display\ElementCreatingDisplayShapeContext.cs" />
<Compile Include="Framework\Drivers\ImportElementContext.cs" />
<Compile Include="Framework\Drivers\ImportLayoutContext.cs" />
<Compile Include="Handlers\ElementRuleCoordinator.cs" />
<Compile Include="Handlers\ElementDriversCoordinator.cs" />
<Compile Include="Helpers\DictionaryExtensions.cs" />
<Compile Include="Helpers\EditorResultExtensions.cs" />
@@ -617,6 +622,9 @@
<ItemGroup>
<Content Include="Views\LayoutEditor.Template.Html.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\LayoutEditor.Template.Rule.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -76,7 +76,7 @@ var LayoutEditor;
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Element = function (type, data, htmlId, htmlClass, htmlStyle, isTemplated) {
LayoutEditor.Element = function (type, data, htmlId, htmlClass, htmlStyle, isTemplated, rule) {
if (!type)
throw new Error("Parameter 'type' is required.");
@@ -86,6 +86,7 @@ var LayoutEditor;
this.htmlClass = htmlClass;
this.htmlStyle = htmlStyle;
this.isTemplated = isTemplated;
this.rule = rule;
this.editor = null;
this.parent = null;
@@ -221,7 +222,8 @@ var LayoutEditor;
htmlId: this.htmlId,
htmlClass: this.htmlClass,
htmlStyle: this.htmlStyle,
isTemplated: this.isTemplated
isTemplated: this.isTemplated,
rule: this.rule
};
};
@@ -387,8 +389,8 @@ var LayoutEditor;
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Canvas = function (data, htmlId, htmlClass, htmlStyle, isTemplated, children) {
LayoutEditor.Element.call(this, "Canvas", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Canvas = function (data, htmlId, htmlClass, htmlStyle, isTemplated, rule, children) {
LayoutEditor.Element.call(this, "Canvas", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
this.toObject = function () {
@@ -405,6 +407,7 @@ var LayoutEditor;
value.htmlClass,
value.htmlStyle,
value.isTemplated,
value.rule,
LayoutEditor.childrenFrom(value.children));
};
@@ -413,8 +416,8 @@ var LayoutEditor;
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Grid = function (data, htmlId, htmlClass, htmlStyle, isTemplated, children) {
LayoutEditor.Element.call(this, "Grid", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Grid = function (data, htmlId, htmlClass, htmlStyle, isTemplated, rule, children) {
LayoutEditor.Element.call(this, "Grid", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Row"], children);
this.toObject = function () {
@@ -431,6 +434,7 @@ var LayoutEditor;
value.htmlClass,
value.htmlStyle,
value.isTemplated,
value.rule,
LayoutEditor.childrenFrom(value.children));
result.toolboxIcon = value.toolboxIcon;
result.toolboxLabel = value.toolboxLabel;
@@ -442,8 +446,8 @@ var LayoutEditor;
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Row = function (data, htmlId, htmlClass, htmlStyle, isTemplated, children) {
LayoutEditor.Element.call(this, "Row", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Row = function (data, htmlId, htmlClass, htmlStyle, isTemplated, rule, children) {
LayoutEditor.Element.call(this, "Row", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Column"], children);
var _self = this;
@@ -716,6 +720,7 @@ var LayoutEditor;
value.htmlClass,
value.htmlStyle,
value.isTemplated,
value.rule,
LayoutEditor.childrenFrom(value.children));
result.toolboxIcon = value.toolboxIcon;
result.toolboxLabel = value.toolboxLabel;
@@ -726,8 +731,8 @@ var LayoutEditor;
})(LayoutEditor || (LayoutEditor = {}));
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, zoneName, collapsible, children) {
LayoutEditor.Element.call(this, "Column", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, zoneName, collapsible, rule, children) {
LayoutEditor.Element.call(this, "Column", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
this.width = width;
@@ -843,6 +848,7 @@ var LayoutEditor;
value.offset,
value.zoneName,
value.collapsible,
value.rule,
LayoutEditor.childrenFrom(value.children));
result.toolboxIcon = value.toolboxIcon;
result.toolboxLabel = value.toolboxLabel;
@@ -869,8 +875,8 @@ var LayoutEditor;
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Content = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor) {
LayoutEditor.Element.call(this, "Content", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Content = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor, rule) {
LayoutEditor.Element.call(this, "Content", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
this.contentType = contentType;
this.contentTypeLabel = contentTypeLabel;
@@ -918,7 +924,8 @@ var LayoutEditor;
value.contentTypeLabel,
value.contentTypeClass,
value.html,
value.hasEditor);
value.hasEditor,
value.rule);
return result;
};
@@ -927,8 +934,8 @@ var LayoutEditor;
var LayoutEditor;
(function ($, LayoutEditor) {
LayoutEditor.Html = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor) {
LayoutEditor.Element.call(this, "Html", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Html = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor, rule) {
LayoutEditor.Element.call(this, "Html", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
this.contentType = contentType;
this.contentTypeLabel = contentTypeLabel;
@@ -985,7 +992,8 @@ var LayoutEditor;
value.contentTypeLabel,
value.contentTypeClass,
value.html,
value.hasEditor);
value.hasEditor,
value.rule);
return result;
};

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,8 @@
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Canvas = function (data, htmlId, htmlClass, htmlStyle, isTemplated, children) {
LayoutEditor.Element.call(this, "Canvas", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Canvas = function (data, htmlId, htmlClass, htmlStyle, isTemplated, rule, children) {
LayoutEditor.Element.call(this, "Canvas", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
this.toObject = function () {
@@ -19,6 +19,7 @@
value.htmlClass,
value.htmlStyle,
value.isTemplated,
value.rule,
LayoutEditor.childrenFrom(value.children));
};

View File

@@ -1,7 +1,7 @@
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, zoneName, collapsible, children) {
LayoutEditor.Element.call(this, "Column", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, zoneName, collapsible, rule, children) {
LayoutEditor.Element.call(this, "Column", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
this.width = width;
@@ -117,6 +117,7 @@
value.offset,
value.zoneName,
value.collapsible,
value.rule,
LayoutEditor.childrenFrom(value.children));
result.toolboxIcon = value.toolboxIcon;
result.toolboxLabel = value.toolboxLabel;

View File

@@ -1,8 +1,8 @@
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Content = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor) {
LayoutEditor.Element.call(this, "Content", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Content = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor, rule) {
LayoutEditor.Element.call(this, "Content", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
this.contentType = contentType;
this.contentTypeLabel = contentTypeLabel;
@@ -50,7 +50,8 @@
value.contentTypeLabel,
value.contentTypeClass,
value.html,
value.hasEditor);
value.hasEditor,
value.rule);
return result;
};

View File

@@ -1,7 +1,7 @@
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Element = function (type, data, htmlId, htmlClass, htmlStyle, isTemplated) {
LayoutEditor.Element = function (type, data, htmlId, htmlClass, htmlStyle, isTemplated, rule) {
if (!type)
throw new Error("Parameter 'type' is required.");
@@ -11,6 +11,7 @@
this.htmlClass = htmlClass;
this.htmlStyle = htmlStyle;
this.isTemplated = isTemplated;
this.rule = rule;
this.editor = null;
this.parent = null;
@@ -146,7 +147,8 @@
htmlId: this.htmlId,
htmlClass: this.htmlClass,
htmlStyle: this.htmlStyle,
isTemplated: this.isTemplated
isTemplated: this.isTemplated,
rule: this.rule
};
};

View File

@@ -1,8 +1,8 @@
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Grid = function (data, htmlId, htmlClass, htmlStyle, isTemplated, children) {
LayoutEditor.Element.call(this, "Grid", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Grid = function (data, htmlId, htmlClass, htmlStyle, isTemplated, rule, children) {
LayoutEditor.Element.call(this, "Grid", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Row"], children);
this.toObject = function () {
@@ -19,6 +19,7 @@
value.htmlClass,
value.htmlStyle,
value.isTemplated,
value.rule,
LayoutEditor.childrenFrom(value.children));
result.toolboxIcon = value.toolboxIcon;
result.toolboxLabel = value.toolboxLabel;

View File

@@ -1,8 +1,8 @@
var LayoutEditor;
(function ($, LayoutEditor) {
LayoutEditor.Html = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor) {
LayoutEditor.Element.call(this, "Html", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Html = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor, rule) {
LayoutEditor.Element.call(this, "Html", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
this.contentType = contentType;
this.contentTypeLabel = contentTypeLabel;
@@ -59,7 +59,8 @@
value.contentTypeLabel,
value.contentTypeClass,
value.html,
value.hasEditor);
value.hasEditor,
value.rule);
return result;
};

View File

@@ -1,8 +1,8 @@
var LayoutEditor;
(function (LayoutEditor) {
LayoutEditor.Row = function (data, htmlId, htmlClass, htmlStyle, isTemplated, children) {
LayoutEditor.Element.call(this, "Row", data, htmlId, htmlClass, htmlStyle, isTemplated);
LayoutEditor.Row = function (data, htmlId, htmlClass, htmlStyle, isTemplated, rule, children) {
LayoutEditor.Element.call(this, "Row", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
LayoutEditor.Container.call(this, ["Column"], children);
var _self = this;
@@ -275,6 +275,7 @@
value.htmlClass,
value.htmlStyle,
value.isTemplated,
value.rule,
LayoutEditor.childrenFrom(value.children));
result.toolboxIcon = value.toolboxIcon;
result.toolboxLabel = value.toolboxLabel;

View File

@@ -36,6 +36,7 @@ namespace Orchard.Layouts.Services {
node["htmlClass"] = element.HtmlClass;
node["htmlStyle"] = element.HtmlStyle;
node["isTemplated"] = element.IsTemplated;
node["rule"] = element.Rule;
}
protected virtual void ToElement(T element, JToken node) {
@@ -44,6 +45,7 @@ namespace Orchard.Layouts.Services {
element.HtmlClass = (string)node["htmlClass"];
element.HtmlStyle = (string)node["htmlStyle"];
element.IsTemplated = (bool)(node["isTemplated"] ?? false);
element.Rule = (string) node["rule"];
}
protected bool? ReadBoolean(JToken node) {
@@ -113,6 +115,7 @@ namespace Orchard.Layouts.Services {
element.HtmlClass = (string)node["htmlClass"];
element.HtmlStyle = (string)node["htmlStyle"];
element.IsTemplated = (bool)(node["isTemplated"] ?? false);
element.Rule = (string) node["rule"];
return element;
}
@@ -122,6 +125,7 @@ namespace Orchard.Layouts.Services {
node["htmlId"] = element.HtmlId;
node["htmlClass"] = element.HtmlClass;
node["htmlStyle"] = element.HtmlStyle;
node["rule"] = element.Rule;
node["isTemplated"] = element.IsTemplated;
node["hasEditor"] = element.HasEditor;
node["contentType"] = element.Descriptor.TypeName;

View File

@@ -5,6 +5,7 @@ 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 CreatingDisplay(ElementCreatingDisplayShapeContext context) {}
public virtual void Displaying(ElementDisplayingContext context) { }
public virtual void Displayed(ElementDisplayedContext context) { }
public virtual void BuildEditor(ElementEditorContext context) { }

View File

@@ -43,7 +43,8 @@ namespace Orchard.Layouts.Services {
isTemplated = element.IsTemplated,
htmlId = element.HtmlId,
htmlClass = element.HtmlClass,
htmlStyle = element.HtmlStyle
htmlStyle = element.HtmlStyle,
rule = element.Rule
};
return dto;
}
@@ -54,10 +55,11 @@ namespace Orchard.Layouts.Services {
if (String.IsNullOrWhiteSpace(elementTypeName))
return null;
var data = (string) node["data"];
var htmlId = (string) node["htmlId"];
var data = (string)node["data"];
var htmlId = (string)node["htmlId"];
var htmlClass = (string)node["htmlClass"];
var htmlStyle = (string)node["htmlStyle"];
var rule = (string)node["rule"];
var elementData = ElementDataHelper.Deserialize(data);
var exportableData = ElementDataHelper.Deserialize((string)node["exportableData"]);
var childNodes = node["elements"];
@@ -74,6 +76,7 @@ namespace Orchard.Layouts.Services {
e.HtmlId = htmlId;
e.HtmlClass = htmlClass;
e.HtmlStyle = htmlStyle;
e.Rule = rule;
});
var container = element as Container;

View File

@@ -6,6 +6,7 @@ namespace Orchard.Layouts.Services {
public interface IElementEventHandler : IEventHandler {
void Creating(ElementCreatingContext context);
void Created(ElementCreatedContext context);
void CreatingDisplay(ElementCreatingDisplayShapeContext context);
void Displaying(ElementDisplayingContext context);
void Displayed(ElementDisplayedContext context);
void BuildEditor(ElementEditorContext context);

View File

@@ -757,6 +757,10 @@ table[rules=all i] > tfoot > tr > td, table[rules=all i] > tfoot > tr > th {
cursor: default;
white-space: nowrap;
line-height: normal;
width: 300px;
}
.layout-editor .layout-popup.wide {
width: 600px;
}
.layout-editor .layout-popup .layout-popup-flex {
display: flex;
@@ -779,6 +783,10 @@ table[rules=all i] > tfoot > tr > td, table[rules=all i] > tfoot > tr > th {
background-color: #f3f4f5;
cursor: pointer;
}
.layout-editor .layout-popup .layout-popup-input input,
.layout-editor .layout-popup .layout-popup-input textarea {
width: 100%;
}
.layout-editor .layout-popup .layout-popup-input > label {
display: block;
font-size: 0.9em;

File diff suppressed because one or more lines are too long

View File

@@ -15,6 +15,10 @@
cursor: default;
white-space: nowrap;
line-height: normal;
width: 300px;
}
.layout-editor .layout-popup.wide {
width: 600px;
}
.layout-editor .layout-popup .layout-popup-flex {
display: flex;
@@ -37,6 +41,10 @@
background-color: #f3f4f5;
cursor: pointer;
}
.layout-editor .layout-popup .layout-popup-input input,
.layout-editor .layout-popup .layout-popup-input textarea {
width: 100%;
}
.layout-editor .layout-popup .layout-popup-input > label {
display: block;
font-size: 0.9em;

View File

@@ -18,6 +18,11 @@
cursor: default;
white-space: nowrap;
line-height: normal;
width: 300px;
&.wide {
width: 600px;
}
.layout-popup-flex {
display: flex;
@@ -46,6 +51,10 @@
}
.layout-popup-input {
input, textarea {
width: 100%;
}
> label {
display: block;
font-size: 0.9em;

View File

@@ -1 +1 @@
.layout-editor .layout-popup{display:none;position:absolute;margin:0;-moz-box-shadow:3px 3px 11px 0 rgba(50,50,50,.5);-webkit-box-shadow:3px 3px 11px 0 rgba(50,50,50,.5);box-shadow:3px 3px 11px 0 rgba(50,50,50,.5);border:1px solid #e4e5e6;padding:2px 0;background-color:#f7f7f7;list-style:none;z-index:20;color:#7c7c7c;text-align:left;cursor:default;white-space:nowrap;line-height:normal}.layout-editor .layout-popup .layout-popup-flex{display:flex;padding:2px 5px}.layout-editor .layout-popup .layout-popup-flex .layout-popup-column+.layout-popup-column{margin-left:4px;border-left:1px solid rgba(128,128,128,.15);padding-left:4px}.layout-editor .layout-popup .layout-popup-item{padding:4px 6px}.layout-editor .layout-popup .layout-popup-label{font-size:.9em;font-weight:bold;color:#7c7c7c}.layout-editor .layout-popup .layout-popup-action:hover{background-color:#f3f4f5;cursor:pointer}.layout-editor .layout-popup .layout-popup-input>label{display:block;font-size:.9em}
.layout-editor .layout-popup{display:none;position:absolute;margin:0;-moz-box-shadow:3px 3px 11px 0 rgba(50,50,50,.5);-webkit-box-shadow:3px 3px 11px 0 rgba(50,50,50,.5);box-shadow:3px 3px 11px 0 rgba(50,50,50,.5);border:1px solid #e4e5e6;padding:2px 0;background-color:#f7f7f7;list-style:none;z-index:20;color:#7c7c7c;text-align:left;cursor:default;white-space:nowrap;line-height:normal;width:300px}.layout-editor .layout-popup.wide{width:600px}.layout-editor .layout-popup .layout-popup-flex{display:flex;padding:2px 5px}.layout-editor .layout-popup .layout-popup-flex .layout-popup-column+.layout-popup-column{margin-left:4px;border-left:1px solid rgba(128,128,128,.15);padding-left:4px}.layout-editor .layout-popup .layout-popup-item{padding:4px 6px}.layout-editor .layout-popup .layout-popup-label{font-size:.9em;font-weight:bold;color:#7c7c7c}.layout-editor .layout-popup .layout-popup-action:hover{background-color:#f3f4f5;cursor:pointer}.layout-editor .layout-popup .layout-popup-input input,.layout-editor .layout-popup .layout-popup-input textarea{width:100%}.layout-editor .layout-popup .layout-popup-input>label{display:block;font-size:.9em}

View File

@@ -3,6 +3,7 @@
<li class="layout-panel-item layout-panel-label">{{::element.contentTypeLabel}}</li>
<li class="layout-panel-item layout-panel-action layout-panel-action-edit" ng-show="{{element.hasEditor}}" title="Edit {{element.contentTypeLabel.toLowerCase()}} content (Enter)" ng-click="edit()"><i class="fa fa-code"></i></li>
@Display(New.LayoutEditor_Template_Properties(ElementTypeName: "{{element.contentTypeLabel.toLowerCase()}}"))
@Display(New.LayoutEditor_Template_Rule(ElementTypeName: "{{element.contentTypeLabel.toLowerCase()}}"))
<li class="layout-panel-item layout-panel-action" title="@T("Delete {{element.contentTypeLabel.toLowerCase()}} (Del)")" ng-click="delete(element)"><i class="fa fa-remove"></i></li>
<li class="layout-panel-item layout-panel-action" title="@T("Move {{element.contentTypeLabel.toLowerCase()}} up (Ctrl+Up)")" ng-click="element.moveUp()" ng-class="{disabled: !element.canMoveUp()}"><i class="fa fa-chevron-up"></i></li>
<li class="layout-panel-item layout-panel-action" title="@T("Move {{element.contentTypeLabel.toLowerCase()}} down (Ctrl+Down)")" ng-click="element.moveDown()" ng-class="{disabled: !element.canMoveDown()}"><i class="fa fa-chevron-down"></i></li>

View File

@@ -19,7 +19,7 @@
<li class="layout-popup-item layout-popup-input">
<label>
@T("CSS styles:")<br/>
<input type="text" ng-model="element.htmlStyle" />
<textarea rows="3" cols="25" ng-model="element.htmlStyle"></textarea>
</label>
</li>
@if (Model.Items != null) {

View File

@@ -0,0 +1,12 @@
@using Orchard.Layouts.ViewModels
<li class="layout-panel-item layout-panel-action layout-panel-action-properties layout-popup-trigger" title="@T("Edit {0} rule", Model.ElementTypeName)">
<i class="fa fa-codepen"></i>
<ul class="layout-popup layout-popup-edit wide" orc-layout-popup>
<li class="layout-popup-item layout-popup-input">
<label>
@T("Rule:")<br/>
<textarea rows="3" cols="25" ng-model="element.rule"></textarea>
</label>
</li>
</ul>
</li>

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Orchard.Localization;
using Orchard.Scripting;
using Orchard.Widgets.Services;