UX: Wiggle invalid form elements. Don't allow a site title of Discourse

This commit is contained in:
Robin Ward
2016-09-15 16:01:44 -04:00
parent 2ff6295f71
commit 74ed2e82ac
4 changed files with 33 additions and 2 deletions

View File

@@ -30,7 +30,11 @@ class Wizard
step.add_field(id: 'site_description', type: 'text', required: true, value: SiteSetting.site_description)
step.on_update do |updater|
updater.apply_settings(:title, :site_description)
updater.ensure_changed(:title)
if updater.errors.blank?
updater.apply_settings(:title, :site_description)
end
end
end

View File

@@ -39,6 +39,10 @@ class Wizard
errors.add(id, e.message)
end
def ensure_changed(id)
errors.add(id, '') if @fields[id] == SiteSetting.defaults[id]
end
def apply_settings(*ids)
ids.each {|id| apply_setting(id)}
end