From e549eb3791ed27db2f87d2a5c38d41bcec01b44e Mon Sep 17 00:00:00 2001
From: luciajanikova <19lucia99@gmail.com>
Date: Thu, 18 Jul 2024 13:33:06 +0200
Subject: [PATCH] Add new method to Message & Update alert wording
---
app/components/message_draft_component.html.erb | 2 +-
app/models/message.rb | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/components/message_draft_component.html.erb b/app/components/message_draft_component.html.erb
index 67b26a1f3..b13ce292c 100644
--- a/app/components/message_draft_component.html.erb
+++ b/app/components/message_draft_component.html.erb
@@ -10,7 +10,7 @@
<% if @message.correctly_created? %>
- <%= form_with(url: submit_message_draft_path(@message), method: :post, data: { turbo_frame: "_top", turbo_confirm: ("Naozaj chcete odoslať správu aj bez vyžiadaných podpisov?" if @message.objects.any?{|message_object| message_object.tags.where(type: SignatureRequestedFromTag.to_s).any?}) }, local: true) do |form| %>
+ <%= form_with(url: submit_message_draft_path(@message), method: :post, data: { turbo_frame: "_top", turbo_confirm: ("Správa ešte nebola podpísaná všetkými podpismi. Naozaj chcete odoslať správu aj bez nich?" if @message.any_objects_with_requested_signature?) }, local: true) do |form| %>
<%= form.submit "Odoslať", class: "flex justify-strech items-start self-stretch flex-grow-0 flex-shrink-0 gap-2 p-6 text-white font-medium rounded-lg text-sm px-3.5 py-2.5 bg-blue-700 hover:bg-blue-800 dark:bg-blue-600 dark:hover:bg-blue-700 focus:ring-4 focus:ring-blue-300 focus:outline-none dark:focus:ring-blue-800" %>
<% end %>
diff --git a/app/models/message.rb b/app/models/message.rb
index c86f7512c..5de1457f4 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -124,6 +124,10 @@ def build_html_visualization
template.transform(form_object.xml_unsigned_content)
end
+ def any_objects_with_requested_signature?
+ objects.any?{|message_object| message_object.tags.where(type: SignatureRequestedFromTag.to_s).any?}
+ end
+
def all_metadata
metadata.merge(template&.metadata || {})
end