Commit 145bc3d9 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-c/3689-colorer-icone-tag-multiple' into 'dev'

Resolve "Colorer l'icône de tag multiple lorsque c'est pertinent"

Closes #3689

See merge request !407
parents 2697c885 2563dd32
Pipeline #63100 failed with stages
in 3 minutes and 13 seconds
......@@ -965,10 +965,9 @@ Clone.prototype = {
*
* */
updateColor: function () {
var allele;
if (this.m.focus == this.index){
this.color = "";
}else if (this.m.colorMethod == "abundance") {
if (this.m.colorMethod == "abundance") {
var size = this.getSize()
if (this.getCluster().length===0){ size = this.getSequenceSize() }
if (size === 0){
......@@ -1008,6 +1007,11 @@ Clone.prototype = {
}else{
this.color = "";
}
this.true_color = this.color
if (this.m.focus == this.index){
this.color = "";
}
},
/**
......
......@@ -880,8 +880,57 @@ changeAlleleNotation: function(alleleNotation) {
this.updateElemStyle([cloneID]);
}
this.colorize_multitag_star_icon()
},
/**
* [colorize_multitag_star_icon description]
* @return {[type]} [description]
*/
colorize_multitag_star_icon: function(){
var color = this.getColorSelectedClone()
try {
// put it in a try to not create errors on qunit
var div = document.getElementById("tag_icon__multiple")
if (color){
div.style.color = color;
} else {
div.style.color = ""
}
} catch (err) {
// ne rien faire.
}
},
/**
* Return the color of selected clones if similar; else return false
* @return {[type]} [description]
*/
getColorSelectedClone: function(){
var selected = this.getSelected()
var list_color = new Set()
if (selected.length == 0){
return false
}
for (var i = 0; i < selected.length; i++) {
var clone_id = selected[i]
var clone = this.clones[clone_id]
var color = clone.true_color;
list_color.add(color)
if (list_color.size == 2){
return false
}
}
return Array.from(list_color)[0]
},
/**
* Unselect an isolated clone
* @param {integer} - cloneID - index of the clone to remove from the selection
......@@ -983,7 +1032,7 @@ changeAlleleNotation: function(alleleNotation) {
this.orderedSelectedClones.push(tmp[j].id);
list[j] = tmp[j].id
}
this.updateStyle();
this.updateElemStyle(list);
this.update();
},
......@@ -1103,7 +1152,7 @@ changeAlleleNotation: function(alleleNotation) {
this.clone(n).updateCloneTagIcon()
}
this.colorize_multitag_star_icon();
},
/**
......
......@@ -449,3 +449,42 @@ QUnit.test("findGermlineFromGene", function(assert) {
});
QUnit.test("tag / color", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
var c4 = new Clone(json_clone4, m, 3)
var c5 = new Clone(json_clone5, m, 4)
var c6 = new Clone(json_clone6, m, 4)
m.initClones()
assert.equal(m.getColorSelectedClone(), false, "Color of selected clones (empty selection) is correct")
// select 2 clones without tag
m.select(0)
m.select(1)
assert.equal(m.getColorSelectedClone(), "", "Color of selected clones (without tags) is correct")
// Change tag of clones
assert.equal(c1.getTag(), 8, "getTag() >> default tag : 8");
c1.changeTag(5)
c2.changeTag(5)
c1.updateColor()
c2.updateColor()
assert.equal(c1.getTag(), 5, "changeTag() >> tag : 5");
// tag 8 color: ''
// tag 5 color: #2aa198
assert.equal(m.getColorSelectedClone(), "#2aa198", "Color of selected clones (same tag) is correct")
// select another clone, without tag
m.select(2)
assert.equal(m.getColorSelectedClone(), "", "Color of selected clones (mix of clones) is false")
});
\ No newline at end of file
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