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

Ensure backlog updates on section modifications

Mir Bhatia68813632627d
diff --git a/frontend/src/stimulus/controllers/dynamic/meetings/add-params.controller.ts b/frontend/src/stimulus/controllers/dynamic/meetings/add-params.controller.ts
index cff28f88e42..820f4ba4d47 100644
--- a/frontend/src/stimulus/controllers/dynamic/meetings/add-params.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/meetings/add-params.controller.ts
@@ -46,11 +46,18 @@ export default class extends ApplicationController {
this.turboRequests = context.services.turboRequests;
}
- interceptMoveTo(event:Event):void {
+ intercept(event:Event):void {
event.preventDefault();
const target = event.currentTarget as HTMLElement;
+
+ const confirmMessage = target.dataset.confirmMessage;
+ if (confirmMessage && !window.confirm(confirmMessage)) {
+ return;
+ }
+
const url = new URL(target.dataset.href!, window.location.origin);
+ const method = target.dataset.method! || 'PUT';
appendCollapsedState(url.searchParams);
@@ -59,7 +66,7 @@ export default class extends ApplicationController {
.request(
url.toString(),
{
- method: 'PUT',
+ method,
headers: {
'X-CSRF-Token': this.csrfToken,
Accept: 'text/vnd.turbo-stream.html',
diff --git a/frontend/src/stimulus/controllers/dynamic/meetings/section-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/meetings/section-form.controller.ts
index 208edf14550..f062d3db974 100644
--- a/frontend/src/stimulus/controllers/dynamic/meetings/section-form.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/meetings/section-form.controller.ts
@@ -31,6 +31,7 @@
import * as Turbo from '@hotwired/turbo';
import { Controller } from '@hotwired/stimulus';
import { useMeta } from 'stimulus-use';
+import { appendCollapsedState } from '../../../helpers/collapsible-helper';
export default class extends Controller {
static values = {
@@ -55,8 +56,11 @@ export default class extends Controller {
}
async cancel() {
- const response = await fetch(this.cancelUrlValue, {
- method: 'GET',
+ const url = new URL(this.cancelUrlValue, window.location.origin);
+ appendCollapsedState(url.searchParams);
+
+ const response = await fetch(url.toString(), {
+ method: 'POST',
headers: {
'X-CSRF-Token': this.csrfToken,
Accept: 'text/vnd.turbo-stream.html',
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 7a73d9c848d..856d4b6b48c 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
@@ -213,7 +213,7 @@ module MeetingAgendaItems
menu.with_item(label: I18n.t(:label_agenda_item_move_to_backlog),
tag: :button,
content_arguments: { data: {
- action: "click->meetings--add-params#interceptMoveTo",
+ action: "click->meetings--add-params#intercept",
href: drop_meeting_agenda_item_path(
@meeting_agenda_item.meeting,
@meeting_agenda_item,
@@ -232,7 +232,7 @@ module MeetingAgendaItems
menu.with_item(label: I18n.t(:label_agenda_item_move_to_current_meeting),
tag: :button,
content_arguments: { data: {
- action: "click->meetings--add-params#interceptMoveTo",
+ action: "click->meetings--add-params#intercept",
href: drop_meeting_agenda_item_path(
@meeting_agenda_item.meeting,
@meeting_agenda_item,
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 d8b17a143d2..3a74a2db500 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
@@ -26,10 +26,12 @@
component.with_item(
label: t("activerecord.models.meeting_section"),
tag: :a,
- content_arguments: {
+ href: meeting_sections_path(@meeting),
+ content_arguments: { data: {
+ action: "click->meetings--add-params#intercept",
href: meeting_sections_path(@meeting),
- data: { "turbo-stream": true, "turbo-method": :post }
- }
+ method: "POST"
+ } }
)
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 3ee728a6f9c..f803224eb7a 100644
--- a/modules/meeting/app/components/meeting_sections/header_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/header_component.html.erb
@@ -63,9 +63,12 @@
render(
Primer::Beta::Button.new(
scheme: :secondary,
- tag: :a,
- href: cancel_edit_meeting_section_path(@meeting_section.meeting, @meeting_section),
- data: { "turbo-stream": true }
+ tag: :button,
+ data: {
+ action: "click->meetings--add-params#intercept",
+ href: cancel_edit_meeting_section_path(@meeting_section.meeting, @meeting_section),
+ method: "POST"
+ }
)
) do |_c|
t("button_cancel")
diff --git a/modules/meeting/app/components/meeting_sections/header_component.rb b/modules/meeting/app/components/meeting_sections/header_component.rb
index 87314df1fd2..daabd848620 100644
--- a/modules/meeting/app/components/meeting_sections/header_component.rb
+++ b/modules/meeting/app/components/meeting_sections/header_component.rb
@@ -153,16 +153,15 @@ module MeetingSections
t("text_are_you_sure")
end
menu.with_item(label: t("text_destroy"),
+ tag: :button,
scheme: :danger,
- href: meeting_section_path(@meeting_section.meeting, @meeting_section),
- form_arguments: {
- method: :delete,
- data: {
- turbo_confirm: confirm_text,
- turbo_stream: true,
- test_selector: "meeting-section-delete"
- }
- }) do |item|
+ content_arguments: { data: {
+ action: "click->meetings--add-params#intercept",
+ href: meeting_section_path(@meeting_section.meeting, @meeting_section),
+ method: "DELETE",
+ confirm_message: confirm_text,
+ test_selector: "meeting-section-delete"
+ } }) do |item|
item.with_leading_visual_icon(icon: :trash)
end
end
diff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rb
index 22c17cb9ee6..f7a7a48d2e8 100644
--- a/modules/meeting/app/controllers/meeting_sections_controller.rb
+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb
@@ -35,6 +35,7 @@ class MeetingSectionsController < ApplicationController
before_action :set_meeting
before_action :set_meeting_section,
except: %i[create clear_backlog clear_backlog_dialog]
+ before_action :set_collapsed_state, only: %i[create cancel_edit destroy]
before_action :authorize
def create # rubocop:disable Metrics/AbcSize
@@ -54,6 +55,8 @@ class MeetingSectionsController < ApplicationController
update_section_via_turbo_stream(force_wrapper: true, state: :edit)
# update the section header of the previously last section in order to ensure the action menu move options are updated
update_section_header_via_turbo_stream(meeting_section: @meeting.sections.last(2).first) if @meeting.sections.count > 1
+ # update backlog to ensure move actions match meeting content
+ update_backlog_via_turbo_stream(meeting: @meeting, collapsed: @collapsed)
update_new_button_via_turbo_stream(disabled: true)
update_header_component_via_turbo_stream
else
@@ -83,6 +86,9 @@ class MeetingSectionsController < ApplicationController
update_new_button_via_turbo_stream(disabled: false)
end
+ # update backlog to ensure move actions match meeting content
+ update_backlog_via_turbo_stream(meeting: @meeting, collapsed: @collapsed)
+
respond_with_turbo_streams
end
@@ -119,6 +125,8 @@ class MeetingSectionsController < ApplicationController
update_new_button_via_turbo_stream(disabled: false)
# update all section headers in order to ensure the action menu move options are updated
update_section_headers_via_turbo_stream
+ # update backlog to ensure move actions match meeting content
+ update_backlog_via_turbo_stream(meeting: @meeting, collapsed: @collapsed)
update_header_component_via_turbo_stream
else
generic_call_failure_response(call)
@@ -214,6 +222,10 @@ class MeetingSectionsController < ApplicationController
@meeting_section = MeetingSection.find(params[:id])
end
+ def set_collapsed_state
+ @collapsed = ActiveModel::Type::Boolean.new.cast(params[:collapsed])
+ end
+
def meeting_section_params
params
.require(:meeting_section)
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index aa2035891b9..87bc486e33d 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -123,7 +123,7 @@ Rails.application.routes.draw do
get :clear_backlog_dialog
end
member do
- get :cancel_edit
+ post :cancel_edit
put :drop
put :move
end