Skip to content

Commit

Permalink
[WIP] Render work package details in each relation group box
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-contreras committed Oct 22, 2024
1 parent cca4b76 commit b480a1e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 21 deletions.
41 changes: 21 additions & 20 deletions app/components/work_package_relations_tab/index_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
<%= turbo_frame_tag "work-package-relations-tab-content" do %>
<%= flex_layout(classes: "work-package-relations-tab--list-container") do |flex| %>
<% @relations.group_by(&:relation_type).each do |relation_type, relations| %>
<%= flex.with_row do %>
<%= render(border_box_container(padding: :condensed)) do |border_box|
border_box.with_header do
flex_layout do |flex|
<%=
blah_blah = "Blah blah"
flex_layout(classes: "work-package-relations-tab--list-container") do |flex|
relations.group_by(&:relation_type).each do |relation_type, relations_of_type|
flex.with_row do
render(border_box_container(padding: :condensed)) do |border_box|
border_box.with_header(py: 3) do
flex_layout(align_items: :center) do |flex|
flex.with_column(mr: 2) do
render(Primer::Beta::Text.new(font_size: :normal, color: :muted)) do
t(relations.first.label_for(@work_package)).capitalize
render(Primer::Beta::Text.new(font_size: :normal, font_weight: :bold)) do
t(relations_of_type.first.label_for(work_package)).capitalize
end
end
flex.with_column do
render(Primer::Beta::Counter.new(count: relations.size,
round: true,
scheme: :primary))
render(Primer::Beta::Counter.new(count: relations_of_type.size,
round: true,
scheme: :primary))
end
end
end
relations.each do |relation|
border_box.with_row do
render(Primer::Beta::Text.new(font_size: :normal, color: :muted)) do
relation.to.subject.to_s
end
relations_of_type.each do |relation|
border_box.with_row(style: "padding-top: 12px; padding-bottom: 12px;") do
render(WorkPackageRelationsTab::RelationComponent.new(work_package: relation.to))
end
end
end %>
<% end %>
<% end %>
<% end %>
end
end
end
end
%>
<% end %>
2 changes: 2 additions & 0 deletions app/components/work_package_relations_tab/index_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
include Turbo::FramesHelper

attr_reader :work_package, :relations

def initialize(work_package:, relations:)
super()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<%= flex_layout(direction: :column, style: "gap: 0.25rem;") do |flex|
flex.with_row(flex_layout: true,
justify_content: :flex_start,
style: "gap: 0.5rem;") do |meta_information_row|
meta_information_row.with_column do
render(Primer::Beta::Text.new(font_size: :small,
font_weight: :bold,
color: :muted)) { "#{work_package.type.name.upcase}" }
end

meta_information_row.with_column do
render(Primer::Beta::Text.new(font_size: :small,
color: :muted)) { "##{work_package.id}" }
end
meta_information_row.with_column do
render(Primer::Beta::Label.new(font_weight: :bold)) { work_package.status.name }
end
end

flex.with_row(flex_layout: true, justify_content: :flex_start) do |subject_line_row|
subject_line_row.with_column do
render(Primer::Beta::Link.new(href: work_package_path(work_package),
color: :default,
underline: false,
font_size: :normal,
font_weight: :bold,
target: "_blank")) { work_package.subject }
end
end

flex.with_row(flex_layout: true, justify_content: :flex_start) do |description_row|
description_row.with_column do
render(Primer::Beta::Text.new(font_size: :small,
color: :muted)) do
format_text(work_package, :description)
end
end
end
end %>
12 changes: 12 additions & 0 deletions app/components/work_package_relations_tab/relation_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class WorkPackageRelationsTab::RelationComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers

attr_reader :work_package

def initialize(work_package:)
super()

@work_package = work_package
end
end
1 change: 0 additions & 1 deletion app/controllers/work_package_relations_tab_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def index
@relations = @work_package
.relations
.includes(:to, :from)
.visible

render(
WorkPackageRelationsTab::IndexComponent.new(
Expand Down

0 comments on commit b480a1e

Please sign in to comment.