Skip to content

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

[#53577] Use sidebar_enabled method on the overview page instead of project meta tags.

Dombi Attilae04c53d7d178
diff --git a/app/views/layouts/_common_head.html.erb b/app/views/layouts/_common_head.html.erb
index f6e22cb7d1c..429cec0a423 100644
--- a/app/views/layouts/_common_head.html.erb
+++ b/app/views/layouts/_common_head.html.erb
@@ -10,8 +10,7 @@
<meta name="current_project"
data-project-name="<%= h @project.name %>"
data-project-id="<%= @project.id %>"
- data-project-identifier="<%= @project.identifier %>"
- data-project-custom-fields-count="<%= @project.project_custom_fields.visible.count %>"/>
+ data-project-identifier="<%= @project.identifier %>"/>
<% end %>
<meta name="current_user"
data-name="<%= User.current.name %>"
diff --git a/frontend/src/app/core/current-project/current-project.service.ts b/frontend/src/app/core/current-project/current-project.service.ts
index 14022de0343..06a95e4f6b2 100644
--- a/frontend/src/app/core/current-project/current-project.service.ts
+++ b/frontend/src/app/core/current-project/current-project.service.ts
@@ -32,7 +32,7 @@ import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
@Injectable({ providedIn: 'root' })
export class CurrentProjectService {
- private current:{ id:string, identifier:string, name:string, customFieldsCount:string };
+ private current:{ id:string, identifier:string, name:string };
constructor(
private PathHelper:PathHelperService,
@@ -73,11 +73,7 @@ export class CurrentProjectService {
return this.getCurrent('identifier');
}
- public get customFieldsCount():string|null {
- return this.getCurrent('customFieldsCount');
- }
-
- private getCurrent(key:'id'|'identifier'|'name'|'customFieldsCount') {
+ private getCurrent(key:'id'|'identifier'|'name') {
if (this.current && this.current[key]) {
return this.current[key].toString();
}
@@ -95,7 +91,6 @@ export class CurrentProjectService {
id: element.dataset.projectId!,
name: element.dataset.projectName!,
identifier: element.dataset.projectIdentifier!,
- customFieldsCount: element.dataset.projectCustomFieldsCount!,
};
}
}
diff --git a/frontend/src/app/features/overview/overview.component.ts b/frontend/src/app/features/overview/overview.component.ts
index 973df236f68..384f9dc1e16 100644
--- a/frontend/src/app/features/overview/overview.component.ts
+++ b/frontend/src/app/features/overview/overview.component.ts
@@ -1,9 +1,10 @@
-import { Component } from '@angular/core';
+import { ChangeDetectionStrategy, Component } from '@angular/core';
import { GridPageComponent } from 'core-app/shared/components/grids/grid/page/grid-page.component';
import { GRID_PROVIDERS } from 'core-app/shared/components/grids/grid/grid.component';
@Component({
selector: 'overview',
+ changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: '../../shared/components/grids/grid/page/grid-page.component.html',
styleUrls: ['../../shared/components/grids/grid/page/grid-page.component.sass'],
providers: GRID_PROVIDERS,
@@ -14,7 +15,8 @@ export class OverviewComponent extends GridPageComponent {
}
protected isTurboFrameSidebarEnabled():boolean {
- return this.currentProject.customFieldsCount !== '0';
+ const sidebarEnabledTag:HTMLMetaElement|null = document.querySelector('meta[name="sidebar_enabled"]');
+ return sidebarEnabledTag?.dataset.enabled === 'true';
}
protected turboFrameSidebarSrc():string {
diff --git a/modules/overviews/app/controllers/overviews/overviews_controller.rb b/modules/overviews/app/controllers/overviews/overviews_controller.rb
index 386b86988a5..af2eca9b9c2 100644
--- a/modules/overviews/app/controllers/overviews/overviews_controller.rb
+++ b/modules/overviews/app/controllers/overviews/overviews_controller.rb
@@ -2,8 +2,8 @@ module ::Overviews
class OverviewsController < ::Grids::BaseInProjectController
include OpTurbo::ComponentStream
- before_action :authorize
before_action :jump_to_project_menu_item
+ before_action :set_sidebar_enabled
menu_item :overview
@@ -57,6 +57,10 @@ module ::Overviews
ProjectCustomFieldSection.find(params[:section_id])
end
+ def set_sidebar_enabled
+ @sidebar_enabled = @project.project_custom_fields.visible.any?
+ end
+
def handle_errors(project_with_errors, section)
update_via_turbo_stream(
component: ProjectCustomFields::Sections::EditDialogComponent.new(
diff --git a/modules/overviews/app/views/overviews/overviews/show.html.erb b/modules/overviews/app/views/overviews/overviews/show.html.erb
index e69de29bb2d..9971a61bc20 100644
--- a/modules/overviews/app/views/overviews/overviews/show.html.erb
+++ b/modules/overviews/app/views/overviews/overviews/show.html.erb
@@ -0,0 +1,3 @@
+<% content_for :header_tags do %>
+ <meta name="sidebar_enabled" data-enabled="<%= @sidebar_enabled %>">
+<% end -%>