UX: Minor cosmetic fixes to the wizard (#11172)

- Does not force users to type a description or a welcome topic
- Adds * marker for required text fields (site title and email)
This commit is contained in:
Penar Musaraj 2020-11-09 15:14:57 -05:00 committed by GitHub
parent 0c2956dd2e
commit 57bd85af31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 5 deletions

View File

@ -1,5 +1,11 @@
<label for={{field.id}}>
<span class="label-value">{{field.label}}</span>
<span class="label-value">
{{field.label}}
{{#if field.required}}
<span class="field-required">*</span>
{{/if}}
</span>
{{#if field.description}}
<div class="field-description">{{html-safe field.description}}</div>
@ -13,3 +19,7 @@
{{#if field.errorDescription}}
<div class="field-error-description">{{html-safe field.errorDescription}}</div>
{{/if}}
{{#if field.extra_description}}
<div class="field-extra-description">{{html-safe field.extra_description}}</div>
{{/if}}

View File

@ -1189,6 +1189,22 @@ body.wizard {
margin-top: 0.5em;
}
.field-extra-description {
margin-top: 0.5em;
color: var(--primary-high);
}
.field-required {
display: none;
}
&.text-field {
.field-required {
display: inline;
color: var(--danger);
}
}
margin-bottom: 2em;
}
}

View File

@ -2,7 +2,7 @@
class WizardFieldSerializer < ApplicationSerializer
attributes :id, :type, :required, :value, :label, :placeholder, :description
attributes :id, :type, :required, :value, :label, :placeholder, :description, :extra_description
has_many :choices, serializer: WizardFieldChoiceSerializer, embed: :objects
def id
@ -60,4 +60,12 @@ class WizardFieldSerializer < ApplicationSerializer
description.present?
end
def extra_description
translate("extra_description", base_path: Discourse.base_path)
end
def include_extra_description?
extra_description.present?
end
end

View File

@ -4663,6 +4663,7 @@ en:
</ul>
<p>Your welcome topic is the first thing new arrivals will read. Think of it as your <b>one paragraph</b> 'elevator pitch' or 'mission statement'. </p>"
one_paragraph: "Please restrict your welcome message to one paragraph."
extra_description: "If you are not sure, you can skip this step and write your welcome topic later."
privacy:
title: "Access"

View File

@ -39,7 +39,7 @@ class Wizard
@wizard.append_step('forum-title') do |step|
step.add_field(id: 'title', type: 'text', required: true, value: SiteSetting.title)
step.add_field(id: 'site_description', type: 'text', required: true, value: SiteSetting.site_description)
step.add_field(id: 'site_description', type: 'text', required: false, value: SiteSetting.site_description)
step.add_field(id: 'short_site_description', type: 'text', required: false, value: SiteSetting.short_site_description)
step.on_update do |updater|
@ -58,8 +58,7 @@ class Wizard
step.disabled = true
step.description_vars = { topic_title: I18n.t("discourse_welcome_topic.title") }
else
step.add_field(id: 'welcome', type: 'textarea', required: true, value: introduction.get_summary)
step.add_field(id: 'welcome', type: 'textarea', required: false, value: introduction.get_summary)
step.on_update do |updater|
value = updater.fields[:welcome].strip