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
Add "name" as a query parameter to be able to pass the name for the unsaved default queries to the frontend
Henriette Darge4c93f8139a4a
diff --git a/frontend/src/app/features/work-packages/routing/work-packages-gantt-routes.ts b/frontend/src/app/features/work-packages/routing/work-packages-gantt-routes.tsindex 938525ea8bc..aef995ba07a 100644--- a/frontend/src/app/features/work-packages/routing/work-packages-gantt-routes.ts+++ b/frontend/src/app/features/work-packages/routing/work-packages-gantt-routes.ts@@ -39,7 +39,7 @@ export const WORK_PACKAGES_GANTT_ROUTES:Ng2StateDeclaration[] = [{name: 'gantt',parent: 'optional_project',- url: '/gantt?query_id&query_props&start_onboarding_tour',+ url: '/gantt?query_id&query_props&name&start_onboarding_tour',redirectTo: 'gantt.partitioned.list',views: {'!$default': { component: WorkPackagesBaseComponent },@@ -54,6 +54,7 @@ export const WORK_PACKAGES_GANTT_ROUTES:Ng2StateDeclaration[] = [query_props: { type: 'opQueryString' },// Optional initial tour paramstart_onboarding_tour: { type: 'query', squash: true, value: undefined },+ name: { type: 'string', dynamic: true },},},{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 3b85809c52b..0cf48c4cab8 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@@ -91,6 +91,11 @@ export class StaticQueriesService {if (matched) {return matched.title;}++ if (this.$state.params.name) {+ const nameKey = this.$state.params.name as string;+ return this.I18n.t(`js.queries.${nameKey}`);+ }}// Try to detect the all open filterdiff --git a/modules/gantt/app/controllers/gantt/gantt_controller.rb b/modules/gantt/app/controllers/gantt/gantt_controller.rbindex 2950e0d8c3f..86ad61479de 100644--- a/modules/gantt/app/controllers/gantt/gantt_controller.rb+++ b/modules/gantt/app/controllers/gantt/gantt_controller.rb@@ -17,14 +17,12 @@ module ::Ganttreturn redirect_to(project_gantt_index_path(@project,- query_props: ::Gantt::DefaultQueryGeneratorService.new(with_project_context: true).call+ ::Gantt::DefaultQueryGeneratorService.new(with_project_context: true).call))elsereturn redirect_to(- gantt_index_path(- query_props: ::Gantt::DefaultQueryGeneratorService.new(with_project_context: false).call- )+ gantt_index_path(Gantt::DefaultQueryGeneratorService.new(with_project_context: false).call))endenddiff --git a/modules/gantt/app/controllers/gantt/menus_controller.rb b/modules/gantt/app/controllers/gantt/menus_controller.rbindex 9e86583fffa..9e2dd962d1c 100644--- a/modules/gantt/app/controllers/gantt/menus_controller.rb+++ b/modules/gantt/app/controllers/gantt/menus_controller.rb@@ -49,7 +49,7 @@ module Ganttbase_query.where('starred' => 't').pluck(:id, :name)- .map { |id, name| menu_item(:query_id, id, name) }+ .map { |id, name| menu_item({ query_id: id }, name) }enddef default_queries@@ -57,7 +57,6 @@ module Ganttqueries = []Gantt::DefaultQueryGeneratorService::QUERY_OPTIONS.each do |query_key|queries << menu_item(- :query_props,query_generator.call(query_key:),Gantt::DefaultQueryGeneratorService::QUERY_MAPPINGS[query_key])@@ -71,7 +70,7 @@ module Gantt.where('starred' => 'f').where('public' => 't').pluck(:id, :name)- .map { |id, name| menu_item(:query_id, id, name) }+ .map { |id, name| menu_item({ query_id: id }, name) }enddef custom_queries@@ -79,7 +78,7 @@ module Gantt.where('starred' => 'f').where('public' => 'f').pluck(:id, :name)- .map { |id, name| menu_item(:query_id, id, name) }+ .map { |id, name| menu_item({ query_id: id }, name) }enddef base_query@@ -95,21 +94,27 @@ module Ganttbase_queryend- def menu_item(filter_key, filter_val, name)+ def menu_item(query_params, name)OpenProject::Menu::MenuItem.new(title: name,- href: gantt_path(filter_key, filter_val),- selected: selected?(filter_key, filter_val))+ href: gantt_path(query_params),+ selected: selected?(query_params))end- def selected?(filter_key, value)- params[filter_key] == value.to_s+ def selected?(query_params)+ query_params.each_key do |filter_key|+ if params[filter_key] != query_params[filter_key].to_s+ return false+ end+ end++ trueend- def gantt_path(filter_key, id)+ def gantt_path(query_params)if @project.present?- project_gantt_index_path(@project, params.permit(filter_key).merge!(filter_key => id))+ project_gantt_index_path(@project, params.permit(query_params.keys).merge!(query_params))else- gantt_index_path(params.permit(filter_key).merge!(filter_key => id))+ gantt_index_path(params.permit(query_params.keys).merge!(query_params))endendenddiff --git a/modules/gantt/app/services/gantt/default_query_generator_service.rb b/modules/gantt/app/services/gantt/default_query_generator_service.rbindex 4056ebdeb5e..b975cbdedca 100644--- a/modules/gantt/app/services/gantt/default_query_generator_service.rb+++ b/modules/gantt/app/services/gantt/default_query_generator_service.rb@@ -30,9 +30,9 @@ module ::Ganttclass DefaultQueryGeneratorServiceDEFAULT_QUERY = :all_openQUERY_MAPPINGS = {- DEFAULT_QUERY => I18n.t('queries.all_open'),- :timeline => I18n.t('queries.timeline'),- :milestones => I18n.t('queries.milestones')+ DEFAULT_QUERY => I18n.t('js.queries.all_open'),+ :timeline => I18n.t('js.queries.timeline'),+ :milestones => I18n.t('js.queries.milestones')}.freezeQUERY_OPTIONS = QUERY_MAPPINGS.keys@@ -66,7 +66,7 @@ module ::Ganttreturnend- params.to_json+ { query_props: params.to_json, name: query_key }endclass << selfdiff --git a/modules/gantt/app/views/gantt/menus/_menu.html.erb b/modules/gantt/app/views/gantt/menus/_menu.html.erbindex 929fd074c6a..a2167a1442c 100644--- a/modules/gantt/app/views/gantt/menus/_menu.html.erb+++ b/modules/gantt/app/views/gantt/menus/_menu.html.erb@@ -1,5 +1,5 @@<%= turbo_frame_tag "gantt_menu",- src: @project ? menu_project_gantt_index_path(@project, params.permit(:query_props, :query_id)) : gantt_menu_path(params.permit(:query_props, :query_id)),+ src: @project ? menu_project_gantt_index_path(@project, params.permit(:query_props, :query_id, :name)) : gantt_menu_path(params.permit(:query_props, :query_id, :name)),target: '_top',data: { turbo: false },loading: :lazy %>diff --git a/modules/gantt/config/locales/en.yml b/modules/gantt/config/locales/en.ymlindex ea1a8eb5fb2..13d8dabe726 100644--- a/modules/gantt/config/locales/en.yml+++ b/modules/gantt/config/locales/en.yml@@ -1,7 +1,3 @@# English strings go hereen:project_module_gantt: "Gantt"- queries:- all_open: 'All open'- timeline: 'Timeline'- milestones: 'Milestones'diff --git a/modules/gantt/config/locales/js-en.yml b/modules/gantt/config/locales/js-en.ymlnew file mode 100644index 00000000000..cac5469b08a--- /dev/null+++ b/modules/gantt/config/locales/js-en.yml@@ -0,0 +1,6 @@+en:+ js:+ queries:+ all_open: 'All open'+ timeline: 'Timeline'+ milestones: 'Milestones'