1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Feature #3408 #3748: The datatable disables vm action buttons depending on the state

This commit is contained in:
Carlos Martín 2015-07-10 11:54:24 +02:00
parent 9e1b783bcb
commit 02adb9463d
3 changed files with 29 additions and 5 deletions

View File

@ -128,6 +128,8 @@ define(function(require) {
}
function _initialize(opts) {
var that = this;
TabDataTable.prototype.initialize.call(this, opts);
$('#' + this.dataTableId).on("click", '.vnc', function() {
@ -155,5 +157,24 @@ define(function(require) {
return false;
});
$('#' + this.dataTableId).on("change", 'tbody input.check_item', function() {
if ($(this).is(":checked")){
StateActions.enableStateActions($(this).attr("state"), $(this).attr("lcm_state"));
} else {
// First disable all actions
StateActions.disableAllStateActions();
// Enable actions available to any of the selected VMs
var nodes = $('tr', that.dataTable); //visible nodes only
$.each($('input.check_item:checked', nodes), function(){
StateActions.enableStateActions($(this).attr("state"), $(this).attr("lcm_state"));
});
}
return true;
});
}
});

View File

@ -63,9 +63,12 @@ define(function(require) {
}
return [
'<input class="check_item" type="checkbox" id="' + RESOURCE.toLowerCase() + '_' +
element.ID + '" name="selected_items" value="' +
element.ID + '"/>',
'<input class="check_item" '+
'type="checkbox" '+
'id="' + RESOURCE.toLowerCase() + '_' + element.ID + '" '+
'name="selected_items" '+
'value="' + element.ID + '" '+
'state="'+element.STATE+'" lcm_state="'+element.LCM_STATE+'"/>',
element.ID,
element.UNAME,
element.GNAME,

View File

@ -284,10 +284,10 @@ define(function(require) {
this.dataTable.on("change", '.check_all', function() {
var table = $(this).closest('.dataTables_wrapper');
if ($(this).is(":checked")) { //check all
$('tbody input.check_item', table).prop('checked', true);
$('tbody input.check_item', table).prop('checked', true).change();
$('td', table).addClass('markrowchecked');
} else { //uncheck all
$('tbody input.check_item', table).prop('checked', false);
$('tbody input.check_item', table).prop('checked', false).change();
$('td', table).removeClass('markrowchecked');
};