DRY up the suggestion logic

This commit is contained in:
Tomas Hykel
2026-03-13 00:54:34 +01:00
parent fe0185c64a
commit aeb3d6eef1
3 changed files with 47 additions and 10 deletions
@@ -0,0 +1,45 @@
# frozen_string_literal: true
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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 Projects
module Concerns
module IdentifierSuggestion
def identifier_suggestion_data
flag_active = OpenProject::FeatureDecisions.semantic_work_package_ids_active?
data = {
controller: "projects--identifier-suggestion",
"projects--identifier-suggestion-mode-value": Project.semantic_alphanumeric_identifier? ? "semantic" : "legacy"
}
data[:"projects--identifier-suggestion-url-value"] = projects_identifier_suggestion_path if flag_active
data
end
end
end
end
@@ -33,6 +33,7 @@ module Projects
include ApplicationHelper
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
include Projects::Concerns::IdentifierSuggestion
options :source_project, :target_project, :copy_options
end
+1 -10
View File
@@ -33,6 +33,7 @@ module Projects
include ApplicationHelper
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
include Projects::Concerns::IdentifierSuggestion
options :project, :template, :step
@@ -44,16 +45,6 @@ module Projects
{ display: :none } unless step == 3
end
def identifier_suggestion_data
flag_active = OpenProject::FeatureDecisions.semantic_work_package_ids_active?
data = {
controller: "projects--identifier-suggestion",
"projects--identifier-suggestion-mode-value": Project.semantic_alphanumeric_identifier? ? "semantic" : "legacy"
}
data[:"projects--identifier-suggestion-url-value"] = projects_identifier_suggestion_path if flag_active
data
end
def workspaces_path
workspace_type = if Project.workspace_types.key?(project.workspace_type)
project.workspace_type