From 9466dc4e07e2bb448886fa29d375f445a03064f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 6 Apr 2025 16:12:18 -0300 Subject: [PATCH] Replace central column jQuery UI's 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 --- resources/js/src/modules/functions.ts | 74 ++++++++++++++------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/resources/js/src/modules/functions.ts b/resources/js/src/modules/functions.ts index 7baf470f27..79b62213a2 100644 --- a/resources/js/src/modules/functions.ts +++ b/resources/js/src/modules/functions.ts @@ -2484,42 +2484,44 @@ export function onloadEnumSetEditor (): void { searchIn = ''; } - var seeMore = ''; + let seeMore = ''; if (listSize > maxRows) { - seeMore = ''; + seeMore = ''; } - var centralColumnsDialog = '
' + - '
' + - searchIn + - '' + fields + '
' + - '
' + - seeMore + - '
'; + let centralColumnsModal = document.getElementById('centralColumnsModal'); + if (centralColumnsModal === null) { + const centralColumnsModalHtml = '\n'; - var width = parseInt( - ((parseInt($('html').css('font-size'), 10) / 13) * 500).toString(), - 10 - ); - if (! width) { - width = 500; + document.body.insertAdjacentHTML('beforeend', centralColumnsModalHtml); + centralColumnsModal = document.getElementById('centralColumnsModal'); } - var buttonOptions = {}; - var $centralColumnsDialog = $(centralColumnsDialog).dialog({ - classes: { - 'ui-dialog-titlebar-close': 'btn-close' - }, - minWidth: width, - maxHeight: 450, - modal: true, - title: window.Messages.pickColumnTitle, - buttons: buttonOptions, - open: function () { + const modal = window.bootstrap.Modal.getOrCreateInstance(centralColumnsModal); + + centralColumnsModal.addEventListener( + 'shown.bs.modal', + function () { $('#col_list').on('click', '.pick', function () { - $centralColumnsDialog.remove(); + modal.hide(); }); $('.filter_rows').on('keyup', function () { @@ -2560,19 +2562,21 @@ export function onloadEnumSetEditor (): void { $('#seeMore').hide(); } - return false; + modal.handleUpdate(); }); + } + ); - $(this).closest('.ui-dialog').find('.ui-dialog-buttonpane button').first().trigger('focus'); - }, - close: function () { + centralColumnsModal.addEventListener( + 'hidden.bs.modal', + function () { $('#col_list').off('click', '.pick'); $('.filter_rows').off('keyup'); $(this).remove(); } - }); + ); - return false; + modal.show(); }); // When "add a new value" is clicked, append an empty text field