[MAGNOLIA-3986] MgnlDynamicTable move functions Created: 01/Mar/12  Updated: 05/Jan/16  Resolved: 05/Jan/16

Status: Closed
Project: Magnolia
Component/s: admininterface
Affects Version/s: 4.4.4
Fix Version/s: None

Type: New Feature Priority: Neutral
Reporter: Stefan Baur Assignee: Philipp Bärfuss
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: 1m
Time Spent: Not Specified
Original Estimate: 1m

Template:
Patch included:
Yes
Acceptance criteria:
Empty
Date of First Response:
Visible to:
Andrew Bernard, Daniel Kummer

 Description   

I have created move functions for the MgnlDynamicTable javascript lib.
The following functions can be added to /mgnl-resources/js-classes/mgnl/controls/DynamicTable.js

The functions have been tested on

  • Safari 5.1.2 (Win7x64)
  • FF 10 (Win7x64)
  • Chrome 17.0.963.56 (Win7x64)
  • IE 9 (Win7x64)
  • IE 6 & 7 (WinXP, separate in a VM, not with multipleIE)
DynamicTable.js
/* ###################################
### Move an Object from one index to another. includes savety checks
################################### */

MgnlDynamicTable.prototype.move = function (from, to){
    if(from == to || from == null || from == 'undefined' || to == null || to == 'undefined') {
        //do nothing 
    } else if (from < to) { //move down
        var index = from;
        var objectToMove = this.objects[from];
        var to = Math.min(to, this.objects.length-1); //safety...
        while(index < to) {
            var nextIndex = index+1;
            var nextObject = this.objects[nextIndex];
            this.set(index, nextObject);
            index = nextIndex;
        }
        this.set(to, objectToMove);
    } else { //move up
        var index = from;
        var objectToMove = this.objects[from]; 
        var to = Math.max(to, 0); //safety...
        while(index > to) {
            var nextIndex = index-1;
            var nextObject = this.objects[nextIndex];
            this.set(index, nextObject);
            index = nextIndex;
        }
        this.set(to, objectToMove);
    }
}


/* ###################################
### Move an Object up
################################### */

MgnlDynamicTable.prototype.moveUp = function (index){
    this.move(index, index-1); 
}


/* ###################################
### Move an Object down
################################### */

MgnlDynamicTable.prototype.moveDown = function (index){
    this.move(index, index+1); 
}



 Comments   
Comment by Stefan Baur [ 18/Jan/13 ]

Going through my reported tickets...

I realize this is strategically non-important looking at magnolia 5 evolving.
So I'm fine this is just closed

Comment by Michael Mühlebach [ 05/Jan/16 ]

I'm going to close this to set expectations so the issue doesn't stay open for years with no updates. If the issue is still relevant please feel free to reopen it or better create a new issue for 5.4.

Generated at Mon Feb 12 03:51:35 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.