Skip to content

Commit 9e66d8a

Browse files
Merge pull request #19665 from MauricioFauth/pick-central-column-modal
Replace central column jQuery UI's dialog with a modal
2 parents 46ba2ed + 9466dc4 commit 9e66d8a

1 file changed

Lines changed: 44 additions & 40 deletions

File tree

resources/js/src/modules/functions.ts

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,42 +2484,44 @@ export function onloadEnumSetEditor (): void {
24842484
searchIn = '';
24852485
}
24862486

2487-
var seeMore = '';
2487+
let seeMore = '';
24882488
if (listSize > maxRows) {
2489-
seeMore = '<div class="card-footer">' +
2490-
'<button type="button" class="btn btn-secondary" id="seeMore">' +
2491-
window.Messages.seeMore + '</button></div>';
2492-
}
2493-
2494-
var centralColumnsDialog = '<div><div class="card">' +
2495-
'<div class="card-body">' +
2496-
searchIn +
2497-
'<table id="col_list" class="table table-borderless values">' + fields + '</table>' +
2498-
'</div>' +
2499-
seeMore +
2500-
'</div></div>';
2501-
2502-
var width = parseInt(
2503-
((parseInt($('html').css('font-size'), 10) / 13) * 500).toString(),
2504-
10
2505-
);
2506-
if (! width) {
2507-
width = 500;
2508-
}
2509-
2510-
var buttonOptions = {};
2511-
var $centralColumnsDialog = $(centralColumnsDialog).dialog({
2512-
classes: {
2513-
'ui-dialog-titlebar-close': 'btn-close'
2514-
},
2515-
minWidth: width,
2516-
maxHeight: 450,
2517-
modal: true,
2518-
title: window.Messages.pickColumnTitle,
2519-
buttons: buttonOptions,
2520-
open: function () {
2489+
seeMore = '<button type="button" class="btn btn-secondary" id="seeMore">' +
2490+
window.Messages.seeMore + '</button>';
2491+
}
2492+
2493+
let centralColumnsModal = document.getElementById('centralColumnsModal');
2494+
if (centralColumnsModal === null) {
2495+
const centralColumnsModalHtml = '<div class="modal fade" id="centralColumnsModal" tabindex="-1" aria-labelledby="centralColumnsModalLabel" aria-hidden="true">\n' +
2496+
' <div class="modal-dialog modal-lg">\n' +
2497+
' <div class="modal-content">\n' +
2498+
' <div class="modal-header">\n' +
2499+
' <h1 class="modal-title fs-5" id="centralColumnsModalLabel">' + window.Messages.pickColumnTitle + '</h1>\n' +
2500+
' <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="' + window.Messages.strClose + '"></button>\n' +
2501+
' </div>\n' +
2502+
' <div class="modal-body">\n' +
2503+
searchIn +
2504+
'<table id="col_list" class="table table-borderless values">' + fields + '</table>' +
2505+
' </div>\n' +
2506+
' <div class="modal-footer">\n' +
2507+
seeMore +
2508+
' <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' + window.Messages.strClose + '</button>\n' +
2509+
' </div>\n' +
2510+
' </div>\n' +
2511+
' </div>\n' +
2512+
'</div>\n';
2513+
2514+
document.body.insertAdjacentHTML('beforeend', centralColumnsModalHtml);
2515+
centralColumnsModal = document.getElementById('centralColumnsModal');
2516+
}
2517+
2518+
const modal = window.bootstrap.Modal.getOrCreateInstance(centralColumnsModal);
2519+
2520+
centralColumnsModal.addEventListener(
2521+
'shown.bs.modal',
2522+
function () {
25212523
$('#col_list').on('click', '.pick', function () {
2522-
$centralColumnsDialog.remove();
2524+
modal.hide();
25232525
});
25242526

25252527
$('.filter_rows').on('keyup', function () {
@@ -2560,19 +2562,21 @@ export function onloadEnumSetEditor (): void {
25602562
$('#seeMore').hide();
25612563
}
25622564

2563-
return false;
2565+
modal.handleUpdate();
25642566
});
2567+
}
2568+
);
25652569

2566-
$(this).closest('.ui-dialog').find('.ui-dialog-buttonpane button').first().trigger('focus');
2567-
},
2568-
close: function () {
2570+
centralColumnsModal.addEventListener(
2571+
'hidden.bs.modal',
2572+
function () {
25692573
$('#col_list').off('click', '.pick');
25702574
$('.filter_rows').off('keyup');
25712575
$(this).remove();
25722576
}
2573-
});
2577+
);
25742578

2575-
return false;
2579+
modal.show();
25762580
});
25772581

25782582
// When "add a new value" is clicked, append an empty text field

0 commit comments

Comments
 (0)