Commit 85e38148 authored by flothoni's avatar flothoni

list.js; add an '-' entrie in sort list

At sample change, the list is moved at '-' value if locked on another sample
Title of icon changed un function of curernt state of sort
Link to #4222
parent db07faad
Pipeline #129313 failed with stages
in 8 seconds
......@@ -48,6 +48,7 @@ function List(id_list, id_data, model, database) {
this.build();
this.sort_option = {
"-" : function () {},
"size" : function(){self.sortListBy(function(id){return self.m.clone(id).getSize();})},
"V/5'" : function(){self.sortListByV()},
"J/3'" : function(){self.sortListByJ()}
......@@ -285,8 +286,10 @@ List.prototype = {
self.sort_option_selected = this.value
// close the lock
self.sort_lock = true
self.current_sample = self.m.t
var div = document.getElementById("div_sortLock")
div.className = "icon-lock-1 list_lock_on"
div.title = "Release sort as '" + self.sort_option_selected +"' on sample " + self.m.getStrTime(self.m.t, "names")
}
for (var key in this.sort_option) {
......@@ -298,23 +301,26 @@ List.prototype = {
sort_span.appendChild(document.createTextNode("sort by "));
sort_span.appendChild(sort);
this.current_sample = this.m.t
var lock_div = document.createElement("icon")
lock_div.id = "div_sortLock"
lock_div.className = "icon-lock-1 list_lock_on"
lock_div.title = "Keep list sorted"
lock_div.title = "Release sort as '" + this.sort_option_selected +"' on sample " + this.m.getStrTime(this.m.t, "names")
lock_div.onclick = function(){
var div = document.getElementById("div_sortLock")
if (self.sort_lock == true){
self.sort_lock = false
div.className = "icon-lock-open list_lock_off"
div.title = "Freeze list"
self.current_sample = self.m.t
div.title = "Freeze list as '" + self.sort_option_selected +"' on sample " + self.m.getStrTime(self.current_sample, "names")
// Apply sort method at unlock
self.sort_option[self.sort_option_selected]()
} else {
self.sort_lock = true
div.className = "icon-lock-1 list_lock_on"
div.title = "Keep list sorted"
self.current_sample = self.m.t
div.title = "Release sort as '" + self.sort_option_selected +"' on sample " + self.m.getStrTime(self.current_sample, "names")
}
}
......@@ -374,6 +380,13 @@ List.prototype = {
// Apply selected sort function if no sort lock
if (this.sort_lock == false){
this.sort_option[this.sort_option_selected]()
this.current_sample = this.m.t
var div = document.getElementById("div_sortLock")
div.title = "Freeze list as '" + this.sort_option_selected +"' on sample " + self.m.getStrTime(this.current_sample, "names")
} else {
if (this.current_sample != this.m.t) {
document.getElementById("list_sort_select").selectedIndex = 0;
}
}
},
......
......@@ -20,34 +20,37 @@ class TestList < BrowserTest
end
def test_00_list_clones
sleep 1
$b.update_icon.wait_while(&:present?)
# declare variables
$lock = $b.listLock()
$listClone = $b.list()
# tester la presence du lock
lock = $b.listLock()
assert ( lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock start in good state (locked)"
assert ( $lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock start in good state (locked)"
assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title start by showing 'release xxx'"
# tester l'ordre des clones
listClone = $b.list()
l0 = listClone.div(index: 0)
l0 = $listClone.div(index: 0)
assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
end
def test_01_xxx
# cahnger de sample, verifier que l'ordre est rester le meme
# Change sample (-> fu1); order should still the same
$b.send_keys :arrow_right
listClone = $b.list()
l0 = listClone.div(index: 0)
l0 = $listClone.div(index: 0)
assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title still showsame message"
$b.screenshot.save 'screenshot.png'
end
def test_02_xxx
# Enlever le lock
lock = $b.listLock()
lock.click
assert ( lock.attribute_value("class") == "icon-lock-open list_lock_off"), "lock in good state after click (unlocked)"
# verifier que l'ordre a déjà changer (automatique sort)
listClone = $b.list()
l0 = listClone.div(index: 0)
# Lock off
$lock.click
assert ( $lock.attribute_value("class") == "icon-lock-open list_lock_off"), "lock in good state after click (unlocked)"
assert ( $lock.attribute_value("title") == "Freeze list as 'size' on sample fu1"), "lock title show correct effet if click in icon (freeze, size, fu1)"
# Clone order should have changed (automatic sort)
l0 = $listClone.div(index: 0)
assert ( l0.id == "listElem_5" ), "opening; correct id of the first element (clone other)"
end
......@@ -55,47 +58,48 @@ class TestList < BrowserTest
def test_03_xxx
# changer de sample
# Change sample (-> diag)
$b.send_keys :arrow_right
sleep 0.1
# verifier que l'ordre est redevenu celui du cas 1
listClone = $b.list()
l0 = listClone.div(index: 0)
$b.update_icon.wait_while(&:present?)
# clone order
l0 = $listClone.div(index: 0)
assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
assert ( $lock.attribute_value("title") == "Freeze list as 'size' on sample diag"), "lock title show correct effet if click in icon (freeze, size, diag)"
end
def test_04_xxx
# verouiller de nouveau
lock = $b.listLock()
lock.click
assert ( lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock in good state after second click (locked)"
# changer de sample
# Lock again
$lock.click
$b.update_icon.wait_while(&:present?)
assert ( $lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock in good state after second click (locked)"
assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title showing 'release ...'size' ... diag'"
# Change sample (-> fu1)
$b.send_keys :arrow_right
sleep 0.1
# verifier que l'ordre est rester le cas 1
listClone = $b.list()
l0 = listClone.div(index: 0)
$b.update_icon.wait_while(&:present?)
assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title showing 'release ...'size' ... diag'"
# Clone order should be as in case 1
l0 = $listClone.div(index: 0)
assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
end
def test_05_xxx
# # tester de changer la valeur de la methode (size => V/5')
# Change sort method (size => V/5')
$b.select(:id => 'list_sort_select').click
$b.send_keys :arrow_down
$b.send_keys :arrow_down
$b.send_keys :enter
sleep 0.1
$b.update_icon.wait_while(&:present?)
lock = $b.listLock()
# verifier que le lock est bien levé
assert ( lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock in good state after change of sort method (locked)"
# voir qu'il y a bien une reorganisation de la liste
# Lock should be open
assert ( $lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock in good state after change of sort method (locked)"
assert ( $lock.attribute_value("title") == "Release sort as 'V/5'' on sample fu1"), "lock title showing 'release ...'V/5'' ... diag'"
listClone = $b.list()
l0 = listClone.div(index: 0)
# clone list should be cha
l0 = $listClone.div(index: 0)
assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
end
......
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