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 current_occurrence parameter to always keep reference

Mir Bhatia150f66448db7
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component.rb
index 8121499c6a6..18f20b2d6e8 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -40,7 +41,8 @@ module MeetingAgendaItems
state: :show,
container: nil,
display_notes_input: nil,
- first_and_last: []
+ first_and_last: [],
+ current_occurrence: nil
)
super
@@ -49,6 +51,7 @@ module MeetingAgendaItems
@display_notes_input = display_notes_input
@container = container
@first_and_last = first_and_last
+ @current_occurrence = current_occurrence
end
def wrapper_uniq_by
@@ -73,7 +76,8 @@ module MeetingAgendaItems
def child_component_params
{
meeting_agenda_item: @meeting_agenda_item,
- display_notes_input: (@display_notes_input if @state == :edit)
+ display_notes_input: (@display_notes_input if @state == :edit),
+ current_occurrence: @current_occurrence
}.compact
end
@@ -89,7 +93,8 @@ module MeetingAgendaItems
id: @meeting_agenda_item.id,
"draggable-id": @meeting_agenda_item.id,
"draggable-type": "agenda-item",
- "drop-url": drop_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item)
+ "drop-url": drop_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,
+ current_occurrence: @current_occurrence)
}
}
end
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb
index c55ff278b7d..ea5a7d30bb8 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -32,12 +33,13 @@ module MeetingAgendaItems
include ApplicationHelper
include OpPrimer::ComponentHelpers
- def initialize(meeting_agenda_item:, display_notes_input: nil)
+ def initialize(meeting_agenda_item:, display_notes_input: nil, current_occurrence: nil)
super
@meeting_agenda_item = meeting_agenda_item
@type = @meeting_agenda_item.item_type.to_sym
@display_notes_input = display_notes_input
+ @current_occurrence = current_occurrence
end
def call
@@ -47,8 +49,10 @@ module MeetingAgendaItems
meeting_section: @meeting_agenda_item.meeting_section,
meeting_agenda_item: @meeting_agenda_item,
method: :put,
- submit_path: meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item, format: :turbo_stream),
- cancel_path: cancel_edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),
+ submit_path: meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,
+ format: :turbo_stream, current_occurrence: @current_occurrence),
+ cancel_path: cancel_edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,
+ current_occurrence: @current_occurrence),
type: @type,
display_notes_input: @display_notes_input
))
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 28b611ebfef..c5532734bfb 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
@@ -36,13 +36,14 @@ module MeetingAgendaItems
include OpPrimer::ComponentHelpers
include Redmine::I18n
- def initialize(meeting_agenda_item:, first_and_last: [])
+ def initialize(meeting_agenda_item:, first_and_last: [], current_occurrence: nil)
super
@meeting_agenda_item = meeting_agenda_item
@meeting = meeting_agenda_item.meeting
@series = @meeting.recurring_meeting
@first_and_last = first_and_last
+ @current_occurrence = current_occurrence
end
def wrapper_uniq_by
@@ -101,7 +102,8 @@ module MeetingAgendaItems
return unless editable?
menu.with_item(label: t("label_edit"),
- href: edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),
+ href: edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,
+ current_occurrence: @current_occurrence),
content_arguments: {
data: { "turbo-stream": true }
}) do |item|
@@ -112,7 +114,7 @@ module MeetingAgendaItems
def add_note_action_item(menu)
menu.with_item(label: t("label_agenda_item_add_notes"),
href: edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,
- display_notes_input: true),
+ display_notes_input: true, current_occurrence: @current_occurrence),
content_arguments: {
data: { "turbo-stream": true }
}) do |item|
@@ -123,7 +125,8 @@ module MeetingAgendaItems
def add_outcome_action_item(menu)
menu.with_item(label: t("label_agenda_item_add_outcome"),
href: new_meeting_outcome_path(@meeting_agenda_item.meeting,
- meeting_agenda_item_id: @meeting_agenda_item&.id),
+ meeting_agenda_item_id: @meeting_agenda_item&.id,
+ current_occurrence: @current_occurrence),
content_arguments: {
data: { "turbo-stream": true }
}) do |item|
@@ -151,8 +154,8 @@ module MeetingAgendaItems
menu.with_item(
label: t(:label_agenda_item_move_to_next),
href: move_to_next_dialog_meeting_agenda_item_path(@meeting_agenda_item.meeting,
- @meeting_agenda_item,
- datetime: next_date.iso8601),
+ @meeting_agenda_item,
+ datetime: next_date.iso8601),
content_arguments: {
data: { controller: "async-dialog" }
}
@@ -176,7 +179,8 @@ module MeetingAgendaItems
label = @meeting_agenda_item.work_package_id.present? ? wp_agenda_item_delete_label : t(:text_destroy)
menu.with_item(label:,
scheme: :danger,
- href: meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),
+ href: meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,
+ current_occurrence: @current_occurrence),
form_arguments: {
method: :delete, data: { turbo_confirm: t(:text_are_you_sure), "turbo-stream": true }
}) do |item|
@@ -190,8 +194,12 @@ module MeetingAgendaItems
def move_action_item(menu, move_to, label_text, icon)
menu.with_item(label: label_text,
- href: move_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,
- move_to:),
+ href: move_meeting_agenda_item_path(
+ @meeting_agenda_item.meeting,
+ @meeting_agenda_item,
+ move_to:,
+ current_occurrence: @current_occurrence
+ ),
form_arguments: {
method: :put, data: { "turbo-stream": true }
}) do |item|
diff --git a/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.html.erb
index c29cc8ef0e7..02136e27091 100644
--- a/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.html.erb
@@ -37,7 +37,8 @@ See COPYRIGHT and LICENSE files for more details.
action: move_to_next_meeting_agenda_item_path(
@agenda_item.meeting,
@agenda_item,
- datetime: @datetime
+ datetime: @datetime,
+ current_occurrence: @current_occurrence
),
method: :post
}
diff --git a/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb
index 11911cb3fa0..d8b17a143d2 100644
--- a/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb
@@ -10,7 +10,7 @@
label: t("activerecord.models.meeting_agenda_item"),
tag: :a,
content_arguments: {
- href: new_meeting_agenda_item_path(@meeting, type: "simple", meeting_section_id: @meeting_section&.id),
+ href: new_meeting_agenda_item_path(@meeting, type: "simple", meeting_section_id: @meeting_section&.id, current_occurrence: @current_occurrence),
data: { "turbo-stream": true }
}
)
@@ -18,7 +18,7 @@
label: t("activerecord.models.work_package"),
tag: :a,
content_arguments: {
- href: new_meeting_agenda_item_path(@meeting, type: "work_package", meeting_section_id: @meeting_section&.id),
+ href: new_meeting_agenda_item_path(@meeting, type: "work_package", meeting_section_id: @meeting_section&.id, current_occurrence: @current_occurrence),
data: { "turbo-stream": true }
}
)
diff --git a/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb b/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb
index 5734fb193ad..b9b5e7b9f5a 100644
--- a/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb
@@ -33,12 +33,13 @@ module MeetingAgendaItems
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(meeting:, meeting_section: nil, disabled: false)
+ def initialize(meeting:, meeting_section: nil, disabled: false, current_occurrence: nil)
super
@meeting = meeting
@meeting_section = meeting_section
@disabled = @meeting.closed? || disabled
+ @current_occurrence = current_occurrence
end
private
diff --git a/modules/meeting/app/components/meeting_agenda_items/new_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/new_component.html.erb
index a8cbb800841..d6981db0330 100644
--- a/modules/meeting/app/components/meeting_agenda_items/new_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/new_component.html.erb
@@ -9,8 +9,8 @@
meeting_agenda_item: @meeting_agenda_item,
meeting_section: @meeting_section,
method: :post,
- submit_path: meeting_agenda_items_path(@meeting, format: :turbo_stream),
- cancel_path: cancel_new_meeting_agenda_items_path(@meeting, meeting_section_id: @meeting_section&.id),
+ submit_path: meeting_agenda_items_path(@meeting, format: :turbo_stream, current_occurrence: @current_occurrence),
+ cancel_path: cancel_new_meeting_agenda_items_path(@meeting, meeting_section_id: @meeting_section&.id, current_occurrence: @current_occurrence),
type: @type
)
)
diff --git a/modules/meeting/app/components/meeting_agenda_items/new_component.rb b/modules/meeting/app/components/meeting_agenda_items/new_component.rb
index f3dde95f1b0..b9eff6da7bb 100644
--- a/modules/meeting/app/components/meeting_agenda_items/new_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/new_component.rb
@@ -33,7 +33,7 @@ module MeetingAgendaItems
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(meeting:, meeting_section: nil, meeting_agenda_item: nil, hidden: true, type: :simple)
+ def initialize(meeting:, meeting_section: nil, meeting_agenda_item: nil, hidden: true, type: :simple, current_occurrence: nil)
super
@meeting = meeting
@@ -41,6 +41,7 @@ module MeetingAgendaItems
@meeting_agenda_item = meeting_agenda_item || build_agenda_item
@hidden = hidden
@type = type
+ @current_occurrence = current_occurrence
end
private
diff --git a/modules/meeting/app/components/meeting_sections/backlogs/clear_backlog_dialog_component.html.erb b/modules/meeting/app/components/meeting_sections/backlogs/clear_backlog_dialog_component.html.erb
index 47fe3abd501..97bd5f5e46e 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/clear_backlog_dialog_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/clear_backlog_dialog_component.html.erb
@@ -5,7 +5,7 @@
confirm_button_text: I18n.t(:label_backlog_clear_button),
title: I18n.t(:label_backlog_clear),
form_arguments: {
- action: clear_backlog_meeting_sections_path(@meeting),
+ action: clear_backlog_meeting_sections_path(@meeting, current_occurrence: @current_occurrence),
method: :post
}
)
diff --git a/modules/meeting/app/components/meeting_sections/backlogs/clear_backlog_dialog_component.rb b/modules/meeting/app/components/meeting_sections/backlogs/clear_backlog_dialog_component.rb
index 2040fcd69fb..eb6cd492296 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/clear_backlog_dialog_component.rb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/clear_backlog_dialog_component.rb
@@ -33,10 +33,11 @@ module MeetingSections
include ApplicationHelper
include OpTurbo::Streamable
- def initialize(meeting)
+ def initialize(meeting, current_occurrence:)
super
@meeting = meeting
+ @current_occurrence = current_occurrence
end
private
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 7f17ee72964..83d60ba1d01 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
@@ -11,7 +11,7 @@
MeetingSections::ShowComponent.new(
meeting_section: @backlog,
collapsed: @collapsed,
- current_meeting: @meeting
+ current_occurrence: @meeting
)
)
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 a9740226af0..a1f4bdd3de1 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb
@@ -34,13 +34,13 @@ module MeetingSections
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(backlog:, collapsed:, current_meeting:, box: nil)
+ def initialize(backlog:, collapsed:, current_occurrence:, box: nil)
super
@backlog = backlog
@meeting = backlog.meeting
@box = box
- @current_meeting = current_meeting
+ @current_occurrence = current_occurrence
# 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
@@ -49,10 +49,10 @@ module MeetingSections
private
- def default_collapsed_state
+ def default_collapsed_state # rubocop:disable Naming/PredicateMethod
# 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
- @current_meeting.in_progress?
+ # For a one-time backlog, @meeting == @current_occurrence
+ @current_occurrence.in_progress?
end
def description
@@ -70,7 +70,7 @@ module MeetingSections
def clear_action_item(menu)
menu.with_item(
label: I18n.t(:label_backlog_clear),
- href: clear_backlog_dialog_meeting_sections_path(@meeting),
+ href: clear_backlog_dialog_meeting_sections_path(@meeting, current_occurrence: @current_occurrence),
scheme: :danger,
tag: :a,
content_arguments: {
@@ -84,7 +84,8 @@ module MeetingSections
def add_agenda_item_action(menu)
menu.with_item(
label: t("label_agenda_item_add", count: 1),
- href: new_meeting_agenda_item_path(@meeting, type: "simple", meeting_section_id: @backlog.id),
+ href: new_meeting_agenda_item_path(@meeting, type: "simple", meeting_section_id: @backlog.id,
+ current_occurrence: @current_occurrence),
content_arguments: {
data: { "turbo-stream": true, "test-selector": "meeting-backlog-add-agenda-item-from-menu" }
}
@@ -96,7 +97,8 @@ module MeetingSections
def add_work_package_action(menu)
menu.with_item(
label: t("label_agenda_item_work_package_add", count: 1),
- href: new_meeting_agenda_item_path(@meeting, type: "work_package", meeting_section_id: @backlog.id),
+ href: new_meeting_agenda_item_path(@meeting, type: "work_package", meeting_section_id: @backlog.id,
+ current_occurrence: @current_occurrence),
content_arguments: {
data: { "turbo-stream": true, "test-selector": "meeting-backlog-add-work-package-from-menu" }
}
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 bafda26f1b4..53eff3ec45d 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, current_meeting: @current_meeting))
+ render(MeetingSections::Backlogs::HeaderComponent.new(backlog: @meeting_section, box: component, collapsed: @collapsed, current_occurrence: @current_occurrence))
end
end
if render_new_button_in_section?
@@ -17,7 +17,7 @@
render(Primer::Beta::Text.new(color: :subtle)) { t("meeting_section.empty_text") }
end
empty_list_container.with_column do
- render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting, meeting_section: @meeting_section))
+ render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting, meeting_section: @meeting_section, current_occurrence: @current_occurrence))
end
end
end
@@ -28,13 +28,14 @@
MeetingAgendaItems::ItemComponent.new(
meeting_agenda_item: agenda_item,
container: component,
- first_and_last:
+ first_and_last:,
+ current_occurrence: @current_occurrence
)
)
end
end
component.with_row(p: 0, border_top: 0, id: insert_target_modifier_id) do
- render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, meeting_section: @meeting_section, hidden: @form_hidden, type: @form_type))
+ render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, meeting_section: @meeting_section, hidden: @form_hidden, type: @form_type, current_occurrence: @current_occurrence))
end
end
end
diff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rb
index fbf4f4a2620..190af1cfba5 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, current_meeting: nil)
+ force_wrapper: false, state: :show, collapsed: nil, current_occurrence: nil)
super
@meeting = meeting_section.meeting
@@ -50,7 +50,7 @@ module MeetingSections
@force_wrapper = force_wrapper
@state = state
@collapsed = collapsed
- @current_meeting = current_meeting
+ @current_occurrence = current_occurrence
end
private
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 082ce87b52f..b0fa014c636 100644
--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
@@ -95,25 +95,27 @@ module Meetings
)
end
- def update_show_items_via_turbo_stream(meeting: @meeting)
+ def update_show_items_via_turbo_stream(meeting: @meeting, current_occurrence: nil)
meeting.sections.each do |meeting_section|
- update_show_items_of_section_via_turbo_stream(meeting_section:)
+ update_show_items_of_section_via_turbo_stream(meeting_section:, current_occurrence:)
end
end
- def update_show_items_of_section_via_turbo_stream(meeting_section: @meeting_section)
+ def update_show_items_of_section_via_turbo_stream(current_occurrence:, meeting_section: @meeting_section)
agenda_items = meeting_section.agenda_items.with_includes_to_render
first_and_last = [agenda_items.first, agenda_items.last]
agenda_items.each do |meeting_agenda_item|
update_via_turbo_stream(
- component: MeetingAgendaItems::ItemComponent::ShowComponent.new(meeting_agenda_item:, first_and_last:)
+ component: MeetingAgendaItems::ItemComponent::ShowComponent.new(meeting_agenda_item:, first_and_last:,
+ current_occurrence:)
)
end
end
- def update_new_component_via_turbo_stream(hidden: false, meeting_section: @meeting_section, meeting_agenda_item: nil,
- meeting: @meeting, type: :simple)
+ def update_new_component_via_turbo_stream(hidden: false, meeting_section: @meeting_section,
+ meeting_agenda_item: nil, meeting: @meeting, type: :simple,
+ current_occurrence: nil)
if meeting_section.nil? && meeting_agenda_item.nil?
meeting_section = meeting.sections.last
end
@@ -128,7 +130,8 @@ module Meetings
meeting:,
meeting_section:,
meeting_agenda_item:,
- type:
+ type:,
+ current_occurrence:
)
)
end
@@ -145,12 +148,12 @@ module Meetings
)
end
- def render_agenda_item_form_via_turbo_stream(collapsed:, meeting: @meeting, meeting_section: @meeting_section,
- type: :simple)
+ def render_agenda_item_form_via_turbo_stream(collapsed:, current_occurrence:, meeting: @meeting,
+ meeting_section: @meeting_section, type: :simple)
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:, collapsed:)
+ render_agenda_item_form_in_section_via_turbo_stream(meeting:, meeting_section:, type:, collapsed:, current_occurrence:)
end
update_new_button_via_turbo_stream(disabled: true) unless meeting_section == meeting.backlog
@@ -164,18 +167,19 @@ module Meetings
)
end
- def render_agenda_item_form_in_section_via_turbo_stream(collapsed:, meeting: @meeting, meeting_section: @meeting_section,
- type: :simple)
+ def render_agenda_item_form_in_section_via_turbo_stream(collapsed:, current_occurrence:, meeting: @meeting,
+ meeting_section: @meeting_section, type: :simple)
if meeting_section.nil?
meeting_section = meeting.sections.last
end
if meeting_section.agenda_items.empty?
- update_section_via_turbo_stream(meeting_section:, form_hidden: false, form_type: type, collapsed:)
+ update_section_via_turbo_stream(meeting_section:, form_hidden: false, form_type: type, collapsed:, current_occurrence:)
else
update_new_component_via_turbo_stream(
hidden: false,
meeting_section:,
- type:
+ type:,
+ current_occurrence:
)
end
end
@@ -204,27 +208,30 @@ module Meetings
update_new_button_via_turbo_stream(disabled: false, meeting:) if form_hidden == true
end
- def update_item_via_turbo_stream(state: :show, meeting_agenda_item: @meeting_agenda_item, display_notes_input: nil)
+ def update_item_via_turbo_stream(current_occurrence:, state: :show, meeting_agenda_item: @meeting_agenda_item,
+ display_notes_input: nil)
update_via_turbo_stream(
component: MeetingAgendaItems::ItemComponent.new(
state:,
meeting_agenda_item:,
- display_notes_input:
+ display_notes_input:,
+ current_occurrence:
)
)
- update_show_items_via_turbo_stream
+ update_show_items_via_turbo_stream(current_occurrence:)
end
- def add_item_via_turbo_stream(meeting_agenda_item: @meeting_agenda_item, clear_slate: false) # rubocop:disable Metrics/AbcSize
+ def add_item_via_turbo_stream(current_occurrence:, meeting_agenda_item: @meeting_agenda_item, clear_slate: false) # rubocop:disable Metrics/AbcSize
if clear_slate
update_list_via_turbo_stream(form_hidden: false, form_type: @agenda_item_type)
- elsif meeting_agenda_item.meeting.agenda_items.count == 1 && meeting_agenda_item.meeting.sections.present?
+ elsif meeting_agenda_item.meeting.agenda_items.one? && meeting_agenda_item.meeting.sections.present?
update_list_via_turbo_stream(form_hidden: true)
update_new_component_via_turbo_stream(
hidden: true,
meeting_section: meeting_agenda_item.meeting_section,
- type: @agenda_item_type
+ type: @agenda_item_type,
+ current_occurrence:
)
else
update_section_header_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)
@@ -232,7 +239,8 @@ module Meetings
add_before_via_turbo_stream(
component: MeetingAgendaItems::ItemComponent.new(
state: :show,
- meeting_agenda_item:
+ meeting_agenda_item:,
+ current_occurrence:
),
target_component: MeetingSections::ShowComponent.new(
meeting_section: @meeting_agenda_item.meeting_section
@@ -242,7 +250,8 @@ module Meetings
update_new_component_via_turbo_stream(
hidden: true,
meeting_section: meeting_agenda_item.meeting_section,
- type: @agenda_item_type
+ type: @agenda_item_type,
+ current_occurrence:
)
update_new_button_via_turbo_stream(disabled: false)
@@ -251,44 +260,45 @@ module Meetings
end
end
- def remove_item_via_turbo_stream(meeting_agenda_item: @meeting_agenda_item, clear_slate: false)
+ def remove_item_via_turbo_stream(meeting_agenda_item: @meeting_agenda_item, clear_slate: false, current_occurrence: nil)
if clear_slate
update_list_via_turbo_stream
else
- update_show_items_of_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)
+ update_show_items_of_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section, current_occurrence:)
if meeting_agenda_item.meeting_section.agenda_items.empty?
# Show the empty section state by updating the whole section if items are empty
- update_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)
+ update_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section, current_occurrence:)
else
remove_via_turbo_stream(
component: MeetingAgendaItems::ItemComponent.new(
state: :show,
meeting_agenda_item:,
- display_notes_input: nil
+ display_notes_input: nil,
+ current_occurrence:
)
)
end
end
end
- def move_item_within_section_via_turbo_stream(meeting_agenda_item: @meeting_agenda_item)
- move_item_via_turbo_stream(meeting_agenda_item:)
+ def move_item_within_section_via_turbo_stream(current_occurrence:, meeting_agenda_item: @meeting_agenda_item)
+ move_item_via_turbo_stream(meeting_agenda_item:, current_occurrence:)
# Update the header for updated timestamp
update_header_component_via_turbo_stream unless @meeting_agenda_item.meeting_section.backlog?
# update the displayed time slots of all other items in the section
- update_show_items_of_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)
+ update_show_items_of_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section, current_occurrence:)
end
# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
- def move_item_to_other_section_via_turbo_stream(old_section:, current_section:, meeting_agenda_item: @meeting_agenda_item,
- collapsed: nil)
+ def move_item_to_other_section_via_turbo_stream(old_section:, current_section:, current_occurrence:,
+ meeting_agenda_item: @meeting_agenda_item, collapsed: nil)
# old_section.meeting and current_section.meeting are different when items are moved to/from a series backlog
current_section_meeting = current_section.meeting
old_section_meeting = old_section.meeting
- move_item_via_turbo_stream(meeting_agenda_item:)
+ move_item_via_turbo_stream(meeting_agenda_item:, current_occurrence:)
# update the old section
if old_section.backlog?
@@ -305,14 +315,14 @@ module Meetings
update_section_via_turbo_stream(meeting_section: old_section)
end
else
- update_show_items_of_section_via_turbo_stream(meeting_section: old_section)
+ update_show_items_of_section_via_turbo_stream(meeting_section: old_section, current_occurrence:)
end
end
# update the new section
if current_section.backlog?
update_backlog_via_turbo_stream(meeting: old_section_meeting, collapsed:)
- elsif current_section_meeting.sections.count == 1 && current_section_meeting.agenda_items.count == 1
+ elsif current_section_meeting.sections.one? && current_section_meeting.agenda_items.one?
# Special case when first item is being moved from backlog to empty meeting
update_list_via_turbo_stream(meeting: current_section_meeting)
update_header_component_via_turbo_stream(meeting: current_section_meeting)
@@ -320,19 +330,19 @@ module Meetings
update_header_component_via_turbo_stream(meeting: current_section_meeting)
update_section_header_via_turbo_stream(meeting_section: current_section)
- if current_section.agenda_items.count == 1
+ if current_section.agenda_items.one?
update_section_via_turbo_stream(meeting_section: current_section)
else
- update_show_items_of_section_via_turbo_stream(meeting_section: current_section)
+ update_show_items_of_section_via_turbo_stream(meeting_section: current_section, current_occurrence:)
end
end
end
# rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
- def move_item_via_turbo_stream(meeting_agenda_item: @meeting_agenda_item)
+ def move_item_via_turbo_stream(current_occurrence:, meeting_agenda_item: @meeting_agenda_item)
# Note: The `remove_component` and the `component` are pointing to the same
# component, but we still need to instantiate them separately, otherwise re-adding
- # of the item will render and empty component.
+ # of the item will render an empty component.
remove_component = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)
remove_via_turbo_stream(component: remove_component)
@@ -341,11 +351,13 @@ module Meetings
target_component = if meeting_agenda_item.lower_item
MeetingAgendaItems::ItemComponent.new(
state: :show,
- meeting_agenda_item: meeting_agenda_item.lower_item
+ meeting_agenda_item: meeting_agenda_item.lower_item,
+ current_occurrence:
)
else
MeetingSections::ShowComponent.new(
- meeting_section: meeting_agenda_item.meeting_section
+ meeting_section: meeting_agenda_item.meeting_section,
+ current_occurrence:
)
end
@@ -385,7 +397,7 @@ module Meetings
end
def update_section_via_turbo_stream(meeting_section: @meeting_section, form_hidden: true, form_type: :simple,
- force_wrapper: false, state: :show, collapsed: nil)
+ force_wrapper: false, state: :show, collapsed: nil, current_occurrence: nil)
update_via_turbo_stream(
component: MeetingSections::ShowComponent.new(
meeting_section:,
@@ -393,7 +405,8 @@ module Meetings
form_hidden:,
force_wrapper:,
state:,
- collapsed:
+ collapsed:,
+ current_occurrence:
)
)
end
diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
index 9f11be858b9..72650648943 100644
--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -53,30 +53,33 @@ class MeetingAgendaItemsController < ApplicationController
collapsed = false
end
end
- render_agenda_item_form_via_turbo_stream(meeting_section:, collapsed:, type: @agenda_item_type)
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
+ render_agenda_item_form_via_turbo_stream(meeting_section:, collapsed:, type: @agenda_item_type, current_occurrence:)
end
respond_with_turbo_streams
end
def cancel_new
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
if params[:meeting_section_id].present?
meeting_section = MeetingSection.find_by(id: params[:meeting_section_id])
if meeting_section.agenda_items.empty?
if meeting_section.backlog?
collapsed = false
end
- update_section_via_turbo_stream(form_hidden: true, meeting_section:, collapsed:)
+ update_section_via_turbo_stream(form_hidden: true, meeting_section:, collapsed:, current_occurrence:)
end
end
- update_new_component_via_turbo_stream(hidden: true, meeting_section:)
+ update_new_component_via_turbo_stream(hidden: true, meeting_section:, current_occurrence:)
update_new_button_via_turbo_stream(disabled: false) unless meeting_section&.backlog?
respond_with_turbo_streams
end
def create # rubocop:disable Metrics/AbcSize
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
call = ::MeetingAgendaItems::CreateService
.new(user: current_user)
.call(
@@ -90,18 +93,19 @@ class MeetingAgendaItemsController < ApplicationController
if call.success?
if @meeting_agenda_item.meeting_section.backlog?
- update_section_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section, collapsed: false)
+ update_section_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section, collapsed: false,
+ current_occurrence:)
else
reset_meeting_from_agenda_item
# enable continue editing
update_header_component_via_turbo_stream
update_sidebar_details_component_via_turbo_stream
- add_item_via_turbo_stream(clear_slate: false)
+ add_item_via_turbo_stream(clear_slate: false, current_occurrence:)
end
else
# show errors
update_new_component_via_turbo_stream(
- hidden: false, meeting_agenda_item: @meeting_agenda_item, type: @agenda_item_type
+ hidden: false, meeting_agenda_item: @meeting_agenda_item, type: @agenda_item_type, current_occurrence:
)
render_base_error_in_flash_message_via_turbo_stream(call.errors)
end
@@ -110,8 +114,9 @@ class MeetingAgendaItemsController < ApplicationController
end
def edit
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
if @meeting_agenda_item.editable?
- update_item_via_turbo_stream(state: :edit, display_notes_input: params[:display_notes_input])
+ update_item_via_turbo_stream(state: :edit, display_notes_input: params[:display_notes_input], current_occurrence:)
else
update_all_via_turbo_stream
render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))
@@ -121,12 +126,14 @@ class MeetingAgendaItemsController < ApplicationController
end
def cancel_edit
- update_item_via_turbo_stream(state: :show)
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
+ update_item_via_turbo_stream(state: :show, current_occurrence:)
respond_with_turbo_streams
end
def update # rubocop:disable Metrics/AbcSize
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
call = ::MeetingAgendaItems::UpdateService
.new(user: current_user, model: @meeting_agenda_item)
.call(meeting_agenda_item_params)
@@ -137,11 +144,11 @@ class MeetingAgendaItemsController < ApplicationController
update_header_component_via_turbo_stream
update_sidebar_details_component_via_turbo_stream
end
- update_item_via_turbo_stream
+ update_item_via_turbo_stream(current_occurrence:)
update_section_header_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section)
else
# show errors
- update_item_via_turbo_stream(state: :edit)
+ update_item_via_turbo_stream(state: :edit, current_occurrence:)
render_base_error_in_flash_message_via_turbo_stream(call.errors)
end
@@ -149,6 +156,7 @@ class MeetingAgendaItemsController < ApplicationController
end
def destroy # rubocop:disable Metrics/AbcSize
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
section = @meeting_agenda_item.meeting_section
call = ::MeetingAgendaItems::DeleteService
@@ -157,12 +165,12 @@ class MeetingAgendaItemsController < ApplicationController
if call.success?
if section.backlog?
- update_section_via_turbo_stream(meeting_section: section, collapsed: false)
+ update_section_via_turbo_stream(meeting_section: section, collapsed: false, current_occurrence:)
else
reset_meeting_from_agenda_item
update_header_component_via_turbo_stream
update_sidebar_details_component_via_turbo_stream
- remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?)
+ remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?, current_occurrence:)
# If section is deleted via an after_destroy/after_update action, it needs to be handled separately
if MeetingSection.exists?(section.id) && section&.reload.present?
@@ -177,6 +185,7 @@ class MeetingAgendaItemsController < ApplicationController
end
def drop # rubocop:disable Metrics/AbcSize
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
meeting_agenda_item_section = @meeting_agenda_item.meeting_section
call = if @target_id.nil?
@@ -196,10 +205,11 @@ class MeetingAgendaItemsController < ApplicationController
move_item_to_other_section_via_turbo_stream(
old_section:,
current_section:,
- collapsed: ActiveModel::Type::Boolean.new.cast(params[:collapsed])
+ collapsed: ActiveModel::Type::Boolean.new.cast(params[:collapsed]),
+ current_occurrence:
)
else
- move_item_within_section_via_turbo_stream
+ move_item_within_section_via_turbo_stream(current_occurrence:)
end
else
generic_call_failure_response(call)
@@ -209,12 +219,13 @@ class MeetingAgendaItemsController < ApplicationController
end
def move
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
call = ::MeetingAgendaItems::UpdateService
.new(user: current_user, model: @meeting_agenda_item)
.call(move_to: params[:move_to]&.to_sym)
if call.success?
- move_item_within_section_via_turbo_stream
+ move_item_within_section_via_turbo_stream(current_occurrence:)
else
generic_call_failure_response(call)
end
diff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rb
index b7376df6dc5..22c17cb9ee6 100644
--- a/modules/meeting/app/controllers/meeting_sections_controller.rb
+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb
@@ -171,6 +171,7 @@ class MeetingSectionsController < ApplicationController
end
def clear_backlog
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
errors = []
meeting_section = @meeting.backlog
@meeting.backlog.agenda_items.each do |item|
@@ -181,14 +182,15 @@ class MeetingSectionsController < ApplicationController
errors << call.errors unless call.success?
end
- update_section_via_turbo_stream(collapsed: true, meeting_section:)
+ update_section_via_turbo_stream(collapsed: true, meeting_section:, current_occurrence: current_occurrence)
render_error_flash_message_via_turbo_stream(message: t("text_backlog_clear_error")) if errors.any?
respond_with_turbo_streams
end
def clear_backlog_dialog
- respond_with_dialog MeetingSections::Backlogs::ClearBacklogDialogComponent.new(@meeting)
+ current_occurrence = Meeting.find_by(id: params[:current_occurrence])
+ respond_with_dialog MeetingSections::Backlogs::ClearBacklogDialogComponent.new(@meeting, current_occurrence:)
end
private