Commit 19c55835 authored by Mikaël Salson's avatar Mikaël Salson

model.js (+tests): Select subclones when cluster is open

Fixes #2837
parent 45a0d74c
......@@ -970,13 +970,21 @@ changeAlleleNotation: function(alleleNotation) {
if (!this.clone(i).split) {
for (var j = 0; j < this.clusters[i].length; j++) {
seq = this.clusters[i][j]
this.clone(seq).disable();
var clone = this.clone(seq);
clone.disable();
if (j > 0 && clone.isSelected())
// Unselect all subclones
this.unselect(seq);
}
this.clone(i).enable(this.top)
} else {
var main_clone = this.clone(this.clusters[i][0]);
for (var k = 0; k < this.clusters[i].length; k++) {
seq = this.clusters[i][k]
this.clone(seq).enable(this.top)
var clone = this.clone(seq);
clone.enable(this.top)
if (clone.isSelected() != main_clone.isSelected())
this.select(seq, main_clone.select);
}
}
}
......
......@@ -170,3 +170,62 @@ QUnit.test("tag/norm", function(assert) {
QUnit.test("cluster", function(assert) {
var m = new Model();
m.parseJsonData(json_data,100)
m.loadGermline()
m.initClones()
var list = new List("list","data",m);
list.init();
m.merge([1, 3, 4]);
var li_clone1 = document.getElementById('1');
var li_clone3 = document.getElementById('3');
var li_clone4 = document.getElementById('4');
setTimeout( function() {
assert.ok( $(li_clone1).is(':visible'), "clone merged, but main clone should be visible");
assert.ok( ! $(li_clone3).is(':visible'), "clone merged should not be visible");
assert.ok( ! $(li_clone4).is(':visible'), "clone merged should not be visible");
}, 500);
var elements = $('[cloneid=1]');
assert.equal( elements.length, 1, "Only one element with cloneid = '1'");
list.showCluster(elements[0]);
li_clone1 = document.getElementById('1');
li_clone3 = document.getElementById('3');
li_clone4 = document.getElementById('4');
setTimeout( function() {
assert.ok( $(li_clone1).is(':visible'), "clone merged, but main clone should be visible");
assert.ok( $(li_clone3).is(':visible'), "clone merged should be visible");
assert.ok( $(li_clone4).is(':visible'), "clone merged should be visible");
}, 500);
list.hideCluster(elements[0]);
setTimeout( function() {
assert.ok( $(li_clone1).is(':visible'), "clone merged, but main clone should be visible");
assert.ok( ! $(li_clone3).is(':visible'), "clone merged should be visible");
assert.ok( ! $(li_clone4).is(':visible'), "clone merged should be visible");
}, 500);
m.select(1);
list.showCluster(elements[0]);
setTimeout( function() {
assert.ok(m.clones[1].isSelected(), "Clone 1 should be selected (main cluster)");
assert.ok(m.clones[3].isSelected(), "Clone 3 should be selected (opened cluster)");
assert.ok(m.clones[4].isSelected(), "Clone 4 should be selected (opened cluster)");
assert.ok(! m.clones[2].isSelected(), "Clone 2 should not be selected (not in cluster)");
}, 500);
list.hideCluster(elements[0]);
setTimeout( function() {
assert.ok(m.clones[1].isSelected(), "Clone 1 should be selected (main cluster)");
assert.ok(! m.clones[3].isSelected(), "Clone 3 should not be selected (closed cluster)");
assert.ok(! m.clones[4].isSelected(), "Clone 4 should not be selected (closed cluster)");
assert.ok(! m.clones[2].isSelected(), "Clone 2 should not be selected (not in cluster)");
}, 500);
});
......@@ -204,6 +204,9 @@ QUnit.test("cluster", function(assert) {
m.merge()
assert.deepEqual(m.clusters[0], [0,1], "merge 0 and 1: build cluster [0,1]");
assert.equal(m.clone(0).getSize(), 0.15, "cluster [0,1] : getsize = 0.15");
assert.ok(! m.clones[1].isSelected(), "Merged clone should not be selected");
assert.ok(m.clones[0].isSelected(), "Main merged clone should not be selected");
m.unselectAll()
m.select(0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment