Skip to content

Commit

Permalink
Merge pull request #474 from slovensko-digital/GO-127/show_sender_by_…
Browse files Browse the repository at this point in the history
…fs_threads

GO-127 Show sender name by FS MessageThreads
  • Loading branch information
luciajanikova authored Sep 26, 2024
2 parents 22343bd + f271990 commit abfe888
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/components/message_threads_table_row_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
<div class="flex flex-wrap gap-2 text-gray-500 text-xs md:text-base items-center">
<% if @message_thread.sender || @message_thread.recipient %>
<span class="text-left font-normal">
<% if @message_thread.is_outbox && @message_thread.recipient.present? %>
<% if MessageThreadHelper.show_recipient?(@message_thread) %>
Komu: <%= @message_thread.recipient %>
<% elsif !@message_thread.is_outbox && @message_thread.sender.present? %>
<% elsif MessageThreadHelper.show_sender?(@message_thread) %>
Od: <%= @message_thread.sender %>
<% end %>
</span>
Expand Down
9 changes: 9 additions & 0 deletions app/helpers/message_thread_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module MessageThreadHelper
def self.show_recipient?(message_thread)
!message_thread.box.single_recipient? && message_thread.is_outbox && message_thread.recipient.present?
end

def self.show_sender?(message_thread)
message_thread.box.single_recipient? || (!message_thread.is_outbox && message_thread.sender.present?)
end
end
4 changes: 4 additions & 0 deletions app/models/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def self.sync_all
find_each(&:sync)
end

def single_recipient?
raise NotImplementedError
end

private

def validate_box_with_api_connection
Expand Down
4 changes: 4 additions & 0 deletions app/models/fs/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def self.create_with_api_connection!(params)
def sync
end

def single_recipient?
true
end

store_accessor :settings, :dic, prefix: true
store_accessor :settings, :subject_id, prefix: true
end
4 changes: 4 additions & 0 deletions app/models/upvs/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def sync
Govbox::SyncBoxJob.perform_later(self)
end

def single_recipient?
false
end

private

def validate_settings_obo
Expand Down
4 changes: 2 additions & 2 deletions test/system/fs/message_drafts_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Fs::MessageDraftsTest < ApplicationSystemTestCase

within_thread_in_listing(message1.thread) do
assert_text "Podanie pre FS (Správa daní) - platné od 1.4.2024"
assert_text "Finančná správa"
assert_text "Od: #{message1.thread.box.name}"

within_tags do
assert_text "Rozpracované"
Expand All @@ -79,7 +79,7 @@ class Fs::MessageDraftsTest < ApplicationSystemTestCase

within_thread_in_listing(message2.thread) do
assert_text "Vyhlásenie o poukázaní sumy do výšky 2% (3%) zaplatenej dane za zdaňovacie obdobie 2021"
assert_text "Finančná správa"
assert_text "Od: #{message2.thread.box.name}"

within_tags do
assert_text "Rozpracované"
Expand Down

0 comments on commit abfe888

Please sign in to comment.