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