-
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 branch 'GO-196/user_select_boxes'
- Loading branch information
Showing
23 changed files
with
213 additions
and
299 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
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,33 @@ | ||
<%# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %> | ||
<%# If color values are changed, adjust the color list below !!!!!!!!! %> | ||
<%# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %> | ||
<div class="flex justify-center items-center relative overflow-hidden gap-1.5 px-2 py-1 rounded-md bg-<%= @box.color %>-100 border border-<%= @box.color %>-400"> | ||
<p class="flex-grow-0 flex-shrink-0 text-sm text-left text-<%= @box.color %>-600"><%= @box.short_name || @box.name[0] %></p> | ||
</div> | ||
<%# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %> | ||
<%# 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" %> |
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,7 @@ | ||
module Common | ||
class BoxLabelComponent < ViewComponent::Base | ||
def initialize(box) | ||
@box = box | ||
end | ||
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,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 %> | ||
<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 %> | ||
<% 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,5 @@ | ||
class Layout::BoxListComponent < ViewComponent::Base | ||
def initialize(boxes) | ||
@boxes = boxes | ||
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,29 @@ | ||
<div class="relative" data-controller="dropdown" | ||
data-dropdown-active-target="#dropdown-button" | ||
data-dropdown-active-class="bg-gray-50" | ||
data-dropdown-invisible-class="opacity-0 scale-95" | ||
data-dropdown-visible-class="opacity-100 scale-100" | ||
data-dropdown-entering-class="ease-out duration-100" | ||
data-dropdown-enter-timeout="100" | ||
data-dropdown-leaving-class="ease-in duration-75" | ||
data-dropdown-leave-timeout="75" | ||
> | ||
<div id="dropdown-button" data-action="click->dropdown#toggle click@window->dropdown#hide" role="button" data-dropdown-target="button" tabindex="0" class="inline-block select-none"> | ||
<button type="button" class="flex items-center gap-2" aria-expanded="false" aria-haspopup="true"> | ||
<div class="flex justify-start items-center relative gap-3 py-1.5 pl-8 rounded-md bg-white"> | ||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class=" w-5 h-5 relative" preserveAspectRatio="xMidYMid meet"> | ||
<path d="M15.8333 9.16667H4.16667M15.8333 9.16667C16.2754 9.16667 16.6993 9.34226 17.0118 9.65482C17.3244 9.96738 17.5 10.3913 17.5 10.8333V15.8333C17.5 16.2754 17.3244 16.6993 17.0118 17.0118C16.6993 17.3244 16.2754 17.5 15.8333 17.5H4.16667C3.72464 17.5 3.30072 17.3244 2.98816 17.0118C2.67559 16.6993 2.5 16.2754 2.5 15.8333V10.8333C2.5 10.3913 2.67559 9.96738 2.98816 9.65482C3.30072 9.34226 3.72464 9.16667 4.16667 9.16667M15.8333 9.16667V7.5C15.8333 7.05797 15.6577 6.63405 15.3452 6.32149C15.0326 6.00893 14.6087 5.83333 14.1667 5.83333M4.16667 9.16667V7.5C4.16667 7.05797 4.34226 6.63405 4.65482 6.32149C4.96738 6.00893 5.39131 5.83333 5.83333 5.83333M14.1667 5.83333V4.16667C14.1667 3.72464 13.9911 3.30072 13.6785 2.98816C13.366 2.67559 12.942 2.5 12.5 2.5H7.5C7.05797 2.5 6.63405 2.67559 6.32149 2.98816C6.00893 3.30072 5.83333 3.72464 5.83333 4.16667V5.83333M14.1667 5.83333H5.83333" stroke="#9CA3AF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> | ||
</svg> | ||
<% if Current.box %> | ||
<%= render Common::BoxLabelComponent.new(Current.box) %> | ||
<p class="text-base text-left text-gray-900"><%= Current.box.name %></p> | ||
<% else %> | ||
<p class=" text-base text-left text-gray-900">Všetky schránky</p> | ||
<% end %> | ||
</div> | ||
</button> | ||
</div> | ||
<div data-dropdown-target="menu" class="z-50 absolute transform transition hidden opacity-0 scale-95" > | ||
<%= render Layout::BoxSelectorPopupComponent.new %> | ||
</div> | ||
</div> |
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,2 @@ | ||
class Layout::BoxSelectorComponent < ViewComponent::Base | ||
end |
28 changes: 28 additions & 0 deletions
28
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<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 %> | ||
</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> |
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,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 |
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
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
Oops, something went wrong.