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
Restructure composition via Outlets + Mixin
Kabiru Mwenjad15e06f05eed
diff --git a/app/components/concerns/work_packages/activities_tab/stimulus_controllers.rb b/app/components/concerns/work_packages/activities_tab/stimulus_controllers.rbindex 6075cb2ef6e..6b6c2c000b9 100644--- a/app/components/concerns/work_packages/activities_tab/stimulus_controllers.rb+++ b/app/components/concerns/work_packages/activities_tab/stimulus_controllers.rb@@ -33,15 +33,23 @@ module WorkPackagesmodule StimulusControllersmodule_function- def index_stimulus_controller(suffix = nil) = "work-packages--activities-tab--index#{suffix}"- def internal_comment_stimulus_controller(suffix = nil) = "work-packages--activities-tab--internal-comment#{suffix}"- def quote_comments_stimulus_controller(suffix = nil) = "work-packages--activities-tab--quote-comment#{suffix}"+ def auto_scrolling_stimulus_controller(suffix = nil) = "#{stimulus_controller_namespace}--auto-scrolling#{suffix}"+ def editor_stimulus_controller(suffix = nil) = "#{stimulus_controller_namespace}--editor#{suffix}"+ def index_stimulus_controller(suffix = nil) = "#{stimulus_controller_namespace}--index#{suffix}"+ def internal_comment_stimulus_controller(suffix = nil) = "#{stimulus_controller_namespace}--internal-comment#{suffix}"+ def polling_stimulus_controller(suffix = nil) = "#{stimulus_controller_namespace}--polling#{suffix}"+ def stems_stimulus_controller(suffix = nil) = "#{stimulus_controller_namespace}--stems#{suffix}"+ def quote_comments_stimulus_controller(suffix = nil) = "#{stimulus_controller_namespace}--quote-comment#{suffix}"- def index_stimulus_controller_outlet_selector = "##{WorkPackages::ActivitiesTab::IndexComponent.index_content_wrapper_key}"+ def index_component_dom_selector+ "##{WorkPackages::ActivitiesTab::IndexComponent.index_content_wrapper_key}"+ end- def internal_comment_stimulus_controller_outlet_selector+ def add_comment_component_dom_selector"##{WorkPackages::ActivitiesTab::IndexComponent.add_comment_wrapper_key}"end++ def stimulus_controller_namespace = "work-packages--activities-tab"endendenddiff --git a/app/components/work_packages/activities_tab/index_component.rb b/app/components/work_packages/activities_tab/index_component.rbindex ab8aecfabaf..b674ea39780 100644--- a/app/components/work_packages/activities_tab/index_component.rb+++ b/app/components/work_packages/activities_tab/index_component.rb@@ -56,9 +56,16 @@ module WorkPackagesattr_reader :work_package, :filter, :last_server_timestamp, :deferreddef wrapper_data_attributes # rubocop:disable Metrics/AbcSize- {- test_selector: "op-wp-activity-tab",- controller: index_stimulus_controller,+ stimulus_controllers = {+ controller: [+ index_stimulus_controller,+ polling_stimulus_controller,+ editor_stimulus_controller,+ auto_scrolling_stimulus_controller,+ stems_stimulus_controller+ ].join(" ")+ }+ stimulus_controller_values = {index_stimulus_controller("-notification-center-path-name-value") => notifications_path,index_stimulus_controller("-update-streams-path-value") => update_streams_work_package_activities_path(work_package),index_stimulus_controller("-sorting-value") => journal_sorting,@@ -70,6 +77,21 @@ module WorkPackagesindex_stimulus_controller("-last-server-timestamp-value") => last_server_timestamp,index_stimulus_controller("-unsaved-changes-confirmation-message-value") => unsaved_changes_confirmation_message}+ stimulus_controller_outlets = {+ auto_scrolling_stimulus_controller("-#{index_stimulus_controller}-outlet") => index_component_dom_selector,+ editor_stimulus_controller("-#{index_stimulus_controller}-outlet") => index_component_dom_selector,+ editor_stimulus_controller("-#{auto_scrolling_stimulus_controller}-outlet") => index_component_dom_selector,+ editor_stimulus_controller("-#{stems_stimulus_controller}-outlet") => index_component_dom_selector,+ polling_stimulus_controller("-#{index_stimulus_controller}-outlet") => index_component_dom_selector,+ polling_stimulus_controller("-#{auto_scrolling_stimulus_controller}-outlet") => index_component_dom_selector,+ polling_stimulus_controller("-#{stems_stimulus_controller}-outlet") => index_component_dom_selector,+ stems_stimulus_controller("-#{index_stimulus_controller}-outlet") => index_component_dom_selector+ }++ { test_selector: "op-wp-activity-tab" }+ .merge(stimulus_controllers)+ .merge(stimulus_controller_values)+ .merge(stimulus_controller_outlets)enddef add_comment_wrapper_data_attributes@@ -77,11 +99,12 @@ module WorkPackagestest_selector: "op-work-package-journal--new-comment-component",controller: internal_comment_stimulus_controller,internal_comment_stimulus_controller("-target") => "formContainer",- action: index_stimulus_controller(":onSubmit-end@window->#{internal_comment_stimulus_controller}#onSubmitEnd"),+ action: editor_stimulus_controller(":onSubmit-end@window->#{internal_comment_stimulus_controller}#onSubmitEnd"),internal_comment_stimulus_controller("-highlight-class") => "work-packages-activities-tab-journals-new-component--journal-notes-body__internal-comment", # rubocop:disable Layout/LineLengthinternal_comment_stimulus_controller("-hidden-class") => "d-none",- internal_comment_stimulus_controller("-#{index_stimulus_controller}-outlet") => index_stimulus_controller_outlet_selector, # rubocop:disable Layout/LineLength- internal_comment_stimulus_controller("-is-internal-value") => false # Initial value+ internal_comment_stimulus_controller("-#{index_stimulus_controller}-outlet") => index_component_dom_selector,+ internal_comment_stimulus_controller("-is-internal-value") => false, # Initial value+ internal_comment_stimulus_controller("-#{editor_stimulus_controller}-outlet") => index_component_dom_selector}enddiff --git a/app/components/work_packages/activities_tab/journals/item_component.rb b/app/components/work_packages/activities_tab/journals/item_component.rbindex 72990178fd4..a90ef2b5cbc 100644--- a/app/components/work_packages/activities_tab/journals/item_component.rb+++ b/app/components/work_packages/activities_tab/journals/item_component.rb@@ -156,6 +156,7 @@ module WorkPackagesdef quote_action_data_attributes # rubocop:disable Metrics/AbcSize{+ test_selector: "op-wp-journal-#{journal.id}-quote",controller: quote_comments_stimulus_controller,action: "click->#{quote_comments_stimulus_controller}#quote:prevent",quote_comments_stimulus_controller("-content-param") => journal.notes,@@ -163,9 +164,9 @@ module WorkPackagesquote_comments_stimulus_controller("-user-name-param") => journal.user.name,quote_comments_stimulus_controller("-is-internal-param") => journal.internal?,quote_comments_stimulus_controller("-text-wrote-param") => I18n.t(:text_wrote),- quote_comments_stimulus_controller("-#{index_stimulus_controller}-outlet") => index_stimulus_controller_outlet_selector, # rubocop:disable Layout/LineLength- quote_comments_stimulus_controller("-#{internal_comment_stimulus_controller}-outlet") => internal_comment_stimulus_controller_outlet_selector, # rubocop:disable Layout/LineLength- test_selector: "op-wp-journal-#{journal.id}-quote"+ quote_comments_stimulus_controller("-#{index_stimulus_controller}-outlet") => index_component_dom_selector,+ quote_comments_stimulus_controller("-#{internal_comment_stimulus_controller}-outlet") => add_comment_component_dom_selector, # rubocop:disable Layout/LineLength+ quote_comments_stimulus_controller("-#{editor_stimulus_controller}-outlet") => index_component_dom_selector}endenddiff --git a/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erbindex a952d1358e4..56db19bbed5 100644--- a/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb@@ -32,7 +32,7 @@data: {turbo_stream: true,turbo_method: :put,- "work-packages--activities-tab--index-target": "reactionButton"+ "#{polling_stimulus_controller}-target": "reactionButton"},aria: { label: I18n.t("reactions.react_with", reaction: reaction.to_s.humanize(capitalize: false)) },font_size: 4,diff --git a/app/components/work_packages/activities_tab/journals/item_component/add_reactions.rb b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.rbindex 3b01df937bc..3671b19cee1 100644--- a/app/components/work_packages/activities_tab/journals/item_component/add_reactions.rb+++ b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.rb@@ -33,6 +33,7 @@ module WorkPackagesinclude ApplicationHelperinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable+ include WorkPackages::ActivitiesTab::StimulusControllersdef initialize(journal:, grouped_emoji_reactions:)superdiff --git a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erbindex db7035d8e0c..20943613980 100644--- a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb@@ -9,7 +9,7 @@turbo: true,turbo_stream: true,test_selector: "op-work-package-journal-form-element",- "work-packages--activities-tab--index-target": "editForm",+ "#{polling_stimulus_controller}-target": "editForm",journal_id: journal.id},url: work_package_activity_path(work_package_id: work_package.id, id: journal.id, filter:)diff --git a/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb b/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erbindex 1408169ae93..4e9138c9b11 100644--- a/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb@@ -16,7 +16,7 @@data: {turbo_stream: true,turbo_method: :put,- "work-packages--activities-tab--index-target": "reactionButton"+ "#{polling_stimulus_controller}-target": "reactionButton"},aria: { label: aria_label_text(reaction, data[:users]) },disabled: current_user_cannot_react?,diff --git a/app/components/work_packages/activities_tab/journals/item_component/reactions.rb b/app/components/work_packages/activities_tab/journals/item_component/reactions.rbindex 75f0e4af96c..8929b110159 100644--- a/app/components/work_packages/activities_tab/journals/item_component/reactions.rb+++ b/app/components/work_packages/activities_tab/journals/item_component/reactions.rb@@ -33,6 +33,7 @@ module WorkPackagesinclude ApplicationHelperinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable+ include WorkPackages::ActivitiesTab::StimulusControllersdef initialize(journal:, grouped_emoji_reactions:)superdiff --git a/app/components/work_packages/activities_tab/journals/new_component.html.erb b/app/components/work_packages/activities_tab/journals/new_component.html.erbindex 99deb177e13..b2b54cefd3b 100644--- a/app/components/work_packages/activities_tab/journals/new_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/new_component.html.erb@@ -4,7 +4,7 @@new_form_container.with_row(display: button_row_display_value,data: {- "work-packages--activities-tab--index-target": "buttonRow"+ "#{editor_stimulus_controller}-target": "buttonRow"}) doflex_layout(justify_content: :space_between) do |button_row|@@ -16,7 +16,7 @@size: :medium,block: true,data: {- action: "click->work-packages--activities-tab--index#showForm dragover->work-packages--activities-tab--index#showForm",+ action: "click->#{editor_stimulus_controller}#showForm dragover->#{editor_stimulus_controller}#showForm",test_selector: "op-open-work-package-journal-form-trigger"})@@ -39,7 +39,7 @@new_form_container.with_row(display: form_row_display_value,- data: { "work-packages--activities-tab--index-target": "formRow" }+ data: { "#{editor_stimulus_controller}-target": "formRow" }) doprimer_form_with(id: "work-package-journal-form-element",@@ -48,7 +48,7 @@data: {turbo: true,turbo_stream: true,- "work-packages--activities-tab--index-target": "form",+ "#{editor_stimulus_controller}-target": "form",test_selector: "op-work-package-journal-form-element"},url: work_package_activities_path(work_package_id: work_package.id)@@ -75,7 +75,7 @@internal_comment_container.with_column(display: :none,- data: { "work-packages--activities-tab--internal-comment-target": "learnMoreLink" },+ data: { "#{internal_comment_stimulus_controller}-target": "learnMoreLink" },pb: 1) dorender(Primer::Beta::Link.new(href: learn_more_static_link_url, target: "_blank")) do |link|@@ -88,7 +88,13 @@form_container_row.with_column(flex_layout: true, align_items: :center) do |submit_container|submit_container.with_column(mr: 2) do- render(Primer::Beta::Button.new(scheme: :secondary, size: :medium, data: { action: "click->work-packages--activities-tab--index#closeEditor" })) do+ render(+ Primer::Beta::Button.new(+ scheme: :secondary,+ size: :medium,+ data: { action: "click->#{editor_stimulus_controller}#closeEditor" }+ )+ ) dot("button_cancel")endend@@ -108,6 +114,7 @@endend%>+<% if adding_internal_comment_allowed? %><%=render(diff --git a/app/components/work_packages/activities_tab/shared_helpers.rb b/app/components/work_packages/activities_tab/shared_helpers.rbindex 9d82ab0391b..b9a03043d47 100644--- a/app/components/work_packages/activities_tab/shared_helpers.rb+++ b/app/components/work_packages/activities_tab/shared_helpers.rb@@ -36,6 +36,8 @@ module WorkPackagesenddef activity_anchor_link(journal)+ auto_scrolling_controller = WorkPackages::ActivitiesTab::StimulusControllers.auto_scrolling_stimulus_controller+render(Primer::Beta::Link.new(href: activity_url(journal),scheme: :secondary,@@ -44,9 +46,9 @@ module WorkPackagesdata: {test_selector: "activity-anchor-link",turbo: false,- action: "click->work-packages--activities-tab--index#setAnchor:prevent",- "work-packages--activities-tab--index-id-param": journal_activity_id(journal),- "work-packages--activities-tab--index-anchor-name-param": activity_anchor_name+ action: "click->#{auto_scrolling_controller}#setAnchor:prevent",+ "#{auto_scrolling_controller}-id-param": journal_activity_id(journal),+ "#{auto_scrolling_controller}-anchor-name-param": activity_anchor_name})) dojournal_updated_at_formatted_time(journal)diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/auto-scrolling.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/auto-scrolling.controller.tsindex 8e6eee667ec..ab7d9d5beb2 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/auto-scrolling.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/auto-scrolling.controller.ts@@ -28,7 +28,8 @@* ++*/-import BaseController from './base.controller';+import { Controller } from '@hotwired/stimulus';+import { withIndexOutletMixin } from './mixins/with-index-outlet';enum AnchorType {Comment = 'comment',@@ -42,9 +43,8 @@ interface CustomEventWithIdParam extends Event {};}-export default class AutoScrollingController extends BaseController {+export default class AutoScrollingController extends withIndexOutletMixin(Controller) {connect() {- super.connect();this.handleInitialScroll();}@@ -57,7 +57,7 @@ export default class AutoScrollingController extends BaseController {// not using the scrollToActivity method here as it is causing flickering issues// in case of a setAnchor click, we can go for a direct scroll approach- const scrollableContainer = this.viewPortService.scrollableContainer;+ const scrollableContainer = this.scrollableContainer;const activityElement = this.getActivityAnchorElement(anchorName, activityId);if (scrollableContainer && activityElement) {@@ -71,9 +71,9 @@ export default class AutoScrollingController extends BaseController {}performAutoScrollingOnStreamsUpdate() {- if (this.sortingValue === 'asc' && this.viewPortService.isJournalsContainerScrolledToBottom()) {+ if (this.indexOutlet.sortingValue === 'asc' && this.isJournalsContainerScrolledToBottom()) {// scroll to (new) bottom if sorting is ascending and journals container was already at bottom before a new activity was added- if (this.viewPortService.isMobile()) {+ if (this.isMobile()) {this.scrollInputContainerIntoView(300);} else {this.scrollJournalContainer(true, true);@@ -82,12 +82,12 @@ export default class AutoScrollingController extends BaseController {}performAutoScrollingOnFormSubmit() {- if (this.viewPortService.isMobile() && !this.viewPortService.isWithinNotificationCenter()) {+ if (this.isMobile() && !this.isWithinNotificationCenter()) {// wait for the keyboard to be fully down before scrolling further// timeout amount tested on mobile devices for best possible user experiencethis.scrollInputContainerIntoView(800);} else {- this.scrollJournalContainer(this.sortingValue === 'asc', true);+ this.scrollJournalContainer(this.indexOutlet.sortingValue === 'asc', true);}}@@ -97,14 +97,14 @@ export default class AutoScrollingController extends BaseController {if (inputContainer) {inputContainer.scrollIntoView({behavior,- block: this.sortingValue === 'desc' ? 'nearest' : 'start',+ block: this.indexOutlet.sortingValue === 'desc' ? 'nearest' : 'start',});}}, timeout);}scrollJournalContainer(toBottom:boolean, smooth:boolean = false) {- const scrollableContainer = this.viewPortService.scrollableContainer;+ const scrollableContainer = this.scrollableContainer;if (scrollableContainer) {if (smooth) {scrollableContainer.scrollTo({@@ -123,7 +123,7 @@ export default class AutoScrollingController extends BaseController {if (activityIdMatch && activityIdMatch.length === 3) {this.scrollToActivity(activityIdMatch[1] as AnchorType, activityIdMatch[2]);- } else if (this.sortingValue === 'asc' && (!this.viewPortService.isMobile() || this.viewPortService.isWithinNotificationCenter())) {+ } else if (this.indexOutlet.sortingValue === 'asc' && (!this.isMobile() || this.isWithinNotificationCenter())) {this.scrollToBottom();}}@@ -138,7 +138,7 @@ export default class AutoScrollingController extends BaseController {}private tryScroll(activityAnchorName:AnchorType, activityId:string, attempts:number, maxAttempts:number) {- const scrollableContainer = this.viewPortService.scrollableContainer;+ const scrollableContainer = this.scrollableContainer;const activityElement = this.getActivityAnchorElement(activityAnchorName, activityId);const topPadding = 70;@@ -158,7 +158,7 @@ export default class AutoScrollingController extends BaseController {}private tryScrollToBottom(attempts:number = 0, maxAttempts:number = 20, behavior:ScrollBehavior = 'smooth') {- const scrollableContainer = this.viewPortService.scrollableContainer;+ const scrollableContainer = this.scrollableContainer;if (!scrollableContainer) {if (attempts < maxAttempts) {diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/base.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/base.controller.tsdeleted file mode 100644index deafe7c6b1e..00000000000--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/base.controller.ts+++ /dev/null@@ -1,88 +0,0 @@-/*- * -- copyright- * OpenProject is an open source project management software.- * Copyright (C) 2023 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.- * ++- */--import { Controller } from '@hotwired/stimulus';-import ViewPortService from './services/view-port-service';--export default class BaseController extends Controller<HTMLElement> {- static values = {- updateStreamsPath: String,- sorting: String,- pollingIntervalInMs: Number,- filter: String,- userId: Number,- workPackageId: Number,- notificationCenterPathName: String,- lastServerTimestamp: String,- showConflictFlashMessageUrl: String,- unsavedChangesConfirmationMessage: String,- };-- declare updateStreamsPathValue:string;- declare sortingValue:string;- declare lastServerTimestampValue:string;- declare intervallId:number;- declare pollingIntervalInMsValue:number;- declare notificationCenterPathNameValue:string;- declare filterValue:string;- declare userIdValue:number;- declare workPackageIdValue:number;- declare latestKnownChangesetUpdatedAtKey:string;- declare showConflictFlashMessageUrlValue:string;- declare unsavedChangesConfirmationMessageValue:string;-- static targets = ['journalsContainer'];- declare readonly journalsContainerTarget:HTMLElement;-- viewPortService:ViewPortService;-- connect() {- this.viewPortService = new ViewPortService(this.notificationCenterPathNameValue);- }-- adjustJournalContainerMarginWith(marginBottomPx:string) {- // don't do this on mobile screens- if (this.viewPortService.isMobile()) { return; }- this.journalsContainerTarget.style.marginBottom = marginBottomPx;- }-- resetJournalsContainerMargins():void {- if (!this.journalsContainerTarget) return;-- this.journalsContainerTarget.style.marginBottom = '';- this.journalsContainerTarget.classList.add('work-packages-activities-tab-index-component--journals-container_with-initial-input-compensation');- }-- setLastServerTimestampViaHeaders(headers:Headers) {- if (headers.has('X-Server-Timestamp')) {- this.lastServerTimestampValue = headers.get('X-Server-Timestamp') as string;- }- }-}diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.tsindex ac53622e3ee..95c5148a1c6 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts@@ -28,23 +28,29 @@* ++*/+import { Controller } from '@hotwired/stimulus';import {ICKEditorInstance,} from 'core-app/shared/components/editor/components/ckeditor/ckeditor.types';import { retrieveCkEditorInstance } from 'core-app/shared/helpers/ckeditor-helpers';import AutoScrollingController from './auto-scrolling.controller';-import BaseController from './base.controller';import StemsController from './stems.controller';+import { withIndexOutletMixin } from './mixins/with-index-outlet';++export default class EditorController extends withIndexOutletMixin(Controller) {+ static outlets = [+ 'work-packages--activities-tab--auto-scrolling',+ 'work-packages--activities-tab--stems',+ ];-export default class EditorController extends BaseController {- static outlets = ['work-packages--activities-tab--auto-scrolling', 'work-packages--activities-tab--stems'];declare readonly workPackagesActivitiesTabAutoScrollingOutlet:AutoScrollingController;declare readonly workPackagesActivitiesTabStemsOutlet:StemsController;+ private get autoScrollingOutlet() { return this.workPackagesActivitiesTabAutoScrollingOutlet; }+ private get stemsOutlet() { return this.workPackagesActivitiesTabStemsOutlet; }- static targets = ['buttonRow', 'formRow', 'journalsContainer', 'form'];+ static targets = ['buttonRow', 'formRow', 'form'];declare readonly buttonRowTarget:HTMLInputElement;declare readonly formRowTarget:HTMLElement;- declare readonly journalsContainerTarget:HTMLElement;declare readonly formTarget:HTMLFormElement;private rescuedEditorDataKey:string;@@ -52,8 +58,6 @@ export default class EditorController extends BaseController {private ckEditorAbortController = new AbortController();connect() {- super.connect();-this.setupEventListeners();this.setLocalStorageKeys();this.populateRescuedEditorContent();@@ -66,7 +70,7 @@ export default class EditorController extends BaseController {}showForm() {- const journalsContainerAtBottom = this.viewPortService.isJournalsContainerScrolledToBottom();+ const journalsContainerAtBottom = this.isJournalsContainerScrolledToBottom();this.buttonRowTarget.classList.add('d-none');this.formRowTarget.classList.remove('d-none');@@ -74,11 +78,11 @@ export default class EditorController extends BaseController {this.addCkEditorEventListeners();- if (this.viewPortService.isMobile()) {+ if (this.isMobile()) {this.focusEditor(0);} else if (this.sortingValue === 'asc' && journalsContainerAtBottom) {// scroll to (new) bottom if sorting is ascending and journals container was already at bottom before showing the form- this.workPackagesActivitiesTabAutoScrollingOutlet.scrollJournalContainer(true);+ this.autoScrollingOutlet.scrollJournalContainer(true);this.focusEditor();} else {this.focusEditor();@@ -108,17 +112,12 @@ export default class EditorController extends BaseController {this.removeCkEditorEventListeners();this.buttonRowTarget.classList.remove('d-none');this.formRowTarget.classList.add('d-none');+ this.indexOutlet.hideJournalsContainerInput();- if (this.journalsContainerTarget) {- this.journalsContainerTarget.style.marginBottom = '';- this.journalsContainerTarget.classList.add('work-packages-activities-tab-index-component--journals-container_with-initial-input-compensation');- this.journalsContainerTarget.classList.remove('work-packages-activities-tab-index-component--journals-container_with-input-compensation');- }-- if (this.viewPortService.isMobile()) {+ if (this.isMobile()) {// wait for the keyboard to be fully down before scrolling further// timeout amount tested on mobile devices for best possible user experience- this.workPackagesActivitiesTabAutoScrollingOutlet.scrollInputContainerIntoView(500);+ this.autoScrollingOutlet.scrollInputContainerIntoView(500);}}@@ -127,7 +126,7 @@ export default class EditorController extends BaseController {this.closeForm();} else {// eslint-disable-next-line no-alert- const shouldClose = window.confirm(this.unsavedChangesConfirmationMessageValue);+ const shouldClose = window.confirm(this.indexOutlet.unsavedChangesConfirmationMessageValue);if (shouldClose) { this.closeForm(); }}}@@ -162,7 +161,7 @@ export default class EditorController extends BaseController {}private setLocalStorageKeys() {- this.rescuedEditorDataKey = `work-package-${this.workPackageIdValue}-rescued-editor-data-${this.userIdValue}`;+ this.rescuedEditorDataKey = `work-package-${this.indexOutlet.workPackageIdValue}-rescued-editor-data-${this.indexOutlet.userIdValue}`;}private populateRescuedEditorContent() {@@ -182,9 +181,7 @@ export default class EditorController extends BaseController {onBlurEditor: () => { void this.onBlurEditor(); },onFocusEditor: () => {void this.onFocusEditor();- if (this.viewPortService.isMobile()) {- void this.workPackagesActivitiesTabAutoScrollingOutlet.scrollInputContainerIntoView(200);- }+ if (this.isMobile()) { void this.autoScrollingOutlet.scrollInputContainerIntoView(200); }},};@@ -221,23 +218,23 @@ export default class EditorController extends BaseController {if (formSubmitResponse.succeeded) {// extract server timestamp from response headers in order to be in sync with the server- this.setLastServerTimestampViaHeaders(formSubmitResponse.response.headers);+ this.indexOutlet.setLastServerTimestampViaHeaders(formSubmitResponse.response.headers);- if (!this.journalsContainerTarget) return;+ if (!this.indexOutlet.hasJournalsContainerTarget) return;this.clearEditor();this.closeForm();- this.resetJournalsContainerMargins();+ this.indexOutlet.resetJournalsContainerMargins();setTimeout(() => {- this.workPackagesActivitiesTabAutoScrollingOutlet.performAutoScrollingOnFormSubmit();- this.workPackagesActivitiesTabStemsOutlet.handleStemVisibility();+ this.autoScrollingOutlet.performAutoScrollingOnFormSubmit();+ this.stemsOutlet.handleStemVisibility();}, 100);}}private adjustJournalContainerMargin() {- this.adjustJournalContainerMarginWith(`${this.formRowTarget.clientHeight + 29}px`);+ this.indexOutlet.adjustJournalContainerMarginWith(`${this.formRowTarget.clientHeight + 29}px`);}private closeForm() {@@ -264,7 +261,7 @@ export default class EditorController extends BaseController {return this.element.querySelector('opce-ckeditor-augmented-textarea');}- private get ckEditorInstance():ICKEditorInstance | undefined {+ get ckEditorInstance():ICKEditorInstance | undefined {return retrieveCkEditorInstance(this.element);}}diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.tsindex c23f16cb71a..ec7a4d9384c 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts@@ -28,19 +28,86 @@* ++*/-import BaseController from './base.controller';+import { Controller } from '@hotwired/stimulus';+import ViewPortService from './services/view-port-service';-export default class IndexController extends BaseController {- async connect() {- super.connect();+export default class IndexController extends Controller<HTMLElement> {+ static values = {+ updateStreamsPath: String,+ sorting: String,+ pollingIntervalInMs: Number,+ filter: String,+ userId: Number,+ workPackageId: Number,+ notificationCenterPathName: String,+ lastServerTimestamp: String,+ showConflictFlashMessageUrl: String,+ unsavedChangesConfirmationMessage: String,+ };+ declare updateStreamsPathValue:string;+ declare sortingValue:string;+ declare lastServerTimestampValue:string;+ declare pollingIntervalInMsValue:number;+ declare notificationCenterPathNameValue:string;+ declare filterValue:string;+ declare userIdValue:number;+ declare workPackageIdValue:number;+ declare showConflictFlashMessageUrlValue:string;+ declare unsavedChangesConfirmationMessageValue:string;++ static targets = ['journalsContainer'];+ declare readonly journalsContainerTarget:HTMLElement;+ declare readonly hasJournalsContainerTarget:boolean;++ viewPortService:ViewPortService;++ connect() {+ this.viewPortService = new ViewPortService(this.notificationCenterPathNameValue);++ this.markAsConnected();this.setCssClasses();}+ disconnect() {+ this.markAsDisconnected();+ }+setFilterToOnlyComments() { this.filterValue = 'only_comments'; }setFilterToOnlyChanges() { this.filterValue = 'only_changes'; }unsetFilter() { this.filterValue = ''; }+ adjustJournalContainerMarginWith(marginBottomPx:string) {+ // don't do this on mobile screens+ if (this.viewPortService.isMobile()) { return; }+ this.journalsContainerTarget.style.marginBottom = marginBottomPx;+ }++ resetJournalsContainerMargins():void {+ if (!this.hasJournalsContainerTarget) return;++ this.journalsContainerTarget.style.marginBottom = '';+ this.journalsContainerTarget.classList.add('work-packages-activities-tab-index-component--journals-container_with-initial-input-compensation');+ }++ setLastServerTimestampViaHeaders(headers:Headers) {+ if (headers.has('X-Server-Timestamp')) {+ this.lastServerTimestampValue = headers.get('X-Server-Timestamp') as string;+ }+ }++ hideJournalsContainerInput() {+ if (!this.hasJournalsContainerTarget) return;++ this.journalsContainerTarget.style.marginBottom = '';+ this.journalsContainerTarget.classList.add('work-packages-activities-tab-index-component--journals-container_with-initial-input-compensation');+ this.journalsContainerTarget.classList.remove('work-packages-activities-tab-index-component--journals-container_with-input-compensation');+ }++ // used in specs for timing+ private markAsConnected() { this.element.dataset.stimulusControllerConnected = 'true'; }+ private markAsDisconnected() { this.element.dataset.stimulusControllerConnected = 'false'; }+private setCssClasses() {if (this.viewPortService.isWithinNotificationCenter()) {this.element.classList.add('work-packages-activities-tab-index-component--within-notification-center');diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.tsindex 6a3dd3200e8..6ee6f7284b2 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts@@ -31,35 +31,37 @@import { Controller } from '@hotwired/stimulus';import { renderStreamMessage } from '@hotwired/turbo';import { useMeta } from 'stimulus-use';-import type IndexController from './index.controller';+import type EditorController from './editor.controller';+import { withIndexOutletMixin } from './mixins/with-index-outlet';-export default class InternalCommentController extends Controller {- static targets = ['confirmationDialog', 'internalCheckbox', 'formContainer', 'learnMoreLink'];- static outlets = ['work-packages--activities-tab--index'];- static classes = ['highlight', 'hidden'];-- static values = {- isInternal: { type: Boolean, default: false },- };+export default class InternalCommentController extends withIndexOutletMixin(Controller) {+ static outlets = ['work-packages--activities-tab--editor'];+ declare readonly workPackagesActivitiesTabEditorOutlet:EditorController;+ private get editorOutlet() { return this.workPackagesActivitiesTabEditorOutlet; }+ static targets = ['confirmationDialog', 'internalCheckbox', 'formContainer', 'learnMoreLink'];declare readonly confirmationDialogTarget:HTMLDialogElement;declare readonly internalCheckboxTarget:HTMLInputElement;declare readonly formContainerTarget:HTMLElement;declare readonly learnMoreLinkTarget:HTMLAnchorElement;- declare readonly workPackagesActivitiesTabIndexOutlet:IndexController;+ declare hasInternalCheckboxTarget:boolean;++ static classes = ['highlight', 'hidden'];declare readonly highlightClass:string;declare readonly hiddenClass:string;- declare isInternalValue:boolean;+ static values = {+ isInternal: { type: Boolean, default: false },+ };- declare hasInternalCheckboxTarget:boolean;+ declare isInternalValue:boolean;static metaNames = ['csrf-token'];-declare readonly csrfToken:string;connect() {- useMeta(this, { suffix: false });+ // FIXME: `this` is not typed as HTMLElement, but as any+ useMeta(this as any, { suffix: false });}onSubmitEnd(_event:CustomEvent):void {@@ -88,11 +90,11 @@ export default class InternalCommentController extends Controller {const confirmed = await this.askForConfirmation();if (confirmed) {- this.workPackagesActivitiesTabIndexOutlet.focusEditor();+ this.editorOutlet.focusEditor();} else {this.internalCheckboxTarget.checked = true;this.setInternalState(this.internalCheckboxTarget.checked);- this.workPackagesActivitiesTabIndexOutlet.focusEditor();+ this.editorOutlet.focusEditor();}}}@@ -105,7 +107,7 @@ export default class InternalCommentController extends Controller {}private toggleLearnMoreLink(isChecked:boolean):void {- if (this.workPackagesActivitiesTabIndexOutlet.viewPortService.isMobile()) return; // hidden on mobile+ if (this.isMobile()) return; // hidden on mobilethis.learnMoreLinkTarget.classList.toggle(this.hiddenClass, !isChecked);}@@ -115,7 +117,7 @@ export default class InternalCommentController extends Controller {const editorData = this.ckEditorInstance.getData({ trim: false });if (editorData.length === 0) return;- const sanitizePath = `/work_packages/${this.workPackagesActivitiesTabIndexOutlet.workPackageIdValue}/activities/sanitize_internal_mentions`;+ const sanitizePath = `/work_packages/${this.indexOutlet.workPackageIdValue}/activities/sanitize_internal_mentions`;try {const response = await fetch(sanitizePath, {@@ -158,6 +160,6 @@ export default class InternalCommentController extends Controller {}private get ckEditorInstance() {- return this.workPackagesActivitiesTabIndexOutlet.ckEditorInstance;+ return this.editorOutlet.ckEditorInstance;}}diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/mixins/with-index-outlet.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/mixins/with-index-outlet.tsnew file mode 100644index 00000000000..56eca91eb1b--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/mixins/with-index-outlet.ts@@ -0,0 +1,55 @@+/*+ * -- copyright+ * OpenProject is an open source project management software.+ * Copyright (C) 2023 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.+ * +++ */++import { useMeta } from 'stimulus-use';+import IndexController from '../index.controller';++export const withIndexOutletMixin = (BaseController:any) => {+ return class extends BaseController<HTMLElement> {+ constructor(...args:any[]) {+ super(...(args));+ }++ static outlets = [+ ...(BaseController.outlets || []),+ 'work-packages--activities-tab--index',+ ];++ declare readonly workPackagesActivitiesTabIndexOutlet:IndexController;+ get indexOutlet() { return this.workPackagesActivitiesTabIndexOutlet; }++ isMobile() { return this.indexOutlet.viewPortService.isMobile(); }+ isWithinNotificationCenter() { return this.indexOutlet.viewPortService.isWithinNotificationCenter(); }+ isWithinSplitScreen() { return this.indexOutlet.viewPortService.isWithinSplitScreen(); }+ isJournalsContainerScrolledToBottom() { return this.indexOutlet.viewPortService.isJournalsContainerScrolledToBottom(); }++ get scrollableContainer() { return this.indexOutlet.viewPortService.scrollableContainer; }+ };+};diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/polling.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/polling.controller.tsindex 3c624af663a..ac227f4661c 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/polling.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/polling.controller.ts@@ -28,17 +28,20 @@* ++*/+import { Controller } from '@hotwired/stimulus';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';import { useMeta } from 'stimulus-use';import type AutoScrollingController from './auto-scrolling.controller';-import BaseController from './base.controller';import StemsController from './stems.controller';+import { withIndexOutletMixin } from './mixins/with-index-outlet';-export default class PollingController extends BaseController {+export default class PollingController extends withIndexOutletMixin(Controller) {static outlets = ['work-packages--activities-tab--auto-scrolling', 'work-packages--activities-tab--stems'];declare readonly workPackagesActivitiesTabAutoScrollingOutlet:AutoScrollingController;declare readonly workPackagesActivitiesTabStemsOutlet:StemsController;+ private get autoScrollingOutlet() { return this.workPackagesActivitiesTabAutoScrollingOutlet; }+ private get stemsOutlet() { return this.workPackagesActivitiesTabStemsOutlet; }static targets = ['editForm', 'reactionButton'];declare readonly editFormTargets:HTMLFormElement[];@@ -48,20 +51,20 @@ export default class PollingController extends BaseController {declare readonly csrfToken:string;private updateInProgress:boolean = false;+ private intervallId:number;private turboRequests:TurboRequestsService;private apiV3Service:ApiV3Service;private abortController = new AbortController();async connect() {- super.connect();- useMeta(this, { suffix: false });+ // FIXME: `this` is not typed as HTMLElement, but as any+ useMeta(this as any, { suffix: false });const context = await window.OpenProject.getPluginContext();this.turboRequests = context.services.turboRequests;this.apiV3Service = context.services.apiV3Service;this.setupEventListeners();- this.markAsConnected();this.safeUpdateWorkPackageFormsWithStateChecks();this.setLatestKnownChangesetUpdatedAt();this.startPolling();@@ -70,7 +73,6 @@ export default class PollingController extends BaseController {disconnect() {this.removeEventListeners();this.stopPolling();- this.markAsDisconnected();}handleWorkPackageUpdate(_event?:Event):void {@@ -98,16 +100,12 @@ export default class PollingController extends BaseController {});}- // used in specs for timing- private markAsConnected() { this.element.dataset.stimulusControllerConnected = 'true'; }- private markAsDisconnected() { this.element.dataset.stimulusControllerConnected = 'false'; }-private startPolling() {if (this.intervallId) {this.stopPolling();}- this.intervallId = window.setInterval(() => this.updateActivitiesList(), this.pollingIntervalInMsValue);+ this.intervallId = window.setInterval(() => this.updateActivitiesList(), this.indexOutlet.pollingIntervalInMsValue);}private stopPolling() {@@ -115,7 +113,7 @@ export default class PollingController extends BaseController {}private setLatestKnownChangesetUpdatedAt() {- const latestKnownChangesetUpdatedAtKey = `work-package-${this.workPackageIdValue}-latest-known-changeset-updated-at-${this.userIdValue}`;+ const latestKnownChangesetUpdatedAtKey = `work-package-${this.indexOutlet.workPackageIdValue}-latest-known-changeset-updated-at-${this.indexOutlet.userIdValue}`;const latestChangesetUpdatedAt = this.parseLatestChangesetUpdatedAtFromDom();if (latestChangesetUpdatedAt) {@@ -168,11 +166,11 @@ export default class PollingController extends BaseController {private prepareUpdateStreamsUrl(editingJournals:Set<string>):string {const baseUrl = window.location.origin;- const url = new URL(this.updateStreamsPathValue, baseUrl);+ const url = new URL(this.indexOutlet.updateStreamsPathValue, baseUrl);- url.searchParams.set('sortBy', this.sortingValue);- url.searchParams.set('filter', this.filterValue);- url.searchParams.set('last_update_timestamp', this.lastServerTimestampValue);+ url.searchParams.set('sortBy', this.indexOutlet.sortingValue);+ url.searchParams.set('filter', this.indexOutlet.filterValue);+ url.searchParams.set('last_update_timestamp', this.indexOutlet.lastServerTimestampValue);if (editingJournals.size > 0) {url.searchParams.set('editing_journals', Array.from(editingJournals).join(','));@@ -186,8 +184,8 @@ export default class PollingController extends BaseController {// the methods below partially rely on the DOM to be updated// a specific signal would be way better than a static timeout, but I couldn't find a suitable onesetTimeout(() => {- this.workPackagesActivitiesTabStemsOutlet.handleStemVisibility();- this.setLastServerTimestampViaHeaders(headers);+ this.stemsOutlet.handleStemVisibility();+ this.indexOutlet.setLastServerTimestampViaHeaders(headers);this.checkForAndHandleWorkPackageUpdate(html);this.checkForNewNotifications(html);this.performAutoScrolling(html);@@ -236,7 +234,7 @@ export default class PollingController extends BaseController {private latestChangesetFromOtherUser():boolean {const latestChangesetUserId = this.parseLatestChangesetUserIdFromDom();- return !!(latestChangesetUserId && (latestChangesetUserId !== this.userIdValue));+ return !!(latestChangesetUserId && (latestChangesetUserId !== this.indexOutlet.userIdValue));}private anyInlineEditActiveInWpSingleView():boolean {@@ -251,13 +249,12 @@ export default class PollingController extends BaseController {// currently we do not have a programmatic way to show the primer flash messages// so we just do a request to the server to show it// should be refactored once we have a programmatic way to show the primer flash messages!- void this.turboRequests.request(`${this.showConflictFlashMessageUrlValue}?scheme=warning`, {- method: 'GET',- });+ const url = `${this.indexOutlet.showConflictFlashMessageUrlValue}?scheme=warning`;+ void this.turboRequests.request(url, { method: 'GET' });}private updateWorkPackageForms() {- const wp = this.apiV3Service.work_packages.id(this.workPackageIdValue);+ const wp = this.apiV3Service.work_packages.id(this.indexOutlet.workPackageIdValue);void wp.refresh();}@@ -278,7 +275,7 @@ export default class PollingController extends BaseController {}private parseLatestChangesetUpdatedAtFromDom():Date | null {- const elements = this.element.querySelectorAll('[data-journal-with-changeset-updated-at]');+ const elements = this.element.querySelectorAll('[data-journal-with-changeset-updated-at]') as NodeListOf<HTMLElement>;const dates = Array.from(elements).map((element) => element.getAttribute('data-journal-with-changeset-updated-at'))@@ -310,6 +307,6 @@ export default class PollingController extends BaseController {return;}- this.workPackagesActivitiesTabAutoScrollingOutlet.performAutoScrollingOnStreamsUpdate();+ this.autoScrollingOutlet.performAutoScrollingOnStreamsUpdate();}}diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/quote-comment.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/quote-comment.controller.tsindex c1ec4b62648..93a502a702a 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/quote-comment.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/quote-comment.controller.ts@@ -30,7 +30,7 @@import { Controller } from '@hotwired/stimulus';-import type IndexController from './index.controller';+import type EditorController from './editor.controller';import type InternalCommentController from './internal-comment.controller';type QuoteParams = {@@ -42,9 +42,9 @@ type QuoteParams = {};export default class QuoteCommentController extends Controller {- static outlets = ['work-packages--activities-tab--index', 'work-packages--activities-tab--internal-comment'];+ static outlets = ['work-packages--activities-tab--editor', 'work-packages--activities-tab--internal-comment'];- declare readonly workPackagesActivitiesTabIndexOutlet:IndexController;+ declare readonly workPackagesActivitiesTabEditorOutlet:EditorController;declare readonly workPackagesActivitiesTabInternalCommentOutlet:InternalCommentController;quote({ params: { userId, userName, textWrote, content, isInternal } }:{ params:QuoteParams }) {@@ -88,14 +88,14 @@ export default class QuoteCommentController extends Controller {}private openEditorWithInitialData(quotedText:string) {- this.workPackagesActivitiesTabIndexOutlet.openEditorWithInitialData(quotedText);+ this.workPackagesActivitiesTabEditorOutlet.openEditorWithInitialData(quotedText);}private get ckEditorInstance() {- return this.workPackagesActivitiesTabIndexOutlet.ckEditorInstance;+ return this.workPackagesActivitiesTabEditorOutlet.ckEditorInstance;}private get isFormVisible():boolean {- return !this.workPackagesActivitiesTabIndexOutlet.formRowTarget.classList.contains('d-none');+ return !this.workPackagesActivitiesTabEditorOutlet.formRowTarget.classList.contains('d-none');}}diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.tsindex dcd12cf9acb..8b4bdb39592 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts@@ -28,11 +28,11 @@* ++*/-import BaseController from './base.controller';+import { Controller } from '@hotwired/stimulus';+import { withIndexOutletMixin } from './mixins/with-index-outlet';-export default class StemsController extends BaseController {+export default class StemsController extends withIndexOutletMixin(Controller) {connect() {- super.connect();this.handleStemVisibility();}@@ -48,8 +48,8 @@ export default class StemsController extends BaseController {}private handleStemVisibilityForMobile() {- if (this.viewPortService.isMobile()) {- if (this.sortingValue === 'asc') return;+ if (this.isMobile()) {+ if (this.indexOutlet.sortingValue === 'asc') return;const initialJournalContainer = this.element.querySelector('.work-packages-activities-tab-journals-item-component-details--journal-details-container[data-initial="true"]') as HTMLElement;@@ -60,14 +60,14 @@ export default class StemsController extends BaseController {}private handleLastStemPartVisibility() {- const emptyLines = this.element.querySelectorAll('.empty-line');+ const emptyLines = this.element.querySelectorAll('.empty-line') as NodeListOf<HTMLElement>;// make sure all are visible firstemptyLines.forEach((container) => {container.classList.remove('work-packages-activities-tab-journals-item-component-details--journal-details-container--hidden');});- if (this.sortingValue === 'asc' || this.filterValue === 'only_changes') return;+ if (this.indexOutlet.sortingValue === 'asc' || this.indexOutlet.filterValue === 'only_changes') return;// then hide the last one againif (emptyLines.length > 0) {diff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rbindex 54ffd22c9eb..bf555ded007 100644--- a/spec/support/components/work_packages/activities.rb+++ b/spec/support/components/work_packages/activities.rb@@ -400,8 +400,8 @@ module Componentsdef trigger_update_streams_pollpage.execute_script(<<~JS)- var target = document.querySelector('[data-controller*="work-packages--activities-tab--index"]')- var controller = window.Stimulus.getControllerForElementAndIdentifier(target, 'work-packages--activities-tab--index')+ var target = document.querySelector('[data-controller*="work-packages--activities-tab--polling"]')+ var controller = window.Stimulus.getControllerForElementAndIdentifier(target, 'work-packages--activities-tab--polling')controller.updateActivitiesList();JS