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
introducing primerized work package activities
Jonas Jabari97f28b52fdeb
diff --git a/app/components/work_packages/activities_tab/index_component.html.erb b/app/components/work_packages/activities_tab/index_component.html.erbnew file mode 100644index 00000000000..6ab67535f89--- /dev/null+++ b/app/components/work_packages/activities_tab/index_component.html.erb@@ -0,0 +1,31 @@+<%=+ content_tag("turbo-frame", id: "work-package-activities-tab-content") do+ component_wrapper(data: wrapper_data_attributes) do+ flex_layout do |activties_tab_container|+ if journal_sorting == "desc"+ activties_tab_container.with_row do+ render(+ WorkPackages::ActivitiesTab::Journals::FormComponent.new(work_package:)+ )+ end+ end+ 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+ end+ if journal_sorting == "asc"+ activties_tab_container.with_row do+ render(+ WorkPackages::ActivitiesTab::Journals::FormComponent.new(work_package:)+ )+ end+ end+ end+ end+ end+%>diff --git a/app/components/work_packages/activities_tab/index_component.rb b/app/components/work_packages/activities_tab/index_component.rbnew file mode 100644index 00000000000..d6a151320d2--- /dev/null+++ b/app/components/work_packages/activities_tab/index_component.rb@@ -0,0 +1,81 @@+# 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+ 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_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)+ }+ 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+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.erbnew file mode 100644index 00000000000..a8f93b076a0--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/form_component.html.erb@@ -0,0 +1,13 @@+<%=+ 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))+ end+ end+%>diff --git a/app/components/work_packages/activities_tab/journals/form_component.rb b/app/components/work_packages/activities_tab/journals/form_component.rbnew file mode 100644index 00000000000..043faa4298a--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/form_component.rb@@ -0,0 +1,51 @@+#-- 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 FormComponent < 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+ end+ end+ end+enddiff --git a/app/components/work_packages/activities_tab/journals/show_component.html.erb b/app/components/work_packages/activities_tab/journals/show_component.html.erbnew file mode 100644index 00000000000..19c8f9559f6--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/show_component.html.erb@@ -0,0 +1,20 @@+<%=+ component_wrapper do+ render(Primer::Box.new(border: true, border_radius: 2, p: 3, my: 3)) do+ flex_layout do |journal_container|+ journal_container.with_row do+ render(Primer::Beta::Text.new) { @journal.notes }+ end+ if @journal.details.any?+ journal_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 }+ end+ end+ end+ end+ end+ end+ end+%>diff --git a/app/components/work_packages/activities_tab/journals/show_component.rb b/app/components/work_packages/activities_tab/journals/show_component.rbnew file mode 100644index 00000000000..930ba21d5d1--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/show_component.rb@@ -0,0 +1,51 @@+#-- 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 ShowComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(journal:)+ super++ @journal = journal+ end++ private++ def wrapper_uniq_by+ @journal.id+ end+ end+ end+ end+enddiff --git a/app/controllers/work_packages/activities_tab_controller.rb b/app/controllers/work_packages/activities_tab_controller.rbnew file mode 100644index 00000000000..ef4f4f68e61--- /dev/null+++ b/app/controllers/work_packages/activities_tab_controller.rb@@ -0,0 +1,108 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-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.+# ++++class WorkPackages::ActivitiesTabController < ApplicationController+ include OpTurbo::ComponentStream++ before_action :find_work_package+ before_action :find_project+ before_action :authorize++ def index+ render(+ WorkPackages::ActivitiesTab::IndexComponent.new(+ work_package: @work_package+ ),+ layout: false+ )+ end++ def journal_streams+ # TODO: only update specific journal components or append/prepend new journals based on latest client state+ update_via_turbo_stream(+ component: WorkPackages::ActivitiesTab::IndexComponent.new(+ work_package: @work_package+ )+ )++ respond_with_turbo_streams+ end++ def create+ 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+ )+ )+ end++ respond_with_turbo_streams+ end++ private++ def find_work_package+ @work_package = WorkPackage.find(params[:work_package_id])+ end++ def find_project+ @project = @work_package.project+ end++ def journal_sorting+ User.current.preference&.comments_sorting || "desc"+ end++ def journal_params+ params.require(:journal).permit(:notes)+ end+enddiff --git a/app/forms/work_packages/activities_tab/journal_form.rb b/app/forms/work_packages/activities_tab/journal_form.rbnew file mode 100644index 00000000000..53d48eec532--- /dev/null+++ b/app/forms/work_packages/activities_tab/journal_form.rb@@ -0,0 +1,56 @@+#-- 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+ class JournalForm < ApplicationForm+ form do |journal_form|+ journal_form.rich_text_area(+ name: :notes,+ label: nil,+ rich_text_options: {+ resource: nil,+ showAttachments: false+ }+ )+ journal_form.submit(name: :submit, label: "Save", scheme: :primary)+ end++ private++ def initialize(disabled: false)+ super()+ @disabled = disabled+ end++ def resource+ return unless object&.journal++ API::V3::Journals::JournalRepresenter+ .new(object.journal, current_user: User.current, embed_links: false)+ end+ end+enddiff --git a/app/views/work_packages/activities_tab/index.html.erb b/app/views/work_packages/activities_tab/index.html.erbnew file mode 100644index 00000000000..ca800ace383--- /dev/null+++ b/app/views/work_packages/activities_tab/index.html.erb@@ -0,0 +1,184 @@+<%#-- 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.++++#%>++<% html_title t(:label_bulk_edit_selected_work_packages) %>++<h2><%= t(:label_bulk_edit_selected_work_packages) %></h2>+<ul>+ <% @work_packages.each do |wp| %>+ <li>+ <%= link_to(h("#{wp.type} ##{wp.id}"), work_package_path(wp)) %>:+ <%= wp.subject %>+ </li>+ <% end %>+</ul>++<%= styled_form_tag(url_for(controller: '/work_packages/bulk', action: :update),+ method: :put, class: '-wide-labels') do %>+ <% @work_packages.each do |wp| %>+ <%= hidden_field_tag 'ids[]', wp.id %>+ <% end %>+ <%= back_url_hidden_field_tag %>+ <section class="form--section">+ <fieldset class="form--fieldset">+ <legend class="form--fieldset-legend"><%= t(:label_change_properties) %></legend>+ <div class="grid-block grid-block_visible-overflow">+ <div class="grid-content medium-6">+ <div class="form--field">+ <%= styled_label_tag :work_package_type_id, WorkPackage.human_attribute_name(:type) %>+ <div class="form--field-container">+ <%= styled_select_tag('work_package[type_id]', "<option value=\"\">#{t(:label_no_change_option)}</option>".html_safe + options_from_collection_for_select(@types, :id, :name)) %>+ </div>+ </div>+ <% if @available_statuses.any? %>+ <div class="form--field">+ <%= styled_label_tag :work_package_status_id, WorkPackage.human_attribute_name(:status) %>+ <div class="form--field-container">+ <%= styled_select_tag('work_package[status_id]', "<option value=\"\">#{t(:label_no_change_option)}</option>".html_safe + options_from_collection_for_select(@available_statuses, :id, :name)) %>+ </div>+ </div>+ <% else %>+ <div class="form--field">+ <%= styled_label_tag :work_package_status_id, WorkPackage.human_attribute_name(:status) %>+ <div class="form--field-container">+ <%= t('work_packages.move.no_common_statuses_exists') %>+ </div>+ </div>+ <% end %>+ <div class="form--field">+ <%= styled_label_tag :work_package_priority_id, WorkPackage.human_attribute_name(:priority) %>+ <div class="form--field-container">+ <%= styled_select_tag('work_package[priority_id]', "<option value=\"\">#{t(:label_no_change_option)}</option>".html_safe + options_from_collection_for_select(IssuePriority.active, :id, :name)) %>+ </div>+ </div>+ <div class="form--field">+ <%= styled_label_tag :work_package_assigned_to_id, WorkPackage.human_attribute_name(:assigned_to) %>+ <div class="form--field-container">+ <%= styled_select_tag('work_package[assigned_to_id]', content_tag('option', t(:label_no_change_option), value: '') ++ content_tag('option', t(:label_nobody), value: 'none') ++ options_from_collection_for_select(@assignables, :id, :name)) %>+ </div>+ </div>+ <div class="form--field">+ <%= styled_label_tag :work_package_responsible_id, WorkPackage.human_attribute_name(:responsible) %>+ <div class="form--field-container">+ <%= styled_select_tag('work_package[responsible_id]', content_tag('option', t(:label_no_change_option), value: '') ++ content_tag('option', t(:label_nobody), value: 'none') ++ options_from_collection_for_select(@responsibles, :id, :name)) %>+ </div>+ </div>+ <% if @project %>+ <div class="form--field">+ <%= styled_label_tag :work_package_category_id, WorkPackage.human_attribute_name(:category) %>+ <div class="form--field-container">+ <%= styled_select_tag('work_package[category_id]', content_tag('option', t(:label_no_change_option), value: '') ++ content_tag('option', t(:label_none), value: 'none') ++ options_from_collection_for_select(@project.categories, :id, :name)) %>+ </div>+ </div>+ <% #TODO: allow editing versions when multiple projects %>+ <div class="form--field">+ <%= styled_label_tag :work_package_version_id, WorkPackage.human_attribute_name(:version) %>+ <div class="form--field-container">+ <%= styled_select_tag('work_package[version_id]', content_tag('option', t(:label_no_change_option), value: '') ++ content_tag('option', t(:label_none), value: 'none') ++ version_options_for_select(@project.shared_versions.with_status_open.order_by_semver_name)) %>+ </div>+ </div>+ <div class="form--field">+ <%= styled_label_tag :work_package_budget_id, Budget.model_name.human %>+ <div class="form--field-container">+ <%= styled_select_tag('work_package[budget_id]',+ content_tag('option', t(:label_no_change_option), :value => '') ++ content_tag('option', t(:label_none), :value => 'none') ++ options_from_collection_for_select(@project.budgets.order(Arel.sql('subject ASC')), :id, :subject))+ %>+ </div>+ </div>+ <% end %>+ <% @custom_fields.each do |custom_field| %>+ <div class="form--field">+ <%= blank_custom_field_label_tag('work_package', custom_field) %>+ <div class="form--field-container">+ <%= custom_field_tag_for_bulk_edit('work_package', custom_field, @project) %>+ </div>+ </div>+ <% end %>+ <%= call_hook(:view_work_packages_bulk_edit_details_bottom, { work_packages: @work_packages }) %>+ </div>+ <div class="grid-content medium-6">+ <div class="form--field">+ <%= styled_label_tag :work_package_subject, WorkPackage.human_attribute_name(:subject) %>+ <div class="form--field-container">+ <%= styled_text_field_tag 'work_package[subject]', '', size: 10 %>+ </div>+ </div>+ <% if @project && User.current.allowed_in_project?(:manage_subtasks, @project) %>+ <div class="form--field">+ <%= styled_label_tag :work_package_parent_id, WorkPackage.human_attribute_name(:parent) %>+ <div class="form--field-container">+ <%= styled_text_field_tag 'work_package[parent_id]', '', size: 10 %>+ </div>+ </div>+ <div id="parent_work_package_candidates" class="autocomplete"></div>+ <% end %>+ <div class="form--field">+ <%= styled_label_tag :work_package_start_date, WorkPackage.human_attribute_name(:start_date) %>+ <div class="form--field-container -visible-overflow">+ <%= angular_component_tag 'op-basic-single-date-picker',+ inputs: {+ id: "work_package_start_date",+ name: "work_package[start_date]"+ }+ %>+ </div>+ </div>+ <div class="form--field">+ <%= styled_label_tag :work_package_due_date, WorkPackage.human_attribute_name(:due_date) %>+ <div class="form--field-container -visible-overflow">+ <%= angular_component_tag 'op-basic-single-date-picker',+ inputs: {+ id: "work_package_due_date",+ name: "work_package[due_date]"+ }+ %>+ </div>+ </div>+ </div>+ </div>+ </fieldset>+ <fieldset class="form--fieldset">+ <legend class="form--fieldset-legend"><%= Journal.human_attribute_name(:notes) %></legend>+ <%= label_tag 'work_package_journal_notes', Journal.human_attribute_name(:notes), class: 'hidden-for-sighted' %>+ <%= styled_text_area_tag 'work_package[journal_notes]', @notes, class: 'wiki-edit', with_text_formatting: true %>+ <p><%= send_notification_option %></p>+ </fieldset>+ </section>+ <p><%= styled_button_tag t(:button_submit), class: '-primary -with-icon icon-checkmark' %></p>+<% end %>diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rbindex 4b3e6ae5d73..67611c5970a 100644--- a/config/initializers/permissions.rb+++ b/config/initializers/permissions.rb@@ -111,7 +111,7 @@ Rails.application.reloader.to_prepare domap.permission :select_project_custom_fields,{- 'projects/settings/project_custom_fields': %i[show toggle enable_all_of_section disable_all_of_section]+ "projects/settings/project_custom_fields": %i[show toggle enable_all_of_section disable_all_of_section]},permissible_on: :project,require: :member@@ -186,7 +186,8 @@ Rails.application.reloader.to_prepare dojournals: %i[index],work_packages: %i[show index],work_packages_api: [:get],- "work_packages/reports": %i[report report_details]+ "work_packages/reports": %i[report report_details],+ "work_packages/activities_tab": %i[index create journal_streams]},permissible_on: %i[work_package project],contract_actions: { work_packages: %i[read] }diff --git a/config/routes.rb b/config/routes.rbindex e5c9878726a..ebe978da5ee 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -528,6 +528,12 @@ Rails.application.routes.draw doendend+ resources :activities, controller: "work_packages/activities_tab", only: %i[index create] do+ collection do+ get :journal_streams+ end+ end+resource :progress, only: %i[new edit update], controller: "work_packages/progress"collection doresource :progress,diff --git a/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment.component.html b/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment.component.htmlindex d18e3d2d6a9..3bff5b7611e 100644--- a/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment.component.html+++ b/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment.component.html@@ -1,4 +1,18 @@-<div id="work-package-activites-container">+<div *ngIf="primerizedActivitiesEnabled" id="work-package-activites-container">+ <turbo-frame [src]="turboFrameSrc" id="work-package-activities-tab-content" loading="lazy">+ <op-content-loader viewBox="0 0 100 100">+ <svg:rect x="0" y="0" width="70" height="5" rx="1" />++ <svg:rect x="75" y="0" width="25" height="5" rx="1" />++ <svg:rect x="0" y="10" width="100" height="8" rx="1" />++ <svg:rect x="0" y="25" width="100" height="12" rx="1" />+ </op-content-loader>+ </turbo-frame>+</div>++<div *ngIf="!primerizedActivitiesEnabled" id="work-package-activites-container"><div id="work-package-comment-container"><ng-container *ngIf="!showAbove" [ngTemplateOutlet]="template"></ng-container>diff --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 02fcc08be3d..bdfa709527b 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@@ -51,9 +51,11 @@ import { WorkPackagesActivityService } from 'core-app/features/work-packages/comimport { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { ErrorResource } from 'core-app/features/hal/resources/error-resource';import { HalError } from 'core-app/features/hal/services/hal-error';+import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import {filter,take,+ timeout,} from 'rxjs/operators';@Component({@@ -83,6 +85,10 @@ export class WorkPackageCommentComponent extends WorkPackageCommentFieldHandlerpublic showAbove:boolean;+ public primerizedActivitiesEnabled:boolean;++ public turboFrameSrc:string;+public htmlId = 'wp-comment-field';constructor(protected elementRef:ElementRef,@@ -95,7 +101,8 @@ export class WorkPackageCommentComponent extends WorkPackageCommentFieldHandlerprotected workPackageNotificationService:WorkPackageNotificationService,protected toastService:ToastService,protected cdRef:ChangeDetectorRef,- protected I18n:I18nService) {+ protected I18n:I18nService,+ readonly PathHelper:PathHelperService) {super(elementRef, injector);}@@ -104,6 +111,8 @@ export class WorkPackageCommentComponent extends WorkPackageCommentFieldHandlerthis.canAddComment = !!this.workPackage.addComment;this.showAbove = this.configurationService.commentsSortedInDescendingOrder();+ this.primerizedActivitiesEnabled = true; // TODO: check for feature flag setting+ this.turboFrameSrc = `${this.PathHelper.staticBase}/work_packages/${this.workPackage.id}/activities`;this.commentService.draft$.pipe(diff --git a/frontend/src/app/features/work-packages/components/wp-edit/work-package-changeset.ts b/frontend/src/app/features/work-packages/components/wp-edit/work-package-changeset.tsindex c3951ee57a6..a41c40b0a80 100644--- a/frontend/src/app/features/work-packages/components/wp-edit/work-package-changeset.ts+++ b/frontend/src/app/features/work-packages/components/wp-edit/work-package-changeset.ts@@ -11,6 +11,13 @@ export class WorkPackageChangeset extends ResourceChangeset<WorkPackageResource>if (key === 'project' || key === 'type') {this.updateForm();}++ // Emit event to notify Stimulus controller in activities tab in order to update the activities list+ // TODO: emit event when change is persisted+ // currently the event might be fired too early as it only reflects the client side change+ document.dispatchEvent(+ new CustomEvent('work-package-updated'),+ );}protected applyChanges(payload:any):any {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.tsnew file mode 100644index 00000000000..0a38798d3a7--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts@@ -0,0 +1,71 @@+/*+ * -- 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 * as Turbo from '@hotwired/turbo';+import { Controller } from '@hotwired/stimulus';++export default class IndexController extends Controller {+ static values = {+ journalStreamsUrl: String,+ };++ declare journalStreamsUrlValue:string;++ connect() {+ this.handleWorkPackageUpdate = this.handleWorkPackageUpdate.bind(this);+ document.addEventListener('work-package-updated', this.handleWorkPackageUpdate);+ }++ disconnect() {+ document.removeEventListener('work-package-updated', this.handleWorkPackageUpdate);+ }++ async handleWorkPackageUpdate(event:Event) {+ setTimeout(() => {+ this.updateActivitiesList();+ }, 2000); // TODO: wait dynamically for persisted change before updating the activities list+ }++ async updateActivitiesList() {+ const response = await fetch(this.journalStreamsUrlValue, {+ method: 'GET',+ headers: {+ 'X-CSRF-Token': (document.querySelector('meta[name="csrf-token"]') as HTMLMetaElement).content,+ Accept: 'text/vnd.turbo-stream.html',+ },+ credentials: 'same-origin',+ });++ if (response.ok) {+ const text = await response.text();+ Turbo.renderStreamMessage(text);+ }+ }+}