mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Position and layer editing fields.
--HG-- branch : dev
This commit is contained in:
@@ -111,6 +111,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
if (widgetPart == null)
|
if (widgetPart == null)
|
||||||
return HttpNotFound();
|
return HttpNotFound();
|
||||||
|
|
||||||
|
widgetPart.LayerPart = _widgetsService.GetLayer(layerId);
|
||||||
dynamic model = Services.ContentManager.BuildEditor(widgetPart);
|
dynamic model = Services.ContentManager.BuildEditor(widgetPart);
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
@@ -126,8 +127,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int widgetPosition = _widgetsService.GetWidgets(layerId).Count() + 1;
|
WidgetPart widgetPart = _widgetsService.CreateWidget(layerId, widgetType, "", "", "");
|
||||||
WidgetPart widgetPart = _widgetsService.CreateWidget(layerId, widgetType, "", widgetPosition.ToString(), "");
|
|
||||||
if (widgetPart == null)
|
if (widgetPart == null)
|
||||||
return HttpNotFound();
|
return HttpNotFound();
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
|
|
||||||
[HttpPost, ActionName("EditWidget")]
|
[HttpPost, ActionName("EditWidget")]
|
||||||
[FormValueRequired("submit.Save")]
|
[FormValueRequired("submit.Save")]
|
||||||
public ActionResult EditWidgetSavePOST(int id) {
|
public ActionResult EditWidgetSavePOST(int id, int layerId) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
@@ -294,6 +294,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
if (widgetPart == null)
|
if (widgetPart == null)
|
||||||
return HttpNotFound();
|
return HttpNotFound();
|
||||||
|
|
||||||
|
widgetPart.LayerPart = _widgetsService.GetLayer(layerId);
|
||||||
var model = Services.ContentManager.UpdateEditor(widgetPart, this);
|
var model = Services.ContentManager.UpdateEditor(widgetPart, this);
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
Services.TransactionManager.Cancel();
|
Services.TransactionManager.Cancel();
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using JetBrains.Annotations;
|
using System.Web.Mvc;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
using Orchard.Widgets.Models;
|
using Orchard.Widgets.Models;
|
||||||
@@ -16,6 +17,7 @@ namespace Orchard.Widgets.Drivers {
|
|||||||
|
|
||||||
protected override DriverResult Editor(WidgetPart widgetPart, dynamic shapeHelper) {
|
protected override DriverResult Editor(WidgetPart widgetPart, dynamic shapeHelper) {
|
||||||
widgetPart.AvailableZones = _widgetsService.GetZones();
|
widgetPart.AvailableZones = _widgetsService.GetZones();
|
||||||
|
widgetPart.AvailableLayers = _widgetsService.GetLayers();
|
||||||
|
|
||||||
return ContentShape("Parts_Widgets_WidgetPart",
|
return ContentShape("Parts_Widgets_WidgetPart",
|
||||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts/Widgets.WidgetPart", Model: widgetPart));
|
() => shapeHelper.EditorTemplate(TemplateName: "Parts/Widgets.WidgetPart", Model: widgetPart));
|
||||||
|
@@ -43,10 +43,23 @@ namespace Orchard.Widgets.Models {
|
|||||||
set { this.As<ICommonPart>().Container = value; }
|
set { this.As<ICommonPart>().Container = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The layerPart identifier.
|
||||||
|
/// </summary>
|
||||||
|
public int LayerId {
|
||||||
|
get { return this.As<ICommonPart>().Container.As<LayerPart>().Id; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The available page zones.
|
/// The available page zones.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HiddenInput(DisplayValue = false)]
|
[HiddenInput(DisplayValue = false)]
|
||||||
public IEnumerable<string> AvailableZones { get; set; }
|
public IEnumerable<string> AvailableZones { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The available layers.
|
||||||
|
/// </summary>
|
||||||
|
[HiddenInput(DisplayValue = false)]
|
||||||
|
public IEnumerable<LayerPart> AvailableLayers { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -5,7 +5,17 @@
|
|||||||
@Html.DropDownListFor(widget => widget.Zone, new SelectList(Model.AvailableZones))
|
@Html.DropDownListFor(widget => widget.Zone, new SelectList(Model.AvailableZones))
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
@Html.LabelFor(widget => widget.LayerId, T("Layer"))
|
||||||
|
@Html.DropDownListFor(widget => widget.LayerId, new SelectList(Model.AvailableLayers, "Id", "Name"))
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@Html.LabelFor(widget => widget.Title, T("Title"))
|
@Html.LabelFor(widget => widget.Title, T("Title"))
|
||||||
@Html.TextBoxFor(widget => widget.Title)
|
@Html.TextBoxFor(widget => widget.Title)
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
@Html.LabelFor(widget => widget.Position, T("Position"))
|
||||||
|
@Html.TextBoxFor(widget => widget.Position)
|
||||||
</fieldset>
|
</fieldset>
|
Reference in New Issue
Block a user