From b5888161eeb3d32fa1f7e030a28d9e8089c0b172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Fri, 27 Sep 2024 13:26:16 +0200 Subject: [PATCH] Move the reference value back to the header https://community.openproject.org/work_packages/58120 --- .../controllers/poll-for-changes.controller.ts | 14 ++++++++++++-- .../components/meetings/header_component.html.erb | 7 +++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/src/stimulus/controllers/poll-for-changes.controller.ts b/frontend/src/stimulus/controllers/poll-for-changes.controller.ts index 811dc91926fd..ba6712479da3 100644 --- a/frontend/src/stimulus/controllers/poll-for-changes.controller.ts +++ b/frontend/src/stimulus/controllers/poll-for-changes.controller.ts @@ -39,9 +39,11 @@ export default class PollForChangesController extends ApplicationController { autoscrollEnabled: Boolean, }; - static targets = ['reloadButton']; + static targets = ['reloadButton', 'reference']; declare reloadButtonTarget:HTMLLinkElement; + declare referenceTarget:HTMLElement; + declare readonly hasReferenceTarget:boolean; declare referenceValue:string; declare urlValue:string; @@ -69,12 +71,20 @@ export default class PollForChangesController extends ApplicationController { clearInterval(this.interval); } + buildReference():string { + if (this.hasReferenceTarget) { + return this.referenceTarget.dataset.referenceValue as string; + } + + return this.referenceValue; + } + reloadButtonTargetConnected() { this.reloadButtonTarget.addEventListener('click', this.rememberCurrentScrollPosition.bind(this)); } triggerTurboStream() { - void fetch(`${this.urlValue}?reference=${this.referenceValue}`, { + void fetch(`${this.urlValue}?reference=${this.buildReference()}`, { headers: { Accept: 'text/vnd.turbo-stream.html', }, diff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erb index c27700bbe91c..1d327152d6a9 100644 --- a/modules/meeting/app/components/meetings/header_component.html.erb +++ b/modules/meeting/app/components/meetings/header_component.html.erb @@ -1,6 +1,5 @@ <%= helpers.content_controller "poll-for-changes", - poll_for_changes_reference_value: @meeting.changed_hash, poll_for_changes_url_value: check_for_updates_meeting_path(@meeting), poll_for_changes_interval_value: check_for_updates_interval, poll_for_changes_autoscroll_enabled_value: true @@ -8,7 +7,11 @@ component_wrapper do render(Primer::OpenProject::PageHeader.new( test_selector: "meeting-page-header", - state: @state + state: @state, + data: { + poll_for_changes_target: "reference", + reference_value: @meeting.changed_hash + } )) do |header| header.with_title do |title| title.with_editable_form(model: @meeting,