Commit 0bffa98c authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-c/4127-filtre-sur-un-clone-graphlist' into 'dev'

Resolve "Avoir un bouton de filtre sur un clone depuis la nouvelle graphlist"

Closes #4127

See merge request !636
parents 58ddcbbd 2eb58213
Pipeline #150397 failed with stages
in 7 minutes and 1 second
......@@ -239,9 +239,20 @@ Graph.prototype = {
var div = document.createElement('div')
div.id = "" + this.id + "_menu"
div.className = "graph_menu"
var list_title = document.createElement('div')
var list_title_line = document.createElement('div')
var list_title = document.createElement('span')
list_title.id = this.id +"_title"
div.appendChild(list_title)
var list_title_samples = document.createElement('span')
list_title_samples.textContent = " sample" + (this.m.samples.number > 1 ? "s" : "")
list_title_samples.id = this.id +"_title_samples"
list_title_samples.style.display = "none"
list_title_line.appendChild(list_title)
list_title_line.appendChild(list_title_samples)
div.appendChild(list_title_line)
var list = document.createElement('table')
list.id = this.id +"_table"
......@@ -262,12 +273,18 @@ Graph.prototype = {
$("#"+ self.id +"_table")
.stop(true, true)
.show()
$("#"+ self.id +"_title_samples")
.stop(true, true)
.show()
self.updateList()
})
.on("mouseout", function () {
$("#"+ self.id +"_table")
.stop(true, true)
.hide()
$("#"+ self.id +"_title_samples")
.stop(true, true)
.hide()
})
this.updateCountActiveSample()
......@@ -288,21 +305,32 @@ Graph.prototype = {
var table = document.getElementById(""+this.id +"_table")
table.removeAllChildren()
// Show All
var line = document.createElement("tr")
var line_content = document.createElement("td")
line_content.id = this.id +"_listElem_showAll"
line_content.classList.add("graph_listAll")
line_content.textContent = "show all samples"
line_content.textContent = "show all"
line_content.colSpan = "2"
line.appendChild(line_content)
table.appendChild(line)
// Hide All
line = document.createElement("tr")
line_content = document.createElement("td")
line_content.id = this.id +"_listElem_hideAll"
line_content.classList.add("graph_listAll")
line_content.textContent = "hide all samples"
line_content.textContent = "focus on selected samples"
line_content.colSpan = "2"
line.appendChild(line_content)
table.appendChild(line)
// Hide not share
line = document.createElement("tr")
line_content = document.createElement("td")
line_content.id = this.id +"_listElem_hideNotShare"
line_content.classList.add("graph_listAll")
line_content.textContent = "focus on selected clones"
line_content.colSpan = "2"
line.appendChild(line_content)
table.appendChild(line)
......@@ -330,6 +358,13 @@ Graph.prototype = {
list_content.appendChild(line_content_check)
list_content.appendChild(line_content_text)
// Add all descripion of sample keys as tooltip
var tooltip = this.m.getStrTime(i, "names")
tooltip += String.fromCharCode(13) + this.m.getStrTime(i, "sampling_date")
tooltip += String.fromCharCode(13) + this.m.getStrTime(i, "delta_date")
list_content.title = tooltip
table.appendChild(list_content)
}
......@@ -341,6 +376,10 @@ Graph.prototype = {
console.log( "self.hideAllTimepoint( true )" )
self.m.hideAllTime()
})
$("#"+this.id +"_listElem_hideNotShare").click(function () {
console.log( "self.hideNotShare()" )
self.m.hideNotShare()
})
$(".graph_listElem").click(function () {
var time = parseInt( this.dataset.time )
......@@ -455,6 +494,7 @@ Graph.prototype = {
/* repositionne le graphique en fonction de la taille de la div le contenant
*
* */
......
......@@ -3364,5 +3364,41 @@ changeAlleleNotation: function(alleleNotation) {
},
/**
* Return a list of samples with selected clones
* @return {Array} list of samples
*/
getSampleWithSelectedClones: function(){
var selected = this.getSelected()
if (selected.length == 0) {
return this.samples.order
}
var list = []
for (var pos = 0; pos < selected.length; pos++) {
var clone = this.clones[selected[pos]]
for (var time = 0; time < clone.reads.length; time++) {
if (clone.reads[time] != 0 && list.indexOf(time) == -1) {
list.push(time)
}
}
}
return list
},
/**
* Remove all sample of the graph except one
*/
hideNotShare: function(){
// get list of sample with shared clone
if (this.getSelected().length == 0) {
return
}
this.changeTimeOrder( this.getSampleWithSelectedClones() )
// this.updateList()
// this.m.update()
return
},
}; //end prototype Model
......@@ -606,6 +606,27 @@ QUnit.test("computeOrderWithStock", function(assert) {
assert.deepEqual( m.samples.stock_order, waited, "Correct stock_order if apply m.switchTimeOrder")
});
QUnit.test("getSampleWithSelectedClones", function(assert) {
var m = new Model();
var data_copy = JSON.parse(JSON.stringify(json_data));
m.parseJsonData(data_copy, 100)
m.initClones()
// clone 1 present only in sample 1 and 2
m.clones[1].reads[2] = 0
m.clones[1].reads[3] = 0
// clone 2 present only in sample 2 and 3
m.clones[2].reads[0] = 0
m.clones[2].reads[3] = 0
assert.deepEqual( m.getSampleWithSelectedClones(), [0,1,2,3], "no selection, should return list of all actives samples")
m.select(1)
assert.deepEqual( m.getSampleWithSelectedClones(), [0,1], "clone 1, should return samples 1 and 2")
m.select(2)
assert.deepEqual( m.getSampleWithSelectedClones(), [0,1,2], "clone 1 and 2, should return samples 1 and 2 and 3")
});
......@@ -23,7 +23,7 @@ class TestGraph < BrowserTest
# By default, 2 samples are present in timeline graph
$time0 = $b.graph_x_legend("0")
$time1 = $b.graph_x_legend("1")
$div_ratio = $b.div(:id => "visu2_title")
$div_ratio = $b.span(:id => "visu2_title")
$check0 = $b.checkbox(:id => "visu2_listElem_check_0")
$check1 = $b.checkbox(:id => "visu2_listElem_check_1")
$sample_arrow = $b.i(:title => "next sample")
......@@ -174,7 +174,28 @@ class TestGraph < BrowserTest
$b.table(:id => "visu2_table").wait_while(&:present?)
end
def test_07_graphlist_filter_on_shared_clones
$b.div(:id => 'visu2_menu').hover
$b.table(:id => "visu2_table").wait_until(&:present?)
$b.td(:id => 'visu2_listElem_showAll').click
$b.clone_in_list('4').click
# Assert on checkbox at init
assert ( $check0.set? ), "first checkbox is true"
assert ( $check1.set? ), "second checkbox is true"
# By default, checkbox are true
$b.div(:id => 'visu2_menu').hover
$b.table(:id => "visu2_table").wait_until(&:present?)
$b.td(:id => 'visu2_listElem_hideNotShare').click
$b.update_icon.wait_while(&:present?) # wait update
# Assert on checkbox after filter on shared clones
assert ( $check0.set? ), "first checkbox is true"
assert ( !$check1.set? ), "second checkbox is false"
end
# Not really a test
def test_zz_close
......
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