mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 15:03:38 +08:00
Better username change validation messages
This commit is contained in:
parent
d1a04fa06a
commit
d73baa23dd
|
@ -1,18 +1,18 @@
|
|||
Discourse.PreferencesUsernameController = Ember.ObjectController.extend Discourse.Presence,
|
||||
|
||||
taken: false
|
||||
invalid: false
|
||||
saving: false
|
||||
error: false
|
||||
errorMessage: null
|
||||
|
||||
saveDisabled: (->
|
||||
return true if @get('saving')
|
||||
return true if @blank('newUsername')
|
||||
return true if @get('taken')
|
||||
return true if @get('invalid')
|
||||
return true if @get('unchanged')
|
||||
return true if @get('errorMessage')
|
||||
false
|
||||
).property('newUsername', 'taken', 'invalid', 'unchanged', 'saving')
|
||||
).property('newUsername', 'taken', 'errorMessage', 'unchanged', 'saving')
|
||||
|
||||
unchanged: (->
|
||||
@get('newUsername') == @get('content.username')
|
||||
|
@ -20,12 +20,12 @@ Discourse.PreferencesUsernameController = Ember.ObjectController.extend Discours
|
|||
|
||||
checkTaken: (->
|
||||
@set('taken', false)
|
||||
@set('invalid', false)
|
||||
@set('errorMessage', null)
|
||||
return if @blank('newUsername')
|
||||
return if @get('unchanged')
|
||||
Discourse.User.checkUsername(@get('newUsername')).then (result) =>
|
||||
if result.errors
|
||||
@set('invalid', true)
|
||||
@set('errorMessage', result.errors.join(' '))
|
||||
else if result.available == false
|
||||
@set('taken', true)
|
||||
).observes('newUsername')
|
||||
|
|
|
@ -23,9 +23,7 @@
|
|||
{{#if controller.taken}}
|
||||
{{i18n user.change_username.taken}}
|
||||
{{/if}}
|
||||
{{#if controller.invalid}}
|
||||
{{i18n user.change_username.invalid}}
|
||||
{{/if}}
|
||||
<span>{{ errorMessage }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user