Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
EXOGTN-1602 [Edit-Inplace] wrong application position after switch la…
Browse files Browse the repository at this point in the history
…yout
  • Loading branch information
phuong_vu authored and vietj committed Oct 26, 2013
1 parent df0a813 commit 1a56ff4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
Expand Up @@ -290,8 +290,18 @@

//
switchLayout : function(newContainer) {
$(this.get("_childrens").models).each(function() {
var apps = this.get("_childrens").models;
var conts = this.getChildrens();
conts.sort(function(m1, m2) {
var i1 = parseInt(m1.getId());
var i2 = parseInt(m2.getId());
if ($.isNumeric(i1) && $.isNumeric(i2)) {
return i1 - i2;
} else {
return 0;
}
});
$.each(conts, function() {
var apps = this.getChildrens();
var id = this.id;
var cont = this;
$(apps).each(function() {
Expand Down
41 changes: 31 additions & 10 deletions portal/web/src/test/resources/assets/testJS/LayoutEditorTest.js
Expand Up @@ -74,16 +74,37 @@ test("test toJSON", function() {
});

test("test switchLayout", function() {
var oneZone = new Container();
oneZone.addChild(new Container({id : "1"}));
equal(1, oneZone.get("_childrens").length);
container.switchLayout(oneZone);

equal(4, oneZone.getChild("1").getChildrens().length);
equal('1_1', oneZone.getChild('1').at(0).getId());
equal('1_2', oneZone.getChild('1').at(1).getId());
equal('2_1', oneZone.getChild('1').at(2).getId());
equal('2_2', oneZone.getChild('1').at(3).getId());
//container order: #1 #2
equal(container.getChild('1').getIndex(), 0);
equal(container.getChild('2').getIndex(), 1);

//new layout with reverted container order
var rLayout = new Container();
rLayout.addChild(new Container({id: '2'}));
rLayout.addChild(new Container({id: '1'}));

container.switchLayout(rLayout);
//
equal(rLayout.getChild('1').getIndex(), 1);
equal('1_1', rLayout.getChild('1').at(0).getId());
equal('1_2', rLayout.getChild('1').at(1).getId());
//
equal(rLayout.getChild('2').getIndex(), 0);
equal('2_1', rLayout.getChild('2').at(0).getId());
equal('2_2', rLayout.getChild('2').at(1).getId());

//new layout with 1 zone
var oneZone = new Container();
oneZone.addChild(new Container({id : "1"}));
equal(1, oneZone.get("_childrens").length);
//switch from reverted layout to 1 zone layout
rLayout.switchLayout(oneZone);

equal(4, oneZone.getChild("1").getChildrens().length);
equal('1_1', oneZone.getChild('1').at(0).getId());
equal('1_2', oneZone.getChild('1').at(1).getId());
equal('2_1', oneZone.getChild('1').at(2).getId());
equal('2_2', oneZone.getChild('1').at(3).getId());

var twoZone = new Container();
twoZone.addChild(new Container({id : "1"}));
Expand Down

0 comments on commit 1a56ff4

Please sign in to comment.