forked from ScoDoc/ScoDoc
proposition ihm groupe+rang
This commit is contained in:
parent
e8accaf6a0
commit
cf8992ebce
@ -27,6 +27,64 @@ $(function () {
|
||||
}
|
||||
}
|
||||
|
||||
const GROUP_RANK_NONE = 0;
|
||||
const GROUP_RANK_GROUP_ONLY = 1;
|
||||
const GROUP_RANK_ALL =2;
|
||||
|
||||
function button_on(but) {
|
||||
but.classList.add("but_on");
|
||||
but.classList.remove("but_off")
|
||||
}
|
||||
function button_off(but) {
|
||||
but.classList.add("but_off");
|
||||
but.classList.remove("but_on")
|
||||
}
|
||||
function update_buttons_group_rank(dt, status, group, but) {
|
||||
console.log(" >>>> " + status + " => " + group);
|
||||
if (status == GROUP_RANK_NONE) {
|
||||
console.log("off");
|
||||
button_off(but);
|
||||
} else if (status == GROUP_RANK_ALL) {
|
||||
console.log("on");
|
||||
button_on(but);
|
||||
} else { // GROUP_RANK_GROUP_ONLY
|
||||
if (group == "partition_aux") {
|
||||
console.log("on");
|
||||
button_on(but);
|
||||
} else {
|
||||
console.log("off");
|
||||
button_off(but);
|
||||
}
|
||||
}
|
||||
}
|
||||
function test_group_rank_visibility(dt) {
|
||||
if (! dt.columns(".partition_aux").visible()[0]) {
|
||||
return GROUP_RANK_NONE;
|
||||
}
|
||||
if (dt.columns(".partition_rangs").visible()[0]) {
|
||||
return GROUP_RANK_ALL
|
||||
}
|
||||
return GROUP_RANK_GROUP_ONLY;
|
||||
}
|
||||
function set_group_rank_visibility(dt, status) {
|
||||
let group_but = document.querySelector("button.dt-button.partition_aux");
|
||||
let rang_but = document.querySelector("button.dt-button.partition_rangs");
|
||||
switch (status) {
|
||||
case GROUP_RANK_ALL:
|
||||
dt.columns('.partition_aux').visible(true);
|
||||
dt.columns('.partition_rangs').visible(true);
|
||||
break;
|
||||
case GROUP_RANK_GROUP_ONLY:
|
||||
dt.columns('.partition_aux').visible(true);
|
||||
dt.columns('.partition_rangs').visible(false);
|
||||
break;
|
||||
case GROUP_RANK_NONE:
|
||||
dt.columns('.partition_aux').visible(false);
|
||||
dt.columns('.partition_rangs').visible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Les colonnes visibles sont mémorisées, il faut initialiser l'état des boutons
|
||||
function update_buttons_labels(dt) {
|
||||
// chaque bouton controle une classe stockée dans le data-group du span
|
||||
@ -35,13 +93,15 @@ $(function () {
|
||||
if (g_span) {
|
||||
let group = g_span.dataset["group"];
|
||||
if (group) {
|
||||
// si le group (= la 1ere col.) est visible, but_on
|
||||
if (dt.columns("." + group).visible()[0]) {
|
||||
but.classList.add("but_on");
|
||||
but.classList.remove("but_off");
|
||||
if ((group == "partition_aux") || (group == "partition_rangs")) {
|
||||
status = test_group_rank_visibility(dt);
|
||||
console.log("update: " + group + "(" + status + ")");
|
||||
update_buttons_group_rank(dt, status, group, but);
|
||||
// group hors partition/rang => si le group (= la 1ere col.) est visible, but_on
|
||||
} else if (dt.columns("." + group).visible()[0]) {
|
||||
button_on(but);
|
||||
} else {
|
||||
but.classList.add("but_off");
|
||||
but.classList.remove("but_on");
|
||||
button_off(but);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,6 +132,36 @@ $(function () {
|
||||
}
|
||||
update_buttons_labels(dt);
|
||||
}
|
||||
function toggle_col_partition_group_visibility(e, dt, node, config) {
|
||||
let status = test_group_rank_visibility(dt);
|
||||
switch (status) {
|
||||
case GROUP_RANK_NONE:
|
||||
set_group_rank_visibility(dt, GROUP_RANK_GROUP_ONLY);
|
||||
break;
|
||||
case GROUP_RANK_ALL:
|
||||
set_group_rank_visibility(dt, GROUP_RANK_GROUP_ONLY)
|
||||
break;
|
||||
case GROUP_RANK_GROUP_ONLY:
|
||||
set_group_rank_visibility(dt, GROUP_RANK_NONE);
|
||||
break;
|
||||
}
|
||||
update_buttons_labels(dt);
|
||||
}
|
||||
function toggle_col_partition_rank_visibility(e, dt, node, config) {
|
||||
let status = test_group_rank_visibility(dt);
|
||||
switch (status) {
|
||||
case GROUP_RANK_NONE:
|
||||
set_group_rank_visibility(dt, GROUP_RANK_ALL);
|
||||
break;
|
||||
case GROUP_RANK_ALL:
|
||||
set_group_rank_visibility(dt, GROUP_RANK_NONE)
|
||||
break;
|
||||
case GROUP_RANK_GROUP_ONLY:
|
||||
set_group_rank_visibility(dt, GROUP_RANK_ALL);
|
||||
break;
|
||||
}
|
||||
update_buttons_labels(dt);
|
||||
}
|
||||
// Definition des boutons au dessus de la table:
|
||||
let buttons = [
|
||||
{
|
||||
@ -107,11 +197,11 @@ $(function () {
|
||||
},
|
||||
{
|
||||
text: '<span data-group="partition_aux"><a title="Affichage des groupes secondaires (la première partition est toujours affichée)">Groupes</a></span>',
|
||||
action: toggle_col_but_visibility,
|
||||
action: toggle_col_partition_group_visibility,
|
||||
},
|
||||
{
|
||||
text: '<span data-group="partition_rangs"><a title="Rangs dans les groupes (si activés dans les partitions concernées)">Rg</a></span>',
|
||||
action: toggle_col_but_visibility,
|
||||
text: '<span data-group="partition_rangs"><a title="Rangs dans les groupes (si activés dans les partitions concernées)">Groupes et Rg</a></span>',
|
||||
action: toggle_col_partition_rank_visibility,
|
||||
},
|
||||
]; // fin des boutons communs à toutes les tables recap
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user