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

Refactor meeting agenda item views into grids

Oliver Güntherab3f82286868
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
new file mode 100644
index 00000000000..296773aa5a2
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
@@ -0,0 +1,101 @@
+<%=
+ flex_layout do |flex|
+ flex.with_row do
+ flex_layout(justify_content: :space_between, align_items: :flex_start) do |flex1|
+ flex1.with_column(flex: 1) do
+ flex_layout(align_items: :flex_start) do |flex2|
+ flex2.with_column(mx: 1, pt: 2) do
+ if drag_and_drop_enabled?
+ render(Primer::OpenProject::DragHandle.new(classes: 'handle'))
+ end
+ end
+ flex2.with_column(flex: 1, mt: 2, pl: drag_and_drop_enabled? ? 0 : 3) do
+ if @meeting_agenda_item.visible_work_package?
+ flex_layout(align_items: :center) do |flex3|
+ flex3.with_column(mr: 2) do
+ render(Primer::Beta::Link.new(href: work_package_path(@meeting_agenda_item.work_package), underline: false,
+ font_size: :normal, font_weight: :bold, target: "_blank")) do
+ render(Primer::Beta::Truncate.new) do |component|
+ component.with_item(max_width: 300, expandable: true) do
+ @meeting_agenda_item.work_package.subject
+ end
+ end
+ end
+ end
+ flex3.with_column(mr: 2) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
+ "#{@meeting_agenda_item.work_package.type.name} ##{@meeting_agenda_item.work_package.id}"
+ end
+ end
+ flex3.with_column(mr: 2) do
+ render(Primer::Beta::Label.new(font_weight: :bold)) do
+ @meeting_agenda_item.work_package.status.name
+ end
+ end
+ flex3.with_column do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
+ "#{@meeting_agenda_item.duration_in_minutes || 0} min"
+ end
+ end
+ end
+ elsif @meeting_agenda_item.linked_work_package?
+ flex_layout(align_items: :center) do |flex3|
+ flex3.with_column(mr: 2) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
+ I18n.t(:label_agenda_item_undisclosed_wp, id: @meeting_agenda_item.work_package_id)
+ end
+ end
+ flex3.with_column do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
+ "#{@meeting_agenda_item.duration_in_minutes || 0} min"
+ end
+ end
+ end
+ else
+ flex_layout(align_items: :center) do |flex3|
+ flex3.with_column(mr: 2) do
+ render(Primer::Beta::Text.new(font_size: :normal, font_weight: :bold, test_selector: 'op-meeting-agenda-title')) do
+ render(Primer::Beta::Truncate.new) do |component|
+ component.with_item(max_width: 300, expandable: true) { @meeting_agenda_item.title }
+ end
+ end
+ end
+ flex3.with_column do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
+ "#{@meeting_agenda_item.duration_in_minutes || 0} min"
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ flex1.with_column do
+ flex_layout(align_items: :center, mt: edit_enabled? ? 1 : 2) do |flex2|
+ flex2.with_column(mr: 2) do
+ title = I18n.t(:label_added_time_by,
+ author: @meeting_agenda_item.author.name,
+ age: helpers.distance_of_time_in_words(Time.zone.now, @meeting_agenda_item.created_at))
+ render(Users::AvatarComponent.new(user: @meeting_agenda_item.author, size: 'mini', title:))
+ end
+ flex2.with_column do
+ render(Primer::Alpha::ActionMenu.new) do |menu|
+ menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_agenda_item_actions"), scheme: :invisible, test_selector: 'op-meeting-agenda-actions')
+ edit_action_item(menu)
+ move_actions(menu)
+ delete_action_item(menu)
+ end if edit_enabled?
+ end
+ end
+ end
+ end
+ end
+ flex.with_row(mt: edit_enabled? ? 1 : 2, pl: 4) do
+ if @meeting_agenda_item.notes.present?
+ render(Primer::Box.new(color: :subtle)) do
+ ::OpenProject::TextFormatting::Renderer.format_text(@meeting_agenda_item.notes)
+ end
+ end
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
index b64bf7742b7..27f1c8a978d 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
@@ -39,17 +39,6 @@ module MeetingAgendaItems
@meeting = meeting_agenda_item.meeting
end
- def call
- flex_layout do |flex|
- flex.with_row do
- first_row_partial
- end
- flex.with_row(mt: edit_enabled? ? 1 : 2, pl: 4) do
- second_row_partial
- end
- end
- end
-
private
def drag_and_drop_enabled?
@@ -60,159 +49,6 @@ module MeetingAgendaItems
@meeting.open? && User.current.allowed_to?(:edit_meetings, @meeting.project)
end
- def first_row_partial
- flex_layout(justify_content: :space_between, align_items: :flex_start) do |flex|
- flex.with_column(flex: 1) do
- left_column_partial
- end
- flex.with_column do
- right_column_partial
- end
- end
- end
-
- def second_row_partial
- if @meeting_agenda_item.notes.present?
- description_partial
- end
- end
-
- def left_column_partial
- flex_layout(align_items: :flex_start) do |flex|
- flex.with_column(mx: 1, pt: 2) do
- if drag_and_drop_enabled?
- drag_handler_partial
- end
- end
- flex.with_column(flex: 1, mt: 2, pl: drag_and_drop_enabled? ? 0 : 3) do
- if @meeting_agenda_item.visible_work_package?
- work_package_title_partial
- elsif @meeting_agenda_item.linked_work_package?
- work_package_undisclosed_partial
- else
- title_partial
- end
- end
- end
- end
-
- def right_column_partial
- flex_layout(align_items: :center, mt: edit_enabled? ? 1 : 2) do |flex|
- flex.with_column(mr: 2) do
- title = I18n.t(:label_added_time_by,
- author: @meeting_agenda_item.author.name,
- age: helpers.distance_of_time_in_words(Time.zone.now, @meeting_agenda_item.created_at))
- render(Users::AvatarComponent.new(user: @meeting_agenda_item.author, size: 'mini', title:))
- end
- flex.with_column do
- actions_partial if edit_enabled?
- end
- end
- end
-
- def drag_handler_partial
- render(Primer::OpenProject::DragHandle.new(classes: 'handle'))
- end
-
- def work_package_title_partial
- flex_layout(align_items: :center) do |flex|
- flex.with_column(mr: 2) do
- work_package_link_partial
- end
- flex.with_column(mr: 2) do
- work_package_type_and_id_partial
- end
- flex.with_column(mr: 2) do
- work_package_status_partial
- end
- flex.with_column do
- duration_partial
- end
- end
- end
-
- def work_package_undisclosed_partial
- flex_layout(align_items: :center) do |flex|
- flex.with_column(mr: 2) do
- render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
- I18n.t(:label_agenda_item_undisclosed_wp, id: @meeting_agenda_item.work_package_id)
- end
- end
- flex.with_column do
- duration_partial
- end
- end
- end
-
- def work_package_link_partial
- render(Primer::Beta::Link.new(href: work_package_path(@meeting_agenda_item.work_package), underline: false,
- font_size: :normal, font_weight: :bold, target: "_blank")) do
- render(Primer::Beta::Truncate.new) do |component|
- component.with_item(max_width: 300, expandable: true) do
- @meeting_agenda_item.work_package.subject
- end
- end
- end
- end
-
- def work_package_type_and_id_partial
- render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
- "#{@meeting_agenda_item.work_package.type.name} ##{@meeting_agenda_item.work_package.id}"
- end
- end
-
- def work_package_status_partial
- render(Primer::Beta::Label.new(font_weight: :bold)) do
- @meeting_agenda_item.work_package.status.name
- end
- end
-
- def duration_partial
- render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
- "#{@meeting_agenda_item.duration_in_minutes || 0} min"
- end
- end
-
- def title_partial
- flex_layout(align_items: :center) do |flex|
- flex.with_column(mr: 2) do
- render(Primer::Beta::Text.new(font_size: :normal, font_weight: :bold, test_selector: 'op-meeting-agenda-title')) do
- render(Primer::Beta::Truncate.new) do |component|
- component.with_item(max_width: 300, expandable: true) { @meeting_agenda_item.title }
- end
- end
- end
- flex.with_column do
- duration_partial
- end
- end
- end
-
- def description_partial
- render(Primer::Box.new(color: :subtle)) do
- ::OpenProject::TextFormatting::Renderer.format_text(@meeting_agenda_item.notes)
- end
- end
-
- def time_slot_partial
- render(Primer::Beta::Text.new(font_size: :normal, color: :subtle)) do
- [
- @meeting_agenda_item.start_time.strftime("%H:%M"),
- "-",
- @meeting_agenda_item.end_time.strftime("%H:%M"),
- "(#{@meeting_agenda_item.duration_in_minutes || 0} min)"
- ].join(" ")
- end
- end
-
- def actions_partial
- render(Primer::Alpha::ActionMenu.new) do |menu|
- menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_agenda_item_actions"), scheme: :invisible, test_selector: 'op-meeting-agenda-actions')
- edit_action_item(menu)
- move_actions(menu)
- delete_action_item(menu)
- end
- end
def edit_action_item(menu)
menu.with_item(label: t("label_edit"),