yakecan / dropthings

Automatically exported from code.google.com/p/dropthings
0 stars 0 forks source link

When moving widgets down in the same zoneId, they do not maintain their positions after a postback #208

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Place 2 widgets in the same zoneId, one in orderNo: 0 and one in OrderNo: 1
2. Move the widget that is in orderNo: 0 down and place it in orderNo: 1. 
Widgets should switch places.  They do on the HTML canvas.
3. Upon page refresh, widgets are back to their old positions, because the 
values in dbo.WidgetInstance.OrderNo did not get updated properly.

What is the expected output? What do you see instead?
Expect that portlets will maintain their position, they do not simply because 
the logic in Facade.Widget.cs, PushDownWidgetInstancesOnWidgetZone() is wrong.  
So when the values are read from the database on a postback, old positions are 
restored.

What version of the product are you using? On what operating system?
Latest, just downloaded today.

Please provide any additional information below.
Just a logic error in PushDownWidgetInstancesOnWidgetZone(), but I have looked 
at the code and haven't been able to fix it yet.

Original issue reported on code.google.com by kaczm...@gmail.com on 10 Jun 2011 at 12:44

GoogleCodeExporter commented 9 years ago
I recently discovered this issue as well and I have not seen anyone post a 
solution to it, here is my fix:

 private void PushDownWidgetInstancesOnWidgetZone(int toRowId, int widgetZoneId, bool isMovingDown)
        {
            IEnumerable<WidgetInstance> list = this.widgetInstanceRepository.GetWidgetInstancesByWidgetZoneIdWithWidget(widgetZoneId);

            if (isMovingDown)
            {
                list.Where(wi => wi.OrderNo <= toRowId)
                    .OrderBy(wi => wi.OrderNo)
                    .Each(wi =>
                    {
                        wi.OrderNo = --wi.OrderNo;
                    });
            }
            else
            {
                int orderNo = toRowId + 1;
                list.Where(wi => wi.OrderNo >= toRowId)
                    .OrderBy(wi => wi.OrderNo)
                    .Each(wi =>
                    {
                        wi.OrderNo = orderNo++;
                    });
            }

            this.widgetInstanceRepository.UpdateList(list);
        }

Original comment by chue...@gmail.com on 2 May 2012 at 12:10

GoogleCodeExporter commented 9 years ago
Hi, i resolved the issue by setting the value of position to length -1 if the 
position value is > 0 in MyFramework.js like following:

-------------
var position = ui.item.parent().children().index(ui.item);
if (position > 0) {
    position = position - 1;
}
---------------
hope this can be useful for you.

Original comment by san.tha...@gmail.com on 19 Jul 2012 at 7:56