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
[#65242] moved most of the wp types related files to new namespace
Eric Schuberte36d115295e2
diff --git a/app/components/_index.sass b/app/components/_index.sassindex c8a5624de14..51b5beecb6d 100644--- a/app/components/_index.sass+++ b/app/components/_index.sass@@ -13,6 +13,7 @@@import "users/hover_card_component"@import "work_package_relations_tab/index_component"@import "work_package_relations_tab/relation_component"+@import "work_package_types/pattern_input"@import "work_packages/activities_tab/index_component"@import "work_packages/activities_tab/journals/new_component"@import "work_packages/activities_tab/journals/index_component"@@ -29,5 +30,4 @@@import "work_packages/hover_card_component"@import "work_packages/progress/modal_body_component"@import "work_packages/reminder/modal_body_component"-@import "work_packages/types/pattern_input"@import "work_packages/split_view_component"diff --git a/app/components/work_packages/types/export_configuration_component.html.erb b/app/components/work_package_types/export_configuration_component.html.erbsimilarity index 93%rename from app/components/work_packages/types/export_configuration_component.html.erbrename to app/components/work_package_types/export_configuration_component.html.erbindex 657a294e510..36a18817b90 100644--- a/app/components/work_packages/types/export_configuration_component.html.erb+++ b/app/components/work_package_types/export_configuration_component.html.erb@@ -28,4 +28,4 @@ See COPYRIGHT and LICENSE files for more details.++#%><p><%= I18n.t("types.edit.export_configuration.intro") %></p>-<%= render(WorkPackages::Types::ExportTemplateListComponent.new(type: model)) %>+<%= render(WorkPackageTypes::ExportTemplateListComponent.new(type: model)) %>diff --git a/app/components/work_packages/types/export_configuration_component.rb b/app/components/work_package_types/export_configuration_component.rbsimilarity index 92%rename from app/components/work_packages/types/export_configuration_component.rbrename to app/components/work_package_types/export_configuration_component.rbindex 17f5ff5c67a..da4839c1178 100644--- a/app/components/work_packages/types/export_configuration_component.rb+++ b/app/components/work_package_types/export_configuration_component.rb@@ -28,9 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module WorkPackages- module Types- class ExportConfigurationComponent < ApplicationComponent- end+module WorkPackageTypes+ class ExportConfigurationComponent < ApplicationComponentendenddiff --git a/app/components/work_packages/types/export_template_list_component.html.erb b/app/components/work_package_types/export_template_list_component.html.erbsimilarity index 98%rename from app/components/work_packages/types/export_template_list_component.html.erbrename to app/components/work_package_types/export_template_list_component.html.erbindex 75c03fd5e32..fb4af1456a5 100644--- a/app/components/work_packages/types/export_template_list_component.html.erb+++ b/app/components/work_package_types/export_template_list_component.html.erb@@ -76,7 +76,7 @@ See COPYRIGHT and LICENSE files for more details.@type.pdf_export_templates.list.each do |template|component.with_row(data: draggable_item_config(template)) dorender(- WorkPackages::Types::ExportTemplateRowComponent.new(+ WorkPackageTypes::ExportTemplateRowComponent.new(type: @type,template:)diff --git a/app/components/work_packages/types/export_template_list_component.rb b/app/components/work_package_types/export_template_list_component.rbsimilarity index 56%rename from app/components/work_packages/types/export_template_list_component.rbrename to app/components/work_package_types/export_template_list_component.rbindex e8ed1fe3eba..ace1a352c41 100644--- a/app/components/work_packages/types/export_template_list_component.rb+++ b/app/components/work_package_types/export_template_list_component.rb@@ -28,42 +28,40 @@# See COPYRIGHT and LICENSE files for more details.#++-module WorkPackages- module Types- class ExportTemplateListComponent < ApplicationComponent- include ApplicationHelper- include OpPrimer::ComponentHelpers- include OpTurbo::Streamable+module WorkPackageTypes+ class ExportTemplateListComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable- def initialize(type:)- super+ def initialize(type:)+ super- @type = type- end+ @type = type+ end- def wrapper_data_attributes- {- controller: "generic-drag-and-drop"- }- end+ def wrapper_data_attributes+ {+ controller: "generic-drag-and-drop"+ }+ end- def drag_and_drop_target_config- {- "is-drag-and-drop-target": true,- "target-container-accessor": "& > ul",- "target-allowed-drag-type": "template",- test_selector: "pdf-export-template-rows"- }- end+ def drag_and_drop_target_config+ {+ "is-drag-and-drop-target": true,+ "target-container-accessor": "& > ul",+ "target-allowed-drag-type": "template",+ test_selector: "pdf-export-template-rows"+ }+ end- def draggable_item_config(template)- {- "draggable-id": template.id,- "draggable-type": "template",- "drop-url": drop_type_pdf_export_template_path(type_id: @type.id, id: template.id),- test_selector: "pdf-export-template-row-#{template.id}"- }- end+ def draggable_item_config(template)+ {+ "draggable-id": template.id,+ "draggable-type": "template",+ "drop-url": drop_type_pdf_export_template_path(type_id: @type.id, id: template.id),+ test_selector: "pdf-export-template-row-#{template.id}"+ }endendenddiff --git a/app/components/work_packages/types/export_template_row_component.html.erb b/app/components/work_package_types/export_template_row_component.html.erbsimilarity index 76%rename from app/components/work_packages/types/export_template_row_component.html.erbrename to app/components/work_package_types/export_template_row_component.html.erbindex 89278f32145..de7dac1c92f 100644--- a/app/components/work_packages/types/export_template_row_component.html.erb+++ b/app/components/work_package_types/export_template_row_component.html.erb@@ -45,16 +45,18 @@ See COPYRIGHT and LICENSE files for more details.endenditem_information.with_column(py: 1, mr: 2) do- render(Primer::Alpha::ToggleSwitch.new(- src: toggle_type_pdf_export_template_path(type_id: @type.id, id: @template.id),- csrf_token: form_authenticity_token,- data: { "turbo-method": :post, "turbo-stream": true },- checked: @template.enabled,- size: :small,- status_label_position: :start,- test_selector: "toggle-pdf-export-template-row-#{@template.id}",- classes: "op-primer-adjustments__toggle-switch--hidden-loading-indicator"- ))+ render(+ Primer::Alpha::ToggleSwitch.new(+ src: toggle_type_pdf_export_template_path(type_id: @type.id, id: @template.id),+ csrf_token: form_authenticity_token,+ data: { "turbo-method": :post, "turbo-stream": true },+ checked: @template.enabled,+ size: :small,+ status_label_position: :start,+ test_selector: "toggle-pdf-export-template-row-#{@template.id}",+ classes: "op-primer-adjustments__toggle-switch--hidden-loading-indicator"+ )+ )endendenddiff --git a/app/components/work_packages/types/export_template_row_component.rb b/app/components/work_package_types/export_template_row_component.rbsimilarity index 79%rename from app/components/work_packages/types/export_template_row_component.rbrename to app/components/work_package_types/export_template_row_component.rbindex 07d9a9aaff2..dd2796f2eef 100644--- a/app/components/work_packages/types/export_template_row_component.rb+++ b/app/components/work_package_types/export_template_row_component.rb@@ -28,18 +28,17 @@# See COPYRIGHT and LICENSE files for more details.#++-module WorkPackages- module Types- class ExportTemplateRowComponent < ApplicationComponent- include ApplicationHelper- include OpPrimer::ComponentHelpers- include OpTurbo::Streamable- def initialize(type:, template:)- super+module WorkPackageTypes+ class ExportTemplateRowComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable- @template = template- @type = type- end+ def initialize(type:, template:)+ super++ @template = template+ @type = typeendendenddiff --git a/app/components/work_packages/types/pattern_input.html.erb b/app/components/work_package_types/pattern_input.html.erbsimilarity index 100%rename from app/components/work_packages/types/pattern_input.html.erbrename to app/components/work_package_types/pattern_input.html.erbdiff --git a/app/components/work_packages/types/pattern_input.rb b/app/components/work_package_types/pattern_input.rbsimilarity index 64%rename from app/components/work_packages/types/pattern_input.rbrename to app/components/work_package_types/pattern_input.rbindex aec45fc3e06..8915573a26d 100644--- a/app/components/work_packages/types/pattern_input.rb+++ b/app/components/work_package_types/pattern_input.rb@@ -28,32 +28,30 @@# See COPYRIGHT and LICENSE files for more details.# ++-module WorkPackages- module Types- class PatternInput < Primer::Forms::BaseComponent- prepend Primer::OpenProject::Forms::WrappedInput+module WorkPackageTypes+ class PatternInput < Primer::Forms::BaseComponent+ prepend Primer::OpenProject::Forms::WrappedInput- delegate :name, to: :@input+ delegate :name, to: :@input- def initialize(input:, value:, suggestions:)- super()- @input = input- @value = value- @suggestions = suggestions- end+ def initialize(input:, value:, suggestions:)+ super()+ @input = input+ @value = value+ @suggestions = suggestions+ end- def suggestions_for_stimulus- @suggestions_for_stimulus ||= @suggestions.to_json- end+ def suggestions_for_stimulus+ @suggestions_for_stimulus ||= @suggestions.to_json+ end- def suggestions_list_component- @suggestions_list_component ||= Primer::Alpha::ActionList.new(- role: :list,- scheme: :inset,- ml: 0,- "data-pattern-input-target": "suggestions"- )- end+ def suggestions_list_component+ @suggestions_list_component ||= Primer::Alpha::ActionList.new(+ role: :list,+ scheme: :inset,+ ml: 0,+ "data-pattern-input-target": "suggestions"+ )endendenddiff --git a/app/components/work_packages/types/pattern_input.sass b/app/components/work_package_types/pattern_input.sasssimilarity index 100%rename from app/components/work_packages/types/pattern_input.sassrename to app/components/work_package_types/pattern_input.sassdiff --git a/app/components/work_packages/types/settings_component.html.erb b/app/components/work_package_types/settings_component.html.erbsimilarity index 95%rename from app/components/work_packages/types/settings_component.html.erbrename to app/components/work_package_types/settings_component.html.erbindex bae0a30f35e..f8a398fc0b9 100644--- a/app/components/work_packages/types/settings_component.html.erb+++ b/app/components/work_package_types/settings_component.html.erb@@ -29,6 +29,6 @@ See COPYRIGHT and LICENSE files for more details.<%=settings_primer_form_with(**form_options) do |f|- render(WorkPackages::Types::SettingsForm.new(f))+ render(WorkPackageTypes::SettingsForm.new(f))end%>diff --git a/app/components/work_packages/types/settings_component.rb b/app/components/work_package_types/settings_component.rbsimilarity index 62%rename from app/components/work_packages/types/settings_component.rbrename to app/components/work_package_types/settings_component.rbindex 926039e5bc8..a92c9fc00f8 100644--- a/app/components/work_packages/types/settings_component.rb+++ b/app/components/work_package_types/settings_component.rb@@ -28,37 +28,35 @@# See COPYRIGHT and LICENSE files for more details.#++-module WorkPackages- module Types- class SettingsComponent < ApplicationComponent- include ApplicationHelper- include OpPrimer::ComponentHelpers- include OpTurbo::Streamable-- def initialize(model, copy_workflow_from: nil, **)- @copy_workflow_from = copy_workflow_from- super(model, **)- end+module WorkPackageTypes+ class SettingsComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(model, copy_workflow_from: nil, **)+ @copy_workflow_from = copy_workflow_from+ super(model, **)+ end- def form_options- if model.new_record?- create_form_options- else- update_form_options- end+ def form_options+ if model.new_record?+ create_form_options+ else+ update_form_optionsend+ end- private+ private- attr_reader :copy_workflow_from+ attr_reader :copy_workflow_from- def create_form_options- { url: types_path, method: :post, model:, copy_workflow_from: }- end+ def create_form_options+ { url: types_path, method: :post, model:, copy_workflow_from: }+ end- def update_form_options- { url: update_tab_type_path(id: model.id, tab: :settings), method: :patch, model: }- end+ def update_form_options+ { url: update_tab_type_path(id: model.id, tab: :settings), method: :patch, model: }endendenddiff --git a/app/components/work_packages/types/subject_configuration_component.html.erb b/app/components/work_package_types/subject_configuration_component.html.erbsimilarity index 95%rename from app/components/work_packages/types/subject_configuration_component.html.erbrename to app/components/work_package_types/subject_configuration_component.html.erbindex 4c1550b80f4..6fff3153b36 100644--- a/app/components/work_packages/types/subject_configuration_component.html.erb+++ b/app/components/work_package_types/subject_configuration_component.html.erb@@ -33,6 +33,6 @@ See COPYRIGHT and LICENSE files for more details.<%=settings_primer_form_with(**form_options) do |f|- render(WorkPackages::Types::SubjectConfigurationForm.new(f))+ render(WorkPackageTypes::SubjectConfigurationForm.new(f))end%>diff --git a/app/components/work_package_types/subject_configuration_component.rb b/app/components/work_package_types/subject_configuration_component.rbnew file mode 100644index 00000000000..a407c2b5b94--- /dev/null+++ b/app/components/work_package_types/subject_configuration_component.rb@@ -0,0 +1,110 @@+# 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 WorkPackageTypes+ class SubjectConfigurationComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(model, subject_configuration_form_data: nil, **)+ @subject_configuration_form_data = subject_configuration_form_data+ super(model, **)+ end++ def form_options+ form_model = subject_form_object++ {+ url: subject_configuration_type_path(id: model.id),+ method: :put,+ model: form_model,+ data: {+ controller: "admin--subject-configuration",+ admin__subject_configuration_hide_pattern_input_value: form_model.subject_configuration == :manual+ }+ }+ end++ private++ def subject_form_object+ values = subject_configuration_form_values++ Forms::SubjectConfigurationFormModel.new(+ subject_configuration: values[:subject_configuration],+ pattern: values[:pattern],+ suggestions: sort_attributes(supported_attributes),+ validation_errors: model.errors+ )+ end++ def supported_attributes+ attribute_tokens = Patterns::TokenPropertyMapper.new.tokens_for_type(model)++ result = {+ work_package: {+ title: I18n.t("types.edit.subject_configuration.token.context.work_package"),+ tokens: []+ },+ parent: {+ title: I18n.t("types.edit.subject_configuration.token.context.parent"),+ tokens: []+ },+ project: {+ title: I18n.t("types.edit.subject_configuration.token.context.project"),+ tokens: []+ }+ }++ attribute_tokens.each_with_object(result) do |token, obj|+ token_hash = { key: token.key, label: token.label, label_with_context: token.label_with_context }+ obj[token.context][:tokens] << token_hash+ end+ end++ def sort_attributes(attributes)+ attributes.each_value { |group| group[:tokens] = group[:tokens].sort_by { |a| a[:label] } }+ attributes+ end++ def subject_configuration_form_values+ if @subject_configuration_form_data.present?+ @subject_configuration_form_data+ else+ persisted_subject_pattern = model.patterns.subject || Pattern.new(blueprint: "", enabled: false)+ subject_configuration = persisted_subject_pattern.enabled ? :generated : :manual+ pattern = persisted_subject_pattern.blueprint++ { subject_configuration:, pattern: }+ end+ end+ end+enddiff --git a/app/components/work_packages/types/subject_configuration_component.rb b/app/components/work_packages/types/subject_configuration_component.rbdeleted file mode 100644index 7d2ecbb53fe..00000000000--- a/app/components/work_packages/types/subject_configuration_component.rb+++ /dev/null@@ -1,112 +0,0 @@-# 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 WorkPackages- module Types- class SubjectConfigurationComponent < ApplicationComponent- include ApplicationHelper- include OpPrimer::ComponentHelpers- include OpTurbo::Streamable-- def initialize(model, subject_configuration_form_data: nil, **)- @subject_configuration_form_data = subject_configuration_form_data- super(model, **)- end-- def form_options- form_model = subject_form_object-- {- url: subject_configuration_type_path(id: model.id),- method: :put,- model: form_model,- data: {- controller: "admin--subject-configuration",- admin__subject_configuration_hide_pattern_input_value: form_model.subject_configuration == :manual- }- }- end-- private-- def subject_form_object- values = subject_configuration_form_values-- ::Types::Forms::SubjectConfigurationFormModel.new(- subject_configuration: values[:subject_configuration],- pattern: values[:pattern],- suggestions: sort_attributes(supported_attributes),- validation_errors: model.errors- )- end-- def supported_attributes- attribute_tokens = ::Types::Patterns::TokenPropertyMapper.new.tokens_for_type(model)-- result = {- work_package: {- title: I18n.t("types.edit.subject_configuration.token.context.work_package"),- tokens: []- },- parent: {- title: I18n.t("types.edit.subject_configuration.token.context.parent"),- tokens: []- },- project: {- title: I18n.t("types.edit.subject_configuration.token.context.project"),- tokens: []- }- }-- attribute_tokens.each_with_object(result) do |token, obj|- token_hash = { key: token.key, label: token.label, label_with_context: token.label_with_context }- obj[token.context][:tokens] << token_hash- end- end-- def sort_attributes(attributes)- attributes.each_value { |group| group[:tokens] = group[:tokens].sort_by { |a| a[:label] } }- attributes- end-- def subject_configuration_form_values- if @subject_configuration_form_data.present?- @subject_configuration_form_data- else- persisted_subject_pattern = model.patterns.subject || ::Types::Pattern.new(blueprint: "", enabled: false)- subject_configuration = persisted_subject_pattern.enabled ? :generated : :manual- pattern = persisted_subject_pattern.blueprint-- { subject_configuration:, pattern: }- end- end- end- end-enddiff --git a/app/contracts/types/base_contract.rb b/app/contracts/types/base_contract.rbindex 8a1920e93e0..af2fbd1b02e 100644--- a/app/contracts/types/base_contract.rb+++ b/app/contracts/types/base_contract.rb@@ -112,9 +112,9 @@ module Typesreturn if blueprint.nil?valid_tokens = flat_valid_token_list- invalid_tokens = blueprint.scan(PatternResolver::TOKEN_REGEX)+ invalid_tokens = blueprint.scan(::WorkPackageTypes::PatternResolver::TOKEN_REGEX).reduce([]) do |acc, match|- token = Patterns::PatternToken.build(match).key+ token = ::WorkPackageTypes::Patterns::PatternToken.build(match).keyvalid_tokens.include?(token) ? acc : acc << tokenend@@ -123,6 +123,6 @@ module Typesendend- def flat_valid_token_list = Patterns::TokenPropertyMapper.new.tokens_for_type(model).map(&:key)+ def flat_valid_token_list = ::WorkPackageTypes::Patterns::TokenPropertyMapper.new.tokens_for_type(model).map(&:key)endenddiff --git a/app/contracts/work_package_types/update_subject_pattern_contract.rb b/app/contracts/work_package_types/update_subject_pattern_contract.rbindex 521fc240957..00d7a6a6fb5 100644--- a/app/contracts/work_package_types/update_subject_pattern_contract.rb+++ b/app/contracts/work_package_types/update_subject_pattern_contract.rb@@ -41,9 +41,9 @@ module WorkPackageTypesreturn if blueprint.nil?valid_tokens = flat_valid_token_list- invalid_tokens = blueprint.scan(Types::PatternResolver::TOKEN_REGEX)+ invalid_tokens = blueprint.scan(WorkPackageTypes::PatternResolver::TOKEN_REGEX).reduce([]) do |acc, match|- token = Types::Patterns::PatternToken.build(match).key+ token = WorkPackageTypes::Patterns::PatternToken.build(match).keyvalid_tokens.include?(token) ? acc : acc << tokenend@@ -52,6 +52,6 @@ module WorkPackageTypesendend- def flat_valid_token_list = Types::Patterns::TokenPropertyMapper.new.tokens_for_type(model).map(&:key)+ def flat_valid_token_list = WorkPackageTypes::Patterns::TokenPropertyMapper.new.tokens_for_type(model).map(&:key)endenddiff --git a/app/controllers/work_package_types/pdf_export_template_controller.rb b/app/controllers/work_package_types/pdf_export_template_controller.rbnew file mode 100644index 00000000000..f4870cff90f--- /dev/null+++ b/app/controllers/work_package_types/pdf_export_template_controller.rb@@ -0,0 +1,91 @@+# 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 WorkPackageTypes+ class PdfExportTemplateController < ApplicationController+ include OpTurbo::ComponentStream+ before_action :require_admin+ before_action :find_type, only: %i[toggle drop enable_all disable_all]+ before_action :find_template, only: %i[toggle drop]++ def enable_all+ return render_404_turbo_stream if @type.nil?++ @type.pdf_export_templates.enable_all+ @type.save!+ respond_section_with_turbo_streams+ end++ def disable_all+ return render_404_turbo_stream if @type.nil?++ @type.pdf_export_templates.disable_all+ @type.save!+ respond_section_with_turbo_streams+ end++ def toggle+ return render_404_turbo_stream if @template.nil?++ @type.pdf_export_templates.toggle(@template.id)+ @type.save!+ respond_with_turbo_streams+ end++ def drop+ return render_404_turbo_stream if @template.nil?++ @type.pdf_export_templates.move(@template.id, params[:position].to_i - 1) # drop index starts at 1+ @type.save!+ respond_to_with_turbo_streams+ end++ protected++ def respond_section_with_turbo_streams+ replace_via_turbo_stream(+ component: ::WorkPackageTypes::ExportTemplateListComponent.new(type: @type)+ )+ respond_to_with_turbo_streams+ end++ def render_404_turbo_stream+ render_error_flash_message_via_turbo_stream(message: t(:notice_file_not_found))+ end++ def find_type+ @type = ::Type.find(params[:type_id])+ end++ def find_template+ @template = @type.pdf_export_templates.find(params[:id])+ end+ end+enddiff --git a/app/controllers/work_package_types/subject_configuration_tab_controller.rb b/app/controllers/work_package_types/subject_configuration_tab_controller.rbnew file mode 100644index 00000000000..c2c269f82e4--- /dev/null+++ b/app/controllers/work_package_types/subject_configuration_tab_controller.rb@@ -0,0 +1,91 @@+# 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 WorkPackageTypes+ class SubjectConfigurationTabController < ApplicationController+ layout "admin"++ before_action :require_admin+ before_action :find_type, only: %i[update_subject_configuration]++ def update_subject_configuration+ form_params = params.expect(+ work_package_types_forms_subject_configuration_form_model: %i[subject_configuration pattern]+ ).to_h++ UpdateTypeService.new(@type, current_user)+ .call({ patterns: pattern_collection_update(form_params) }) do |call|+ call.on_success do+ redirect_to tab_path, notice: I18n.t(:notice_successful_update)+ end++ call.on_failure do+ params[:tab] = "subject_configuration"+ render template: "types/edit", status: :unprocessable_entity+ end+ end+ end++ private++ def find_type+ @type = ::Type.find(params[:id])+ end++ def tab_path = edit_tab_type_path(id: @type.id, tab: :subject_configuration)++ def pattern_collection_update(form_params)+ patterns = @type.patterns.to_h.symbolize_keys++ subject_pattern =+ case form_params+ in { subject_configuration: "generated", pattern: String => blueprint }+ { subject: { blueprint:, enabled: true } }+ in { subject_configuration: "manual", pattern: String => blueprint }+ if blueprint.empty?+ # Submitting the form with an empty blueprint and manual subject configuration will+ # remove the subject pattern from the collection+ nil+ else+ { subject: { blueprint:, enabled: false } }+ end+ else+ nil+ end++ if subject_pattern.nil?+ patterns.delete(:subject)+ patterns+ else+ patterns.merge(subject_pattern)+ end+ end+ end+enddiff --git a/app/controllers/work_packages/types/pdf_export_template_controller.rb b/app/controllers/work_packages/types/pdf_export_template_controller.rbdeleted file mode 100644index f39133f8456..00000000000--- a/app/controllers/work_packages/types/pdf_export_template_controller.rb+++ /dev/null@@ -1,93 +0,0 @@-# 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 WorkPackages- module Types- class PdfExportTemplateController < ApplicationController- include OpTurbo::ComponentStream- before_action :require_admin- before_action :find_type, only: %i[toggle drop enable_all disable_all]- before_action :find_template, only: %i[toggle drop]-- def enable_all- return render_404_turbo_stream if @type.nil?-- @type.pdf_export_templates.enable_all- @type.save!- respond_section_with_turbo_streams- end-- def disable_all- return render_404_turbo_stream if @type.nil?-- @type.pdf_export_templates.disable_all- @type.save!- respond_section_with_turbo_streams- end-- def toggle- return render_404_turbo_stream if @template.nil?-- @type.pdf_export_templates.toggle(@template.id)- @type.save!- respond_with_turbo_streams- end-- def drop- return render_404_turbo_stream if @template.nil?-- @type.pdf_export_templates.move(@template.id, params[:position].to_i - 1) # drop index starts at 1- @type.save!- respond_to_with_turbo_streams- end-- protected-- def respond_section_with_turbo_streams- replace_via_turbo_stream(- component: ::WorkPackages::Types::ExportTemplateListComponent.new(type: @type)- )- respond_to_with_turbo_streams- end-- def render_404_turbo_stream- render_error_flash_message_via_turbo_stream(message: t(:notice_file_not_found))- end-- def find_type- @type = ::Type.find(params[:type_id])- end-- def find_template- @template = @type.pdf_export_templates.find(params[:id])- end- end- end-enddiff --git a/app/controllers/work_packages/types/subject_configuration_tab_controller.rb b/app/controllers/work_packages/types/subject_configuration_tab_controller.rbdeleted file mode 100644index f39837b1c27..00000000000--- a/app/controllers/work_packages/types/subject_configuration_tab_controller.rb+++ /dev/null@@ -1,93 +0,0 @@-# 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 WorkPackages- module Types- class SubjectConfigurationTabController < ApplicationController- layout "admin"-- before_action :require_admin- before_action :find_type, only: %i[update_subject_configuration]-- def update_subject_configuration- form_params = params.require(:types_forms_subject_configuration_form_model)- .permit(:subject_configuration, :pattern)- .to_h-- UpdateTypeService.new(@type, current_user)- .call({ patterns: pattern_collection_update(form_params) }) do |call|- call.on_success do- redirect_to tab_path, notice: I18n.t(:notice_successful_update)- end-- call.on_failure do- params[:tab] = "subject_configuration"- render template: "types/edit", status: :unprocessable_entity- end- end- end-- private-- def find_type- @type = ::Type.find(params[:id])- end-- def tab_path = edit_tab_type_path(id: @type.id, tab: :subject_configuration)-- def pattern_collection_update(form_params)- patterns = @type.patterns.to_h.symbolize_keys-- subject_pattern =- case form_params- in { subject_configuration: "generated", pattern: String => blueprint }- { subject: { blueprint:, enabled: true } }- in { subject_configuration: "manual", pattern: String => blueprint }- if blueprint.empty?- # Submitting the form with an empty blueprint and manual subject configuration will- # remove the subject pattern from the collection- nil- else- { subject: { blueprint:, enabled: false } }- end- else- nil- end-- if subject_pattern.nil?- patterns.delete(:subject)- patterns- else- patterns.merge(subject_pattern)- end- end- end- end-enddiff --git a/app/forms/work_package_types/settings_form.rb b/app/forms/work_package_types/settings_form.rbnew file mode 100644index 00000000000..7ae69313334--- /dev/null+++ b/app/forms/work_package_types/settings_form.rb@@ -0,0 +1,117 @@+# 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 WorkPackageTypes+ class SettingsForm < ApplicationForm+ form do |settings_form|+ settings_form.text_field(+ name: :name,+ label: label(:name),+ placeholder: I18n.t(:label_name),+ required: true,+ disabled: model.is_standard?+ )++ settings_form.color_select_list(+ name: :color_id,+ label: Color.model_name.human,+ input_width: :medium,+ caption: I18n.t("types.edit.settings.type_color_text")+ )++ if show_work_flow_copy?+ settings_form.select_list(+ name: :copy_workflow_from,+ input_width: :medium,+ label: I18n.t(:label_copy_workflow_from),+ include_blank: true,+ validation_message: validation_message_for(:copy_workflow_from)+ ) do |other_types|+ work_package_types.each do |type|+ other_types.option(+ value: type.id,+ label: type.name,+ selected: type.id == prefilled_copy_workflow_from+ )+ end+ end+ end++ settings_form.rich_text_area(+ name: :description,+ label: label(:description),+ rich_text_options: { showAttachments: false }+ )++ settings_form.check_box(+ name: :is_milestone,+ label: label(:is_milestone)+ )++ settings_form.check_box(+ name: :is_in_roadmap,+ label: label(:is_in_roadmap)+ )++ settings_form.check_box(+ name: :is_default,+ label: label(:is_default)+ )++ settings_form.submit(+ name: :submit,+ label: I18n.t(:button_save),+ scheme: :primary+ )+ end++ private++ def label(attribute)+ model.class.human_attribute_name(attribute)+ end++ def show_work_flow_copy?+ model.new_record?+ end++ def work_package_types+ Type.all+ end++ def validation_message_for(attribute)+ model.errors.messages_for(attribute).to_sentence.presence+ end++ def prefilled_copy_workflow_from+ @builder.options[:copy_workflow_from]+ end+ end+enddiff --git a/app/forms/work_package_types/subject_configuration_form.rb b/app/forms/work_package_types/subject_configuration_form.rbnew file mode 100644index 00000000000..046c0d39524--- /dev/null+++ b/app/forms/work_package_types/subject_configuration_form.rb@@ -0,0 +1,99 @@+# 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 WorkPackageTypes+ class SubjectConfigurationForm < ApplicationForm+ form do |subject_form|+ subject_form.radio_button_group(name: :subject_configuration) do |group|+ group.radio_button(+ value: :manual,+ checked: subject_configuration_manual?,+ label: I18n.t("types.edit.subject_configuration.manually_editable_subjects.label"),+ caption: I18n.t("types.edit.subject_configuration.manually_editable_subjects.caption"),+ data: { action: "admin--subject-configuration#hidePatternInput" }+ )+ group.radio_button(+ value: :generated,+ checked: !subject_configuration_manual?,+ label: I18n.t("types.edit.subject_configuration.automatically_generated_subjects.label"),+ caption: I18n.t("types.edit.subject_configuration.automatically_generated_subjects.caption"),+ disabled: !enterprise? && subject_configuration_manual?,+ data: { action: "admin--subject-configuration#showPatternInput" }+ )+ end++ subject_form.group(data: { "admin--subject-configuration-target": "patternInput" }) do |toggleable_group|+ toggleable_group.pattern_input(+ name: :pattern,+ value: model.pattern,+ suggestions: model.suggestions,+ label: I18n.t("types.edit.subject_configuration.pattern.label"),+ caption: pattern_input_caption,+ required: true,+ validation_message: validation_message_for(:patterns)+ )+ end++ subject_form.submit(+ name: :submit,+ label: I18n.t(:button_save),+ scheme: :primary+ )+ end++ private++ def subject_configuration_manual?+ model.subject_configuration == :manual+ end++ def enterprise?+ EnterpriseToken.allows_to?(:work_package_subject_generation)+ end++ def validation_message_for(attribute)+ model.validation_errors.messages_for(attribute).to_sentence.presence+ end++ def pattern_input_caption+ I18n.t(+ "types.edit.subject_configuration.pattern.caption_with_supported_attributes_link",+ link: make_link(+ ::OpenProject::Static::Links.url_for(:enterprise_features, :work_package_subject_generation),+ I18n.t("types.edit.subject_configuration.pattern.supported_attributes_link")+ )+ ).html_safe+ end++ def make_link(href, link_text)+ render(Primer::Beta::Link.new(href:, target: "_blank")) { link_text }+ end+ end+enddiff --git a/app/forms/work_packages/types/settings_form.rb b/app/forms/work_packages/types/settings_form.rbdeleted file mode 100644index a6ab9bba160..00000000000--- a/app/forms/work_packages/types/settings_form.rb+++ /dev/null@@ -1,119 +0,0 @@-# 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 WorkPackages- module Types- class SettingsForm < ApplicationForm- form do |settings_form|- settings_form.text_field(- name: :name,- label: label(:name),- placeholder: I18n.t(:label_name),- required: true,- disabled: model.is_standard?- )-- settings_form.color_select_list(- name: :color_id,- label: Color.model_name.human,- input_width: :medium,- caption: I18n.t("types.edit.settings.type_color_text")- )-- if show_work_flow_copy?- settings_form.select_list(- name: :copy_workflow_from,- input_width: :medium,- label: I18n.t(:label_copy_workflow_from),- include_blank: true,- validation_message: validation_message_for(:copy_workflow_from)- ) do |other_types|- work_package_types.each do |type|- other_types.option(- value: type.id,- label: type.name,- selected: type.id == prefilled_copy_workflow_from- )- end- end- end-- settings_form.rich_text_area(- name: :description,- label: label(:description),- rich_text_options: { showAttachments: false }- )-- settings_form.check_box(- name: :is_milestone,- label: label(:is_milestone)- )-- settings_form.check_box(- name: :is_in_roadmap,- label: label(:is_in_roadmap)- )-- settings_form.check_box(- name: :is_default,- label: label(:is_default)- )-- settings_form.submit(- name: :submit,- label: I18n.t(:button_save),- scheme: :primary- )- end-- private-- def label(attribute)- model.class.human_attribute_name(attribute)- end-- def show_work_flow_copy?- model.new_record?- end-- def work_package_types- Type.all- end-- def validation_message_for(attribute)- model.errors.messages_for(attribute).to_sentence.presence- end-- def prefilled_copy_workflow_from- @builder.options[:copy_workflow_from]- end- end- end-enddiff --git a/app/forms/work_packages/types/subject_configuration_form.rb b/app/forms/work_packages/types/subject_configuration_form.rbdeleted file mode 100644index 9a6897c98e6..00000000000--- a/app/forms/work_packages/types/subject_configuration_form.rb+++ /dev/null@@ -1,101 +0,0 @@-# 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 WorkPackages- module Types- class SubjectConfigurationForm < ApplicationForm- form do |subject_form|- subject_form.radio_button_group(name: :subject_configuration) do |group|- group.radio_button(- value: :manual,- checked: subject_configuration_manual?,- label: I18n.t("types.edit.subject_configuration.manually_editable_subjects.label"),- caption: I18n.t("types.edit.subject_configuration.manually_editable_subjects.caption"),- data: { action: "admin--subject-configuration#hidePatternInput" }- )- group.radio_button(- value: :generated,- checked: !subject_configuration_manual?,- label: I18n.t("types.edit.subject_configuration.automatically_generated_subjects.label"),- caption: I18n.t("types.edit.subject_configuration.automatically_generated_subjects.caption"),- disabled: !enterprise? && subject_configuration_manual?,- data: { action: "admin--subject-configuration#showPatternInput" }- )- end-- subject_form.group(data: { "admin--subject-configuration-target": "patternInput" }) do |toggleable_group|- toggleable_group.pattern_input(- name: :pattern,- value: model.pattern,- suggestions: model.suggestions,- label: I18n.t("types.edit.subject_configuration.pattern.label"),- caption: pattern_input_caption,- required: true,- validation_message: validation_message_for(:patterns)- )- end-- subject_form.submit(- name: :submit,- label: I18n.t(:button_save),- scheme: :primary- )- end-- private-- def subject_configuration_manual?- model.subject_configuration == :manual- end-- def enterprise?- EnterpriseToken.allows_to?(:work_package_subject_generation)- end-- def validation_message_for(attribute)- model.validation_errors.messages_for(attribute).to_sentence.presence- end-- def pattern_input_caption- I18n.t(- "types.edit.subject_configuration.pattern.caption_with_supported_attributes_link",- link: make_link(- ::OpenProject::Static::Links.url_for(:enterprise_features, :work_package_subject_generation),- I18n.t("types.edit.subject_configuration.pattern.supported_attributes_link")- )- ).html_safe- end-- def make_link(href, link_text)- render(Primer::Beta::Link.new(href:, target: "_blank")) { link_text }- end- end- end-enddiff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rbindex 84855815ddc..5ab45d2d8ee 100644--- a/app/helpers/types_helper.rb+++ b/app/helpers/types_helper.rb@@ -36,7 +36,7 @@ module ::TypesHelpername: "settings",path: edit_tab_type_path(id: @type.id, tab: :settings),label: I18n.t("types.edit.settings.tab"),- view_component: WorkPackages::Types::SettingsComponent+ view_component: WorkPackageTypes::SettingsComponent},{name: "form_configuration",@@ -48,7 +48,7 @@ module ::TypesHelpername: "subject_configuration",path: edit_tab_type_path(id: @type.id, tab: :subject_configuration),label: I18n.t("types.edit.subject_configuration.tab"),- view_component: WorkPackages::Types::SubjectConfigurationComponent,+ view_component: WorkPackageTypes::SubjectConfigurationComponent,enterprise_feature: :work_package_subject_generation},{@@ -61,7 +61,7 @@ module ::TypesHelpername: "export_configuration",path: edit_tab_type_path(id: @type.id, tab: :export_configuration),label: I18n.t("types.edit.export_configuration.tab"),- view_component: WorkPackages::Types::ExportConfigurationComponent+ view_component: WorkPackageTypes::ExportConfigurationComponent}]enddiff --git a/app/models/type.rb b/app/models/type.rbindex 2bbd17aefda..a3b26c86b54 100644--- a/app/models/type.rb+++ b/app/models/type.rb@@ -36,7 +36,7 @@ class Type < ApplicationRecordinclude ::Scopes::Scoped- attribute :patterns, Types::Patterns::CollectionType.new+ attribute :patterns, WorkPackageTypes::Patterns::CollectionType.newstore_attribute :pdf_export_templates_config, :export_templates_disabled, :jsonstore_attribute :pdf_export_templates_config, :export_templates_order, :jsondiff --git a/app/models/types/forms/subject_configuration_form_model.rb b/app/models/work_package_types/forms/subject_configuration_form_model.rbsimilarity index 98%rename from app/models/types/forms/subject_configuration_form_model.rbrename to app/models/work_package_types/forms/subject_configuration_form_model.rbindex 3a8a53cff94..878d78962dd 100644--- a/app/models/types/forms/subject_configuration_form_model.rb+++ b/app/models/work_package_types/forms/subject_configuration_form_model.rb@@ -28,7 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module Types+module WorkPackageTypesmodule Formsclass SubjectConfigurationFormModelextend ActiveModel::Namingdiff --git a/app/models/types/pattern.rb b/app/models/work_package_types/pattern.rbsimilarity index 98%rename from app/models/types/pattern.rbrename to app/models/work_package_types/pattern.rbindex 8efe8eac5c4..3e10276075b 100644--- a/app/models/types/pattern.rb+++ b/app/models/work_package_types/pattern.rb@@ -28,7 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module Types+module WorkPackageTypesPattern = Data.define(:blueprint, :enabled) dodef enabled? = !!enableddiff --git a/app/models/types/pattern_resolver.rb b/app/models/work_package_types/pattern_resolver.rbsimilarity index 99%rename from app/models/types/pattern_resolver.rbrename to app/models/work_package_types/pattern_resolver.rbindex 084a42ecbbb..1fb0dcde3bb 100644--- a/app/models/types/pattern_resolver.rb+++ b/app/models/work_package_types/pattern_resolver.rb@@ -28,7 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module Types+module WorkPackageTypesclass PatternResolverTOKEN_REGEX = /{{[0-9A-Za-z_]+}}/ATTRIBUTE_PLACEHOLDER = "N/A"diff --git a/app/models/types/patterns/attribute_token.rb b/app/models/work_package_types/patterns/attribute_token.rbsimilarity index 97%rename from app/models/types/patterns/attribute_token.rbrename to app/models/work_package_types/patterns/attribute_token.rbindex 2b5f5859c5e..27a8125adb9 100644--- a/app/models/types/patterns/attribute_token.rb+++ b/app/models/work_package_types/patterns/attribute_token.rb@@ -23,12 +23,12 @@## 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.+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.#++-module Types+module WorkPackageTypesmodule PatternsAttributeToken = Data.define(:key, :label_fn, :resolve_fn) dodef label_with_contextdiff --git a/app/models/types/patterns/collection.rb b/app/models/work_package_types/patterns/collection.rbsimilarity index 98%rename from app/models/types/patterns/collection.rbrename to app/models/work_package_types/patterns/collection.rbindex c779f1278fa..54951129ae1 100644--- a/app/models/types/patterns/collection.rb+++ b/app/models/work_package_types/patterns/collection.rb@@ -28,7 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module Types+module WorkPackageTypesmodule PatternsCollection = Data.define(:patterns) doextend Dry::Monads[:result]diff --git a/app/models/types/patterns/collection_contract.rb b/app/models/work_package_types/patterns/collection_contract.rbsimilarity index 98%rename from app/models/types/patterns/collection_contract.rbrename to app/models/work_package_types/patterns/collection_contract.rbindex 74f06b8a2da..c518694360b 100644--- a/app/models/types/patterns/collection_contract.rb+++ b/app/models/work_package_types/patterns/collection_contract.rb@@ -28,7 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module Types+module WorkPackageTypesmodule Patternsclass CollectionContract < Dry::Validation::Contractconfig.messages.backend = :i18ndiff --git a/app/models/types/patterns/collection_type.rb b/app/models/work_package_types/patterns/collection_type.rbsimilarity index 98%rename from app/models/types/patterns/collection_type.rbrename to app/models/work_package_types/patterns/collection_type.rbindex f7c84b23416..c7a4b2f4250 100644--- a/app/models/types/patterns/collection_type.rb+++ b/app/models/work_package_types/patterns/collection_type.rb@@ -28,7 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module Types+module WorkPackageTypesmodule Patternsclass CollectionType < ActiveModel::Type::Valuedef assert_valid_value(value)diff --git a/app/models/types/patterns/pattern_token.rb b/app/models/work_package_types/patterns/pattern_token.rbsimilarity index 98%rename from app/models/types/patterns/pattern_token.rbrename to app/models/work_package_types/patterns/pattern_token.rbindex 04abe5016e4..ad2b449f791 100644--- a/app/models/types/patterns/pattern_token.rb+++ b/app/models/work_package_types/patterns/pattern_token.rb@@ -28,7 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module Types+module WorkPackageTypesmodule PatternsPatternToken = Data.define(:pattern, :key) doprivate_class_method :newdiff --git a/app/models/types/patterns/token_property_mapper.rb b/app/models/work_package_types/patterns/token_property_mapper.rbsimilarity index 99%rename from app/models/types/patterns/token_property_mapper.rbrename to app/models/work_package_types/patterns/token_property_mapper.rbindex 780c7c29b98..c9391be3ad9 100644--- a/app/models/types/patterns/token_property_mapper.rb+++ b/app/models/work_package_types/patterns/token_property_mapper.rb@@ -28,7 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module Types+module WorkPackageTypesmodule Patternsclass TokenPropertyMapper# rubocop:disable Layout/LineLengthdiff --git a/app/services/update_type_service.rb b/app/services/update_type_service.rbindex d41b417f9ac..3d3ca1aa14a 100644--- a/app/services/update_type_service.rb+++ b/app/services/update_type_service.rb@@ -63,7 +63,7 @@ class UpdateTypeService < BaseTypeServiceenddef set_patterns(patterns)- Types::Patterns::Collection+ WorkPackageTypes::Patterns::Collection.build(patterns:).either(->(collection) { type.patterns = collection },diff --git a/app/services/work_package_types/set_attributes_service.rb b/app/services/work_package_types/set_attributes_service.rbindex 2b658ffb80c..f9b7abed268 100644--- a/app/services/work_package_types/set_attributes_service.rb+++ b/app/services/work_package_types/set_attributes_service.rb@@ -65,7 +65,7 @@ module WorkPackageTypesreturn unless params.key?(:patterns)return if params.key?(:patterns) && params[:patterns].blank?- result = Types::Patterns::CollectionContract.new.call(params[:patterns])+ result = WorkPackageTypes::Patterns::CollectionContract.new.call(params[:patterns])if result.failure?@param_validations.update({ patterns: validation_failure_to_message(result).join(", ") })enddiff --git a/app/views/types/new.html.erb b/app/views/types/new.html.erbindex 899c3b45861..23af62c8b5a 100644--- a/app/views/types/new.html.erb+++ b/app/views/types/new.html.erb@@ -43,5 +43,5 @@ See COPYRIGHT and LICENSE files for more details.<%=copy_workflow_from = maybe_integer(params.dig(:type, :copy_workflow_from)).value_or(nil)- render WorkPackages::Types::SettingsComponent.new(@type, copy_workflow_from:)+ render WorkPackageTypes::SettingsComponent.new(@type, copy_workflow_from:)%>diff --git a/config/routes.rb b/config/routes.rbindex edf55acfa57..41a3cbaabe2 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -144,12 +144,12 @@ Rails.application.routes.draw doget "edit/:tab" => "types#edit", as: "edit_tab"match "update/:tab" => "types#update", as: "update_tab", via: %i[post patch]put :subject_configuration,- controller: "work_packages/types/subject_configuration_tab",+ controller: "work_package_types/subject_configuration_tab",action: "update_subject_configuration"endresources :pdf_export_template, only: %i[],- controller: "work_packages/types/pdf_export_template",+ controller: "work_package_types/pdf_export_template",path: "pdf_export_template" domember dopost :togglediff --git a/lib/primer/open_project/forms/dsl/pattern_input.rb b/lib/primer/open_project/forms/dsl/pattern_input.rbindex 31388419be1..62037b627b5 100644--- a/lib/primer/open_project/forms/dsl/pattern_input.rb+++ b/lib/primer/open_project/forms/dsl/pattern_input.rb@@ -45,7 +45,7 @@ module Primerenddef to_component- WorkPackages::Types::PatternInput.new(input: self, value:, suggestions:)+ WorkPackageTypes::PatternInput.new(input: self, value:, suggestions:)enddef typediff --git a/lookbook/docs/patterns/17-settings-pages.md.erb b/lookbook/docs/patterns/17-settings-pages.md.erbindex 47c8c12dd62..b08286a198d 100644--- a/lookbook/docs/patterns/17-settings-pages.md.erb+++ b/lookbook/docs/patterns/17-settings-pages.md.erb@@ -10,7 +10,7 @@ way, the rendered form is wrapped into a container with `680px` max-width.```erb<%%=settings_primer_form_with(**form_options) do |f|- render(WorkPackages::Types::SettingsForm.new(f))+ render(WorkPackageTypes::SettingsForm.new(f))end %>```diff --git a/spec/components/work_packages/types/subject_configuration_component_spec.rb b/spec/components/work_package_types/subject_configuration_component_spec.rbsimilarity index 91%rename from spec/components/work_packages/types/subject_configuration_component_spec.rbrename to spec/components/work_package_types/subject_configuration_component_spec.rbindex 532bd803d3a..56578de9c21 100644--- a/spec/components/work_packages/types/subject_configuration_component_spec.rb+++ b/spec/components/work_package_types/subject_configuration_component_spec.rb@@ -30,7 +30,7 @@require "rails_helper"-RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :component do+RSpec.describe WorkPackageTypes::SubjectConfigurationComponent, type: :component dolet(:type) { create(:type) }let(:subject_configuration_form_data) { nil }@@ -68,8 +68,7 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :componit "must have generated option checked and pattern input filled" doexpect(page.find("input[type=radio][value=generated]")).to be_checked- expect(page.find("input[type=hidden][id=types_forms_subject_configuration_form_model_pattern]", visible: false).value)- .to eq("Created by {{assignee}}")+ expect(page.find(hidden_input_field_selector, visible: false).value).to eq("Created by {{assignee}}")endendend@@ -98,8 +97,7 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :componit "must have generated option checked and pattern input filled" doexpect(page.find("input[type=radio][value=generated]")).to be_checked- expect(page.find("input[type=hidden][id=types_forms_subject_configuration_form_model_pattern]", visible: false).value)- .to eq("Created by {{assignee}}")+ expect(page.find(hidden_input_field_selector, visible: false).value).to eq("Created by {{assignee}}")endendend@@ -136,4 +134,10 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :componendendend++ private++ def hidden_input_field_selector+ "input[type=hidden][id=work_package_types_forms_subject_configuration_form_model_pattern]"+ endenddiff --git a/spec/contracts/types/base_contract_spec.rb b/spec/contracts/types/base_contract_spec.rbindex ec76e81524b..7c40efc395f 100644--- a/spec/contracts/types/base_contract_spec.rb+++ b/spec/contracts/types/base_contract_spec.rb@@ -38,15 +38,15 @@ RSpec.describe Types::BaseContract dodescribe "#validation" docontext "if subject generation patterns contains invalid tokens" do- let(:valid_tokens) { [Types::Patterns::AttributeToken.new(:assignee, nil, nil)] }+ let(:valid_tokens) { [WorkPackageTypes::Patterns::AttributeToken.new(:assignee, nil, nil)] }let(:work_package_type) doType.new(patterns: { subject: { blueprint: "Vacation {{vaders_toy}}", enabled: true } })endbefore do- token_mapper_double = instance_double(Types::Patterns::TokenPropertyMapper)+ token_mapper_double = instance_double(WorkPackageTypes::Patterns::TokenPropertyMapper)allow(token_mapper_double).to receive(:tokens_for_type).and_return(valid_tokens)- allow(Types::Patterns::TokenPropertyMapper).to receive(:new).and_return(token_mapper_double)+ allow(WorkPackageTypes::Patterns::TokenPropertyMapper).to receive(:new).and_return(token_mapper_double)endit "is invalid" dodiff --git a/spec/controllers/work_packages/types/pdf_export_template_controller_spec.rb b/spec/controllers/work_package_types/pdf_export_template_controller_spec.rbsimilarity index 98%rename from spec/controllers/work_packages/types/pdf_export_template_controller_spec.rbrename to spec/controllers/work_package_types/pdf_export_template_controller_spec.rbindex 900079822ca..b3c846a33e8 100644--- a/spec/controllers/work_packages/types/pdf_export_template_controller_spec.rb+++ b/spec/controllers/work_package_types/pdf_export_template_controller_spec.rb@@ -31,7 +31,7 @@require "spec_helper"-RSpec.describe WorkPackages::Types::PdfExportTemplateController do+RSpec.describe WorkPackageTypes::PdfExportTemplateController dolet(:user) { create(:admin) }let(:wp_type) { create(:type) }diff --git a/spec/controllers/work_packages/types/subject_configuration_tab_controller_spec.rb b/spec/controllers/work_package_types/subject_configuration_tab_controller_spec.rbsimilarity index 96%rename from spec/controllers/work_packages/types/subject_configuration_tab_controller_spec.rbrename to spec/controllers/work_package_types/subject_configuration_tab_controller_spec.rbindex 76c6aeb92b4..8cade82168b 100644--- a/spec/controllers/work_packages/types/subject_configuration_tab_controller_spec.rb+++ b/spec/controllers/work_package_types/subject_configuration_tab_controller_spec.rb@@ -31,7 +31,7 @@require "spec_helper"-RSpec.describe WorkPackages::Types::SubjectConfigurationTabController do+RSpec.describe WorkPackageTypes::SubjectConfigurationTabController dolet(:user) { create(:admin) }let(:wp_type) { create(:type) }@@ -67,7 +67,7 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationTabController doput :update_subject_configuration,params: {id: wp_type.id,- types_forms_subject_configuration_form_model: form_data+ work_package_types_forms_subject_configuration_form_model: form_data}enddiff --git a/spec/models/type_spec.rb b/spec/models/type_spec.rbindex dc010a922ac..14e464cc7fc 100644--- a/spec/models/type_spec.rb+++ b/spec/models/type_spec.rb@@ -132,7 +132,7 @@ RSpec.describe Type doit "returns an empty collection when no patterns are defined" dotype = create(:type)- expect(type.patterns).to eq(Types::Patterns::Collection.empty)+ expect(type.patterns).to eq(WorkPackageTypes::Patterns::Collection.empty)endit "returns a PatternCollection" do@@ -140,9 +140,9 @@ RSpec.describe Type dosubject: { blueprint: "{{work_package:custom_field_123}} - {{project:custom_field_321}}", enabled: true }})- expect(type.patterns).to be_a(Types::Patterns::Collection)+ expect(type.patterns).to be_a(WorkPackageTypes::Patterns::Collection)expect(type.patterns.subject)- .to eq(Types::Pattern.new("{{work_package:custom_field_123}} - {{project:custom_field_321}}", true))+ .to eq(WorkPackageTypes::Pattern.new("{{work_package:custom_field_123}} - {{project:custom_field_321}}", true))endend@@ -150,7 +150,7 @@ RSpec.describe Type dosubject(:type) { build(:type) }it "assigns a patterns collection as-is" do- collection = Types::Patterns::Collection.build(patterns: {+ collection = WorkPackageTypes::Patterns::Collection.build(patterns: {subject: { blueprint: "some_string", enabled: false }}).value!@@ -164,7 +164,7 @@ RSpec.describe Type doit "defaults to an empty collection" dotype.patterns = 4- expect(type.patterns).to eq(Types::Patterns::Collection.empty)+ expect(type.patterns).to eq(WorkPackageTypes::Patterns::Collection.empty)expect { type.save! }.not_to raise_errorendend@@ -173,8 +173,8 @@ RSpec.describe Type doit "converts the incoming hash into a PatternCollection" dotype.patterns = { subject: { blueprint: "some_string", enabled: false } }- expect(type.patterns).to be_a(Types::Patterns::Collection)- expect(type.patterns.subject).to be_a(Types::Pattern)+ expect(type.patterns).to be_a(WorkPackageTypes::Patterns::Collection)+ expect(type.patterns.subject).to be_a(WorkPackageTypes::Pattern)expect { type.save! }.not_to raise_errorenddiff --git a/spec/models/types/pattern_resolver_spec.rb b/spec/models/work_package_types/pattern_resolver_spec.rbsimilarity index 98%rename from spec/models/types/pattern_resolver_spec.rbrename to spec/models/work_package_types/pattern_resolver_spec.rbindex bcd550a7034..9c94b737a26 100644--- a/spec/models/types/pattern_resolver_spec.rb+++ b/spec/models/work_package_types/pattern_resolver_spec.rb@@ -30,7 +30,7 @@require "spec_helper"-RSpec.describe Types::PatternResolver do+RSpec.describe WorkPackageTypes::PatternResolver dolet(:subject_pattern) { "ID Please: {{id}}" }shared_let(:work_package) { create(:work_package) }diff --git a/spec/models/types/patterns/token_property_mapper_spec.rb b/spec/models/work_package_types/patterns/token_property_mapper_spec.rbsimilarity index 97%rename from spec/models/types/patterns/token_property_mapper_spec.rbrename to spec/models/work_package_types/patterns/token_property_mapper_spec.rbindex 200df7572b2..995fa744e49 100644--- a/spec/models/types/patterns/token_property_mapper_spec.rb+++ b/spec/models/work_package_types/patterns/token_property_mapper_spec.rb@@ -30,7 +30,7 @@require "spec_helper"-RSpec.describe Types::Patterns::TokenPropertyMapper do+RSpec.describe WorkPackageTypes::Patterns::TokenPropertyMapper doshared_let(:responsible) { create(:user, firstname: "Responsible") }shared_let(:assignee) { create(:user, firstname: "Assignee") }shared_let(:version) { create(:version) }@@ -128,7 +128,7 @@ RSpec.describe Types::Patterns::TokenPropertyMapper docf = string_custom_fieldtokens = described_class.new.tokens_for_type(work_package.type)- expect(tokens.first).to be_a(Types::Patterns::AttributeToken)+ expect(tokens.first).to be_a(WorkPackageTypes::Patterns::AttributeToken)expect(detect(tokens, :project_status).label).to eq(Project.human_attribute_name(:status_code))expect(detect(tokens, :"custom_field_#{cf.id}").label).to eq(cf.name)enddiff --git a/spec/services/work_package_types/set_attributes_service_spec.rb b/spec/services/work_package_types/set_attributes_service_spec.rbindex 68537c94f98..e30e15fe45d 100644--- a/spec/services/work_package_types/set_attributes_service_spec.rb+++ b/spec/services/work_package_types/set_attributes_service_spec.rb@@ -86,7 +86,7 @@ module WorkPackageTypesit "sets the patterns to an empty collection" doservice.call(params)- expect(model.patterns).to eq(Types::Patterns::Collection.empty)+ expect(model.patterns).to eq(WorkPackageTypes::Patterns::Collection.empty)endend