Commit 45a0d74c authored by Mikaël Salson's avatar Mikaël Salson

model.js: Clone unselection

Method for unselecting (requires to update the list containin selection in
order).

Unit test it and also checks that selected sequences appear in the segmenter.
parent 4dd4eeef
......@@ -816,6 +816,26 @@ changeAlleleNotation: function(alleleNotation) {
}
},
/**
* Unselect an isolated clone
* @param {integer} - cloneID - index of the clone to remove from the selection
*/
unselect: function(cloneID) {
console.log("unselect() (clone " + cloneID + ")");
if (this.clones[cloneID].isVirtual()) {
return 0;
}
if (this.clone(cloneID).isSelected()) {
var index = this.orderedSelectedClones.indexOf(cloneID);
if (index > -1)
this.orderedSelectedClones.splice(index, 1);
this.clone(cloneID).select = false;
this.updateElemStyle([cloneID]);
}
console.log("orderedSelectedClones: " + this.orderedSelectedClones.join(","));
},
toggleSelect: function(cloneID) {
console.log("toggle() (clone " + cloneID + ")");
......
......@@ -149,6 +149,10 @@ QUnit.test("select/focus", function(assert) {
assert.deepEqual(m.getSelected(), [], "unselect all");
m.multiSelect([0,2,3])
assert.deepEqual(m.getSelected(), [0,2,3], "multi-select");
m.unselect(2);
assert.deepEqual(m.getSelected(), [0, 3], "unselect");
m.unselect(5);
assert.deepEqual(m.getSelected(), [0, 3], "unselect");
m.unselectAll()
assert.equal(m.findWindow("aaaaaaaaaaaid1aaaaaaa"), 0, "findWindow : Ok")
assert.equal(m.findWindow("aaaaaaaaaaaplopaaaaaaa"), -1, "findWindow : Ok")
......
......@@ -30,6 +30,13 @@ QUnit.test("segmenter", function(assert) {
assert.equal(document.getElementById("f0"), null, "unselect : Ok")
assert.equal(document.getElementById("f1"), null, "unselect : Ok")
assert.equal(document.getElementById("f2"), null, "unselect : Ok")
m.select(0);
m.select(2);
m.unselect(2);
assert.notEqual(div0.innerHTML.indexOf("test1"), -1, "select : Ok")
assert.equal(document.getElementById("f2"), null, "unselect : Ok")
m.unselectAll();
//
assert.deepEqual(segment.findPotentialField(), ["","cdr3","fr1", "5", "id", "f1", "V-REGION","J-REGION","D-REGION","CDR3-IMGT"], "potentialField : Ok")
......
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