mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Changing up Widget wrappers a little
--HG-- branch : dev
This commit is contained in:
@@ -117,13 +117,13 @@
|
||||
</None>
|
||||
<None Include="Views\Admin\Index.cshtml" />
|
||||
<Content Include="Views\Items_Widget.Editor.cshtml" />
|
||||
<None Include="Views\Widget.Manage.cshtml" />
|
||||
<None Include="Views\Widget.ControlWrapper.cshtml" />
|
||||
<None Include="Views\EditorTemplates\Parts\Widgets.WidgetPart.cshtml" />
|
||||
<None Include="Views\EditorTemplates\Parts\Widgets.LayerPart.cshtml" />
|
||||
<None Include="Views\EditorTemplates\Parts\Widgets.WidgetBagPart.cshtml" />
|
||||
<Content Include="Views\Items_Widget.cshtml" />
|
||||
<Content Include="Views\Items\Content-WidgetPage.cshtml" />
|
||||
<None Include="Views\Widget.cshtml" />
|
||||
<None Include="Views\Widget.Wrapper.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -4,33 +4,25 @@ using Orchard.Widgets.Models;
|
||||
|
||||
namespace Orchard.Widgets {
|
||||
public class Shapes : IShapeTableProvider {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public Shapes(IOrchardServices orchardServices) {
|
||||
_orchardServices = orchardServices;
|
||||
}
|
||||
|
||||
public void Discover(ShapeTableBuilder builder) {
|
||||
builder.Describe("Items_Widget")
|
||||
.Configure(descriptor => {
|
||||
// todo: have "alternates" for chrome
|
||||
if (_orchardServices.Authorizer.Authorize(Permissions.ManageWidgets))
|
||||
descriptor.Wrappers.Add("Widget_Manage");
|
||||
else
|
||||
descriptor.Wrappers.Add("Widget");
|
||||
descriptor.Wrappers.Add("Widget_Wrapper");
|
||||
descriptor.Wrappers.Add("Widget_ControlWrapper");
|
||||
})
|
||||
.OnCreated(created => {
|
||||
var widget = created.Shape;
|
||||
widget.Main.Add(created.New.PlaceChildContent(Source: widget));
|
||||
})
|
||||
.OnDisplaying(displaying => {
|
||||
ContentItem contentItem = displaying.Shape.ContentItem;
|
||||
var widget = displaying.Shape;
|
||||
widget.Classes.Add("widget");
|
||||
ContentItem contentItem = widget.ContentItem;
|
||||
if (contentItem != null) {
|
||||
var zoneName = contentItem.As<WidgetPart>().Zone;
|
||||
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + contentItem.ContentType);
|
||||
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName);
|
||||
//...would like...if '__' was collapsible
|
||||
//displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName + "__" + contentItem.ContentType);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -0,0 +1,14 @@
|
||||
@using Orchard.ContentManagement;
|
||||
@using Orchard.Widgets;
|
||||
@{
|
||||
if (AuthorizedFor(Permissions.ManageWidgets)) {
|
||||
Model.Classes.Add("widget-manage");
|
||||
}
|
||||
var tag = Tag(Model, "div");
|
||||
}
|
||||
@tag.StartElement
|
||||
@if (AuthorizedFor(Permissions.ManageWidgets)) {
|
||||
<div class="manage-actions">@Html.ItemEditLinkWithReturnUrl(T("Edit").Text, (ContentItem)Model.ContentItem)</div>
|
||||
}
|
||||
@Display(Model.Main)
|
||||
@tag.EndElement
|
@@ -1,5 +0,0 @@
|
||||
@using Orchard.ContentManagement;
|
||||
<div class="widget widget-manage">
|
||||
<div class="actions">@Html.ItemEditLinkWithReturnUrl(T("Edit").Text, (ContentItem)Model.ContentItem)</div>
|
||||
@Display(Model.Main)
|
||||
</div>
|
@@ -0,0 +1,14 @@
|
||||
@using Orchard.ContentManagement;
|
||||
@using Orchard.Widgets;
|
||||
@{
|
||||
if (AuthorizedFor(Permissions.ManageWidgets)) {
|
||||
Model.Classes.Add("widget-manage");
|
||||
}
|
||||
var tag = Tag(Model, "div");
|
||||
}
|
||||
@tag.StartElement
|
||||
@if (AuthorizedFor(Permissions.ManageWidgets)) {
|
||||
<div class="manage-actions">@Html.ItemEditLinkWithReturnUrl(T("Edit").Text, (ContentItem)Model.ContentItem)</div>
|
||||
}
|
||||
@Display(Model.Main)
|
||||
@tag.EndElement
|
@@ -1 +0,0 @@
|
||||
@Display(Model.Main)
|
Reference in New Issue
Block a user