mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 06:43:37 +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,
|
Discourse.PreferencesUsernameController = Ember.ObjectController.extend Discourse.Presence,
|
||||||
|
|
||||||
taken: false
|
taken: false
|
||||||
invalid: false
|
|
||||||
saving: false
|
saving: false
|
||||||
error: false
|
error: false
|
||||||
|
errorMessage: null
|
||||||
|
|
||||||
saveDisabled: (->
|
saveDisabled: (->
|
||||||
return true if @get('saving')
|
return true if @get('saving')
|
||||||
return true if @blank('newUsername')
|
return true if @blank('newUsername')
|
||||||
return true if @get('taken')
|
return true if @get('taken')
|
||||||
return true if @get('invalid')
|
|
||||||
return true if @get('unchanged')
|
return true if @get('unchanged')
|
||||||
|
return true if @get('errorMessage')
|
||||||
false
|
false
|
||||||
).property('newUsername', 'taken', 'invalid', 'unchanged', 'saving')
|
).property('newUsername', 'taken', 'errorMessage', 'unchanged', 'saving')
|
||||||
|
|
||||||
unchanged: (->
|
unchanged: (->
|
||||||
@get('newUsername') == @get('content.username')
|
@get('newUsername') == @get('content.username')
|
||||||
|
@ -20,12 +20,12 @@ Discourse.PreferencesUsernameController = Ember.ObjectController.extend Discours
|
||||||
|
|
||||||
checkTaken: (->
|
checkTaken: (->
|
||||||
@set('taken', false)
|
@set('taken', false)
|
||||||
@set('invalid', false)
|
@set('errorMessage', null)
|
||||||
return if @blank('newUsername')
|
return if @blank('newUsername')
|
||||||
return if @get('unchanged')
|
return if @get('unchanged')
|
||||||
Discourse.User.checkUsername(@get('newUsername')).then (result) =>
|
Discourse.User.checkUsername(@get('newUsername')).then (result) =>
|
||||||
if result.errors
|
if result.errors
|
||||||
@set('invalid', true)
|
@set('errorMessage', result.errors.join(' '))
|
||||||
else if result.available == false
|
else if result.available == false
|
||||||
@set('taken', true)
|
@set('taken', true)
|
||||||
).observes('newUsername')
|
).observes('newUsername')
|
||||||
|
|
|
@ -23,9 +23,7 @@
|
||||||
{{#if controller.taken}}
|
{{#if controller.taken}}
|
||||||
{{i18n user.change_username.taken}}
|
{{i18n user.change_username.taken}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if controller.invalid}}
|
<span>{{ errorMessage }}</span>
|
||||||
{{i18n user.change_username.invalid}}
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user