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
[#59997] added new form component to configure wp subjects
Eric Schubert566ddb3a895f
diff --git a/app/components/types/edit_page_header_component.html.erb b/app/components/types/edit_page_header_component.html.erbindex 70c2494d395..27e38756b3c 100644--- a/app/components/types/edit_page_header_component.html.erb+++ b/app/components/types/edit_page_header_component.html.erb@@ -35,7 +35,7 @@ See COPYRIGHT and LICENSE files for more details.header.with_tab_nav(label: nil) do |tab_nav|@tabs.each do |tab|tab_nav.with_tab(selected: selected_tab(@tabs) == tab, href: tab[:path]) do |t|- t.with_text { I18n.t("js.#{tab[:label]}") }+ t.with_text { I18n.t(tab[:label]) }endendend if @tabs.present?diff --git a/app/components/work_packages/types/subject_configuration_component.html.erb b/app/components/work_packages/types/subject_configuration_component.html.erbnew file mode 100644index 00000000000..95792457632--- /dev/null+++ b/app/components/work_packages/types/subject_configuration_component.html.erb@@ -0,0 +1,34 @@+<%#-- 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.++++#%>++<%=+ primer_form_with(**form_options) do |f|+ render(WorkPackages::Types::SubjectConfigurationForm.new(f))+ end+%>diff --git a/app/components/work_packages/types/subject_configuration_component.rb b/app/components/work_packages/types/subject_configuration_component.rbnew file mode 100644index 00000000000..cef32cb4322--- /dev/null+++ b/app/components/work_packages/types/subject_configuration_component.rb@@ -0,0 +1,46 @@+# 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 OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def form_options+ {+ url: "https://example.com",+ method: :put,+ model:+ }+ end+ end+ end+enddiff --git a/app/forms/work_packages/types/subject_configuration_form.rb b/app/forms/work_packages/types/subject_configuration_form.rbnew file mode 100644index 00000000000..e48944c561b--- /dev/null+++ b/app/forms/work_packages/types/subject_configuration_form.rb@@ -0,0 +1,68 @@+# 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: !has_pattern?,+ label: I18n.t("types.edit.subject_configuration.manually_editable_subjects.label"),+ caption: I18n.t("types.edit.subject_configuration.manually_editable_subjects.caption")+ )+ group.radio_button(+ value: "auto",+ checked: has_pattern?,+ label: I18n.t("types.edit.subject_configuration.automatically_generated_subjects.label"),+ caption: I18n.t("types.edit.subject_configuration.automatically_generated_subjects.caption")+ )+ end++ subject_form.text_field(+ name: :pattern,+ label: I18n.t("types.edit.subject_configuration.pattern.label"),+ caption: I18n.t("types.edit.subject_configuration.pattern.caption"),+ required: true,+ input_width: :large+ )++ subject_form.submit(name: :submit, label: I18n.t(:button_save), scheme: :primary)+ end++ private++ def has_pattern?+ false+ end+ end+ end+enddiff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rbindex fcac23fc709..71f103504d7 100644--- a/app/helpers/types_helper.rb+++ b/app/helpers/types_helper.rb@@ -33,19 +33,25 @@ module ::TypesHelpername: "settings",partial: "types/form/settings",path: edit_type_tab_path(id: @type.id, tab: :settings),- label: "types.edit.settings"+ label: "types.edit.settings.tab"},{name: "form_configuration",partial: "types/form/form_configuration",path: edit_type_tab_path(id: @type.id, tab: :form_configuration),- label: "types.edit.form_configuration"+ label: "types.edit.form_configuration.tab"+ },+ {+ name: "subject_configuration",+ path: edit_type_tab_path(id: @type.id, tab: :subject_configuration),+ label: "types.edit.subject_configuration.tab",+ view_component: WorkPackages::Types::SubjectConfigurationComponent},{name: "projects",partial: "types/form/projects",path: edit_type_tab_path(id: @type.id, tab: :projects),- label: "types.edit.projects"+ label: "types.edit.projects.tab"}]enddiff --git a/app/views/types/edit.html.erb b/app/views/types/edit.html.erbindex c3b52c8f96a..cdba71ebc00 100644--- a/app/views/types/edit.html.erb+++ b/app/views/types/edit.html.erb@@ -33,12 +33,19 @@ See COPYRIGHT and LICENSE files for more details.<%= render ::Types::EditPageHeaderComponent.new(type: @type, tabs: tabs) %>-<%= form_for @type,+<%=+ selected_tab = selected_tab(tabs)++ if selected_tab.key?(:view_component)+ render selected_tab[:view_component].new(@type)+ else+ form_for @type,url: update_type_tab_path(id: @type.id, tab: @tab),builder: TabularFormBuilder,- lang: current_language do |f| %>-- <%= render_tabs tabs, f, with_tab_nav: false %>-<% end %>+ lang: current_language do |f|+ render partial: "common/tabs", locals: { f:, tabs:, selected_tab:, with_tab_nav: false }+ end+ end+%><%= error_messages_for 'type' %>diff --git a/app/views/types/form/_projects.html.erb b/app/views/types/form/_projects.html.erbindex 081f5cf2d59..68407540cf1 100644--- a/app/views/types/form/_projects.html.erb+++ b/app/views/types/form/_projects.html.erb@@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details.<% if @projects.any? %><fieldset class="form--fieldset" id="type_project_ids"><legend class="form--fieldset-legend" >- <%= t('types.edit.enabled_projects') %>+ <%= t('types.edit.projects.enabled_projects') %></legend><div class="form--toolbar"><span class="form--toolbar-item">diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 88621dabd1b..dc40b9cc084 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -628,8 +628,8 @@ en:no_results_title_text: There are currently no types.no_results_content_text: Create a new typeedit:- settings: "Settings"- form_configuration: "Form configuration"+ form_configuration:+ tab: "Form configuration"more_info_text_html: >Enterprise edition allows you to customize form configuration with these additional add-ons: <br><ul class="%{list_styling_class}">@@ -637,14 +637,23 @@ en:<li><b>Rename attribute groups</b></li><li><b>Add a table of related work packages</b></li></ul>- projects: "Projects"- enabled_projects: "Enabled projects"- edit_query: "Edit table"- query_group_placeholder: "Give the table a name"- reset: "Reset to defaults"- type_color_text: |- The selected color distinguishes different types- in Gantt charts or work packages tables. It is therefore recommended to use a strong color.+ projects:+ tab: "Projects"+ enabled_projects: "Enabled projects"+ settings:+ tab: "Settings"+ type_color_text: The selected color distinguishes different types in Gantt charts or work packages tables. It is therefore recommended to use a strong color.+ subject_configuration:+ tab: "Subject configuration"+ manually_editable_subjects:+ label: "Manually editable subjects"+ caption: "Users can manually enter and edit work package subjects without restrictions."+ automatically_generated_subjects:+ label: "Automatically generated subjects"+ caption: "Define a pattern using referenced attributes and text to automatically generate work package subjects. Users will not be able to manually edit subjects."+ pattern:+ label: "Subject pattern"+ caption: "Search for an attribute or add text. To create a space between elements add it as a text."versions:overview:@@ -1693,7 +1702,7 @@ en:create_new_page: "Wiki page"date:- abbr_day_names: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]+ abbr_day_names: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]abbr_month_names:[~,@@ -2022,20 +2031,20 @@ en:pdf_generator:page_nr_footer: "Page %{page} of %{total}"dialog:- title: Generate PDF- submit: Generate- header_right:- label: Header right- caption: Text to be displayed in the right of the header- footer_center:- label: Footer center- caption: Text to be displayed in the center of the footer- hyphenation:- label: Hyphenation- caption: Break words between lines to improve text justification and readability.- paper_size:- label: Paper size- caption: The size of the paper to use for the PDF.+ title: Generate PDF+ submit: Generate+ header_right:+ label: Header right+ caption: Text to be displayed in the right of the header+ footer_center:+ label: Footer center+ caption: Text to be displayed in the center of the footer+ hyphenation:+ label: Hyphenation+ caption: Break words between lines to improve text justification and readability.+ paper_size:+ label: Paper size+ caption: The size of the paper to use for the PDF.extraction:available:diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex b71023bec41..862d69ddd6c 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -838,10 +838,6 @@ en:upgrade_to_ee_text: "Wow! If you need this add-on you are a super pro! Would you mind supporting us OpenSource developers by becoming an Enterprise edition client?"more_information: "More information"nevermind: "Nevermind"- edit:- form_configuration: "Form Configuration"- projects: "Projects"- settings: "Settings"time_entry:work_package_required: "Requires selecting a work package first."