Merge pull request #1948 from jstarner/custom-delete-modals

Replace turbo confirmation dialogs with custom delete modals
This commit is contained in:
Jorge Manrubia
2025-12-07 11:48:58 +01:00
committed by GitHub
4 changed files with 31 additions and 14 deletions
-8
View File
@@ -18,14 +18,6 @@ module CardsHelper
&block
end
def button_to_delete_card(card)
button_to card_path(card),
method: :delete, class: "btn txt-negative borderless txt-small", data: { turbo_frame: "_top", turbo_confirm: "Are you sure you want to permanently delete this card?" } do
concat(icon_tag("trash"))
concat(tag.span("Delete this card"))
end
end
def card_title_tag(card)
title = [
card.title,
+14 -5
View File
@@ -1,7 +1,16 @@
<%= form_with model: board, class: "txt-align-center margin-block-start-auto", method: :delete do |form| %>
<%= form.button class: "btn txt-negative borderless txt-small", data: { turbo_confirm: "Are you sure you want to permanently delete this board and all the cards on it? This can't be undone." } do %>
<div class="txt-align-center margin-block-start-auto" data-controller="dialog" data-dialog-modal-value="true" data-action="keydown.esc->dialog#close:stop">
<button type="button" class="btn txt-negative borderless txt-small" data-action="dialog#open">
<%= icon_tag "trash" %>
<span>Delete this board</span>
<% end %>
<% end %>
</button>
<dialog class="dialog panel fill-white shadow gap flex-column" style="max-width: 40ch" data-dialog-target="dialog">
<h3 class="txt-large txt-bold">Delete this board?</h3>
<p class="txt-medium margin-block-half">Are you sure you want to permanently delete this board and all the cards on it? This can't be undone.</p>
<div class="flex gap-half justify-center margin-block-start">
<button type="button" class="btn" data-action="dialog#close">Cancel</button>
<%= button_to board_path(board), method: :delete, class: "btn txt-negative", data: { turbo_frame: "_top" } do %>
<span>Delete board</span>
<% end %>
</div>
</dialog>
</div>
+16
View File
@@ -0,0 +1,16 @@
<div data-controller="dialog" data-dialog-modal-value="true" data-action="keydown.esc->dialog#close:stop">
<button type="button" class="btn txt-negative borderless txt-small" data-action="dialog#open">
<%= icon_tag "trash" %>
<span>Delete this card</span>
</button>
<dialog class="dialog panel fill-white shadow gap flex-column" style="max-width: 40ch" data-dialog-target="dialog">
<h3 class="txt-large txt-bold">Delete this card?</h3>
<p class="txt-medium margin-block-half">Are you sure you want to permanently delete this card?</p>
<div class="flex gap-half justify-center margin-block-start">
<button type="button" class="btn" data-action="dialog#close">Cancel</button>
<%= button_to card_path(card), method: :delete, class: "btn txt-negative", data: { turbo_frame: "_top" } do %>
<span>Delete card</span>
<% end %>
</div>
</dialog>
</div>
+1 -1
View File
@@ -9,7 +9,7 @@
<% if Current.user.can_administer_card?(card) %>
<footer class="delete-card txt-align-center full-width flex flex-column margin-block-start-double">
<hr class="separator--horizontal full-width margin-block" style="--border-color: var(--color-ink-lighter)">
<%= button_to_delete_card(card) %>
<%= render "cards/delete", card: card %>
</footer>
<% end %>
<% end %>