Skip to content

Commit 2737939

Browse files
authored
Add modal template and tests (#151)
1 parent 739f5b7 commit 2737939

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Next Release
44

55
* Added support for [Switches](https://getbootstrap.com/docs/5.2/forms/checks-radios/#switches). (#162)
6+
* Added modal template
67

78
## 2023.10 (2023-10-2023)
89
* Added Django 5.0 and 4.2 support
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div id="{{ modal.css_id }}" class="modal fade {{ modal.css_class }}" {{ modal.flat_attrs }}>
2+
<div class="modal-dialog" role="document">
3+
<div class="modal-content">
4+
<div class="modal-header">
5+
<h5 class="modal-title {{ modal.title_class }}" id="{{ modal.title_id }}-label">{{ modal.title }}</h5>
6+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
7+
</div>
8+
<div class="modal-body">
9+
{{ fields }}
10+
</div>
11+
</div>
12+
</div>
13+
</div>

tests/results/modal.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div aria-labelledby="modal_title_id-label" class="fade modal modal-class-ex" id="modal-id-ex" role="dialog"
2+
tabindex="-1">
3+
<div class="modal-dialog" role="document">
4+
<div class="modal-content">
5+
<div class="modal-header">
6+
<h5 class="modal-title" id="modal_title_id-label">
7+
This is my modal
8+
</h5>
9+
<button aria-label="Close" class="btn-close" data-bs-dismiss="modal" type="button"></button>
10+
</div>
11+
<div class="modal-body">
12+
</div>
13+
</div>
14+
</div>
15+
</div>

tests/test_layout_objects.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
InlineCheckboxes,
1212
InlineField,
1313
InlineRadios,
14+
Modal,
1415
PrependedAppendedText,
1516
PrependedText,
1617
StrictButton,
@@ -621,3 +622,17 @@ def test_switch_horizontal(self):
621622
form.helper.form_class = "form-horizontal"
622623
form.helper.layout = Layout(Switch("is_company"), "first_name")
623624
assert parse_form(form) == parse_expected("test_switch_horizontal.html")
625+
626+
def test_modal(self):
627+
test_form = SampleForm()
628+
test_form.helper = FormHelper()
629+
test_form.helper.form_tag = False
630+
test_form.helper.layout = Layout(
631+
Modal(
632+
'field1',
633+
css_id="modal-id-ex",
634+
css_class="modal-class-ex",
635+
title="This is my modal",
636+
)
637+
)
638+
assert parse_form(test_form) == parse_expected("modal.html")

0 commit comments

Comments
 (0)