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
WIP[Op#54749]: Enabled creation of project attributes
Andreas Pfohl461d13b89eff
diff --git a/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.html.erb b/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.html.erbindex ce0f1e1750a..d6d7f4c13ab 100644--- a/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.html.erb+++ b/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.html.erb@@ -9,7 +9,8 @@openDirectly: false,focusDirectly: false,dropdownPosition: 'bottom',- disabledProjects: projects_with_custom_field_mapping+ disabledProjects: projects_with_custom_field_mapping,+ inputName: 'project_custom_field_project_mapping[project_id]'})diff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rbindex 00830c436d2..a4336ea29f6 100644--- a/app/controllers/admin/settings/project_custom_fields_controller.rb+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb@@ -39,7 +39,7 @@ module Admin::Settings# rubocop:disable Rails/LexicallyScopedActionFilterbefore_action :set_sections, only: %i[show index edit update move drop]before_action :find_custom_field,- only: %i(show edit project_mappings unlink update destroy delete_option reorder_alphabetical move drop)+ only: %i(show edit project_mappings link unlink update destroy delete_option reorder_alphabetical move drop)before_action :prepare_custom_option_position, only: %i(update create)before_action :find_custom_option, only: :delete_optionbefore_action :project_custom_field_mappings_query, only: %i[project_mappings unlink]@@ -73,11 +73,14 @@ module Admin::Settingsenddef link- @project_mapping = ProjectCustomFieldProjectMapping.new(permitted_params.project_custom_field_project_mapping)+ @project_mapping = ProjectCustomFieldProjectMapping.new(+ project_id: permitted_params.project_custom_field_project_mapping["project_id"],+ custom_field_id: @custom_field.id+ )create_service = ProjectCustomFieldProjectMappings::CreateService- .new(user: current_user, model: @project_mapping)- .call+ .new(user: current_user)+ .call(custom_field_id: @project_mapping.custom_field_id, project_id: @project_mapping.project_id)create_service.on_success { render_unlink_response(project: @project_mapping.project) }diff --git a/app/services/project_custom_field_project_mappings/create_service.rb b/app/services/project_custom_field_project_mappings/create_service.rbnew file mode 100644index 00000000000..16d8d20e0a0--- /dev/null+++ b/app/services/project_custom_field_project_mappings/create_service.rb@@ -0,0 +1,37 @@+# frozen_string_literal: true++#-- 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 ProjectCustomFieldProjectMappings+ class CreateService < ::BaseServices::Create+ def default_contract_class+ ProjectCustomFieldProjectMappings::UpdateContract+ end+ end+end