mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Partial fix for widget position input
--HG-- branch : dev
This commit is contained in:
@@ -122,12 +122,12 @@ namespace Orchard.Widgets.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool MoveWidgetUp(WidgetPart widgetPart) {
|
public bool MoveWidgetUp(WidgetPart widgetPart) {
|
||||||
int currentPosition = int.Parse(widgetPart.Record.Position);
|
int currentPosition = ParsePosition(widgetPart);
|
||||||
|
|
||||||
WidgetPart widgetBefore = GetWidgets(widgetPart.LayerPart.Id)
|
WidgetPart widgetBefore = GetWidgets(widgetPart.LayerPart.Id)
|
||||||
.Where(widget => widget.Zone == widgetPart.Zone)
|
.Where(widget => widget.Zone == widgetPart.Zone)
|
||||||
.OrderByDescending(widget => widget.Position, new UI.FlatPositionComparer())
|
.OrderByDescending(widget => widget.Position, new UI.FlatPositionComparer())
|
||||||
.FirstOrDefault(widget => int.Parse(widget.Record.Position) < currentPosition);
|
.FirstOrDefault(widget => ParsePosition(widget) < currentPosition);
|
||||||
|
|
||||||
if (widgetBefore != null) {
|
if (widgetBefore != null) {
|
||||||
SwitchWidgetPositions(widgetBefore, widgetPart);
|
SwitchWidgetPositions(widgetBefore, widgetPart);
|
||||||
@@ -138,17 +138,24 @@ namespace Orchard.Widgets.Services {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int ParsePosition(WidgetPart widgetPart) {
|
||||||
|
int value;
|
||||||
|
if (!int.TryParse(widgetPart.Record.Position, out value))
|
||||||
|
return 0;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public bool MoveWidgetUp(int widgetId) {
|
public bool MoveWidgetUp(int widgetId) {
|
||||||
return MoveWidgetUp(GetWidget(widgetId));
|
return MoveWidgetUp(GetWidget(widgetId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MoveWidgetDown(WidgetPart widgetPart) {
|
public bool MoveWidgetDown(WidgetPart widgetPart) {
|
||||||
int currentPosition = int.Parse(widgetPart.Record.Position);
|
int currentPosition = ParsePosition(widgetPart);
|
||||||
|
|
||||||
WidgetPart widgetAfter = GetWidgets(widgetPart.LayerPart.Id)
|
WidgetPart widgetAfter = GetWidgets(widgetPart.LayerPart.Id)
|
||||||
.Where(widget => widget.Zone == widgetPart.Zone)
|
.Where(widget => widget.Zone == widgetPart.Zone)
|
||||||
.OrderBy(widget => widget.Position, new UI.FlatPositionComparer())
|
.OrderBy(widget => widget.Position, new UI.FlatPositionComparer())
|
||||||
.FirstOrDefault(widget => int.Parse(widget.Record.Position) > currentPosition);
|
.FirstOrDefault(widget => ParsePosition(widget) > currentPosition);
|
||||||
|
|
||||||
if (widgetAfter != null) {
|
if (widgetAfter != null) {
|
||||||
SwitchWidgetPositions(widgetAfter, widgetPart);
|
SwitchWidgetPositions(widgetAfter, widgetPart);
|
||||||
|
|||||||
Reference in New Issue
Block a user