1
0
Fork 0

Add confirmation

This commit is contained in:
Alex Kotov 2020-04-10 10:13:07 +05:00
parent 9e28dae0a8
commit ec1ac0aa76
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 15 additions and 0 deletions

View file

@ -1,6 +1,12 @@
# frozen_string_literal: true
module ContactsHelper
def contact_public_switch_confirmation(contact)
return if contact.show_in_public?
translate :contact_public_switch_confirmation, value: contact.value
end
def contact_destroy_confirmation(contact)
value = "#{Contact.model_name.human(count: 1)} \"#{contact.value}\""

View file

@ -21,6 +21,7 @@
<% contacts.each do |contact| %>
<tr>
<td><%= contact.contact_network.name %></td>
<td>
<% if contact.link.nil? %>
<%= truncate contact.value %>
@ -29,6 +30,7 @@
<i class="fas fa-external-link-alt fa-xs text-muted"></i>
<% end %>
</td>
<td>
<% if policy([
:settings,
@ -42,6 +44,7 @@
<% end %>
<% end %>
</td>
<td>
<% if policy([
:settings,
@ -50,11 +53,13 @@
<%= link_to(
settings_contact_public_switch_path(contact),
method: :post,
data: { confirm: contact_public_switch_confirmation(contact) },
) do %>
<%= bool_badge contact.show_in_public %>
<% end %>
<% end %>
</td>
<td>
<% if policy([:settings, contact]).destroy? %>
<%= link_to(

View file

@ -15,3 +15,5 @@ en:
new_sign_in: New sign in to your account
sidekiq: Sidekiq
since: since
contact_public_switch_confirmation: >
Do you really want to make contact "%{value}" public?

View file

@ -15,3 +15,5 @@ ru:
new_sign_in: Произведён вход в ваш аккаунт
sidekiq: Sidekiq
since: с
contact_public_switch_confirmation: >
Вы действительно хотите сделать контакт "%{value}" публичным?