From 02adb9463d5fe5af07039ea1dc05abd88a7f0ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 10 Jul 2015 11:54:24 +0200 Subject: [PATCH] Feature #3408 #3748: The datatable disables vm action buttons depending on the state --- .../public/app/tabs/vms-tab/datatable.js | 21 +++++++++++++++++++ .../tabs/vms-tab/utils/datatable-common.js | 9 +++++--- .../public/app/utils/tab-datatable.js | 4 ++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/sunstone/public/app/tabs/vms-tab/datatable.js b/src/sunstone/public/app/tabs/vms-tab/datatable.js index 52f0bdb736..c8d9347869 100644 --- a/src/sunstone/public/app/tabs/vms-tab/datatable.js +++ b/src/sunstone/public/app/tabs/vms-tab/datatable.js @@ -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; + }); + } }); diff --git a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js index cdfaa96339..3c79d81fe6 100644 --- a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js +++ b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js @@ -63,9 +63,12 @@ define(function(require) { } return [ - '', + '', element.ID, element.UNAME, element.GNAME, diff --git a/src/sunstone/public/app/utils/tab-datatable.js b/src/sunstone/public/app/utils/tab-datatable.js index c22d43d4d0..b2319dab59 100644 --- a/src/sunstone/public/app/utils/tab-datatable.js +++ b/src/sunstone/public/app/utils/tab-datatable.js @@ -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'); };