From fb7877061ee860c519128f7ce9ad5f2c3fc46732 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 19 Oct 2022 16:26:17 +0200 Subject: [PATCH] Fix #17812 - Add missing styles on old confirm modal go/cancel buttons everywhere Fixes: #17812 Signed-off-by: William Desportes --- js/src/database/events.js | 38 ++++++++++++++++++--------- js/src/database/routines.js | 51 +++++++++++++++++++++++++------------ js/src/database/triggers.js | 32 +++++++++++++++-------- js/src/functions.js | 18 ++++++++++--- 4 files changed, 96 insertions(+), 43 deletions(-) diff --git a/js/src/database/events.js b/js/src/database/events.js index e71dfb61ce..3256af1ba5 100644 --- a/js/src/database/events.js +++ b/js/src/database/events.js @@ -17,11 +17,6 @@ const DatabaseEvents = { * @var syntaxHiglighter Reference to the codemirror editor */ syntaxHiglighter: null, - /** - * @var buttonOptions Object containing options for - * the jQueryUI dialog buttons - */ - buttonOptions: {}, /** * Validate editor form fields. * @@ -100,12 +95,17 @@ const DatabaseEvents = { if (data.success === true) { Functions.ajaxRemoveMessage($msg); /** - * @var button_options Object containing options + * @var buttonOptions Object containing options * for jQueryUI dialog buttons */ - var buttonOptions = {}; - buttonOptions[Messages.strClose] = function () { - $(this).dialog('close').remove(); + var buttonOptions = { + [Messages.strClose]: { + text: Messages.strClose, + class: 'btn btn-primary', + click: function () { + $(this).dialog('close').remove(); + }, + }, }; /** * Display the dialog to the user @@ -154,9 +154,23 @@ const DatabaseEvents = { if (data.success === true) { // We have successfully fetched the editor form Functions.ajaxRemoveMessage($msg); + /** + * @var buttonOptions Object containing options + * for jQueryUI dialog buttons + */ + var buttonOptions = { + [Messages.strGo]: { + text: Messages.strGo, + class: 'btn btn-primary', + }, + [Messages.strClose]: { + text: Messages.strClose, + class: 'btn btn-secondary', + }, + }; // Now define the function that is called when // the user presses the "Go" button - that.buttonOptions[Messages.strGo] = function () { + buttonOptions[Messages.strGo].click = function () { // Move the data from the codemirror editor back to the // textarea, where it can be used in the form submission. if (typeof CodeMirror !== 'undefined') { @@ -271,7 +285,7 @@ const DatabaseEvents = { }); // end $.post() } // end "if (that.validate())" }; // end of function that handles the submission of the Editor - that.buttonOptions[Messages.strClose] = function () { + buttonOptions[Messages.strClose].click = function () { $(this).dialog('close'); }; /** @@ -283,7 +297,7 @@ const DatabaseEvents = { }, width: 700, minWidth: 500, - buttons: that.buttonOptions, + buttons: buttonOptions, // Issue #15810 - use button titles for modals (eg: new procedure) // Respect the order: title on href tag, href content, title sent in response title: $this.attr('title') || $this.text() || $(data.title).text(), diff --git a/js/src/database/routines.js b/js/src/database/routines.js index 1ffcd4d3c8..826a826c75 100644 --- a/js/src/database/routines.js +++ b/js/src/database/routines.js @@ -27,11 +27,6 @@ const DatabaseRoutines = { * @var syntaxHiglighter Reference to the codemirror editor */ syntaxHiglighter: null, - /** - * @var buttonOptions Object containing options for - * the jQueryUI dialog buttons - */ - buttonOptions: {}, /** * Validate editor form fields. * @@ -115,12 +110,17 @@ const DatabaseRoutines = { if (data.success === true) { Functions.ajaxRemoveMessage($msg); /** - * @var button_options Object containing options + * @var buttonOptions Object containing options * for jQueryUI dialog buttons */ - var buttonOptions = {}; - buttonOptions[Messages.strClose] = function () { - $(this).dialog('close').remove(); + var buttonOptions = { + [Messages.strClose]: { + text: Messages.strClose, + class: 'btn btn-primary', + click: function () { + $(this).dialog('close').remove(); + } + }, }; /** * Display the dialog to the user @@ -167,11 +167,21 @@ const DatabaseRoutines = { var $msg = Functions.ajaxShowMessage(); $.get($this.attr('href'), { 'ajax_request': true }, function (data) { if (data.success === true) { + var buttonOptions = { + [Messages.strGo]: { + text: Messages.strGo, + class: 'btn btn-primary', + }, + [Messages.strClose]: { + text: Messages.strClose, + class: 'btn btn-secondary', + }, + }; // We have successfully fetched the editor form Functions.ajaxRemoveMessage($msg); // Now define the function that is called when // the user presses the "Go" button - that.buttonOptions[Messages.strGo] = function () { + buttonOptions[Messages.strGo].click = function () { // Move the data from the codemirror editor back to the // textarea, where it can be used in the form submission. if (typeof CodeMirror !== 'undefined') { @@ -288,7 +298,7 @@ const DatabaseRoutines = { }); // end $.post() } // end "if (that.validate())" }; // end of function that handles the submission of the Editor - that.buttonOptions[Messages.strClose] = function () { + buttonOptions[Messages.strClose].click = function () { $(this).dialog('close'); }; /** @@ -301,7 +311,7 @@ const DatabaseRoutines = { height: 400, width: 700, minWidth: 500, - buttons: that.buttonOptions, + buttons: buttonOptions, // Issue #15810 - use button titles for modals (eg: new procedure) // Respect the order: title on href tag, href content, title sent in response title: $this.attr('title') || $this.text() || $(data.title).text(), @@ -749,7 +759,6 @@ const DatabaseRoutines = { } }, executeDialog: function ($this) { - var that = this; /** * @var msg jQuery object containing the reference to * the AJAX message shown to the user @@ -763,9 +772,19 @@ const DatabaseRoutines = { // to get the input parameters for routine, otherwise // we just show the results of the query if (data.dialog) { + var buttonOptions = { + [Messages.strGo]: { + text: Messages.strGo, + class: 'btn btn-primary', + }, + [Messages.strClose]: { + text: Messages.strClose, + class: 'btn btn-secondary', + }, + }; // Define the function that is called when // the user presses the "Go" button - that.buttonOptions[Messages.strGo] = function () { + buttonOptions[Messages.strGo].click = function () { /** * @var data Form data to be sent in the AJAX request */ @@ -784,7 +803,7 @@ const DatabaseRoutines = { } }); }; - that.buttonOptions[Messages.strClose] = function () { + buttonOptions[Messages.strClose].click = function () { $(this).dialog('close'); }; /** @@ -795,7 +814,7 @@ const DatabaseRoutines = { 'ui-dialog-titlebar-close': 'btn-close' }, width: 650, - buttons: that.buttonOptions, + buttons: buttonOptions, title: data.title, modal: true, close: function () { diff --git a/js/src/database/triggers.js b/js/src/database/triggers.js index daca171288..3421bfebcc 100644 --- a/js/src/database/triggers.js +++ b/js/src/database/triggers.js @@ -16,11 +16,6 @@ const DatabaseTriggers = { * @var syntaxHiglighter Reference to the codemirror editor */ syntaxHiglighter: null, - /** - * @var buttonOptions Object containing options for - * the jQueryUI dialog buttons - */ - buttonOptions: {}, /** * Validate editor form fields. * @@ -109,11 +104,16 @@ const DatabaseTriggers = { if (data.success === true) { Functions.ajaxRemoveMessage($msg); /** - * @var button_options Object containing options + * @var buttonOptions Object containing options * for jQueryUI dialog buttons */ - var buttonOptions = {}; - buttonOptions[Messages.strClose] = function () { + var buttonOptions = { + [Messages.strClose]: { + text: Messages.strClose, + class: 'btn btn-primary', + }, + }; + buttonOptions[Messages.strClose].click = function () { $(this).dialog('close').remove(); }; /** @@ -161,11 +161,21 @@ const DatabaseTriggers = { var $msg = Functions.ajaxShowMessage(); $.get($this.attr('href'), { 'ajax_request': true }, function (data) { if (data.success === true) { + var buttonOptions = { + [Messages.strGo]: { + text: Messages.strGo, + class: 'btn btn-primary', + }, + [Messages.strClose]: { + text: Messages.strClose, + class: 'btn btn-secondary', + }, + }; // We have successfully fetched the editor form Functions.ajaxRemoveMessage($msg); // Now define the function that is called when // the user presses the "Go" button - that.buttonOptions[Messages.strGo] = function () { + buttonOptions[Messages.strGo].click = function () { // Move the data from the codemirror editor back to the // textarea, where it can be used in the form submission. if (typeof CodeMirror !== 'undefined') { @@ -280,7 +290,7 @@ const DatabaseTriggers = { }); // end $.post() } // end "if (that.validate())" }; // end of function that handles the submission of the Editor - that.buttonOptions[Messages.strClose] = function () { + buttonOptions[Messages.strClose].click = function () { $(this).dialog('close'); }; /** @@ -292,7 +302,7 @@ const DatabaseTriggers = { }, width: 700, minWidth: 500, - buttons: that.buttonOptions, + buttons: buttonOptions, // Issue #15810 - use button titles for modals (eg: new procedure) // Respect the order: title on href tag, href content, title sent in response title: $this.attr('title') || $this.text() || $(data.title).text(), diff --git a/js/src/functions.js b/js/src/functions.js index 5e25cdbaf0..58f98397e2 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -2793,10 +2793,20 @@ AJAX.registerOnload('functions.js', function () { var $msgbox = Functions.ajaxShowMessage(); /** - * @var button_options Object containing options to be passed to jQueryUI's dialog + * @var buttonOptions Object containing options to be passed to jQueryUI's dialog */ - var buttonOptions = {}; - buttonOptions[Messages.strGo] = function () { + var buttonOptions = { + [Messages.strGo]: { + text: Messages.strGo, + 'class': 'btn btn-primary', + }, + [Messages.strCancel]: { + text: Messages.strCancel, + 'class': 'btn btn-secondary', + }, + }; + + buttonOptions[Messages.strGo].click = function () { event.preventDefault(); /** @@ -2833,7 +2843,7 @@ AJAX.registerOnload('functions.js', function () { }); // end $.post() }; - buttonOptions[Messages.strCancel] = function () { + buttonOptions[Messages.strCancel].click = function () { $(this).dialog('close'); }; $.get($(this).attr('href'), { 'ajax_request': true }, function (data) {