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
Fixes from PR review
Christophe Bliarda3a221fdaa85
diff --git a/app/components/op_primer/form_helpers.rb b/app/components/op_primer/form_helpers.rbindex 9c6d465bfd2..fb742d2a5d4 100644--- a/app/components/op_primer/form_helpers.rb+++ b/app/components/op_primer/form_helpers.rb@@ -51,7 +51,7 @@ module OpPrimer# end# end#- # @param f [Object] The form object to be used for the form.+ # @param form_builder [Object] The form builder object to be used for the form.# @param blk [Proc] A block that defines the form structure.def render_inline_form(form_builder, &blk)form_class = Class.new(ApplicationForm) do@@ -85,7 +85,7 @@ module OpPrimer# end# end#- # @param f [Object] The form object to be used for the form.+ # @param form_builder [Object] The form builder object to be used for the form.# @param blk [Proc] A block that defines the form structure.def render_inline_settings_form(form_builder, &blk)form_class = Class.new(ApplicationForm) dodiff --git a/lookbook/docs/patterns/14-forms.md.erb b/lookbook/docs/patterns/14-forms.md.erbindex 18199a8afac..1c1598b39cb 100644--- a/lookbook/docs/patterns/14-forms.md.erb+++ b/lookbook/docs/patterns/14-forms.md.erb@@ -60,6 +60,36 @@ This helper allows to render an anymous form instance, avoiding the need tocreate a dedicated form class. This can be useful for simple forms or when youdon't want to pollute the form class namespace.+The above example which was needing a dedicated `TextFieldAndCheckboxForm` form+class can be rewritten like this:++```erb+<%%=+primer_form_with(url: "/foo") do |f|+ render_inline_form(f) do |my_form|+ my_form.text_field(+ name: :ultimate_answer,+ label: "Ultimate answer",+ required: true,+ caption: "The answer to life, the universe, and everything"+ )++ my_form.check_box(+ name: :enable_ipd,+ label: "Enable the Infinite Improbability Drive",+ caption: "Cross interstellar distances in a mere nothingth of a second."+ )+ end+end+%>+```++### `FormObject#html_content` to mix form fields and html content++This helper allows to render non-form content in a form. For instance it can be+used to render a description box inside a form, an image, or whatever makes+sense for the form being built.+```rubyclass TextFieldWithWarningForm < ApplicationFormattr_reader :warning@@ -71,8 +101,8 @@ class TextFieldWithWarningForm < ApplicationFormform do |my_form|my_form.text_field(- name: :answer,- label: "answer",+ name: :full_name,+ label: "Full name",required: true)@@ -87,21 +117,6 @@ class TextFieldWithWarningForm < ApplicationFormend```-### `FormObject#html_content` to mix form fields and html content--This helper allows to render non-form content in a form. For instance it can be-used to render a description box inside a form, an image, or whatever makes-sense for the form being built.--```erb-<%%= primer_form_with(url: "/foo") do |f| %>- <%%= render(TextFieldAndCheckboxForm.new(f)) %>- <%%= f.html_content do %>- <%%= render(MessageComponent.new(icon: :info, message: "This will be fine!")) %>- <%% end %>-<%% end %>-```-## Forms for administration pagesAdministration pages forms are used to change the values of `Settings`. The name@@ -166,8 +181,8 @@ or configuration files), the field name has to be translated and the value mustbe read from `Settings`. Entering all this information manually is tedious anderror prone.-In this case, `settings_form` can be usedinstead of `form` to get a form-instance with knowledge about to render fields for settings.+In this case, `settings_form` can be used instead of `form` to get a form+instance with knowledge about how render fields for settings.The above example then becomes:@@ -200,7 +215,7 @@ endIt is easier to write and read.Under the hood, the form object is decorated with `SettingsFormDecorator`.-That's where all the helper methods are defined. There are not much for now, but+That's where all the helper methods are defined. There aren't many for now, butthis is intended to grow to support more advanced form features foradministration pages.diff --git a/spec/controllers/admin/settings/aggregation_settings_controller_spec.rb b/spec/controllers/admin/settings/aggregation_settings_controller_spec.rbindex 9495179af8a..93ed0c63a78 100644--- a/spec/controllers/admin/settings/aggregation_settings_controller_spec.rb+++ b/spec/controllers/admin/settings/aggregation_settings_controller_spec.rb@@ -34,7 +34,7 @@ require "spec_helper"RSpec.describe Admin::Settings::AggregationSettingsController doshared_let(:user) { create(:admin) }- shared_current_user { user }+ current_user { user }include_examples "GET #show requires admin permission and renders template", path: "aggregation_settings"end