From 54afeca51a27b2e3abfeee19a64c39674849d681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 9 Dec 2020 22:05:52 -0300 Subject: [PATCH 1/4] Replace jQuery UI dialog with Bootstrap's modal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces "make consistent with central list" confirmation dialog written with jQuery UI with Bootstrap's modal component. Signed-off-by: Maurício Meneghini Fauth --- js/src/database/structure.js | 52 +++++-------------- .../JavaScriptMessagesController.php | 5 -- .../database/structure/check_all_tables.twig | 21 ++++++++ 3 files changed, 35 insertions(+), 43 deletions(-) diff --git a/js/src/database/structure.js b/js/src/database/structure.js index 4760bfd909..706aa16ce1 100644 --- a/js/src/database/structure.js +++ b/js/src/database/structure.js @@ -185,36 +185,9 @@ DatabaseStructure.fetchRealRowCount = function ($target) { }; AJAX.registerOnload('database/structure.js', function () { -/** - * function to open the confirmation dialog for making table consistent with central list - * - * @param string msg message text to be displayed to user - * @param function success function to be called on success - * - */ - var jqConfirm = function (msg, success) { - var dialogObj = $('
' + msg + '
'); - $('body').append(dialogObj); - var buttonOptions = {}; - buttonOptions[Messages.strContinue] = function () { - success(); - $(this).dialog('close'); - }; - buttonOptions[Messages.strCancel] = function () { - $(this).dialog('close'); - $('#tablesForm')[0].reset(); - }; - $(dialogObj).dialog({ - resizable: false, - modal: true, - title: Messages.confirmTitle, - buttons: buttonOptions - }); - }; - /** - * Event handler on select of "Make consistent with central list" - */ + * Event handler on select of "Make consistent with central list" + */ $('select[name=submit_mult]').on('change', function (event) { var url = 'index.php?route=/database/structure'; var action = $(this).val(); @@ -222,12 +195,12 @@ AJAX.registerOnload('database/structure.js', function () { if (action === 'make_consistent_with_central_list') { event.preventDefault(); event.stopPropagation(); - jqConfirm( - Messages.makeConsistentMessage, - function () { - var $form = $('#tablesForm'); - var argsep = CommonParams.get('arg_separator'); - var data = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true'; + + $('#makeConsistentWithCentralListModal').modal('show').on('shown.bs.modal', function () { + $('#makeConsistentWithCentralListContinue').on('click', function () { + const $form = $('#tablesForm'); + const argSep = CommonParams.get('arg_separator'); + const data = $form.serialize() + argSep + 'ajax_request=true' + argSep + 'ajax_page_request=true'; Functions.ajaxShowMessage(); AJAX.source = $form; @@ -237,9 +210,12 @@ AJAX.registerOnload('database/structure.js', function () { data, AJAX.responseHandler ); - } - ); - return false; + + $('#makeConsistentWithCentralListModal').modal('hide'); + }); + }); + + return; } if (action === 'copy_tbl' || diff --git a/libraries/classes/Controllers/JavaScriptMessagesController.php b/libraries/classes/Controllers/JavaScriptMessagesController.php index 56944cbd11..d477d2684d 100644 --- a/libraries/classes/Controllers/JavaScriptMessagesController.php +++ b/libraries/classes/Controllers/JavaScriptMessagesController.php @@ -405,11 +405,6 @@ final class JavaScriptMessagesController . 'database %s has columns that are not present in the current table.' ), 'seeMore' => __('See more'), - 'confirmTitle' => __('Are you sure?'), - 'makeConsistentMessage' => __( - 'This action may change some of the columns definition.
Are you sure you ' - . 'want to continue?' - ), 'strContinue' => __('Continue'), /** For normalization */ diff --git a/templates/database/structure/check_all_tables.twig b/templates/database/structure/check_all_tables.twig index 3e9a0996f9..ea4906af01 100644 --- a/templates/database/structure/check_all_tables.twig +++ b/templates/database/structure/check_all_tables.twig @@ -38,3 +38,24 @@ {{ hidden_fields|join('\n')|raw }} + +{% if central_columns_work is defined and central_columns_work %} + +{% endif %} From d570ad5a38378db01c5942ac0dde027fcdb8f8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Thu, 10 Dec 2020 20:19:11 -0300 Subject: [PATCH 2/4] Replace db structure bulk action dialog with a modal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- js/src/database/structure.js | 30 +++++++------------ .../JavaScriptMessagesController.php | 1 - .../database/structure/check_all_tables.twig | 17 +++++++++++ 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/js/src/database/structure.js b/js/src/database/structure.js index 706aa16ce1..a5082c6064 100644 --- a/js/src/database/structure.js +++ b/js/src/database/structure.js @@ -248,25 +248,17 @@ AJAX.registerOnload('database/structure.js', function () { url: url, dataType: 'html', data: formData - - }).done(function (data) { - var dialogObj = $('
' + data + '
'); - $('body').append(dialogObj); - var buttonOptions = {}; - buttonOptions[Messages.strContinue] = function () { - $('#ajax_form').trigger('submit'); - $(this).dialog('close'); - }; - buttonOptions[Messages.strCancel] = function () { - $(this).dialog('close'); - $('#tablesForm')[0].reset(); - }; - $(dialogObj).dialog({ - minWidth: 500, - resizable: false, - modal: true, - title: modalTitle, - buttons: buttonOptions + }).done(function (modalBody) { + const bulkActionModal = $('#bulkActionModal'); + bulkActionModal.on('show.bs.modal', function () { + this.querySelector('.modal-title').innerText = modalTitle; + this.querySelector('.modal-body').innerHTML = modalBody; + }); + bulkActionModal.modal('show').on('shown.bs.modal', function () { + $('#bulkActionContinue').on('click', function () { + $('#ajax_form').trigger('submit'); + $('#bulkActionModal').modal('hide'); + }); }); }); diff --git a/libraries/classes/Controllers/JavaScriptMessagesController.php b/libraries/classes/Controllers/JavaScriptMessagesController.php index d477d2684d..83454b4190 100644 --- a/libraries/classes/Controllers/JavaScriptMessagesController.php +++ b/libraries/classes/Controllers/JavaScriptMessagesController.php @@ -405,7 +405,6 @@ final class JavaScriptMessagesController . 'database %s has columns that are not present in the current table.' ), 'seeMore' => __('See more'), - 'strContinue' => __('Continue'), /** For normalization */ 'strAddPrimaryKey' => __('Add primary key'), diff --git a/templates/database/structure/check_all_tables.twig b/templates/database/structure/check_all_tables.twig index ea4906af01..48c980bb62 100644 --- a/templates/database/structure/check_all_tables.twig +++ b/templates/database/structure/check_all_tables.twig @@ -39,6 +39,23 @@ {{ hidden_fields|join('\n')|raw }} + + {% if central_columns_work is defined and central_columns_work %}