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
WIP: primerizing work_package activities, editing not yet implemented, tagging users not yet possible
Jonas Jabari932bb52dbb7c
diff --git a/app/components/_index.sass b/app/components/_index.sassindex df5d51df72f..9bbe0035237 100644--- a/app/components/_index.sass+++ b/app/components/_index.sass@@ -1,3 +1,4 @@+@import "work_packages/activities_tab/journals/new_component"@import "work_packages/share/modal_body_component"@import "work_packages/share/invite_user_form_component"@import "work_packages/progress/modal_body_component"diff --git a/app/components/work_packages/activities_tab/index_component.html.erb b/app/components/work_packages/activities_tab/index_component.html.erbindex 6ab67535f89..cc375be53e1 100644--- a/app/components/work_packages/activities_tab/index_component.html.erb+++ b/app/components/work_packages/activities_tab/index_component.html.erb@@ -5,23 +5,19 @@if journal_sorting == "desc"activties_tab_container.with_row dorender(- WorkPackages::ActivitiesTab::Journals::FormComponent.new(work_package:)+ WorkPackages::ActivitiesTab::Journals::NewComponent.new(work_package:))endend- activties_tab_container.with_row(flex_layout: true, id: insert_target_modifier_id) do |journals_container|- journals.each do |journal|- journals_container.with_row do- render(- WorkPackages::ActivitiesTab::Journals::ShowComponent.new(journal:)- )- end- end+ activties_tab_container.with_row do+ render(+ WorkPackages::ActivitiesTab::Journals::IndexComponent.new(work_package:)+ )endif journal_sorting == "asc"activties_tab_container.with_row dorender(- WorkPackages::ActivitiesTab::Journals::FormComponent.new(work_package:)+ WorkPackages::ActivitiesTab::Journals::NewComponent.new(work_package:))endenddiff --git a/app/components/work_packages/activities_tab/index_component.rb b/app/components/work_packages/activities_tab/index_component.rbindex d6a151320d2..fd9e39468eb 100644--- a/app/components/work_packages/activities_tab/index_component.rb+++ b/app/components/work_packages/activities_tab/index_component.rb@@ -45,19 +45,12 @@ module WorkPackagesattr_reader :work_package- def insert_target_modified?- true- end-- def insert_target_id- "work-package-journals"- end-def wrapper_data_attributes{controller: "work-packages--activities-tab--index","application-target": "dynamic",- "work-packages--activities-tab--index-journal-streams-url-value": journal_streams_work_package_activities_path(work_package)+ "work-packages--activities-tab--index-journal-streams-url-value": journal_streams_work_package_activities_path(work_package),+ "work-packages--activities-tab--index-sorting-value": journal_sorting}enddiff --git a/app/components/work_packages/activities_tab/journals/form_component.html.erb b/app/components/work_packages/activities_tab/journals/form_component.html.erbindex a8f93b076a0..c17f19237af 100644--- a/app/components/work_packages/activities_tab/journals/form_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/form_component.html.erb@@ -1,13 +1,31 @@<%=- component_wrapper do- primer_form_with(- id: "work-package-journal-form",- model: journal,- method: :post,- data: { turbo: true, turbo_stream: true },- url: work_package_activities_path(work_package_id: work_package.id),- ) do |f|- render(WorkPackages::ActivitiesTab::JournalForm.new(f))+ primer_form_with(+ id: "work-package-journal-form",+ model: journal,+ method: :post,+ data: { turbo: true, turbo_stream: true },+ url: submit_path,+ ) do |f|+ flex_layout do |form_container|+ form_container.with_row do+ render(WorkPackages::ActivitiesTab::Journals::NotesForm.new(f))+ end+ form_container.with_row(flex_layout: true, mt: 3, justify_content: :flex_end) do |submit_container|+ submit_container.with_column(mr: 2) do+ render(Primer::Beta::Button.new(+ scheme: :default,+ size: :medium,+ data: {+ "action": "click->work-packages--activities-tab--new#hideForm"+ }+ )) do+ render(Primer::Beta::Text.new()) { I18n.t("button_cancel") }+ end+ end+ submit_container.with_column do+ render(WorkPackages::ActivitiesTab::Journals::Submit.new(f))+ end+ endendend%>diff --git a/app/components/work_packages/activities_tab/journals/form_component.rb b/app/components/work_packages/activities_tab/journals/form_component.rbindex 043faa4298a..25525fcd28c 100644--- a/app/components/work_packages/activities_tab/journals/form_component.rb+++ b/app/components/work_packages/activities_tab/journals/form_component.rb@@ -32,19 +32,15 @@ module WorkPackagesclass FormComponent < ApplicationComponentinclude ApplicationHelperinclude OpPrimer::ComponentHelpers- include OpTurbo::Streamable- def initialize(work_package:)+ def initialize(journal:, submit_path:)super- @work_package = work_package+ @journal = journal+ @submit_path = submit_pathend- attr_reader :work_package-- def journal- Journal.new(journable: work_package)- end+ attr_reader :journal, :submit_pathendendenddiff --git a/app/components/work_packages/activities_tab/journals/index_component.html.erb b/app/components/work_packages/activities_tab/journals/index_component.html.erbnew file mode 100644index 00000000000..c31a60b7d8b--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/index_component.html.erb@@ -0,0 +1,13 @@+<%=+ component_wrapper do+ flex_layout(id: insert_target_modifier_id) do |journals_index_container|+ journals.each do |journal|+ journals_index_container.with_row do+ render(+ WorkPackages::ActivitiesTab::Journals::ShowComponent.new(journal:)+ )+ end+ end+ end+ end+%>diff --git a/app/components/work_packages/activities_tab/journals/index_component.rb b/app/components/work_packages/activities_tab/journals/index_component.rbnew file mode 100644index 00000000000..5eb71d2cbcc--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/index_component.rb@@ -0,0 +1,75 @@+# frozen_string_literal: true++# -- 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.+# ++++module WorkPackages+ module ActivitiesTab+ module Journals+ class IndexComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(work_package:)+ super++ @work_package = work_package+ end++ private++ attr_reader :work_package++ def insert_target_modified?+ true+ end++ def insert_target_modifier_id+ "work-package-journals"+ end++ def journal_sorting+ User.current.preference&.comments_sorting || "desc"+ end++ def only_comments?+ false # TODO: Implement this+ end++ def journals+ result = work_package.journals.includes(:user).reorder(version: journal_sorting)++ result = result.where.not(notes: "") if only_comments?++ result+ end+ end+ end+ end+enddiff --git a/app/components/work_packages/activities_tab/journals/new_component.html.erb b/app/components/work_packages/activities_tab/journals/new_component.html.erbnew file mode 100644index 00000000000..31482dbb115--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/new_component.html.erb@@ -0,0 +1,30 @@+<%=+ component_wrapper(data: wrapper_data_attributes) do+ flex_layout(my: 2) do |new_form_container|+ new_form_container.with_row() do+ render(Primer::Beta::Button.new(+ scheme: :default,+ size: :medium,+ block: true,+ data: {+ "work-packages--activities-tab--new-target": "button",+ "action": "click->work-packages--activities-tab--new#showForm"+ }+ )) do+ render(Primer::Beta::Text.new()) { I18n.t("js.label_add_comment_title") }+ end+ end+ new_form_container.with_row(+ display: :none,+ data: { "work-packages--activities-tab--new-target": "form" }+ ) do+ render(+ WorkPackages::ActivitiesTab::Journals::FormComponent.new(+ journal:,+ submit_path: work_package_activities_path(work_package_id: work_package.id)+ )+ )+ end+ end+ end+%>diff --git a/app/components/work_packages/activities_tab/journals/new_component.rb b/app/components/work_packages/activities_tab/journals/new_component.rbnew file mode 100644index 00000000000..91a980e3190--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/new_component.rb@@ -0,0 +1,58 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-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.+#++++module WorkPackages+ module ActivitiesTab+ module Journals+ class NewComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(work_package:)+ super++ @work_package = work_package+ end++ attr_reader :work_package++ def journal+ Journal.new(journable: work_package)+ end++ def wrapper_data_attributes+ {+ controller: "work-packages--activities-tab--new",+ "application-target": "dynamic"+ }+ end+ end+ end+ end+enddiff --git a/app/components/work_packages/activities_tab/journals/new_component.sass b/app/components/work_packages/activities_tab/journals/new_component.sassnew file mode 100644index 00000000000..f21398240e0--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/new_component.sass@@ -0,0 +1,3 @@+#work-packages-activities-tab-journals-new-component+ #work-package-journal-new-label+ cursor: pointerdiff --git a/app/components/work_packages/activities_tab/journals/show_component.html.erb b/app/components/work_packages/activities_tab/journals/show_component.html.erbindex 19c8f9559f6..387bcd99864 100644--- a/app/components/work_packages/activities_tab/journals/show_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/show_component.html.erb@@ -1,15 +1,75 @@<%=- component_wrapper do- render(Primer::Box.new(border: true, border_radius: 2, p: 3, my: 3)) do+ component_wrapper(data: wrapper_data_attributes) do+ render(Primer::Box.new(id: "activity-#{@journal.version}", border: true, border_radius: 2, p: 3, my: 2)) doflex_layout do |journal_container|- journal_container.with_row do- render(Primer::Beta::Text.new) { @journal.notes }+ journal_container.with_row(flex_layout: true, align_items: :center, justify_content: :space_between) do |header_container|+ header_container.with_column(flex_layout: true) do |header_start_container|+ header_start_container.with_column(mr: 2) do+ render Users::AvatarComponent.new(user: @journal.user, show_name: false)+ end+ header_start_container.with_column(flex_layout: true) do |header_text_container|+ header_text_container.with_row do+ render(Primer::Beta::Link.new(+ href: user_url(@journal.user),+ target: "_blank",+ scheme: :primary,+ underline: false,+ font_weight: :bold+ )) do+ @journal.user.name+ end+ end+ header_text_container.with_row(flex_layout: true) do |header_text_timestamp_container|+ header_text_timestamp_container.with_column(mr: 1) do+ render(Primer::Beta::Text.new(color: :subtle, mt: 1, font_size: :small)) do+ if updated?+ I18n.t("attributes.updated_at")+ else+ I18n.t("attributes.created_at")+ end+ end+ end+ header_text_timestamp_container.with_column do+ render(Primer::Beta::Text.new(color: :subtle, mt: 1, font_size: :small)) { format_time(@journal.updated_at) }+ end+ end+ end+ end+ header_container.with_column(flex_layout: true, align_items: :center) do |header_end_container|+ header_end_container.with_column do+ render(Primer::Beta::Link.new(+ href: activity_anchor,+ scheme: :secondary,+ underline: false,+ font_size: :small,+ data: { turbo: false }+ )) do+ "##{@journal.version}"+ end+ end+ header_end_container.with_column(ml: 2) do+ render(Primer::Alpha::ActionMenu.new) do |menu|+ menu.with_show_button(icon: "kebab-horizontal",+ 'aria-label': I18n.t(:button_actions),+ scheme: :invisible)+ copy_url_action_item(menu)+ edit_action_item(menu) if editable?+ end+ end+ end+ end+ if @journal.notes.present?+ journal_container.with_row(mt: 3) do+ render(Primer::Box.new(mt: 1)) do+ format_text(@journal, :notes)+ end+ endend- if @journal.details.any?+ if @journal.details.any? && @journal.version != 1journal_container.with_row(flex_layout: true, border_radius: 2, p: 3, my: 3, bg: :subtle) do |details_container|@journal.details.each do |detail|- details_container.with_row do- render(Primer::Beta::Text.new) { detail.to_s }+ details_container.with_row(mt: 1, font_size: :small) do+ render(Primer::Beta::Text.new) { @journal.render_detail(detail) }endendenddiff --git a/app/components/work_packages/activities_tab/journals/show_component.rb b/app/components/work_packages/activities_tab/journals/show_component.rbindex 930ba21d5d1..bad947775f7 100644--- a/app/components/work_packages/activities_tab/journals/show_component.rb+++ b/app/components/work_packages/activities_tab/journals/show_component.rb@@ -31,6 +31,8 @@ module WorkPackagesmodule Journalsclass ShowComponent < ApplicationComponentinclude ApplicationHelper+ include AvatarHelper+ include JournalFormatterinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable@@ -45,6 +47,71 @@ module WorkPackagesdef wrapper_uniq_by@journal.idend++ def wrapper_data_attributes+ {+ controller: "work-packages--activities-tab--show",+ "application-target": "dynamic",+ "work-packages--activities-tab--show-activity-url-value": activity_url+ }+ end++ def activity_url+ "#{project_work_package_url(@journal.journable.project, @journal.journable)}/activity#{activity_anchor}"+ end++ def activity_anchor+ "#activity-#{@journal.version}"+ end++ def data_type+ @journal.data_type+ end++ def editable?+ @journal.user == User.current+ end++ def initial_version?+ @journal.version == 1+ end++ def updated?+ return false if initial_version?++ @journal.updated_at - @journal.created_at > 5.seconds+ end++ def copy_url_action_item(menu)+ menu.with_item(label: t("button_copy_link_to_clipboard"),+ tag: :button,+ content_arguments: {+ data: {+ action: "click->work-packages--activities-tab--show#copyActivityUrlToClipboard"+ }+ }) do |item|+ item.with_leading_visual_icon(icon: :copy)+ end+ end++ def edit_action_item(menu)+ # menu.with_item(label: t("label_edit"),+ # href: edit_work_package_activity_path(@journal.journable, @journal),+ # content_arguments: {+ # data: { "turbo-stream": true }+ # }) do |item|+ # item.with_leading_visual_icon(icon: :pencil)+ # end+ menu.with_item(label: t("label_edit"),+ tag: :button,+ content_arguments: {+ data: {+ action: "click->work-packages--activities-tab--show#edit"+ }+ }) do |item|+ item.with_leading_visual_icon(icon: :pencil)+ end+ endendendenddiff --git a/app/controllers/work_packages/activities_tab_controller.rb b/app/controllers/work_packages/activities_tab_controller.rbindex ef4f4f68e61..2d801d4df11 100644--- a/app/controllers/work_packages/activities_tab_controller.rb+++ b/app/controllers/work_packages/activities_tab_controller.rb@@ -47,7 +47,7 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerdef journal_streams# TODO: only update specific journal components or append/prepend new journals based on latest client stateupdate_via_turbo_stream(- component: WorkPackages::ActivitiesTab::IndexComponent.new(+ component: WorkPackages::ActivitiesTab::Journals::IndexComponent.new(work_package: @work_package))@@ -56,35 +56,18 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerenddef create+ latest_journal_version = @work_package.journals.last.try(:version) || 0+call = Journals::CreateService.new(@work_package, User.current).call(notes: journal_params[:notes])- if call.success?- stream_config = {- target_component: WorkPackages::ActivitiesTab::IndexComponent.new(- work_package: @work_package- ),- component: WorkPackages::ActivitiesTab::Journals::ShowComponent.new(- journal: call.result- )- }-- # Append or prepend the new journal depending on the sorting- if journal_sorting == "asc"- append_via_turbo_stream(**stream_config)- else- prepend_via_turbo_stream(**stream_config)- end-- # Clear the form- update_via_turbo_stream(- component: WorkPackages::ActivitiesTab::Journals::FormComponent.new(- work_package: @work_package- )- )+ if call.success? && call.result+ after_create_turbo_stream(call, latest_journal_version)end+ clear_form_via_turbo_stream+respond_with_turbo_streamsend@@ -105,4 +88,46 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerdef journal_paramsparams.require(:journal).permit(:notes)end++ def after_create_turbo_stream(call, latest_journal_version)+ # journals might get merged in some cases,+ # thus we need to check if the journal is already present and update it rather then ap/prepending it+ if latest_journal_version < call.result.version+ append_or_prepend_latest_journal_via_turbo_stream(call.result)+ else+ update_journal_via_turbo_stream(call.result)+ end+ end++ def append_or_prepend_latest_journal_via_turbo_stream(journal)+ stream_config = {+ target_component: WorkPackages::ActivitiesTab::Journals::IndexComponent.new(+ work_package: @work_package+ ),+ component: WorkPackages::ActivitiesTab::Journals::ShowComponent.new(+ journal:+ )+ }++ # Append or prepend the new journal depending on the sorting+ if journal_sorting == "asc"+ append_via_turbo_stream(**stream_config)+ else+ prepend_via_turbo_stream(**stream_config)+ end+ end++ def update_journal_via_turbo_stream(journal)+ update_via_turbo_stream(+ component: WorkPackages::ActivitiesTab::Journals::ShowComponent.new(journal:)+ )+ end++ def clear_form_via_turbo_stream+ update_via_turbo_stream(+ component: WorkPackages::ActivitiesTab::Journals::NewComponent.new(+ work_package: @work_package+ )+ )+ endenddiff --git a/app/forms/work_packages/activities_tab/journal_form.rb b/app/forms/work_packages/activities_tab/journals/notes_form.rbsimilarity index 84%rename from app/forms/work_packages/activities_tab/journal_form.rbrename to app/forms/work_packages/activities_tab/journals/notes_form.rbindex 53d48eec532..6ec9038b92f 100644--- a/app/forms/work_packages/activities_tab/journal_form.rb+++ b/app/forms/work_packages/activities_tab/journals/notes_form.rb@@ -25,10 +25,10 @@## See COPYRIGHT and LICENSE files for more details.#++-module WorkPackages::ActivitiesTab- class JournalForm < ApplicationForm- form do |journal_form|- journal_form.rich_text_area(+module WorkPackages::ActivitiesTab::Journals+ class NotesForm < ApplicationForm+ form do |notes_form|+ notes_form.rich_text_area(name: :notes,label: nil,rich_text_options: {@@ -36,16 +36,10 @@ module WorkPackages::ActivitiesTabshowAttachments: false})- journal_form.submit(name: :submit, label: "Save", scheme: :primary)endprivate- def initialize(disabled: false)- super()- @disabled = disabled- end-def resourcereturn unless object&.journaldiff --git a/app/forms/work_packages/activities_tab/journals/submit.rb b/app/forms/work_packages/activities_tab/journals/submit.rbnew file mode 100644index 00000000000..4c49a840a4b--- /dev/null+++ b/app/forms/work_packages/activities_tab/journals/submit.rb@@ -0,0 +1,34 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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.+#+++module WorkPackages::ActivitiesTab::Journals+ class Submit < ApplicationForm+ form do |notes_form|+ notes_form.submit(name: :submit, label: "Save", scheme: :primary)+ end+ end+enddiff --git a/config/initializers/feature_decisions.rb b/config/initializers/feature_decisions.rbindex e98381d9be1..ac2c8470307 100644--- a/config/initializers/feature_decisions.rb+++ b/config/initializers/feature_decisions.rb@@ -38,3 +38,5 @@ require_relative "../../lib_static/open_project/feature_decisions"# initializer 'the_engine.feature_decisions' do# OpenProject::FeatureDecisions.add :some_flag# end+#+OpenProject::FeatureDecisions.add :primerized_work_package_activitiesdiff --git a/config/routes.rb b/config/routes.rbindex ebe978da5ee..c5d6cc885b9 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -528,7 +528,7 @@ Rails.application.routes.draw doendend- resources :activities, controller: "work_packages/activities_tab", only: %i[index create] do+ resources :activities, controller: "work_packages/activities_tab", only: %i[index create edit] docollection doget :journal_streamsenddiff --git a/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment.component.ts b/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment.component.tsindex bdfa709527b..d85c3a9d919 100644--- a/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment.component.ts+++ b/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment.component.ts@@ -111,7 +111,7 @@ export class WorkPackageCommentComponent extends WorkPackageCommentFieldHandlerthis.canAddComment = !!this.workPackage.addComment;this.showAbove = this.configurationService.commentsSortedInDescendingOrder();- this.primerizedActivitiesEnabled = true; // TODO: check for feature flag setting+ this.primerizedActivitiesEnabled = this.configurationService.activeFeatureFlags.includes('primerizedWorkPackageActivities');this.turboFrameSrc = `${this.PathHelper.staticBase}/work_packages/${this.workPackage.id}/activities`;this.commentService.draft$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 0a38798d3a7..652a89230ea 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@@ -34,19 +34,45 @@ import { Controller } from '@hotwired/stimulus';export default class IndexController extends Controller {static values = {journalStreamsUrl: String,+ sorting: String,};declare journalStreamsUrlValue:string;+ declare sortingValue:string;connect() {this.handleWorkPackageUpdate = this.handleWorkPackageUpdate.bind(this);document.addEventListener('work-package-updated', this.handleWorkPackageUpdate);++ if (window.location.hash.includes('#activity-')) {+ this.scrollToActivity();+ } else if (this.sortingValue === 'asc') {+ this.scrollToBottom();+ }}disconnect() {document.removeEventListener('work-package-updated', this.handleWorkPackageUpdate);}+ scrollToActivity() {+ const activityId = window.location.hash.replace('#activity-', '');+ const activityElement = document.getElementById(`activity-${activityId}`);+ if (activityElement) {+ activityElement.scrollIntoView({ behavior: 'smooth' });+ }+ }++ scrollToBottom():void {+ // copied from frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment.component.ts+ const scrollableContainer = jQuery(this.element).scrollParent()[0];+ if (scrollableContainer) {+ setTimeout(() => {+ scrollableContainer.scrollTop = scrollableContainer.scrollHeight;+ }, 400);+ }+ }+async handleWorkPackageUpdate(event:Event) {setTimeout(() => {this.updateActivitiesList();diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/new.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/new.controller.tsnew file mode 100644index 00000000000..365a88a45ae--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/new.controller.ts@@ -0,0 +1,53 @@+/*+ * -- 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';++export default class NewController extends Controller {+ static targets = ['button', 'form'];+ declare readonly buttonTarget:HTMLInputElement;+ declare readonly formTarget:HTMLInputElement;++ showForm() {+ this.buttonTarget.classList.add('d-none');+ this.formTarget.classList.remove('d-none');+ setTimeout(() => {+ const ckEditorElement = this.formTarget.querySelectorAll('.document-editor__editable')[0] as HTMLElement;+ if (ckEditorElement) {+ ckEditorElement.focus();+ }+ }, 10);+ }++ hideForm() {+ this.buttonTarget.classList.remove('d-none');+ this.formTarget.classList.add('d-none');+ }+}diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/show.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/show.controller.tsnew file mode 100644index 00000000000..047c04efe70--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/show.controller.ts@@ -0,0 +1,47 @@+/*+ * -- 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';++export default class ShowController extends Controller {+ static values = {+ activityUrl: String,+ };++ declare activityUrlValue:string;++ async copyActivityUrlToClipboard() {+ await navigator.clipboard.writeText(this.activityUrlValue);+ }++ edit() {+ alert('Not yet implemented');+ }+}