Skip to content

Commit

Permalink
Use common delete modal also for home highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
svera committed Mar 31, 2024
1 parent 7cbad17 commit 374e050
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/webserver/embedded/js/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// We use several conventions to be able to use the same code to delete different resources.
// The link that initiates the action needs to have an attribute called data-id which must contain an unique identifier
// for the resource to delete.
// This identifier well be sent to the backend controller specified in the form's action attribute
// under the name "id".
// This code is designed to be used alongside partials/delete-modal.html

const deleteModal = document.getElementById('delete-modal');
Expand Down
2 changes: 1 addition & 1 deletion internal/webserver/embedded/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2>{{t .Lang "Your highlights" }}</h2>
</div>
{{end}}
</div>
{{template "partials/delete-modal" .}}
{{template "partials/delete-modal" dict "Lang" .Lang "Action" "/document" "ModalHeader" "Delete document" "ModalBody" "Are you sure you want to delete this document?" "ModalErrorMessage" "There was an error deleting the document"}}

<script type="text/javascript" src="/js/delete.js"></script>
<script type="text/javascript" src="/js/actions.js"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="modal fade" id="delete-modal" tabindex="-1" aria-labelledby="delete-modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="{{.Action}}" data-error-message='{{t .Lang .ModalErrorMessage}}' id="delete-form">
<form action="{{.Action}}" data-error-message='{{t .Lang .ModalErrorMessage}}' id="delete-form">
<div class="modal-header">
<h1 class="modal-title fs-5" id="delete-modal-label">{{t .Lang .ModalHeader}}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
Expand Down

0 comments on commit 374e050

Please sign in to comment.