Update form and only show email text area when checked

This commit is contained in:
Mir Bhatia
2025-11-17 19:16:40 +01:00
parent c2857596dc
commit ee42e49ae6
8 changed files with 59 additions and 20 deletions
@@ -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))
@@ -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
@@ -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"),
+1
View File
@@ -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
+9 -5
View File
@@ -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."
@@ -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
@@ -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 %>
@@ -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