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
[#60144] primerize wp types settings form
Eric Schubertcf3567973d42
diff --git a/app/components/work_packages/types/settings_component.html.erb b/app/components/work_packages/types/settings_component.html.erbnew file mode 100644index 00000000000..f9c74101ee8--- /dev/null+++ b/app/components/work_packages/types/settings_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::SettingsForm.new(f))+ end+%>diff --git a/app/components/work_packages/types/settings_component.rb b/app/components/work_packages/types/settings_component.rbnew file mode 100644index 00000000000..fa08b10fbbb--- /dev/null+++ b/app/components/work_packages/types/settings_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 SettingsComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def form_options+ {+ url: model.new_record? ? types_path : type_path(id: model.id),+ method: model.new_record? ? :post : :patch,+ model:+ }+ end+ end+ end+enddiff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rbindex 3c2bf3b7293..939264122d9 100644--- a/app/controllers/types_controller.rb+++ b/app/controllers/types_controller.rb@@ -62,7 +62,7 @@ class TypesController < ApplicationControllerendend- def create # rubocop:disable Metrics/AbcSize+ def createCreateTypeService.new(current_user).call(permitted_type_params, copy_workflow_from: params[:copy_workflow_from]) do |call|@@ -72,9 +72,7 @@ class TypesController < ApplicationControllerredirect_to_type_tab_path(@type, t(:notice_successful_create))end- call.on_failure do |result|- flash[:error] = result.errors.full_messages.join("\n")- load_projects_and_types+ call.on_failure dorender action: :new, status: :unprocessable_entityendenddiff --git a/app/forms/work_packages/types/settings_form.rb b/app/forms/work_packages/types/settings_form.rbnew file mode 100644index 00000000000..e9bcdcbcab1--- /dev/null+++ b/app/forms/work_packages/types/settings_form.rb@@ -0,0 +1,108 @@+# 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 |subject_form|+ subject_form.text_field(+ name: :name,+ label: label(:name),+ placeholder: I18n.t(:label_name),+ input_width: :large,+ required: true,+ disabled: model.is_standard?+ )++ subject_form.color_select_list(+ name: :color_id,+ label: Color.model_name.human,+ caption: I18n.t("types.edit.settings.type_color_text"),+ input_width: :large+ )++ if show_work_flow_copy?+ subject_form.select_list(+ name: :copy_workflow_from,+ label: label(:copy_workflow_from),+ include_blank: true,+ input_width: :large+ ) do |other_types|+ work_package_types.each do |type|+ other_types.option(value: type.id, label: type.name)+ end+ end+ end++ subject_form.rich_text_area(+ name: :description,+ label: label(:description),+ input_width: :large,+ rich_text_options: { showAttachments: false }+ )++ subject_form.check_box(+ name: :is_milestone,+ label: label(:is_milestone)+ )++ subject_form.check_box(+ name: :is_in_roadmap,+ label: label(:is_in_roadmap)+ )++ subject_form.check_box(+ name: :is_default,+ label: label(:is_default)+ )++ subject_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+ end+ end+enddiff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rbindex 934ce2ed2e7..2e9c38b7012 100644--- a/app/helpers/types_helper.rb+++ b/app/helpers/types_helper.rb@@ -34,9 +34,9 @@ module ::TypesHelpertabs = [{name: "settings",- partial: "types/form/settings",path: edit_tab_type_path(id: @type.id, tab: :settings),- label: "types.edit.settings.tab"+ label: "types.edit.settings.tab",+ view_component: WorkPackages::Types::SettingsComponent},{name: "form_configuration",diff --git a/app/views/types/form/_settings.html.erb b/app/views/types/form/_settings.html.erbdeleted file mode 100644index 13ba08e6a56..00000000000--- a/app/views/types/form/_settings.html.erb+++ /dev/null@@ -1,75 +0,0 @@-<%#-- 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.--++#%>--<div class="grid-block">- <div class="grid-content">- <!--[form:type]-->- <div class="form--field -required -wide-label"><%= f.text_field :name, required: true, disabled: @type.is_standard?, container_class: '-middle' %></div>- <div class="form--field -wide-label"><%= f.check_box :is_in_roadmap %></div>- <%= render partial: '/colors/color_autocomplete_field',- locals: {- form: f,- object: @type,- type: 'type',- highlight_text_inline: true,- label: t('types.edit.settings.type_color_text'),- form_field_class: '-wide-label',- container_class: '-slim'- } %>- <div class="form--field -wide-label"><%= f.check_box :is_default %></div>- <div class="form--field -wide-label"><%= f.check_box :is_milestone %></div>-- <% if @type.new_record? && @types.any? %>- <div class="form--field -wide-label">- <%= styled_label_tag 'copy_workflow_from', t(:label_copy_workflow_from) %>- <%= styled_select_tag(:copy_workflow_from,- options_from_collection_for_select(@types, :id, :name, params[:copy_workflow_from]),- include_blank: true,- container_class: '-slim') %>- </div>- <% end %>-- <div class="form--field -wide-label -large-height">- <%= f.text_area :description,- class: 'wiki-edit wiki-toolbar',- container_class: '-xxwide',- with_text_formatting: true %>- </div>-- <!--[eoform:type]-->-- </div>-</div>--<div class="grid-block">- <div class="generic-table--action-buttons">- <%= styled_button_tag t(@type.new_record? ? :button_create : :button_save),- class: '-primary -with-icon icon-checkmark' %>- </div>-</div>diff --git a/app/views/types/new.html.erb b/app/views/types/new.html.erbindex 60cc30a16a0..4b937fc9b35 100644--- a/app/views/types/new.html.erb+++ b/app/views/types/new.html.erb@@ -39,8 +39,4 @@ See COPYRIGHT and LICENSE files for more details.end%>-<%= error_messages_for 'type' %>--<%= form_for controller.type, builder: TabularFormBuilder, lang: current_language do |f| %>- <%= render partial: 'types/form/settings', locals: { f: f } %>-<% end %>+<%= render WorkPackages::Types::SettingsComponent.new(@type) %>diff --git a/lib/primer/open_project/forms/color_select.html.erb b/lib/primer/open_project/forms/color_select.html.erbindex a6678dce90d..fe59102fab5 100644--- a/lib/primer/open_project/forms/color_select.html.erb+++ b/lib/primer/open_project/forms/color_select.html.erb@@ -2,7 +2,7 @@<%= content_tag(:div, **@field_wrap_arguments) do %><%= builder.hidden_field :color_id %><%= angular_component_tag("opce-colors-autocompleter",- class: "colors-autocomplete form--select-container -middle",+ class: "colors-autocomplete form--select-container",data: {colors:,classes: "ng-select--primerized",