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
Create component-based split view
Oliver Günther0c7e43df79f8
diff --git a/app/components/work_packages/details/tab_component.html.erb b/app/components/work_packages/details/tab_component.html.erbnew file mode 100644index 00000000000..0c7b53a2972--- /dev/null+++ b/app/components/work_packages/details/tab_component.html.erb@@ -0,0 +1,10 @@+<%=+ render(Primer::Alpha::UnderlineNav.new(align: :left, label: "Tabs")) do |component|+ %i[overview activity files relations watchers github gitlab meetings].each do |tab|+ component.with_tab(selected: @tab == tab,+ href: url_for(tab: tab)) do |c|+ c.with_text { t("js.work_packages.tabs.#{tab}") }+ end+ end+ end+%>diff --git a/app/components/work_packages/details/tab_component.rb b/app/components/work_packages/details/tab_component.rbnew file mode 100644index 00000000000..09fe0242f17--- /dev/null+++ b/app/components/work_packages/details/tab_component.rb@@ -0,0 +1,11 @@+# frozen_string_literal: true++class WorkPackages::Details::TabComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(id:, tab: :overview)+ @id = id+ @tab = tab.to_sym+ end+enddiff --git a/app/components/work_packages/split_view_component.html.erb b/app/components/work_packages/split_view_component.html.erbnew file mode 100644index 00000000000..5ae2ac28d1c--- /dev/null+++ b/app/components/work_packages/split_view_component.html.erb@@ -0,0 +1,16 @@+<%=+ content_tag("turbo-frame", id: "work-package-details-#{@id}") do+ flex_layout(h: :full) do |flex|+ flex.with_row do+ render(WorkPackages::Details::TabComponent.new(id: @id, tab: @tab))+ end+ flex.with_row(flex: 1) do+ helpers.angular_component_tag "opce-wp-split-view",+ inputs: {+ work_package_id: params[:work_package_id],+ activeTab: @tab+ }+ end+ end+ end+%>diff --git a/app/components/work_packages/split_view_component.rb b/app/components/work_packages/split_view_component.rbnew file mode 100644index 00000000000..2fa98f63aff--- /dev/null+++ b/app/components/work_packages/split_view_component.rb@@ -0,0 +1,11 @@+# frozen_string_literal: true++class WorkPackages::SplitViewComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(id:, tab: 'overview')+ @id = id+ @tab = tab+ end+enddiff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rbindex 27862273f08..3df58827cef 100644--- a/app/controllers/notifications_controller.rb+++ b/app/controllers/notifications_controller.rb@@ -29,7 +29,7 @@class NotificationsController < ApplicationControllerbefore_action :require_loginbefore_action :filtered_query, only: :mark_all_read- no_authorization_required! :index, :mark_all_read+ no_authorization_required! :index, :split_view, :mark_all_readdef index# Frontend will handle rendering@@ -37,6 +37,14 @@ class NotificationsController < ApplicationControllerrender layout: "angular/notifications"end+ def split_view+ respond_to do |format|+ format.html do+ render :index, layout: "angular/notifications"+ end+ end+ end+def mark_all_readif filtered_query.valid?filtered_query.results.update_all(read_ian: true, updated_at: Time.zone.now)diff --git a/app/helpers/work_packages/split_view_helper.rb b/app/helpers/work_packages/split_view_helper.rbnew file mode 100644index 00000000000..edeb97b2527--- /dev/null+++ b/app/helpers/work_packages/split_view_helper.rb@@ -0,0 +1,9 @@+module WorkPackages::SplitViewHelper+ def optional_work_package_split_view+ return unless params[:work_package_split_view]++ content_for :content_body_right do+ render WorkPackages::SplitViewComponent.new(id: params[:work_package_id], tab: params[:tab])+ end+ end+enddiff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erbindex af811c9cb70..d2b79d21eba 100644--- a/app/views/notifications/index.html.erb+++ b/app/views/notifications/index.html.erb@@ -1,23 +1,16 @@<% html_title t("js.notifications.title") %>-<% content_for :content_body do %>-<%= render(Notifications::IndexPageHeaderComponent.new(- facet: params[:facet],- filter_name: params[:name],- filter_type: params[:filter]-)) %>+<% content_for :content_header do %>+ <%= render(Notifications::IndexPageHeaderComponent.new(+ facet: params[:facet],+ filter_name: params[:name],+ filter_type: params[:filter]+ )) %>+<% end %>-<%= angular_component_tag "opce-notification-center" %>+<% content_for :content_body do %>+ <%= angular_component_tag "opce-notification-center" %><% end %>-<% if params[:work_package_id] %>- <% content_for :content_body_right do %>- <%= angular_component_tag "opce-wp-split-view",- inputs: {- work_package_id: params[:work_package_id],- activeTab: "overview"- }- %>- <% end %>-<% end %>+<% optional_work_package_split_view %>diff --git a/config/routes.rb b/config/routes.rbindex 113c7a64801..223f608f278 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -700,7 +700,12 @@ Rails.application.routes.draw doroot to: "account#login"concern :with_split_view do |options|- get "details/:work_package_id(/:tab)", on: :collection, action: options.fetch(:action, :index), as: :details+ get "details/:work_package_id(/:tab)",+ on: :collection,+ action: options.fetch(:action, :split_view),+ defaults: { tab: :overview },+ as: :details,+ work_package_split_view: trueendresources :notifications, only: :index dodiff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.tsindex 3013cd4a850..ba2cb680fc0 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts@@ -26,19 +26,19 @@// See COPYRIGHT and LICENSE files for more details.//++-import {- ChangeDetectorRef,- Directive,- OnInit,-} from '@angular/core';+import { ChangeDetectorRef, Directive, OnInit } from '@angular/core';import { UIRouterGlobals } from '@uirouter/core';import { Observable } from 'rxjs';-import { map, distinctUntilChanged } from 'rxjs/operators';+import { distinctUntilChanged, map } from 'rxjs/operators';import { take } from 'rxjs/internal/operators/take';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { HalResource } from 'core-app/features/hal/resources/hal-resource';-import { ActivityEntryInfo } from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info';-import { WorkPackagesActivityService } from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/wp-activity.service';+import {+ ActivityEntryInfo,+} from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info';+import {+ WorkPackagesActivityService,+} from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/wp-activity.service';import { I18nService } from 'core-app/core/i18n/i18n.service';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';@@ -93,11 +93,7 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implementsthis.reverse = wpActivity.isReversed;this.togglerText = this.text.commentsOnly;- const lastTransitionName = uiRouterGlobals.successfulTransitions.peekTail().from().name as string;- const comingFromNotifications = /^notifications/.test(lastTransitionName);- const firstRouteOnMobile = lastTransitionName === '' && this.browserDetector.isMobile;-- if (comingFromNotifications || firstRouteOnMobile) {+ if (window.location.href.includes('/notifications')) {this.comingFromNotifications = true;}}diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.component.tsindex 26d9a90715c..a0bedd77547 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.component.ts@@ -26,14 +26,12 @@// See COPYRIGHT and LICENSE files for more details.//++-import {- ChangeDetectionStrategy,- Component,- Input,-} from '@angular/core';+import { ChangeDetectionStrategy, Component, Input } from '@angular/core';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { trackByProperty } from 'core-app/shared/helpers/angular/tracking-functions';-import { ActivityPanelBaseController } from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller';+import {+ ActivityPanelBaseController,+} from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller';@Component({templateUrl: './activity-tab.html',@@ -49,7 +47,7 @@ export class WorkPackageActivityTabComponent extends ActivityPanelBaseControllerngOnInit() {const { workPackageId } = this.uiRouterGlobals.params as unknown as { workPackageId:string };- this.workPackageId = workPackageId;+ this.workPackageId = (this.workPackage.id as string) || workPackageId;super.ngOnInit();}}diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/relations-tab/relations-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/relations-tab/relations-tab.component.tsindex 07bb6364f17..c42e70c85b6 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/relations-tab/relations-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/relations-tab/relations-tab.component.ts@@ -26,7 +26,7 @@// See COPYRIGHT and LICENSE files for more details.//++-import { Transition } from '@uirouter/core';+import { UIRouterGlobals } from '@uirouter/core';import { Component, Input, OnInit } from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';@@ -42,24 +42,27 @@ export class WorkPackageRelationsTabComponent extends UntilDestroyedMixin implem@Input() public workPackage:WorkPackageResource;- public constructor(readonly I18n:I18nService,- readonly $transition:Transition,- readonly apiV3Service:ApiV3Service) {+ public constructor(+ readonly I18n:I18nService,+ readonly uiRouterGlobals:UIRouterGlobals,+ readonly apiV3Service:ApiV3Service,+ ) {super();}ngOnInit() {- const wpId = this.workPackageId || this.$transition.params('to').workPackageId;+ const { workPackageId } = this.uiRouterGlobals.params as unknown as { workPackageId:string };+ this.workPackageId = (this.workPackage.id as string) || workPackageId;+this.apiV3Service.work_packages- .id(wpId)+ .id(this.workPackageId).requireAndStream().pipe(this.untilDestroyed(),).subscribe((wp) => {- this.workPackageId = wp.id!;this.workPackage = wp;});}diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.tsindex 50ea8c0cf43..84e6c65c593 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.ts@@ -26,23 +26,20 @@// See COPYRIGHT and LICENSE files for more details.//++-import {- ChangeDetectionStrategy,- ChangeDetectorRef,- Component,- ElementRef,- Input,- OnInit,-} from '@angular/core';-import { Transition } from '@uirouter/core';+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, Input, OnInit } from '@angular/core';+import { UIRouterGlobals } from '@uirouter/core';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { LoadingIndicatorService } from 'core-app/core/loading-indicator/loading-indicator.service';import { I18nService } from 'core-app/core/i18n/i18n.service';-import { WorkPackageWatchersService } from 'core-app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watchers.service';+import {+ WorkPackageWatchersService,+} from 'core-app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watchers.service';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import { trackByHref } from 'core-app/shared/helpers/angular/tracking-functions';-import { WorkPackageNotificationService } from 'core-app/features/work-packages/services/notifications/work-package-notification.service';+import {+ WorkPackageNotificationService,+} from 'core-app/features/work-packages/services/notifications/work-package-notification.service';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';@@ -82,22 +79,24 @@ export class WorkPackageWatchersTabComponent extends UntilDestroyedMixin impleme},};- public constructor(readonly I18n:I18nService,+ public constructor(+ readonly I18n:I18nService,readonly elementRef:ElementRef,readonly wpWatchersService:WorkPackageWatchersService,- readonly $transition:Transition,+ readonly uiRouterGlobals:UIRouterGlobals,readonly notificationService:WorkPackageNotificationService,readonly loadingIndicator:LoadingIndicatorService,readonly cdRef:ChangeDetectorRef,readonly pathHelper:PathHelperService,- readonly apiV3Service:ApiV3Service) {+ readonly apiV3Service:ApiV3Service,+ ) {super();}public ngOnInit() {this.$element = jQuery(this.elementRef.nativeElement);-- this.workPackageId = this.$transition.params('to').workPackageId;+ const { workPackageId } = this.uiRouterGlobals.params as unknown as { workPackageId:string };+ this.workPackageId = (this.workPackage.id as string) || workPackageId;this.apiV3Service.work_packagesdiff --git a/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view-entry.component.ts b/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view-entry.component.tsindex c9437642f64..56dd4634532 100644--- a/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view-entry.component.ts+++ b/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view-entry.component.ts@@ -43,6 +43,7 @@ import { populateInputsFromDataset } from 'core-app/shared/components/dataset-in<op-wp-split-view[workPackageId]="workPackageId"[activeTab]="activeTab"+ [showTabs]="false"></op-wp-split-view>`,})diff --git a/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view.component.ts b/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view.component.tsindex 004ad39f48c..183cb20f366 100644--- a/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view.component.ts+++ b/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view.component.ts@@ -26,7 +26,7 @@// See COPYRIGHT and LICENSE files for more details.//++-import { ChangeDetectionStrategy, Component, Injector, Input, OnInit } from '@angular/core';+import { ChangeDetectionStrategy, Component, Injector, Input, OnInit, Type } from '@angular/core';import { StateService } from '@uirouter/core';import {WorkPackageViewFocusService,@@ -51,6 +51,10 @@ import { WpSingleViewService } from 'core-app/features/work-packages/routing/wp-import { CommentService } from 'core-app/features/work-packages/components/wp-activity/comment-service';import { RecentItemsService } from 'core-app/core/recent-items.service';import { UrlParamsService } from 'core-app/core/url-params/url-params.service';+import {+ WorkPackageTabsService,+} from 'core-app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-tabs.service';+import { TabComponent } from 'core-app/features/work-packages/components/wp-tabs/components/wp-tab-wrapper/tab';@Component({templateUrl: './wp-split-view.html',@@ -68,6 +72,7 @@ export class WorkPackageSplitViewComponent extends WorkPackageSingleViewBase impprivate baseRoute:string = this.$state.current?.data?.baseRoute;@Input() workPackageId:string;+ @Input() showTabs = true;@Input() activeTab?:string;constructor(@@ -81,6 +86,7 @@ export class WorkPackageSplitViewComponent extends WorkPackageSingleViewBase impreadonly $state:StateService,readonly urlParams:UrlParamsService,readonly backRouting:BackRoutingService,+ readonly wpTabs:WorkPackageTabsService,) {super(injector, $state.params.workPackageId);}@@ -124,6 +130,14 @@ export class WorkPackageSplitViewComponent extends WorkPackageSingleViewBase impreturn this.$state.params.focus === true;}+ get activeTabComponent():Type<TabComponent>|undefined {+ return this+ .wpTabs+ .tabs+ .find((tab) => tab.id === this.activeTab)+ ?.component;+ }+showBackButton():boolean {return this.baseRoute?.includes('bim');}diff --git a/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view.html b/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view.htmlindex 86f1cac1a0b..6cb165fd247 100644--- a/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view.html+++ b/frontend/src/app/features/work-packages/routing/wp-split-view/wp-split-view.html@@ -3,8 +3,14 @@data-indicator-name="wpDetails"*ngIf="workPackage">- <op-wp-tabs [workPackage]="workPackage" [view]="'split'"></op-wp-tabs>- <div class="work-packages--details-content work-packages-tab-view--overflow" *ngIf="workPackage">+ <op-wp-tabs+ *ngIf="showTabs"+ [workPackage]="workPackage"+ [view]="'split'"+ ></op-wp-tabs>+ <div class="work-packages--details-content work-packages-tab-view--overflow"+ [class.work-packages--details-content_no-tabs]="!showTabs"+ *ngIf="workPackage"><spanclass="hidden-for-sighted"tabindex="-1"@@ -35,11 +41,22 @@</div><div+ *ngIf="showTabs"class="work-package-details-tab"data-notification-selector='notification-scroll-container'+ ui-view>- <wp-overview-tab [workPackage]="workPackage"></wp-overview-tab></div>+ <div+ *ngIf="!showTabs && activeTab"+ class="work-package-details-tab"+ data-notification-selector='notification-scroll-container'+ >+ <ndc-dynamic [ndcDynamicComponent]="activeTabComponent"+ [ndcDynamicInputs]="{ workPackage: workPackage }">+ </ndc-dynamic>+ </div>+</edit-form></div>diff --git a/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts b/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.tsindex 3533652a88d..ffb4e03f071 100644--- a/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts+++ b/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts@@ -139,7 +139,9 @@ export class WpResizerDirective extends UntilDestroyedMixin implements OnInit, AngOnDestroy() {super.ngOnDestroy();// Reset the style when killing this directive, otherwise the style remains- this.resizingElement.style[this.resizeStyle] = '';+ if (this.resizingElement) {+ this.resizingElement.style[this.resizeStyle] = '';+ }}resizeStart() {diff --git a/frontend/src/global_styles/layout/work_packages/_details_view.sass b/frontend/src/global_styles/layout/work_packages/_details_view.sassindex 94ebaac627f..8d7ae4f7a69 100644--- a/frontend/src/global_styles/layout/work_packages/_details_view.sass+++ b/frontend/src/global_styles/layout/work_packages/_details_view.sass@@ -80,6 +80,9 @@ body.router--work-packages-partitioned-split-view-newwidth: 100%overflow: hidden+ &_no-tabs+ top: 0+&.-create-modepadding: 0 5px 10px 20pxdiff --git a/spec/components/previews/work_packages/split_view_component_preview.rb b/spec/components/previews/work_packages/split_view_component_preview.rbnew file mode 100644index 00000000000..5d951149e24--- /dev/null+++ b/spec/components/previews/work_packages/split_view_component_preview.rb@@ -0,0 +1,7 @@+# frozen_string_literal: true++class WorkPackages::SplitViewComponentPreview < ViewComponent::Preview+ def default+ render(WorkPackages::SplitViewComponent.new(work_package: "work_package", tab: "tab"))+ end+enddiff --git a/spec/components/work_packages/split_view_component_spec.rb b/spec/components/work_packages/split_view_component_spec.rbnew file mode 100644index 00000000000..87b68bfad55--- /dev/null+++ b/spec/components/work_packages/split_view_component_spec.rb@@ -0,0 +1,15 @@+# frozen_string_literal: true++require "rails_helper"++RSpec.describe WorkPackages::SplitViewComponent, type: :component do+ pending "add some examples to (or delete) #{__FILE__}"++ # it "renders something useful" do+ # expect(+ # render_inline(described_class.new(attr: "value")) { "Hello, components!" }.css("p").to_html+ # ).to include(+ # "Hello, components!"+ # )+ # end+end