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
Replace angular sidemenu with rails based Submenu component for BIM module
Henriette Darge0192773f9640
diff --git a/frontend/src/app/features/bim/ifc_models/openproject-ifc-models.routes.ts b/frontend/src/app/features/bim/ifc_models/openproject-ifc-models.routes.tsindex 1886303dbdb..595099fbd75 100644--- a/frontend/src/app/features/bim/ifc_models/openproject-ifc-models.routes.ts+++ b/frontend/src/app/features/bim/ifc_models/openproject-ifc-models.routes.ts@@ -35,11 +35,18 @@ import { WorkPackagesBaseComponent } from 'core-app/features/work-packages/routiimport { BcfSplitLeftComponent } from 'core-app/features/bim/ifc_models/bcf/split/left/bcf-split-left.component';import { BcfSplitRightComponent } from 'core-app/features/bim/ifc_models/bcf/split/right/bcf-split-right.component';+export const sidemenuId = 'bim_sidemenu';++export const sideMenuOptions = {+ sidemenuId,+ hardReloadOnBaseRoute: true,+};+export const IFC_ROUTES:Ng2StateDeclaration[] = [{name: 'bim',parent: 'optional_project',- url: '/bcf?query_id&query_props&models&viewpoint',+ url: '/bcf?query_id&query_props&models&viewpoint&name',abstract: true,component: WorkPackagesBaseComponent,redirectTo: 'bim.partitioned.list',@@ -49,6 +56,7 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [query_props: { type: 'opQueryString', dynamic: true },models: { type: 'opQueryString', dynamic: true },viewpoint: { type: 'int', dynamic: true },+ name: { type: 'string', dynamic: true },},},{@@ -58,6 +66,7 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [component: IFCViewerPageComponent,data: {bodyClasses: 'router--bim',+ sideMenuOptions,},},{@@ -67,6 +76,7 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [baseRoute: 'bim.partitioned.list',newRoute: 'bim.partitioned.list.new',partition: '-split',+ sideMenuOptions,},reloadOnSearch: false,views: {@@ -83,6 +93,7 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [allowMovingInEditMode: true,partition: '-left-only',successState: 'bim.partitioned.show',+ sideMenuOptions,},views: { 'content-left': { component: WorkPackageNewFullViewComponent } },},@@ -92,6 +103,7 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [data: {baseRoute: 'bim.partitioned.list',partition: '-left-only',+ sideMenuOptions,},reloadOnSearch: false,redirectTo: 'bim.partitioned.show.details',diff --git a/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts b/frontend/src/app/shared/components/op-view-select/op-static-queries.service.tsindex 75d16b7a937..51566ed8c9d 100644--- a/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts+++ b/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts@@ -93,7 +93,7 @@ export class StaticQueriesService {if (this.$state.params.name) {const nameKey = this.$state.params.name as string;- return this.I18n.t(`js.queries.${nameKey}`);+ return this.I18n.t(`js.work_packages.default_queries.${nameKey}`);}}@@ -143,33 +143,6 @@ export class StaticQueriesService {},view: 'WorkPackagesTable',},- {- title: this.text.all_open,- uiSref: 'bim.partitioned.list',- uiParams: {- query_id: undefined,- query_props: '{"c":["id","subject","bcfThumbnail","type","status","assignee","updatedAt"],"t":"id:desc"}',- },- view: 'Bim',- },- {- title: this.text.latest_activity,- uiSref: 'bim.partitioned.list',- uiParams: {- query_id: undefined,- query_props: '{"c":["id","subject","bcfThumbnail","type","status","assignee","updatedAt"],"t":"updatedAt:desc","f":[{"n":"status","o":"o","v":[]}]}',- },- view: 'Bim',- },- {- title: this.text.recently_created,- uiSref: 'bim.partitioned.list',- uiParams: {- query_id: undefined,- query_props: '{"c":["id","subject","bcfThumbnail","type","status","assignee","createdAt"],"t":"createdAt:desc","f":[{"n":"status","o":"o","v":[]}]}',- },- view: 'Bim',- },];const projectIdentifier = this.CurrentProject.identifier;@@ -237,24 +210,6 @@ export class StaticQueriesService {isEnterprise: true,...this.eeGuardedShareWithMeRoute,},- {- title: this.text.created_by_me,- uiSref: 'bim.partitioned.list',- uiParams: {- query_id: undefined,- query_props: '{"c":["id","subject","bcfThumbnail","type","status","assignee","updatedAt"],"t":"id:desc","f":[{"n":"status","o":"o","v":[]},{"n":"author","o":"=","v":["me"]}]}',- },- view: 'Bim',- },- {- title: this.text.assigned_to_me,- uiSref: 'bim.partitioned.list',- uiParams: {- query_id: undefined,- query_props: '{"c":["id","subject","bcfThumbnail","type","status","author","updatedAt"],"t":"id:desc","f":[{"n":"status","o":"o","v":[]},{"n":"assigneeOrGroup","o":"=","v":["me"]}]}',- },- view: 'Bim',- },];}diff --git a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rbindex a2b62136608..8eacce3c976 100644--- a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb+++ b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb@@ -197,9 +197,10 @@ module Bimenddef frontend_redirect(model_ids)- props = '{"c":["id","subject","bcfThumbnail","type","status","assignee","updatedAt"],"t":"id:desc"}'+ props = Bim::Menus::DefaultQueryGeneratorService.new.callredirect_to bcf_project_frontend_path(models: JSON.dump(Array(model_ids)),- query_props: props)+ query_props: props[:query_props],+ name: props[:name])enddef find_all_ifc_modelsdiff --git a/modules/bim/app/controllers/bim/menus_controller.rb b/modules/bim/app/controllers/bim/menus_controller.rbnew file mode 100644index 00000000000..5ac4a2eeea9--- /dev/null+++ b/modules/bim/app/controllers/bim/menus_controller.rb@@ -0,0 +1,39 @@+# -- 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.+# +++module ::Bim+ class MenusController < ApplicationController+ before_action :find_project_by_project_id,+ :authorize++ def show+ @submenu_menu_items = ::Bim::Menu.new(project: @project, params:).menu_items++ render layout: nil+ end+ end+enddiff --git a/modules/bim/app/menus/bim/menu.rb b/modules/bim/app/menus/bim/menu.rbnew file mode 100644index 00000000000..0041f2901ce--- /dev/null+++ b/modules/bim/app/menus/bim/menu.rb@@ -0,0 +1,57 @@+# -- 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.+# +++module Bim+ class Menu < Submenu+ attr_reader :view_type, :project, :params++ def initialize(project: nil, params: nil)+ @view_type = "bim"+ @project = project+ @params = params++ super(view_type:, project:, params:)+ end++ def default_queries+ query_generator = Bim::Menus::DefaultQueryGeneratorService.new+ Bim::Menus::DefaultQueryGeneratorService::QUERY_OPTIONS.filter_map do |query_key|+ params = query_generator.call(query_key:)+ next if params.nil?++ menu_item(+ I18n.t("js.work_packages.default_queries.#{query_key}"),+ params+ )+ end+ end++ def query_path(query_params)+ bcf_project_frontend_path(project, query_params)+ end+ end+enddiff --git a/modules/bim/app/services/bim/menus/default_query_generator_service.rb b/modules/bim/app/services/bim/menus/default_query_generator_service.rbnew file mode 100644index 00000000000..98922a00616--- /dev/null+++ b/modules/bim/app/services/bim/menus/default_query_generator_service.rb@@ -0,0 +1,113 @@+#-- 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 ::Bim+ module Menus+ class DefaultQueryGeneratorService+ DEFAULT_QUERY = :all_open++ QUERY_OPTIONS = [+ DEFAULT_QUERY,+ :latest_activity,+ :recently_created,+ :created_by_me,+ :assigned_to_me+ ].freeze++ def call(query_key: DEFAULT_QUERY)+ params = self.class.assign_params(query_key)++ return if params.nil?++ { query_props: params.to_json, name: query_key }+ end++ class << self+ def all_open_query+ {+ c: %w[id subject bcfThumbnail type status assignee updatedAt],+ t: "id:desc"+ }+ end++ def latest_activity_query+ {+ c: %w[id subject bcfThumbnail type status assignee updatedAt],+ t: "updatedAt:desc",+ f: [{ "n" => "status", "o" => "o", "v" => [] }]+ }+ end++ def recently_created_query+ {+ c: %w[id subject bcfThumbnail type status assignee createdAt],+ t: "createdAt:desc",+ f: [{ "n" => "status", "o" => "o", "v" => [] }]+ }+ end++ def created_by_me_query+ {+ c: %w[id subject bcfThumbnail type status author updatedAt],+ t: "id:desc",+ f: [{ "n" => "status", "o" => "o", "v" => [] },+ { "n" => "author", "o" => "=", "v" => ["me"] }]+ }+ end++ def assigned_to_me_query+ {+ c: %w[id subject bcfThumbnail type status author updatedAt],+ t: "id:desc",+ f: [{ "n" => "status", "o" => "o", "v" => [] },+ { "n" => "assigneeOrGroup", "o" => "=", "v" => ["me"] }]+ }+ end++ def assign_params(query_key)+ case query_key+ when DEFAULT_QUERY+ all_open_query+ when :latest_activity+ latest_activity_query+ when :recently_created+ recently_created_query+ when :created_by_me+ return unless User.current.logged?++ created_by_me_query+ when :assigned_to_me+ return unless User.current.logged?++ assigned_to_me_query+ end+ end+ end+ end+ end+enddiff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/_panels.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_models/_panels.html.erbdeleted file mode 100644index 9cef6950158..00000000000--- a/modules/bim/app/views/bim/ifc_models/ifc_models/_panels.html.erb+++ /dev/null@@ -1,17 +0,0 @@-<div class="op-ifc-viewer--sidemenu op-sidebar">- <div class="op-sidebar--body">- <%=- angular_component_tag 'op-view-select',- inputs: {- projectId: (@project ? @project.id.to_s : ''),- menuItems: [parent_name, name],- baseRoute: 'bim.partitioned.list',- viewType: 'Bim',- }- %>-- <hr>-- <div class="op-ifc-viewer--tree-panel active" data-test-selector="op-ifc-viewer--tree-panel"></div>- </div>-</div>diff --git a/modules/bim/app/views/bim/menus/_menu.html.erb b/modules/bim/app/views/bim/menus/_menu.html.erbnew file mode 100644index 00000000000..e4afbbc2b52--- /dev/null+++ b/modules/bim/app/views/bim/menus/_menu.html.erb@@ -0,0 +1,9 @@+ <%= turbo_frame_tag "bim_sidemenu",+ src: bcf_project_bcf_menu_path(@project, **params.permit(:query_props, :query_id, :name)),+ target: '_top',+ data: { turbo: false },+ loading: :lazy %>++ <hr>++ <div class="op-ifc-viewer--tree-panel active" data-test-selector="op-ifc-viewer--tree-panel"></div>diff --git a/modules/bim/app/views/bim/menus/show.html.erb b/modules/bim/app/views/bim/menus/show.html.erbnew file mode 100644index 00000000000..c7077b4e55c--- /dev/null+++ b/modules/bim/app/views/bim/menus/show.html.erb@@ -0,0 +1,4 @@+<%= turbo_frame_tag "bim_sidemenu" do %>+ <%= render OpenProject::Common::SubmenuComponent.new(sidebar_menu_items: @submenu_menu_items,+ searchable: true) %>+<% end %>diff --git a/modules/bim/config/routes.rb b/modules/bim/config/routes.rbindex 3cffff4a359..376d349105b 100644--- a/modules/bim/config/routes.rb+++ b/modules/bim/config/routes.rb@@ -31,6 +31,8 @@ Rails.application.routes.draw domount Bim::Bcf::API::Root => "/api/bcf"scope "projects/:project_id", as: "project" do+ get "bcf/menu" => "bim/menus#show"+resources :issues, controller: "bim/bcf/issues" doget :upload, action: :upload, on: :collectionpost :prepare_import, action: :prepare_import, on: :collectiondiff --git a/modules/bim/lib/open_project/bim/engine.rb b/modules/bim/lib/open_project/bim/engine.rbindex 5d20fb118ee..e4871e55bc4 100644--- a/modules/bim/lib/open_project/bim/engine.rb+++ b/modules/bim/lib/open_project/bim/engine.rb@@ -46,7 +46,8 @@ module OpenProject::Bimpermission :view_ifc_models,{"bim/ifc_models/ifc_models": %i[index show defaults],- "bim/ifc_models/ifc_viewer": %i[show]+ "bim/ifc_models/ifc_viewer": %i[show],+ "bim/menus": %i[show]},permissible_on: :project,contract_actions: { ifc_models: %i[read] }@@ -105,7 +106,7 @@ module OpenProject::Bimmenu.push :ifc_viewer_panels,{ controller: "/bim/ifc_models/ifc_models", action: "defaults" },parent: :ifc_models,- partial: "/bim/ifc_models/ifc_models/panels"+ partial: "/bim/menus/menu"endenddiff --git a/modules/gantt/app/menus/gantt/menu.rb b/modules/gantt/app/menus/gantt/menu.rbindex 2ee70ad4cb9..adaef1f8294 100644--- a/modules/gantt/app/menus/gantt/menu.rb+++ b/modules/gantt/app/menus/gantt/menu.rb@@ -44,7 +44,7 @@ module Ganttnext if params.nil?menu_item(- I18n.t("js.queries.#{query_key}"),+ I18n.t("js.work_packages.default_queries.#{query_key}"),params)enddiff --git a/modules/gantt/config/locales/js-en.yml b/modules/gantt/config/locales/js-en.ymlindex cac5469b08a..670a4262a6a 100644--- a/modules/gantt/config/locales/js-en.yml+++ b/modules/gantt/config/locales/js-en.yml@@ -1,6 +1,5 @@en:js:- queries:- all_open: 'All open'- timeline: 'Timeline'- milestones: 'Milestones'+ work_packages:+ default_queries:+ milestones: 'Milestones'