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

Add backlog component and visibility conditions

Mir Bhatia2a52c42b44ed
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
index 9f78903439a..1c8b5dd03c0 100644
--- a/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb
@@ -3,12 +3,18 @@
flex_layout(mb: 3) do |flex|
if @meeting.template?
flex.with_row(mb: 3) do
- render Primer::Alpha::Banner.new(scheme: :default,
- icon: :info,
- dismiss_scheme: :none) do
- t("recurring_meeting.template.banner_html",
- link: link_to(@meeting.recurring_meeting.title,
- project_recurring_meeting_path(@meeting.project, @meeting.recurring_meeting)))
+ render Primer::Alpha::Banner.new(
+ scheme: :default,
+ icon: :info,
+ dismiss_scheme: :none
+ ) do
+ t(
+ "recurring_meeting.template.banner_html",
+ link: link_to(
+ @meeting.recurring_meeting.title,
+ project_recurring_meeting_path(@meeting.project, @meeting.recurring_meeting)
+ )
+ )
end
end
end
@@ -16,7 +22,7 @@
first_and_last = [@meeting.sections.first, @meeting.sections.last]
render(
MeetingSections::ShowComponent.with_collection(
- @meeting.sections,
+ sections_except_backlog,
first_and_last:
)
)
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 6a74a2f6a96..31a2f064bf4 100644
--- a/modules/meeting/app/components/meeting_agenda_items/list_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/list_component.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -68,5 +69,9 @@ module MeetingAgendaItems
def insert_target_modifier_id
"meeting-section-new-item"
end
+
+ def sections_except_backlog
+ @meeting.sections.reject(&:backlog?)
+ end
end
end
diff --git a/modules/meeting/app/components/meeting_sections/backlog_component.html.erb b/modules/meeting/app/components/meeting_sections/backlog_component.html.erb
new file mode 100644
index 00000000000..1055b549118
--- /dev/null
+++ b/modules/meeting/app/components/meeting_sections/backlog_component.html.erb
@@ -0,0 +1,15 @@
+<%=
+ component_wrapper(data: wrapper_data_attributes) do
+ if show?
+ flex_layout(mb: 3) do |flex|
+ flex.with_row(classes: "dragula-container", id: insert_target_modifier_id, data: { "allowed-drop-type": "section" }.merge(drop_target_config)) do
+ render(
+ MeetingSections::ShowComponent.new(
+ meeting_section: @backlog
+ )
+ )
+ end
+ end
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meeting_sections/backlog_component.rb b/modules/meeting/app/components/meeting_sections/backlog_component.rb
new file mode 100644
index 00000000000..2de8cf9f570
--- /dev/null
+++ b/modules/meeting/app/components/meeting_sections/backlog_component.rb
@@ -0,0 +1,80 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module MeetingSections
+ class BacklogComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:, form_hidden: true, form_type: :simple)
+ super
+
+ @meeting = meeting
+ @form_hidden = form_hidden
+ @form_type = form_type
+ @backlog = meeting.backlog
+ end
+
+ def empty?
+ @meeting.agenda_items.empty? && @meeting.sections.empty?
+ end
+
+ private
+
+ def show?
+ end
+
+ def wrapper_data_attributes
+ {
+ controller: "generic-drag-and-drop",
+ "application-target": "dynamic"
+ }
+ end
+
+ def drop_target_config
+ {
+ "is-drag-and-drop-target": true,
+ "target-container-accessor": ".Box > ul", # the accessor of the container that contains the drag and drop items
+ "target-id": @backlog.id, # the id of the target
+ "target-allowed-drag-type": "agenda-item" # the type of dragged items which are allowed to be dropped in this target
+ }
+ end
+
+ def insert_target_modified?
+ true
+ end
+
+ def insert_target_modifier_id
+ "meeting-section-new-item"
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meeting_sections/header_component.html.erb b/modules/meeting/app/components/meeting_sections/header_component.html.erb
index bd763b7a6db..bbaea7e7b7c 100644
--- a/modules/meeting/app/components/meeting_sections/header_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/header_component.html.erb
@@ -7,18 +7,39 @@
render(Primer::OpenProject::DragHandle.new(classes: "handle"))
end
end
+
grid.with_area(:content, tag: :span) do
render(Primer::Beta::Text.new(font_weight: :bold, mr: 2)) do
@meeting_section.title.presence || I18n.t("meeting_section.untitled_title")
end
end
- if @meeting_section.agenda_items_sum_duration_in_minutes > 0
+
+ if @meeting_section.agenda_items_sum_duration_in_minutes > 0 && !backlog?
grid.with_area(:duration, Primer::Beta::Text, color: :subtle, mr: 1) do
render(Primer::Beta::Text.new(font_weight: :normal, color: :subtle)) do
render(OpenProject::Common::DurationComponent.new(@meeting_section.agenda_items_sum_duration_in_minutes, :minutes, abbreviated: true))
end
end
end
+
+ if backlog?
+ grid.with_area(:duration, ml: 1, mr: 1, classes: "backlog-header") do
+ concat(render(Primer::Beta::Counter.new(count: @meeting_agenda_items.count, scheme: :primary, mr: 1)))
+ concat(
+ render(
+ Primer::Beta::IconButton.new(
+ tag: :a,
+ scheme: :invisible,
+ icon: @expanded ? "chevron-up" : "chevron-down",
+ "aria-label": I18n.t(:label_agenda_backlog_toggle),
+ href: toggle_meeting_section_path(@meeting, @meeting_section, expanded: @expanded),
+ data: { turbo_stream: true }
+ )
+ )
+ )
+ end
+ end
+
grid.with_area(:actions, tag: :div, justify_self: :end, classes: "hide-when-print") do
if editable?
render(Primer::Alpha::ActionMenu.new(data: { test_selector: "meeting-section-action-menu" })) do |menu|
@@ -36,6 +57,14 @@
end
end
end
+
+ if backlog? && @expanded
+ grid.with_area(:description, tag: :span, classes: "hide-when-print hidden-for-mobile") do
+ render(Primer::Beta::Text.new(font_weight: :normal, color: :subtle)) do
+ I18n.t(:text_agenda_backlog)
+ end
+ end
+ end
end
else
primer_form_with(
diff --git a/modules/meeting/app/components/meeting_sections/header_component.rb b/modules/meeting/app/components/meeting_sections/header_component.rb
index 35ef3da18ab..8e2aaaddba5 100644
--- a/modules/meeting/app/components/meeting_sections/header_component.rb
+++ b/modules/meeting/app/components/meeting_sections/header_component.rb
@@ -33,13 +33,15 @@ module MeetingSections
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
- def initialize(meeting_section:, state: :show, first_and_last: [])
+ def initialize(meeting_section:, state: :show, first_and_last: [], expanded: true)
super
@meeting_section = meeting_section
+ @meeting = meeting_section.meeting
@meeting_agenda_items = meeting_section.agenda_items
@first_and_last = first_and_last
@state = state
+ @expanded = expanded
end
private
@@ -162,5 +164,9 @@ module MeetingSections
item.with_leading_visual_icon(icon: :trash)
end
end
+
+ def backlog?
+ @meeting_section == @meeting.backlog
+ end
end
end
diff --git a/modules/meeting/app/components/meeting_sections/header_component.sass b/modules/meeting/app/components/meeting_sections/header_component.sass
index e855233a9e5..34c61b2dd3b 100644
--- a/modules/meeting/app/components/meeting_sections/header_component.sass
+++ b/modules/meeting/app/components/meeting_sections/header_component.sass
@@ -3,11 +3,12 @@
.op-meeting-section
display: grid
grid-template-columns: 20px auto 1fr fit-content(40px)
- grid-template-areas: "drag-handle content duration actions"
+ grid-template-areas: "drag-handle content duration actions" ". description description description"
&--drag-handle,
&--duration,
- &--content
+ &--content,
+ &--description
align-self: center
&--actions
@@ -19,5 +20,9 @@
&--content
@include text-shortener
+ .backlog-header
+ display: flex
+ align-items: center
+
@media screen and (max-width: $breakpoint-lg)
grid-template-columns: 20px auto 1fr 50px
diff --git a/modules/meeting/app/components/meeting_sections/show_component.html.erb b/modules/meeting/app/components/meeting_sections/show_component.html.erb
index 7795c5ec196..d067b55a575 100644
--- a/modules/meeting/app/components/meeting_sections/show_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/show_component.html.erb
@@ -3,7 +3,7 @@
render(border_box_container(mt: 3, data: drag_and_drop_target_config)) do |component|
if render_section_wrapper?
component.with_header(font_weight: :bold, pl: 0) do
- render(MeetingSections::HeaderComponent.new(meeting_section: @meeting_section, state: @state))
+ render(MeetingSections::HeaderComponent.new(meeting_section: @meeting_section, state: @state, expanded: @expanded))
end
end
if render_new_button_in_section?
@@ -17,7 +17,7 @@
end
end
end
- else
+ elsif @expanded
first_and_last = [@meeting_agenda_items.first, @meeting_agenda_items.last]
@meeting_agenda_items.each do |agenda_item|
render(
diff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rb
index 4e0dd40ac6d..768152991af 100644
--- a/modules/meeting/app/components/meeting_sections/show_component.rb
+++ b/modules/meeting/app/components/meeting_sections/show_component.rb
@@ -37,7 +37,7 @@ module MeetingSections
with_collection_parameter :meeting_section
def initialize(meeting_section:, first_and_last: [], form_hidden: true, form_type: :simple, insert_target_modified: true,
- force_wrapper: false, state: :show)
+ force_wrapper: false, state: :show, expanded: true)
super
@meeting = meeting_section.meeting
@@ -49,7 +49,7 @@ module MeetingSections
@insert_target_modified = insert_target_modified
@force_wrapper = force_wrapper
@state = state
- @backlog = meeting_section.backlog?
+ @expanded = expanded
end
private
@@ -70,11 +70,6 @@ module MeetingSections
@meeting_section.editable? && User.current.allowed_in_project?(:manage_agendas, @meeting_section.project)
end
- def render?
- # !@backlog
- true
- end
-
def render_section_wrapper?
@force_wrapper || !@meeting_section.untitled? || @meeting.sections.count > 1
end
diff --git a/modules/meeting/app/components/meetings/show_component.html.erb b/modules/meeting/app/components/meetings/show_component.html.erb
index 8f153034fd5..dbce8f3012a 100644
--- a/modules/meeting/app/components/meetings/show_component.html.erb
+++ b/modules/meeting/app/components/meetings/show_component.html.erb
@@ -16,6 +16,10 @@
render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting))
end
+ agenda.with_row do
+ render(MeetingSections::BacklogComponent.new(meeting: @meeting))
+ end
+
agenda.with_row(mt: 3, display: [:block, nil, :none]) do
resource = ::API::V3::Meetings::MeetingRepresenter.new(@meeting, current_user: User.current, embed_links: false)
concat render(Primer::Beta::Heading.new(tag: :h4)) { I18n.t(:label_attachment_plural) }
diff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
index 063780eda58..ea44b942cc4 100644
--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
@@ -143,7 +143,7 @@ module Meetings
end
def render_agenda_item_form_via_turbo_stream(meeting: @meeting, meeting_section: @meeting_section, type: :simple)
- if meeting.sections.empty?
+ if meeting.sections.empty? && meeting_section != meeting.backlog
render_agenda_item_form_for_empty_meeting_via_turbo_stream(type:)
else
render_agenda_item_form_in_section_via_turbo_stream(meeting:, meeting_section:, type:)
@@ -202,6 +202,14 @@ module Meetings
update_new_button_via_turbo_stream(disabled: false) if form_hidden == true
end
+ def update_backlog_via_turbo_stream(meeting: @meeting)
+ update_via_turbo_stream(
+ component: MeetingSections::BacklogComponent.new(
+ meeting:
+ )
+ )
+ end
+
def update_item_via_turbo_stream(state: :show, meeting_agenda_item: @meeting_agenda_item, display_notes_input: nil)
replace_via_turbo_stream(
component: MeetingAgendaItems::ItemComponent.new(
@@ -340,24 +348,26 @@ module Meetings
end
end
- def update_section_header_via_turbo_stream(meeting_section: @meeting_section, state: :show)
+ def update_section_header_via_turbo_stream(meeting_section: @meeting_section, state: :show, expanded: true)
update_via_turbo_stream(
component: MeetingSections::HeaderComponent.new(
meeting_section:,
- state:
+ state:,
+ expanded:
)
)
end
def update_section_via_turbo_stream(meeting_section: @meeting_section, form_hidden: true, form_type: :simple,
- force_wrapper: false, state: :show)
+ force_wrapper: false, state: :show, expanded: true)
update_via_turbo_stream(
component: MeetingSections::ShowComponent.new(
meeting_section:,
form_type:,
form_hidden:,
force_wrapper:,
- state:
+ state:,
+ expanded:
)
)
end
@@ -430,6 +440,7 @@ module Meetings
update_sidebar_component_via_turbo_stream
update_new_button_via_turbo_stream
update_list_via_turbo_stream
+ update_backlog_via_turbo_stream
end
end
end
diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
index 02cd387402b..de9e7dae4c1 100644
--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -47,7 +47,11 @@ class MeetingAgendaItemsController < ApplicationController
render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))
else
if params[:meeting_section_id].present?
- meeting_section = @meeting.sections.find(params[:meeting_section_id])
+ meeting_section = if params[:meeting_section_id] == @meeting.backlog.id.to_s
+ @meeting.backlog
+ else
+ @meeting.sections.find(params[:meeting_section_id])
+ end
end
render_agenda_item_form_via_turbo_stream(meeting_section:, type: @agenda_item_type)
end
diff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rb
index c2e827c2ed8..9e2c13de404 100644
--- a/modules/meeting/app/controllers/meeting_sections_controller.rb
+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb
@@ -170,6 +170,16 @@ class MeetingSectionsController < ApplicationController
respond_with_turbo_streams
end
+ def toggle
+ @meeting_section = MeetingSection.find(toggle_params[:id])
+ next_state = !ActiveModel::Type::Boolean.new.cast(toggle_params[:expanded])
+
+ update_section_header_via_turbo_stream(expanded: next_state)
+ update_section_via_turbo_stream(expanded: next_state)
+
+ respond_with_turbo_streams
+ end
+
private
def set_meeting
@@ -204,4 +214,8 @@ class MeetingSectionsController < ApplicationController
# show additional base error message
render_base_error_in_flash_message_via_turbo_stream(call.errors)
end
+
+ def toggle_params
+ @toggle_params ||= params.permit(:id, :expanded)
+ end
end
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index 7e42f08ddfa..daf304ef7e1 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -286,10 +286,13 @@ class MeetingsController < ApplicationController
case params[:state]
when "open"
@meeting.open!
+ expanded = true
when "closed"
@meeting.closed!
+ expanded = nil
when "in_progress"
@meeting.in_progress!
+ expanded = false
end
if @meeting.errors.any?
@@ -298,6 +301,10 @@ class MeetingsController < ApplicationController
update_all_via_turbo_stream
end
+ @meeting_section = @meeting.backlog
+ update_section_header_via_turbo_stream(expanded: expanded)
+ update_section_via_turbo_stream(expanded: expanded)
+
respond_with_turbo_streams
end
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index 04694c7b91b..be92639d731 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -53,8 +53,8 @@ class Meeting < ApplicationRecord
after_add: :send_participant_added_mail
has_many :agenda_items, dependent: :destroy, class_name: "MeetingAgendaItem", inverse_of: :meeting
- has_many :sections, dependent: :delete_all, class_name: "MeetingSection"
- has_one :backlog, -> { where(backlog: true) }, class_name: "MeetingSection"
+ has_many :sections, -> { where(backlog: false) }, dependent: :delete_all, class_name: "MeetingSection"
+ has_one :backlog, -> { where(backlog: true) }, dependent: :destroy, class_name: "MeetingSection"
accepts_nested_attributes_for :agenda_items
diff --git a/modules/meeting/app/services/meetings/create_service.rb b/modules/meeting/app/services/meetings/create_service.rb
index 99c59b2dd57..ab60482cb89 100644
--- a/modules/meeting/app/services/meetings/create_service.rb
+++ b/modules/meeting/app/services/meetings/create_service.rb
@@ -55,7 +55,7 @@ module Meetings
{
meeting_id: meeting.id,
backlog: true,
- title: "Agenda backlog"
+ title: I18n.t(:label_agenda_backlog)
}
)
end
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 54a9292a3c9..39b4eef1067 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -428,6 +428,11 @@ en:
label_agenda_outcome_delete: "Remove outcome"
text_outcome_not_editable_anymore: "This outcome is not editable anymore."
+ label_agenda_backlog: "Agenda backlog"
+ text_agenda_backlog: "The backlog is shared with all occurrences of this series. You can drag items in and out to add or remove them from a particular meeting. The backlog is only visible when the meeting status is open and hidden once the meeting is in progress."
+ label_agenda_backlog_toggle: "Toggle"
+
+
text_agenda_item_title: 'Agenda item "%{title}"'
text_agenda_work_package_deleted: 'Agenda item for deleted work package'
text_deleted_agenda_item: 'Deleted agenda item'
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index f2ff0936874..87d11300988 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -119,6 +119,7 @@ Rails.application.routes.draw do
get :cancel_edit
put :drop
put :move
+ get :toggle
end
end
resources :outcomes, controller: "meeting_outcomes" do
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index a522fb332c7..44adb9676b5 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -48,7 +48,8 @@ module OpenProject::Meeting
meeting_minutes: %i[history show diff],
"meetings/menus": %i[show],
work_package_meetings_tab: %i[index count],
- recurring_meetings: %i[index show new create download_ics]
+ recurring_meetings: %i[index show new create download_ics],
+ meeting_sections: %i[toggle]
},
permissible_on: :project
permission :create_meetings,