Commit b099c687 authored by Celine Noirot's avatar Celine Noirot

add disable of button in obsolete tab and in demand tab; handle select all close #17

parent af3b33f2
......@@ -391,7 +391,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<th align="left" colspan="10">
With selection :
<div class="btn-group">
<button id="send_mail" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Send mail </button>
<button id="btn_obsolete_mail" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Send mail </button>
</div>
</th>
</tr>
......@@ -432,8 +432,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<th align="left" colspan="7">
With selection :
<div class="btn-group">
<button id="delete_data_from_list" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-remove"></i> Delete data</button>
<button id="extend_data_retention_from_list" type="button" class="btn btn-sm btn-default"><i class="glyphicon glyphicon-pencil"></i> Extend retention date </button>
<button id="btn_demand_delete_data" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-remove"></i> Delete data</button>
<button id="btn_demand_retention" type="button" class="btn btn-sm btn-default"><i class="glyphicon glyphicon-pencil"></i> Extend retention date </button>
</div>
</th>
</tr>
......
......@@ -365,7 +365,7 @@ $(function () {
//Obsolete project / purge demand
//mark mail sent
$("#send_mail").click(function(){
$("#btn_obsolete_mail").click(function(){
$('#data_table_obsolete_wait').show();
$('#obsolete_list').hide();
......@@ -393,7 +393,7 @@ $(function () {
});
// Delete data after selecting list of ids demand
$("#delete_data_from_list").click(function(){
$("#btn_demand_delete_data").click(function(){
var del_auth_html = [
'<div class="tx-nG6-pi1-login">',
' This functionality is only available for ng6 unix user on the server. <br /> <br /> ',
......@@ -466,7 +466,7 @@ $(function () {
});
// Extend retention after selecting list of ids demand
$("#extend_data_retention_from_list").click(function(){
$("#btn_demand_retention").click(function(){
demands="";
$(':checked[id^=chk_demand').each(function(){
demand_id=$(this).val();
......@@ -481,7 +481,7 @@ $(function () {
var type = $(this).attr("id").split("_")[2];
var chk_status = $(this)[0].checked ;
$('input[id^=chk_'+type+']').prop('checked', chk_status);
updateDatatableButton(purge_table[type],type);
});
});
......@@ -542,6 +542,7 @@ function extend_date(list_ids, purge_demand_datatable, obsolete_project_datatabl
$('#data_table_purge_demand_wait').show();
$('#purge_demand_list').hide();
$.ajax({
url: "index.php?eID=tx_nG6&type=refresh_purge_demand&purge_delay="+purge_delay,
dataType: 'json',
......@@ -573,6 +574,10 @@ function extend_date(list_ids, purge_demand_datatable, obsolete_project_datatabl
oTable.draw();
$('#purge_demand_list').show();
$('#data_table_purge_demand_wait').hide();
updateDatatableButton(purge_demand_datatable, "demand");
$("input[type=checkbox][class=chk_demand]").change(function(){
updateDatatableButton(purge_demand_datatable, "demand");
});
}
});
......@@ -595,7 +600,7 @@ function refresh_project_obsolete(obsolete_project_datatable){
without_lab.push($(this).val());
});
$(':checked[class^=chk_with_lab_').each(function(){
with_lab.push($(this).val());
with_lab.push($(this).val());
});
without_laboratories = without_lab.join(',');
with_laboratories = with_lab.join(',');
......@@ -604,15 +609,15 @@ function refresh_project_obsolete(obsolete_project_datatable){
url: "index.php?eID=tx_nG6&type=refresh_purge_list&max_retention_date="+max_retention_date+"&filter_size="+filter_size+"&create_users="+create_users_string+"&without_lab="+without_laboratories+"&with_lab="+with_laboratories,
dataType: 'json',
success: function(val, status, xhr) {
var nb_purgeable_project=0,
global_purgeable_size=0;
var nb_purgeable_project=0,
global_purgeable_size=0;
oTable = obsolete_project_datatable;
oTable.clear();
$.each(val, function(key,values){
global_purgeable_size+=values["total_purgeable_size"];
nb_purgeable_project+=1;
var checkbox = '<center><input id="chk_obsolete_'+key+'" type="checkbox" value="' + key + '"></center>' ;
global_purgeable_size+=values["total_purgeable_size"];
nb_purgeable_project+=1;
var checkbox = '<center><input id="chk_obsolete_'+key+'" class="chk_obsolete" type="checkbox" value="' + key + '"></center>' ;
var row=[checkbox, "<a href='index.php?id=3&tx_nG6_pi1[project_id]="+key+"'>"+values["project_name"]+"</a>", values["nb_runs"]];
var nb_purgeable_element=0,
nb_all_element=parseInt(values["nb_runs"], 10);
......@@ -665,11 +670,49 @@ function refresh_project_obsolete(obsolete_project_datatable){
$('#global_purgeable_size').text(get_octet_string_representation(global_purgeable_size,2));
$('#obsolete_list').show();
$('#data_table_obsolete_wait').hide();
updateDatatableButton(obsolete_project_datatable, "obsolete");
$("input[type=checkbox][class=chk_obsolete]").change(function(){
updateDatatableButton(obsolete_project_datatable, "obsolete");
});
}
});
}
/*
* Retrieve checked values for data managment
*/
function getPurgeDatatableCheckedValue(oTable, type){
var values = new Array();
$.each(oTable.rows().nodes(), function(idx, node){
$(node)
.find('input[type=checkbox][class=chk_'+type+']:checked')
.each(function(idx,element){
values.push($(this).val());
});
});
return values
}
/*
* Handle buttons of datatables for data managment
*/
function updateDatatableButton(oTable, type){
var values = new Array();
var nb_selected = getPurgeDatatableCheckedValue(oTable, type).length;
if ( nb_selected <= 0) {
$("[id^=btn_"+type+"_]").each(function(){
this.disabled = true;
});
$("[id^=all_chk_"+type+"]")[0].checked = false;
} else {
$("[id^=btn_"+type+"_]").each(function(){
this.disabled = false;
});
}
}
function set_active_tab(active_tab){
......
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