-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from solver-it-sro/GO-223/default_box_selection
single-box-tenants solution for boxselection
- Loading branch information
Showing
16 changed files
with
78 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
<%= 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 %> | ||
<div class="flex justify-start items-center flex-grow-0 flex-shrink-0 relative gap-3"> | ||
<div class="justify-start w-16"> | ||
<%= render Common::BoxLabelComponent.new(box) %> | ||
</div> | ||
<p class="flex-grow-0 flex-shrink-0 text-base font-medium text-left text-gray-900"><%= box.name %></p> | ||
</div> | ||
<div class="flex justify-center items-center flex-grow-0 flex-shrink-0 relative overflow-hidden gap-1.5 px-1.5 py-0.5 rounded-md bg-gray-50 border border-gray-300"> | ||
<p class="flex-grow-0 flex-shrink-0 text-sm text-left text-gray-600"><%= box.messages.where(read: false).size %></p> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<%= 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 %> | ||
<div class="flex justify-start items-center flex-grow-0 flex-shrink-0 relative gap-3"> | ||
<div class="justify-start w-16"> | ||
<%= render Common::BoxLabelComponent.new(@box) %> | ||
</div> | ||
<p class="flex-grow-0 flex-shrink-0 text-base font-medium text-left text-gray-900"><%= @box.name %></p> | ||
</div> | ||
<div class="flex justify-center items-center flex-grow-0 flex-shrink-0 relative overflow-hidden gap-1.5 px-1.5 py-0.5 rounded-md bg-gray-50 border border-gray-300"> | ||
<p class="flex-grow-0 flex-shrink-0 text-sm text-left text-gray-600"><%= @unread_messages %></p> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
class Layout::BoxListComponent < ViewComponent::Base | ||
def initialize(boxes) | ||
@boxes = boxes | ||
end | ||
end | ||
with_collection_parameter :box | ||
def initialize(box:) | ||
@box = box | ||
@unread_messages = Pundit.policy_scope(Current.user, Message).joins(thread: { folder: :box }).where(box: { id: @box.id}, read: false).size | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
class Layout::BoxSelectorComponent < ViewComponent::Base | ||
def initialize(current_tenant_boxes_count) | ||
@disabled = current_tenant_boxes_count == 1 | ||
end | ||
end |
52 changes: 28 additions & 24 deletions
52
app/components/layout/box_selector_popup_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
<div class="flex flex-col justify-start items-start w-[360px] gap-px py-0.5 rounded-lg bg-white border border-gray-300" style="box-shadow: 1px 1px 4px 0 rgba(0,0,0,0.1);"> | ||
<%= 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 %> | ||
<div class="flex justify-center items-center flex-grow-0 flex-shrink-0 relative overflow-hidden gap-[29px]"> | ||
<p class="flex-grow-0 flex-shrink-0 text-base font-medium text-left text-gray-900">Všetky schránky</p> | ||
</div> | ||
<div class="flex justify-center items-center flex-grow-0 flex-shrink-0 relative overflow-hidden gap-1.5 px-1.5 py-0.5 rounded-md bg-gray-50 border border-gray-300"> | ||
<p class="flex-grow-0 flex-shrink-0 text-sm text-left text-gray-600"><%= @all_unread_messages&.count %></p> | ||
</div> | ||
<% end %> | ||
<div class="flex justify-start items-center self-stretch flex-grow-0 flex-shrink-0 relative"> | ||
<svg width="360" height="1" viewBox="0 0 360 1" fill="none" xmlns="http://www.w3.org/2000/svg" class="flex-grow" preserveAspectRatio="xMidYMid meet"> | ||
<line y1="0.5" x2="360" y2="0.5" stroke="#E5E7EB"></line> | ||
</svg> | ||
</div> | ||
<%= 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| %> | ||
<div class="flex w-full items-center rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600"> | ||
<div class="p-2"> | ||
<%= render Icons::SearchComponent.new %> | ||
<%= tag.turbo_frame id:'box-selector-popup' do %> | ||
<div class="flex flex-col justify-start items-start w-[360px] gap-px py-0.5 rounded-lg bg-white border border-gray-300" style="box-shadow: 1px 1px 4px 0 rgba(0,0,0,0.1);"> | ||
<%= 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 %> | ||
<div class="flex justify-center items-center flex-grow-0 flex-shrink-0 relative overflow-hidden gap-[29px]"> | ||
<p class="flex-grow-0 flex-shrink-0 text-base font-medium text-left text-gray-900">Všetky schránky</p> | ||
</div> | ||
<div class="flex justify-center items-center flex-grow-0 flex-shrink-0 relative overflow-hidden gap-1.5 px-1.5 py-0.5 rounded-md bg-gray-50 border border-gray-300"> | ||
<p class="flex-grow-0 flex-shrink-0 text-sm text-left text-gray-600"><%= @all_unread_messages_count %></p> | ||
</div> | ||
<%= tag.turbo_frame id:'box-search-results' %> | ||
<%= form.search_field :name_search, value: params[:name_search], placeholder: "Vyhľadaj schránku", | ||
<% end %> | ||
<div class="flex justify-start items-center self-stretch flex-grow-0 flex-shrink-0 relative"> | ||
<svg width="360" height="1" viewBox="0 0 360 1" fill="none" xmlns="http://www.w3.org/2000/svg" class="flex-grow" preserveAspectRatio="xMidYMid meet"> | ||
<line y1="0.5" x2="360" y2="0.5" stroke="#E5E7EB"></line> | ||
</svg> | ||
</div> | ||
<%= 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| %> | ||
<div class="flex w-full items-center rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600"> | ||
<div class="p-2"> | ||
<%= render Icons::SearchComponent.new %> | ||
</div> | ||
<%= 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" %> | ||
</div> | ||
<% end %> | ||
<%= render Layout::BoxListComponent.new(@boxes) %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<%= tag.turbo_frame id:'box-list', class:"flex-col self-stretch" do %> | ||
<%= render Layout::BoxListComponent.with_collection(@boxes) %> | ||
<% end %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +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 | ||
def initialize(boxes, all_unread_messages_count) | ||
@boxes = boxes | ||
@all_unread_messages_count = all_unread_messages_count | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
class TW::TopNavigationComponent < ViewComponent::Base | ||
def initialize(current_tenant_boxes_count) | ||
@current_tenant_boxes_count = current_tenant_boxes_count | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,8 @@ def search? | |
true | ||
end | ||
|
||
def get_selector? | ||
true | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render Layout::BoxSelectorPopupComponent.new(@boxes, @all_unread_messages_count) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<%= turbo_stream.update 'box-list' do %> | ||
<%= render Layout::BoxListComponent.new(@boxes) %> | ||
<%= render Layout::BoxListComponent.with_collection(@boxes) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters