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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Rework components to use new CollapsibleHeader
Mir Bhatia262aa7068c62
diff --git a/modules/meeting/app/components/meeting_sections/backlog_component.html.erb b/modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erbsimilarity index 100%rename from modules/meeting/app/components/meeting_sections/backlog_component.html.erbrename to modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erbdiff --git a/modules/meeting/app/components/meeting_sections/backlog_component.rb b/modules/meeting/app/components/meeting_sections/backlogs/container_component.rbsimilarity index 86%rename from modules/meeting/app/components/meeting_sections/backlog_component.rbrename to modules/meeting/app/components/meeting_sections/backlogs/container_component.rbindex 2de8cf9f570..8b5bedfc270 100644--- a/modules/meeting/app/components/meeting_sections/backlog_component.rb+++ b/modules/meeting/app/components/meeting_sections/backlogs/container_component.rb@@ -29,23 +29,22 @@#++module MeetingSections- class BacklogComponent < ApplicationComponent+ class Backlogs::ContainerComponent < ApplicationComponentinclude ApplicationHelperinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- def initialize(meeting:, form_hidden: true, form_type: :simple)+ def initialize(meeting:)super+ # binding.pry@meeting = meeting- @form_hidden = form_hidden- @form_type = form_type@backlog = meeting.backlogend- def empty?- @meeting.agenda_items.empty? && @meeting.sections.empty?- end+ # def empty?+ # @meeting.agenda_items.empty? && @meeting.sections.empty?+ # endprivate@@ -64,7 +63,7 @@ module MeetingSections{"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-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}enddiff --git a/modules/meeting/app/components/meeting_sections/backlogs/header_component.html.erb b/modules/meeting/app/components/meeting_sections/backlogs/header_component.html.erbnew file mode 100644index 00000000000..8ad819e39be--- /dev/null+++ b/modules/meeting/app/components/meeting_sections/backlogs/header_component.html.erb@@ -0,0 +1,7 @@+<%=+ component_wrapper do+ if show?+ render(Primer::OpenProject::BorderBox::CollapsibleHeader.new(title: I18n.t("label_agenda_backlog"), box: @box, description: I18n.t("text_agenda_backlog"), count: @backlog.agenda_items.count, collapsed: @collapsed))+ end+ end+%>diff --git a/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb b/modules/meeting/app/components/meeting_sections/backlogs/header_component.rbnew file mode 100644index 00000000000..8b2f7c6cfd4--- /dev/null+++ b/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb@@ -0,0 +1,85 @@+# 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 Backlogs::HeaderComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(backlog:, box: nil)+ super++ # binding.pry+ @backlog = backlog+ @meeting = backlog.meeting+ @box = box+ @collapsed = collapsed?+ end++ private++ def show?+ end++ def collapsed?+ if @meeting.open?+ false+ elsif @meeting.in_progress?+ true+ end+ 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+enddiff --git a/modules/meeting/app/components/meeting_sections/header_component.html.erb b/modules/meeting/app/components/meeting_sections/header_component.html.erbindex bbaea7e7b7c..dacf46f6867 100644--- a/modules/meeting/app/components/meeting_sections/header_component.html.erb+++ b/modules/meeting/app/components/meeting_sections/header_component.html.erb@@ -14,7 +14,7 @@endend- if @meeting_section.agenda_items_sum_duration_in_minutes > 0 && !backlog?+ if @meeting_section.agenda_items_sum_duration_in_minutes > 0grid.with_area(:duration, Primer::Beta::Text, color: :subtle, mr: 1) dorender(Primer::Beta::Text.new(font_weight: :normal, color: :subtle)) dorender(OpenProject::Common::DurationComponent.new(@meeting_section.agenda_items_sum_duration_in_minutes, :minutes, abbreviated: true))@@ -22,24 +22,6 @@endend- 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") doif editable?render(Primer::Alpha::ActionMenu.new(data: { test_selector: "meeting-section-action-menu" })) do |menu|@@ -57,14 +39,6 @@endendend-- 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- endendelseprimer_form_with(diff --git a/modules/meeting/app/components/meeting_sections/header_component.rb b/modules/meeting/app/components/meeting_sections/header_component.rbindex 8e2aaaddba5..35ef3da18ab 100644--- a/modules/meeting/app/components/meeting_sections/header_component.rb+++ b/modules/meeting/app/components/meeting_sections/header_component.rb@@ -33,15 +33,13 @@ module MeetingSectionsinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable- def initialize(meeting_section:, state: :show, first_and_last: [], expanded: true)+ def initialize(meeting_section:, state: :show, first_and_last: [])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 = expandedendprivate@@ -164,9 +162,5 @@ module MeetingSectionsitem.with_leading_visual_icon(icon: :trash)endend-- def backlog?- @meeting_section == @meeting.backlog- endendenddiff --git a/modules/meeting/app/components/meeting_sections/show_component.html.erb b/modules/meeting/app/components/meeting_sections/show_component.html.erbindex d067b55a575..f8bfc638875 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,11 @@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, expanded: @expanded))+ render(MeetingSections::HeaderComponent.new(meeting_section: @meeting_section, state: @state))+ end+ elsif render_backlog? && [email protected]?+ component.with_header do+ render(MeetingSections::Backlogs::HeaderComponent.new(backlog: @meeting_section, box: component))endendif render_new_button_in_section?@@ -17,7 +21,7 @@endendend- elsif @expanded+ elsefirst_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.rbindex 768152991af..1886f7add28 100644--- a/modules/meeting/app/components/meeting_sections/show_component.rb+++ b/modules/meeting/app/components/meeting_sections/show_component.rb@@ -37,9 +37,10 @@ module MeetingSectionswith_collection_parameter :meeting_sectiondef initialize(meeting_section:, first_and_last: [], form_hidden: true, form_type: :simple, insert_target_modified: true,- force_wrapper: false, state: :show, expanded: true)+ force_wrapper: false, state: :show, collapsed: false)super+ # binding.pry@meeting = meeting_section.meeting@meeting_section = meeting_section@meeting_agenda_items = meeting_section.agenda_items@@ -49,7 +50,7 @@ module MeetingSections@insert_target_modified = insert_target_modified@force_wrapper = force_wrapper@state = state- @expanded = expanded+ @collapsed = collapsedendprivate@@ -71,6 +72,8 @@ module MeetingSectionsenddef render_section_wrapper?+ return false if render_backlog?+@force_wrapper || !@meeting_section.untitled? || @meeting.sections.count > 1end@@ -94,5 +97,9 @@ module MeetingSections"target-allowed-drag-type": "agenda-item" # the type of dragged items which are allowed to be dropped in this target}end++ def render_backlog?+ @meeting_section == @meeting.backlog+ endendenddiff --git a/modules/meeting/app/components/meetings/show_component.html.erb b/modules/meeting/app/components/meetings/show_component.html.erbindex dbce8f3012a..9a3eaa89b7c 100644--- a/modules/meeting/app/components/meetings/show_component.html.erb+++ b/modules/meeting/app/components/meetings/show_component.html.erb@@ -17,7 +17,7 @@endagenda.with_row do- render(MeetingSections::BacklogComponent.new(meeting: @meeting))+ render(MeetingSections::Backlogs::ContainerComponent.new(meeting: @meeting))endagenda.with_row(mt: 3, display: [:block, nil, :none]) dodiff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex ea44b942cc4..2ce98364b4e 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -202,14 +202,6 @@ module Meetingsupdate_new_button_via_turbo_stream(disabled: false) if form_hidden == trueend- 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(@@ -348,12 +340,19 @@ module Meetingsendend- def update_section_header_via_turbo_stream(meeting_section: @meeting_section, state: :show, expanded: true)+ def update_section_header_via_turbo_stream(meeting_section: @meeting_section, state: :show)update_via_turbo_stream(component: MeetingSections::HeaderComponent.new(meeting_section:,- state:,- expanded:+ state:+ )+ )+ end++ def update_backlog_via_turbo_stream(meeting: @meeting)+ update_via_turbo_stream(+ component: MeetingSections::Backlogs::ContainerComponent.new(+ meeting: meeting))enddiff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rbindex 9e2c13de404..c2e827c2ed8 100644--- a/modules/meeting/app/controllers/meeting_sections_controller.rb+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb@@ -170,16 +170,6 @@ class MeetingSectionsController < ApplicationControllerrespond_with_turbo_streamsend- 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-privatedef set_meeting@@ -214,8 +204,4 @@ class MeetingSectionsController < ApplicationController# show additional base error messagerender_base_error_in_flash_message_via_turbo_stream(call.errors)end-- def toggle_params- @toggle_params ||= params.permit(:id, :expanded)- endenddiff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rbindex daf304ef7e1..7e42f08ddfa 100644--- a/modules/meeting/app/controllers/meetings_controller.rb+++ b/modules/meeting/app/controllers/meetings_controller.rb@@ -286,13 +286,10 @@ class MeetingsController < ApplicationControllercase params[:state]when "open"@meeting.open!- expanded = truewhen "closed"@meeting.closed!- expanded = nilwhen "in_progress"@meeting.in_progress!- expanded = falseendif @meeting.errors.any?@@ -301,10 +298,6 @@ class MeetingsController < ApplicationControllerupdate_all_via_turbo_streamend- @meeting_section = @meeting.backlog- update_section_header_via_turbo_stream(expanded: expanded)- update_section_via_turbo_stream(expanded: expanded)-respond_with_turbo_streamsenddiff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.ymlindex 39b4eef1067..2e26e8e7209 100644--- a/modules/meeting/config/locales/en.yml+++ b/modules/meeting/config/locales/en.yml@@ -430,7 +430,6 @@ en: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}"'diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rbindex 87d11300988..f2ff0936874 100644--- a/modules/meeting/config/routes.rb+++ b/modules/meeting/config/routes.rb@@ -119,7 +119,6 @@ Rails.application.routes.draw doget :cancel_editput :dropput :move- get :toggleendendresources :outcomes, controller: "meeting_outcomes" dodiff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rbindex 44adb9676b5..a522fb332c7 100644--- a/modules/meeting/lib/open_project/meeting/engine.rb+++ b/modules/meeting/lib/open_project/meeting/engine.rb@@ -48,8 +48,7 @@ module OpenProject::Meetingmeeting_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],- meeting_sections: %i[toggle]+ recurring_meetings: %i[index show new create download_ics]},permissible_on: :projectpermission :create_meetings,