-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the profiles delete button a modal
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class ModalForm: | ||
form: int = None | ||
instance_id: int = None | ||
template_name: str = "htmx/_base_form_modal2.html" | ||
|
||
# needed by template | ||
button_class: str = "btn-primary" | ||
cancel_text: str = "Cancel" | ||
submit_text: str = "Ok" | ||
button_title: str | ||
dialog_id: str | ||
endpoint: str | ||
explanation: str | ||
header: str | ||
|
||
def get_endpoint(self): | ||
if self.instance_id: | ||
return self.endpoint.format(self.instance_id) | ||
return self.endpoint | ||
|
||
|
||
class DeleteModalForm(ModalForm): | ||
button_title = "Delete title" | ||
header = "Delete header" | ||
submit_text = "Delete nao" | ||
explanation = "Delete explanation" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<button class="btn {{ form.button_class }}" | ||
onclick="htmx.find('#{{ form.dialog_id }}').showModal()">{{ button_title }}</button> | ||
<dialog id="{{ form.dialog_id }}" class="modal"> | ||
<div class="modal-box card card-compact shadow-xl loading-box"> | ||
<div class="w-full"> | ||
<div class="divider divider-start"> | ||
<h3 class="card-title">{{ form.header }}</h3> | ||
</div> | ||
<form id="{{ form.dialog_id }}-form" | ||
class="card-body" | ||
{% block form_control %} | ||
method="post" | ||
action="{{ endpoint }}" | ||
{% endblock form_control %}> | ||
{% csrf_token %} | ||
<fieldset class="menu menu-vertical gap-4"> | ||
<legend class="antialiased text-base font-bold py-2">{{ form.explanation }}</legend> | ||
{% block dialogform %} | ||
{% endblock dialogform %} | ||
</fieldset> | ||
</form> | ||
<div class="modal-action card-actions"> | ||
<form method="dialog" class="w-full"> | ||
<div class="divider divider-end"> | ||
<button type="submit" | ||
form="{{ form.dialog_id }}-form" | ||
class="btn {{ form.button_class }}"> | ||
<span>{{ form.submit_text }}</span> | ||
</button> | ||
<button class="btn">{{ form.cancel_text }}</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
<div class="htmx-indicator loading loading-spinner text-primary"></div> | ||
</div> | ||
<form method="dialog" class="modal-backdrop"> | ||
<button>close</button> | ||
</form> | ||
</dialog> |
1 change: 1 addition & 0 deletions
1
src/argus/htmx/templates/htmx/notificationprofile/_notificationprofile_buttons.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters