@@ -16,7 +14,10 @@
<%= link_to edit_admin_tenant_box_path(@box.tenant, @box), data: { turbo_frame: :modal } do %>
<%= render Common::EditButtonComponent.new %>
<% end %>
- <%= button_to admin_tenant_box_path(@box.tenant, @box), method: :delete do %>
+ <%= button_to admin_tenant_box_path(@box.tenant, @box),
+ method: :delete,
+ disabled: @box == Current.box,
+ data: { turbo_confirm: "Naozaj odstrániť schránku #{@box.name} ?"} do %>
<%= render Common::DeleteButtonComponent.new %>
<% end %>
diff --git a/app/components/common/box_label_component.html.erb b/app/components/common/box_label_component.html.erb
new file mode 100644
index 000000000..e95421051
--- /dev/null
+++ b/app/components/common/box_label_component.html.erb
@@ -0,0 +1,33 @@
+<%# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %>
+<%# If color values are changed, adjust the color list below !!!!!!!!! %>
+<%# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %>
+
+
<%= @box.short_name || @box.name[0] %>
+
+<%# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %>
+<%# Necessary to generate proper CSS for dynamically generated colors %>
+<%# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %>
+<%# !!!!!! Change values here, if values in template change !!!!!! %>
+<%# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %>
+<%# class="bg-slate-100 border border-slate-400 text-slate-600" %>
+<%# class="bg-gray-100 border border-gray-400 text-gray-600" %>
+<%# class="bg-zinc-100 border border-zinc-400 text-zinc-600" %>
+<%# class="bg-neutral-100 border border-neutral-400 text-neutral-600" %>
+<%# class="bg-stone-100 border border-stone-400 text-stone-600" %>
+<%# class="bg-red-100 border border-red-400 text-red-600" %>
+<%# class="bg-orange-100 border border-orange-400 text-orange-600" %>
+<%# class="bg-amber-100 border border-amber-400 text-amber-600" %>
+<%# class="bg-yellow-100 border border-yellow-400 text-yellow-600" %>
+<%# class="bg-lime-100 border border-lime-400 text-lime-600" %>
+<%# class="bg-green-100 border border-green-400 text-green-600" %>
+<%# class="bg-emerald-100 border border-emerald-400 text-emerald-600" %>
+<%# class="bg-teal-100 border border-teal-400 text-teal-600" %>
+<%# class="bg-cyan-100 border border-cyan-400 text-cyan-600" %>
+<%# class="bg-sky-100 border border-sky-400 text-sky-600" %>
+<%# class="bg-blue-100 border border-blue-400 text-blue-600" %>
+<%# class="bg-indigo-100 border border-indigo-400 text-indigo-600" %>
+<%# class="bg-violet-100 border border-violet-400 text-violet-600" %>
+<%# class="bg-purple-100 border border-purple-400 text-purple-600" %>
+<%# class="bg-fuchsia-100 border border-fuchsia-400 text-fuchsia-600" %>
+<%# class="bg-pink-100 border border-pink-400 text-pink-600" %>
+<%# class="bg-rose-100 border border-rose-400 text-rose-600" %>
diff --git a/app/components/common/box_label_component.rb b/app/components/common/box_label_component.rb
new file mode 100644
index 000000000..391984fa1
--- /dev/null
+++ b/app/components/common/box_label_component.rb
@@ -0,0 +1,7 @@
+module Common
+ class BoxLabelComponent < ViewComponent::Base
+ def initialize(box)
+ @box = box
+ end
+ end
+end
diff --git a/app/components/layout/box_list_component.html.erb b/app/components/layout/box_list_component.html.erb
new file mode 100644
index 000000000..a0e60abf5
--- /dev/null
+++ b/app/components/layout/box_list_component.html.erb
@@ -0,0 +1,15 @@
+<%= tag.turbo_frame id:'box-list', class:"flex-col self-stretch" do %>
+ <% @boxes.each do |box| %>
+ <%= link_to select_box_path(box), class:"flex justify-between items-center self-stretch flex-grow-0 flex-shrink-0 px-4 py-2", data: { turbo_frame: "_top" } do %>
+
+
+ <%= render Common::BoxLabelComponent.new(box) %>
+
+
<%= box.name %>
+
+
+
<%= box.messages.where(read: false).size %>
+
+ <% end %>
+ <% end %>
+<% end %>
diff --git a/app/components/layout/box_list_component.rb b/app/components/layout/box_list_component.rb
new file mode 100644
index 000000000..588d2fcff
--- /dev/null
+++ b/app/components/layout/box_list_component.rb
@@ -0,0 +1,5 @@
+class Layout::BoxListComponent < ViewComponent::Base
+ def initialize(boxes)
+ @boxes = boxes
+ end
+end
\ No newline at end of file
diff --git a/app/components/layout/box_selector_component.html.erb b/app/components/layout/box_selector_component.html.erb
new file mode 100644
index 000000000..aab74e635
--- /dev/null
+++ b/app/components/layout/box_selector_component.html.erb
@@ -0,0 +1,29 @@
+
+
+
+ <%= render Layout::BoxSelectorPopupComponent.new %>
+
+
diff --git a/app/components/layout/box_selector_component.rb b/app/components/layout/box_selector_component.rb
new file mode 100644
index 000000000..cf9dc24a3
--- /dev/null
+++ b/app/components/layout/box_selector_component.rb
@@ -0,0 +1,2 @@
+class Layout::BoxSelectorComponent < ViewComponent::Base
+end
diff --git a/app/components/layout/box_selector_popup_component.html.erb b/app/components/layout/box_selector_popup_component.html.erb
new file mode 100644
index 000000000..94513ca25
--- /dev/null
+++ b/app/components/layout/box_selector_popup_component.html.erb
@@ -0,0 +1,28 @@
+
+ <%= link_to select_all_boxes_path, class:"flex justify-between items-center self-stretch flex-grow-0 flex-shrink-0 px-4 py-2" do %>
+
+
+
<%= @all_unread_messages&.count %>
+
+ <% end %>
+
+
+
+
+
+ <%= form_with url: search_boxes_path, class:"flex justify-start items-center self-stretch flex-grow-0 flex-shrink-0 gap-2 p-4 border-t-0 border-r-0 border-b border-l-0 border-gray-200" do |form| %>
+
+
+ <%= render Icons::SearchComponent.new %>
+
+ <%= tag.turbo_frame id:'box-search-results' %>
+ <%= form.search_field :name_search, value: params[:name_search], placeholder: "Vyhľadaj schránku",
+ oninput: "this.form.requestSubmit()",
+ onreset: "this.form.requestSubmit()",
+ class: "block w-full flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6" %>
+
+ <% end %>
+ <%= render Layout::BoxListComponent.new(@boxes) %>
+
diff --git a/app/components/layout/box_selector_popup_component.rb b/app/components/layout/box_selector_popup_component.rb
new file mode 100644
index 000000000..0d25ba36b
--- /dev/null
+++ b/app/components/layout/box_selector_popup_component.rb
@@ -0,0 +1,6 @@
+class Layout::BoxSelectorPopupComponent < ViewComponent::Base
+ def initialize
+ @boxes = Current.tenant.boxes.where.not(boxes: { id: nil }) || []
+ @all_unread_messages = Pundit.policy_scope(Current.user, Message).where(read:false) if Current.user
+ end
+end
\ No newline at end of file
diff --git a/app/components/message_threads_table_row_component.html.erb b/app/components/message_threads_table_row_component.html.erb
index 48c33b3fd..9388cd249 100644
--- a/app/components/message_threads_table_row_component.html.erb
+++ b/app/components/message_threads_table_row_component.html.erb
@@ -2,31 +2,29 @@
<%= check_box_tag('message_thread_ids[]', @message_thread.id) %>
>
-
-
+
+ <%= render Common::BoxLabelComponent.new(@message_thread.box) %>
-
- <%= link_to @message_thread, class:"flex justify-stretch overflow-clip items-center grow gap-2" do %>
-
-
"><%= @message_thread.title %>
-
<%= @message_thread.with_whom %>
-
- <% @message_thread.tags.each do |tag| %>
- <% if tag.visible %>
-
+ <%= link_to @message_thread, class:"flex justify-stretch overflow-clip items-center grow gap-2" do %>
+
+
"><%= @message_thread.title %>
+
<%= @message_thread.with_whom %>
+
+
+ <% @message_thread.tags.each do |tag| %>
+ <% if tag.visible %>
+
+ <% end %>
<% end %>
- <% end %>
-
-
-
<%= l @message_thread.last_message_delivered_at, :format => :long %>
-
-
-
-
- <% end %>
-
+
+
+
<%= l @message_thread.last_message_delivered_at, :format => :long %>
+
+
+
+
+ <% end %>
+
diff --git a/app/components/t_w/top_navigation_component.html.erb b/app/components/t_w/top_navigation_component.html.erb
index dff3636b2..cbd210e5d 100644
--- a/app/components/t_w/top_navigation_component.html.erb
+++ b/app/components/t_w/top_navigation_component.html.erb
@@ -1,12 +1,5 @@
-
-
-
-
-
-
Všetky schránky
-
-
+ <%= render Layout::BoxSelectorComponent.new %>
@@ -28,7 +21,6 @@
<% end %>
<%= f.search_field :q, value: params[:q], placeholder: 'Vyhľadaj správu', class: 'pl-10 text-base text-left text-gray-900 placeholder-gray-400', style: 'width: 100%' %>
<% end %>
-