Skip to content

Commit ee57160

Browse files
Replace Page settings dialog with modal (#17127)
* Replace Page settings dialog with modal Signed-off-by: Saksham Gupta <shucontech@gmail.com> Fix max-width class Signed-off-by: Saksham Gupta <shucontech@gmail.com> * Fix failing tests Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev> Co-authored-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 4a606ee commit ee57160

4 files changed

Lines changed: 34 additions & 24 deletions

File tree

js/src/page_settings.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,21 @@
88
*/
99

1010
function showSettings (selector) {
11-
var buttons = {};
12-
buttons[Messages.strApply] = function () {
11+
// Keeping a clone to restore in case the user cancels the operation
12+
var $clone = $(selector + ' .page_settings').clone(true);
13+
14+
$('#pageSettingsModalApplyButton').on('click', function () {
1315
$('.config-form').trigger('submit');
14-
};
16+
});
1517

16-
buttons[Messages.strCancel] = function () {
17-
$(this).dialog('close');
18-
};
18+
$('#pageSettingsModalCloseButton,#pageSettingsModalCancelButton').on('click', function () {
19+
$(selector + ' .page_settings').replaceWith($clone);
20+
$('#pageSettingsModal').modal('hide');
21+
});
1922

20-
// Keeping a clone to restore in case the user cancels the operation
21-
var $clone = $(selector + ' .page_settings').clone(true);
22-
$(selector)
23-
.dialog({
24-
title: Messages.strPageSettings,
25-
width: 700,
26-
minHeight: 250,
27-
modal: true,
28-
open: function () {
29-
$(this).dialog('option', 'maxHeight', $(window).height() - $(this).offset().top);
30-
},
31-
close: function () {
32-
$(selector + ' .page_settings').replaceWith($clone);
33-
},
34-
buttons: buttons
35-
});
23+
$('#pageSettingsModal').modal('show');
24+
$('#pageSettingsModal').find('.modal-body').first().html($(selector));
25+
$(selector).css('display', 'block');
3626
}
3727

3828
function showPageSettings () {

templates/footer.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{ include('modals/function_confirm.twig') }}
22
{{ include('modals/add_index.twig') }}
3+
{{ include('modals/page_settings.twig') }}
34
{% if not is_ajax %}
45
</div>
56
{% endif %}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="modal fade" id="pageSettingsModal" tabindex="-1" aria-labelledby="pageSettingsModalLabel" aria-hidden="true">
2+
<div class="modal-dialog modal-lg" id="pageSettingsModalDialog">
3+
<div class="modal-content">
4+
<div class="modal-header">
5+
<h5 class="modal-title" id="pageSettingsModalLabel">{% trans 'Page-related settings' %}</h5>
6+
<button type="button" class="btn-close" id="pageSettingsModalCloseButton" aria-label="{% trans 'Close' %}"></button>
7+
</div>
8+
<div class="modal-body"></div>
9+
<div class="modal-footer">
10+
<button type="button" class="btn btn-secondary" id="pageSettingsModalApplyButton">{% trans 'Apply' %}</button>
11+
<button type="button" class="btn btn-secondary" id="pageSettingsModalCancelButton">{% trans 'Cancel' %}</button>
12+
</div>
13+
</div>
14+
</div>
15+
</div>

test/classes/FooterTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ public function testAjax(): void
126126
$footer->setAjax(true);
127127
$template = new Template();
128128
$this->assertEquals(
129-
$template->render('modals/function_confirm') . "\n" . $template->render('modals/add_index') . "\n",
129+
$template->render('modals/function_confirm') . "\n"
130+
. $template->render('modals/add_index') . "\n"
131+
. $template->render('modals/page_settings') . "\n",
130132
$footer->getDisplay()
131133
);
132134
}
@@ -167,7 +169,9 @@ public function testMinimal(): void
167169
$template = new Template();
168170
$this->assertEquals(
169171
$template->render('modals/function_confirm') . "\n"
170-
. $template->render('modals/add_index') . "\n </div>\n </body>\n</html>\n",
172+
. $template->render('modals/add_index') . "\n"
173+
. $template->render('modals/page_settings')
174+
. "\n </div>\n </body>\n</html>\n",
171175
$footer->getDisplay()
172176
);
173177
}

0 commit comments

Comments
 (0)