diff --git a/app/components/projects/settings/creation_wizard/submission_form_component.html.erb b/app/components/projects/settings/creation_wizard/submission_form_component.html.erb index 91dc68d9c4d..480e2ce4026 100644 --- a/app/components/projects/settings/creation_wizard/submission_form_component.html.erb +++ b/app/components/projects/settings/creation_wizard/submission_form_component.html.erb @@ -39,7 +39,8 @@ See COPYRIGHT and LICENSE files for more details. url: update_submission_settings_project_settings_creation_wizard_path(@project), method: :post, data: { - refresh_on_form_changes_target: "form" + refresh_on_form_changes_target: "form", + controller: "show-when-checked" } ) do |f| render(Projects::Settings::CreationWizard::SubmissionForm.new(f)) diff --git a/app/controllers/projects/settings/creation_wizard_controller.rb b/app/controllers/projects/settings/creation_wizard_controller.rb index 696ef0de059..260330edf90 100644 --- a/app/controllers/projects/settings/creation_wizard_controller.rb +++ b/app/controllers/projects/settings/creation_wizard_controller.rb @@ -124,7 +124,8 @@ class Projects::Settings::CreationWizardController < Projects::SettingsControlle submission_status_when_submitted_id submission_send_confirmation_email submission_notification_text - submission_assignee_id] + submission_assignee_id + submission_work_package_comment] ) end end diff --git a/app/forms/projects/settings/creation_wizard/submission_form.rb b/app/forms/projects/settings/creation_wizard/submission_form.rb index 6a850033860..8502bbe54c6 100644 --- a/app/forms/projects/settings/creation_wizard/submission_form.rb +++ b/app/forms/projects/settings/creation_wizard/submission_form.rb @@ -74,12 +74,6 @@ module Projects end end - f.check_box( - name: :submission_send_confirmation_email, - label: I18n.t("settings.project_initiation_request.submission.send_confirmation_email"), - checked: model.submission_send_confirmation_email - ) - f.autocompleter( name: :submission_assignee_id, label: I18n.t("settings.project_initiation_request.submission.assignee"), @@ -101,15 +95,48 @@ module Projects end f.rich_text_area( - name: :submission_notification_text, - label: I18n.t("settings.project_initiation_request.submission.notification_text"), + name: :submission_work_package_comment, + label: I18n.t("settings.project_initiation_request.submission.work_package_comment"), + caption: I18n.t("settings.project_initiation_request.submission.work_package_comment_caption"), required: true, + value: model.submission_work_package_comment.presence || I18n.t( + "settings.project_initiation_request.submission.work_package_comment_default", project_name: model.name + ), rich_text_options: { showAttachments: false, editorType: "constrained" } ) + f.check_box( + name: :submission_send_confirmation_email, + label: I18n.t("settings.project_initiation_request.submission.send_confirmation_email"), + checked: model.submission_send_confirmation_email.presence, + data: { + "show-when-checked-target": "cause", + target_name: "send_confirmation_email" + } + ) + + f.rich_text_area( + name: :submission_notification_text, + label: I18n.t("settings.project_initiation_request.submission.confirmation_email_text"), + required: true, + value: model.submission_notification_text.presence || I18n.t( + "settings.project_initiation_request.submission.confirmation_email_default", project_name: model.name + ), + rich_text_options: { + showAttachments: false, + editorType: "constrained" + }, + wrapper_classes: model.submission_send_confirmation_email.blank? ? "d-none" : "", + wrapper_data_attributes: { + "show-when-checked-target": "effect", + target_name: "send_confirmation_email", + "visibility-class": "d-none" + } + ) + f.submit( name: :submit, label: I18n.t("button_save"), diff --git a/app/models/projects/creation_wizard.rb b/app/models/projects/creation_wizard.rb index 25dce19dc22..3199fac3bfa 100644 --- a/app/models/projects/creation_wizard.rb +++ b/app/models/projects/creation_wizard.rb @@ -39,5 +39,6 @@ module Projects::CreationWizard store_attribute :settings, :submission_send_confirmation_email, :boolean store_attribute :settings, :submission_assignee_id, :integer store_attribute :settings, :submission_notification_text, :string + store_attribute :settings, :submission_work_package_comment, :string end end diff --git a/config/locales/en.yml b/config/locales/en.yml index ebd3f47aa01..8342782dd08 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4621,13 +4621,17 @@ en: checkbox_message: "I understand that this action is not reversible" submission: work_package_type: "Work package type" - work_package_type_caption: "The work package type that should be used to store the completed artefact" + work_package_type_caption: "The work package type that should be used to store the completed artefact." status_when_submitted: "Status when submitted" - status_when_submitted_caption: "The status the generated work package will transition to once the request is submitted" + status_when_submitted_caption: "The status the generated work package will transition to once the request is submitted." send_confirmation_email: "Send confirmation email to the user that submitted the project initiation request" - assignee: "Assignee" - assignee_caption: "This person or group will be notified when the project initiation request is submitted or updated" - notification_text: "Notification text" + assignee: "Assignee when submitted" + assignee_caption: "The person or group this project initiation request will be assigned to." + confirmation_email_text: "Confirmation email text" + confirmation_email_default: "Hello,\n\nYou submitted a project initiation request for **%{project_name}**. It is now awaiting review.\nClick the link below to access the work package with your request." + work_package_comment: "Work package comment" + work_package_comment_caption: "The assignee selected above will automatically be @mentioned in the comment." + work_package_comment_default: "A project initiation request for **%{project_name}** was submitted and is awaiting review." project_phase_definitions: heading: "Project life cycle" heading_description: "Project life cycle define the project phases that can be used for your project planning and will appear in the overview page of each project. These attributes can be enabled or disabled but not re-ordered at a project level." diff --git a/lib/primer/open_project/forms/dsl/rich_text_area_input.rb b/lib/primer/open_project/forms/dsl/rich_text_area_input.rb index 4ae4facfa02..5052e563a69 100644 --- a/lib/primer/open_project/forms/dsl/rich_text_area_input.rb +++ b/lib/primer/open_project/forms/dsl/rich_text_area_input.rb @@ -5,19 +5,22 @@ module Primer module Forms module Dsl class RichTextAreaInput < Primer::Forms::Dsl::Input - attr_reader :name, :label, :classes + attr_reader :name, :label, :classes, :wrapper_data_attributes, :wrapper_classes - def initialize(name:, label:, rich_text_options:, **system_arguments) + def initialize(name:, label:, rich_text_options:, wrapper_data_attributes: {}, wrapper_classes: nil, **system_arguments) @name = name @label = label @rich_text_options = rich_text_options + @wrapper_data_attributes = wrapper_data_attributes + @wrapper_classes = wrapper_classes @classes = system_arguments[:classes] super(**system_arguments) end def to_component - RichTextArea.new(input: self, rich_text_options: @rich_text_options) + RichTextArea.new(input: self, rich_text_options: @rich_text_options, + wrapper_data_attributes: @wrapper_data_attributes, wrapper_classes: @wrapper_classes) end def type diff --git a/lib/primer/open_project/forms/rich_text_area.html.erb b/lib/primer/open_project/forms/rich_text_area.html.erb index a25af691581..d0529c2f9cb 100644 --- a/lib/primer/open_project/forms/rich_text_area.html.erb +++ b/lib/primer/open_project/forms/rich_text_area.html.erb @@ -1,4 +1,4 @@ -<%= render(FormControl.new(input: @input)) do %> +<%= render(FormControl.new(input: @input, class: @wrapper_classes, data: @wrapper_data_attributes)) do %> <%= content_tag(:div, hidden: true) do %> <%= builder.text_area(@input.name, **@input.input_arguments) %> <% end %> diff --git a/lib/primer/open_project/forms/rich_text_area.rb b/lib/primer/open_project/forms/rich_text_area.rb index 123a50d9e20..22da7c43200 100644 --- a/lib/primer/open_project/forms/rich_text_area.rb +++ b/lib/primer/open_project/forms/rich_text_area.rb @@ -9,9 +9,11 @@ module Primer delegate :builder, :form, to: :@input - def initialize(input:, rich_text_options:) + def initialize(input:, rich_text_options:, wrapper_data_attributes: {}, wrapper_classes: nil) super() @input = input + @wrapper_data_attributes = wrapper_data_attributes + @wrapper_classes = wrapper_classes @rich_text_data = rich_text_options.delete(:data) { {} } @rich_text_data[:"test-selector"] ||= "augmented-text-area-#{@input.name}" @rich_text_options = rich_text_options