mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Changing widget placement movement to also make use of MakeRoomForWidgetPosition(widgetPart)
--HG-- branch : dev
This commit is contained in:
@@ -125,8 +125,8 @@ namespace Orchard.Widgets.Services {
|
||||
.FirstOrDefault(widget => ParsePosition(widget) < currentPosition);
|
||||
|
||||
if (widgetBefore != null) {
|
||||
SwitchWidgetPositions(widgetBefore, widgetPart);
|
||||
|
||||
widgetPart.Position = widgetBefore.Position;
|
||||
MakeRoomForWidgetPosition(widgetPart);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ namespace Orchard.Widgets.Services {
|
||||
.FirstOrDefault(widget => ParsePosition(widget) > currentPosition);
|
||||
|
||||
if (widgetAfter != null) {
|
||||
SwitchWidgetPositions(widgetAfter, widgetPart);
|
||||
|
||||
widgetAfter.Position = widgetPart.Position;
|
||||
MakeRoomForWidgetPosition(widgetAfter);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Orchard.Widgets.Services {
|
||||
int targetPosition = ParsePosition(widgetPart);
|
||||
|
||||
IEnumerable<WidgetPart> widgetsToMove = GetWidgets()
|
||||
.Where(widget => widget.Zone == widgetPart.Zone && ParsePosition(widget) >= targetPosition)
|
||||
.Where(widget => widget.Zone == widgetPart.Zone && ParsePosition(widget) >= targetPosition && widget.Id != widgetPart.Id)
|
||||
.OrderBy(widget => widget.Position, new UI.FlatPositionComparer()).ToList();
|
||||
|
||||
// no need to continue if there are no widgets that will conflict with this widget's position
|
||||
@@ -178,11 +178,5 @@ namespace Orchard.Widgets.Services {
|
||||
return 0;
|
||||
return value;
|
||||
}
|
||||
|
||||
private static void SwitchWidgetPositions(WidgetPart sourceWidget, WidgetPart targetWidget) {
|
||||
string tempPosition = sourceWidget.Record.Position;
|
||||
sourceWidget.Record.Position = targetWidget.Record.Position;
|
||||
targetWidget.Record.Position = tempPosition;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user