From fa814e17b7ca8cd0ba2bd022bb1b4b93f5736aa5 Mon Sep 17 00:00:00 2001 From: Sergio Betanzos Date: Wed, 13 May 2020 11:14:43 +0200 Subject: [PATCH] B #4697: Unselect row when previously selected (#4716) --- .../public/app/utils/tab-datatable.js | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/sunstone/public/app/utils/tab-datatable.js b/src/sunstone/public/app/utils/tab-datatable.js index ced6d7bece..3f0df76871 100644 --- a/src/sunstone/public/app/utils/tab-datatable.js +++ b/src/sunstone/public/app/utils/tab-datatable.js @@ -441,8 +441,7 @@ define(function(require) { if ($(e.target).is('input') || $(e.target).is('select') || $(e.target).is('option')) { return true; } - - if (info_action) { + else if (info_action) { //If ctrl is hold down, make check_box click if (e.ctrlKey || e.metaKey || $(e.target).is('input')) { $('.check_item', this).trigger('click'); @@ -969,27 +968,25 @@ define(function(require) { that.selectOptions.unselect_callback(aData, that.selectOptions); }); } else { - $('#' + that.dataTableId + ' tbody', section).delegate("tr", "click", function(e) { + $('#' + that.dataTableId + ' tbody', section).delegate("tr", "click", function() { that.dataTable.unbind("draw"); + var wasChecked = $("td.markrow", this).hasClass("markrow"); var aData = that.dataTable.fnGetData(this); + var check = aData != undefined && !wasChecked; - $("td.markrow", that.dataTable).removeClass('markrow'); - $('tbody input.check_item', that.dataTable).prop('checked', false); + $("td", that.dataTable).removeClass('markrow'); + $("td", this).toggleClass('markrow', check); + $('tbody input.check_item', that.dataTable).prop('checked', check); - if (aData != undefined){ - $("td", this).addClass('markrow'); - $('input.check_item', this).prop('checked', true); + $('#selected_resource_' + that.dataTableId, section).toggle(check); + $('#select_resource_' + that.dataTableId, section).toggle(!check); - $('#selected_resource_' + that.dataTableId, section).show(); - $('#select_resource_' + that.dataTableId, section).hide(); + $('#selected_resource_id_' + that.dataTableId, section) + .val(function() { return check ? aData[that.selectOptions.id_index] : "" }).trigger("change"); + $('#selected_resource_name_' + that.dataTableId, section) + .text(function() { return check ? aData[that.selectOptions.name_index] : "" }).trigger("change"); - $('#selected_resource_id_' + that.dataTableId, section).val(aData[that.selectOptions.id_index]).trigger("change"); - - $('#selected_resource_name_' + that.dataTableId, section).text(aData[that.selectOptions.name_index]).trigger("change"); - $('#selected_resource_name_' + that.dataTableId, section).show(); - - that.selectOptions.select_callback(aData, that.selectOptions); - } + $('#selected_resource_name_' + that.dataTableId, section).toggle(check); $('#selected_resource_id_' + that.dataTableId, section).removeData("pending_select");