Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Extract ListComponent view into erb

Oliver Günther59fae20f75c1
diff --git a/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb
new file mode 100644
index 00000000000..db176d0988a
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb
@@ -0,0 +1,44 @@
+<%=
+ component_wrapper(data: wrapper_data_attributes) do
+ # The borderBox needs to be `position: relative` because of bug #49853
+ # (The action menu items float somewhere on the page as soon as you have to scroll the Box in Firefox)
+ render(Primer::Beta::BorderBox.new(position: :relative)) do |border_box|
+ if @meeting.agenda_items.empty? && @form_hidden
+ border_box.with_body(
+ scheme: :default
+ ) do
+ render(Primer::Beta::Blankslate.new) do |component|
+ component.with_visual_icon(icon: :book)
+ component.with_heading(tag: :h2).with_content(t("text_meeting_empty_heading"))
+ component.with_description do
+ flex_layout do |flex|
+ flex.with_row(mb: 2) do
+ render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_1") }
+ end
+ flex.with_row do
+ render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_2") }
+ end
+ end
+ end
+ end
+ end
+ else
+ @meeting.agenda_items.each do |meeting_agenda_item|
+ border_box.with_row(
+ pl: 0,
+ scheme: :default,
+ data: {
+ id: meeting_agenda_item.id,
+ 'drop-url': drop_meeting_agenda_item_path(meeting_agenda_item.meeting, meeting_agenda_item)
+ }
+ ) do
+ render(MeetingAgendaItems::ItemComponent.new(meeting_agenda_item:))
+ end
+ end
+ end
+ border_box.with_row(p: 0, border_top: 0) do
+ render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, hidden: @form_hidden, type: @form_type))
+ end
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meeting_agenda_items/list_component.rb b/modules/meeting/app/components/meeting_agenda_items/list_component.rb
index 327ebc1ceb2..acb5fdf48f0 100644
--- a/modules/meeting/app/components/meeting_agenda_items/list_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/list_component.rb
@@ -40,25 +40,6 @@ module MeetingAgendaItems
@form_type = form_type
end
- def call
- component_wrapper(data: wrapper_data_attributes) do
- # The borderBox needs to be `position: relative` because of bug #49853
- # (The action menu items float somewhere on the page as soon as you have to scroll the Box in Firefox)
- render(Primer::Beta::BorderBox.new(position: :relative)) do |border_box|
- if @meeting.agenda_items.empty? && @form_hidden
- empty_state_partial(border_box)
- else
- @meeting.agenda_items.each do |meeting_agenda_item|
- row_partial(border_box, meeting_agenda_item)
- end
- end
- border_box.with_row(p: 0, border_top: 0) do
- new_form_partial
- end
- end
- end
- end
-
private
def wrapper_data_attributes
@@ -68,47 +49,5 @@ module MeetingAgendaItems
'target-tag': 'ul'
}
end
-
- def empty_state_partial(border_box)
- border_box.with_body(
- scheme: :default
- ) do
- blank_slate_partial
- end
- end
-
- def blank_slate_partial
- render(Primer::Beta::Blankslate.new) do |component|
- component.with_visual_icon(icon: :book)
- component.with_heading(tag: :h2).with_content(t("text_meeting_empty_heading"))
- component.with_description do
- flex_layout do |flex|
- flex.with_row(mb: 2) do
- render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_1") }
- end
- flex.with_row do
- render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_2") }
- end
- end
- end
- end
- end
-
- def row_partial(border_box, meeting_agenda_item)
- border_box.with_row(
- pl: 0,
- scheme: :default,
- data: {
- id: meeting_agenda_item.id,
- 'drop-url': drop_meeting_agenda_item_path(meeting_agenda_item.meeting, meeting_agenda_item)
- }
- ) do
- render(MeetingAgendaItems::ItemComponent.new(meeting_agenda_item:))
- end
- end
-
- def new_form_partial
- render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, hidden: @form_hidden, type: @form_type))
- end
end
end