Add a more detailed confirmation message

The message "Are you sure?" is usually followed by blindly clicking
"Yes" without really thinking about what one is doing. So we're
including a bit more information about what's about to happen. That way
it's more likely users will notice it when they accidentally click the
wrong button.

Ideally we would offer the option to undo every common action and then
we wouldn't have to ask for confirmation. But since that isn't the case,
for now we're adding a better confirmation message.

Note we're removing the `resource_name` parameter from the translation
to confirm the action of deleting a record. The reason is, in many
languages it only makes sense to add the model name when it's got an
associated article, and, unlike in English (where "the" is used for
every word), that article is different depending on the noun it's
related to. So we'd have to provide a translation like "name with
article, when singular" for every model.

The complexity of these translations could scalate quickly. And, given
the context, IMHO it isn't essential to add the resouce name. When we're
in the proposals index and there's a proposal named "Improve XYZ", and
we click on "Delete" and see a message saying "This action will delete
XYZ", it is implied that XYZ is a proposal.

So instead we're changing the message so it works for every record with
no need of noun-dependent articles.
This commit is contained in:
Javi Martín
2021-08-17 23:16:16 +02:00
parent 2b4b2f3442
commit 6510cb9615
7 changed files with 59 additions and 15 deletions

View File

@@ -39,7 +39,7 @@ describe Admin::TableActionsComponent, controller: Admin::BaseController do
end
it "allows custom URLs" do
render_inline Admin::TableActionsComponent.new(nil, edit_path: "/myedit", destroy_path: "/mydestroy")
render_inline Admin::TableActionsComponent.new(record, edit_path: "/myedit", destroy_path: "/mydestroy")
expect(page).to have_link "Edit", href: "/myedit"
expect(page).to have_link "Delete", href: "/mydestroy"