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

Update actions to work with series backlogs

Mir Bhatia0617b26601d8
diff --git a/frontend/src/stimulus/controllers/keep-collapsed-state.controller.ts b/frontend/src/stimulus/controllers/add-meeting-params.controller.ts
similarity index 89%
rename from frontend/src/stimulus/controllers/keep-collapsed-state.controller.ts
rename to frontend/src/stimulus/controllers/add-meeting-params.controller.ts
index d0ef42a5c98..6f72cc83fa2 100644
--- a/frontend/src/stimulus/controllers/keep-collapsed-state.controller.ts
+++ b/frontend/src/stimulus/controllers/add-meeting-params.controller.ts
@@ -32,8 +32,11 @@ import { ApplicationController } from 'stimulus-use';
import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';
import { appendCollapsedState } from '../helpers/collapsible-helper';
-export default class KeepCollapsedStateController extends ApplicationController {
+export default class AddMeetingParamsController extends ApplicationController {
private turboRequests:TurboRequestsService;
+ static targets = ['container'];
+
+ declare readonly containerTarget:HTMLElement;
async connect() {
const context = await window.OpenProject.getPluginContext();
@@ -47,6 +50,7 @@ export default class KeepCollapsedStateController extends ApplicationController
const url = new URL(target.dataset.href!, window.location.origin);
appendCollapsedState(url.searchParams);
+ url.searchParams.append('current_meeting_id', this.containerTarget.dataset.meeting!);
void this
.turboRequests
diff --git a/frontend/src/stimulus/setup.ts b/frontend/src/stimulus/setup.ts
index 50ba7e3dcd9..0994c26908b 100644
--- a/frontend/src/stimulus/setup.ts
+++ b/frontend/src/stimulus/setup.ts
@@ -20,7 +20,7 @@ import PatternInputController from './controllers/pattern-input.controller';
import HoverCardTriggerController from './controllers/hover-card-trigger.controller';
import ScrollIntoViewController from './controllers/scroll-into-view.controller';
import CkeditorFocusController from './controllers/ckeditor-focus.controller';
-import KeepCollapsedStateController from './controllers/keep-collapsed-state.controller';
+import AddMeetingParamsController from './controllers/add-meeting-params.controller';
declare global {
interface Window {
@@ -56,4 +56,4 @@ instance.register('keep-scroll-position', KeepScrollPositionController);
instance.register('pattern-input', PatternInputController);
instance.register('scroll-into-view', ScrollIntoViewController);
instance.register('ckeditor-focus', CkeditorFocusController);
-instance.register('keep-collapsed-state', KeepCollapsedStateController);
+instance.register('add-meeting-params', AddMeetingParamsController);
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
index c3a33b187fa..94024261ac1 100644
--- 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
@@ -77,7 +77,7 @@
move_actions(menu)
end
- if !in_template?
+ if !in_template? || (in_template? && in_backlog?)
menu.with_divider if OpenProject::FeatureDecisions.meeting_backlogs_active?
move_to_current_meeting_action_item(menu) if move_to_current_meeting_action?
move_to_backlog_action_item(menu) if move_to_backlog_action?
@@ -88,8 +88,11 @@
move_to_next_meeting_action_item(menu)
end
- menu.with_divider
- copy_action_item(menu)
+ if !in_backlog?
+ menu.with_divider
+ copy_action_item(menu)
+ end
+
menu.with_divider
delete_action_item(menu)
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 be737e35486..c3c5ab9de39 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
@@ -193,7 +193,7 @@ module MeetingAgendaItems
menu.with_item(label: I18n.t(:label_agenda_item_move_to_backlog),
tag: :button,
content_arguments: { data: {
- action: "click->keep-collapsed-state#interceptMoveTo",
+ action: "click->add-meeting-params#interceptMoveTo",
href: drop_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item, type: :to_backlog)
} }) do |item|
item.with_leading_visual_icon(icon: "discussion-outdated")
@@ -204,7 +204,7 @@ module MeetingAgendaItems
menu.with_item(label: I18n.t(:label_agenda_item_move_to_current_meeting),
tag: :button,
content_arguments: { data: {
- action: "click->keep-collapsed-state#interceptMoveTo",
+ action: "click->add-meeting-params#interceptMoveTo",
href: drop_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item, type: :to_current)
} }) do |item|
item.with_leading_visual_icon(icon: "cross-reference")
diff --git a/modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erb b/modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erb
index 6e34fe7443f..7f17ee72964 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erb
@@ -1,5 +1,5 @@
<%=
- component_wrapper do
+ component_wrapper(data: wrapper_data_attributes) do
if show?
flex_layout(mb: 3) do |flex|
flex.with_row(mt: 3) do
@@ -10,7 +10,8 @@
render(
MeetingSections::ShowComponent.new(
meeting_section: @backlog,
- collapsed: @collapsed
+ collapsed: @collapsed,
+ current_meeting: @meeting
)
)
end
diff --git a/modules/meeting/app/components/meeting_sections/backlogs/container_component.rb b/modules/meeting/app/components/meeting_sections/backlogs/container_component.rb
index 415158d3c0f..af1a55c6043 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/container_component.rb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/container_component.rb
@@ -49,5 +49,12 @@ module MeetingSections
OpenProject::FeatureDecisions.meeting_backlogs_active?
end
+
+ def wrapper_data_attributes
+ {
+ "add-meeting-params-target": "container",
+ meeting: @meeting.id
+ }
+ end
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.rb
index 0e35b4b9410..fa250597adc 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb
@@ -34,22 +34,27 @@ module MeetingSections
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(backlog:, collapsed:, box: nil)
+ def initialize(backlog:, collapsed:, current_meeting:, box: nil)
super
@backlog = backlog
@meeting = backlog.meeting
@box = box
+ @current_meeting = current_meeting
+ # When a specific collapsed state is needed, collapsed is passed in as either true or false
+ # When the collapsed state needs to be determined based on meeting status, collapsed is nil and set via default
@collapsed = collapsed.nil? ? default : collapsed
end
private
def default
- if @meeting.open?
+ # For a series backlog, the status of the current occurrence needs to be checked instead of the template
+ # For a one-time backlog, @meeting == @current_meeting
+ if @current_meeting.open?
false
- elsif @meeting.in_progress?
+ elsif @current_meeting.in_progress?
true
end
end
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 b98e72b463d..bafda26f1b4 100644
--- a/modules/meeting/app/components/meeting_sections/show_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/show_component.html.erb
@@ -7,7 +7,7 @@
end
elsif render_backlog?
component.with_header do
- render(MeetingSections::Backlogs::HeaderComponent.new(backlog: @meeting_section, box: component, collapsed: @collapsed))
+ render(MeetingSections::Backlogs::HeaderComponent.new(backlog: @meeting_section, box: component, collapsed: @collapsed, current_meeting: @current_meeting))
end
end
if render_new_button_in_section?
diff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rb
index d4f4153df7b..fbf4f4a2620 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, collapsed: nil)
+ force_wrapper: false, state: :show, collapsed: nil, current_meeting: nil)
super
@meeting = meeting_section.meeting
@@ -50,6 +50,7 @@ module MeetingSections
@force_wrapper = force_wrapper
@state = state
@collapsed = collapsed
+ @current_meeting = current_meeting
end
private
diff --git a/modules/meeting/app/components/meetings/show_component.rb b/modules/meeting/app/components/meetings/show_component.rb
index eade7b8a981..ef09de85cbd 100644
--- a/modules/meeting/app/components/meetings/show_component.rb
+++ b/modules/meeting/app/components/meetings/show_component.rb
@@ -43,7 +43,7 @@ module Meetings
def wrapper_data_attributes
{
- controller: "meetings-drag-and-drop keep-collapsed-state",
+ controller: "meetings-drag-and-drop add-meeting-params",
"application-target": "dynamic"
}
end
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 b432818911a..da4bf5a3cd3 100644
--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
@@ -292,7 +292,7 @@ module Meetings
# update the old section
if old_section.backlog?
- update_backlog_via_turbo_stream(collapsed:)
+ update_backlog_via_turbo_stream(meeting: current_section.meeting, collapsed:)
else
update_section_header_via_turbo_stream(meeting_section: old_section)
@@ -305,7 +305,7 @@ module Meetings
# update the new section
if current_section.backlog?
- update_backlog_via_turbo_stream(collapsed:)
+ update_backlog_via_turbo_stream(meeting: old_section.meeting, collapsed:)
else
update_section_header_via_turbo_stream(meeting_section: current_section)
@@ -457,7 +457,6 @@ 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 6760b201c02..3eda8a7c3a7 100644
--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -93,11 +93,13 @@ class MeetingAgendaItemsController < ApplicationController
if call.success?
reset_meeting_from_agenda_item
# enable continue editing
- add_item_via_turbo_stream(clear_slate: false)
update_header_component_via_turbo_stream
update_sidebar_details_component_via_turbo_stream
if @meeting_agenda_item.meeting_section.backlog?
- update_backlog_via_turbo_stream(collapsed: false)
+ update_section_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section, collapsed: false)
+ update_new_button_via_turbo_stream(disabled: false)
+ else
+ add_item_via_turbo_stream(clear_slate: false)
end
else
# show errors
@@ -156,12 +158,13 @@ class MeetingAgendaItemsController < ApplicationController
if call.success?
reset_meeting_from_agenda_item
- remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?)
update_header_component_via_turbo_stream
- update_section_header_via_turbo_stream(meeting_section: section) if section&.reload.present?
update_sidebar_details_component_via_turbo_stream
if section.backlog?
- update_backlog_via_turbo_stream(collapsed: false)
+ update_section_via_turbo_stream(meeting_section: section, collapsed: false)
+ else
+ remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?)
+ update_section_header_via_turbo_stream(meeting_section: section) if section&.reload.present?
end
else
generic_call_failure_response(call)
@@ -305,7 +308,8 @@ class MeetingAgendaItemsController < ApplicationController
def assign_drop_params # rubocop:disable Metrics/AbcSize
@target_id, @position =
if params[:type] == "to_current"
- section = @meeting.sections.reorder(position: :desc).first
+ meeting = Meeting.find_by(id: params[:current_meeting_id])
+ section = meeting.sections.reorder(position: :desc).first
[section&.id, section&.last_position]
elsif params[:type] == "to_backlog"
[@meeting.backlog.id, @meeting.backlog.last_position]
diff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rb
index 84bc6d0a0c9..7eb8d7d87f1 100644
--- a/modules/meeting/app/controllers/meeting_sections_controller.rb
+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb
@@ -173,7 +173,7 @@ class MeetingSectionsController < ApplicationController
def clear_backlog
errors = []
-
+ meeting_section = @meeting.backlog
@meeting.backlog.agenda_items.each do |item|
call = ::MeetingAgendaItems::DeleteService
.new(user: current_user, model: item)
@@ -182,7 +182,7 @@ class MeetingSectionsController < ApplicationController
errors << call.errors unless call.success?
end
- update_backlog_via_turbo_stream(collapsed: true)
+ update_section_via_turbo_stream(collapsed: true, meeting_section:)
render_error_flash_message_via_turbo_stream(message: t("text_backlog_clear_error")) if errors.any?
respond_with_turbo_streams