diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6
index 11feda8e3f9..6e43dfde817 100644
--- a/app/assets/javascripts/discourse/components/d-editor.js.es6
+++ b/app/assets/javascripts/discourse/components/d-editor.js.es6
@@ -205,6 +205,10 @@ export default Ember.Component.extend({
_readyNow() {
this.set('ready', true);
+
+ if (this.get('autofocus')) {
+ this.$('textarea').focus();
+ }
},
init() {
diff --git a/app/assets/javascripts/discourse/controllers/preferences/username.js.es6 b/app/assets/javascripts/discourse/controllers/preferences/username.js.es6
index c1976a91fbc..a597df810a4 100644
--- a/app/assets/javascripts/discourse/controllers/preferences/username.js.es6
+++ b/app/assets/javascripts/discourse/controllers/preferences/username.js.es6
@@ -39,18 +39,19 @@ export default Ember.Controller.extend({
}.property('saving'),
actions: {
- changeUsername: function() {
- var self = this;
- return bootbox.confirm(I18n.t("user.change_username.confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
+ changeUsername() {
+ if (this.get('saveDisabled')) { return; }
+
+ return bootbox.confirm(I18n.t("user.change_username.confirm"),
+ I18n.t("no_value"),
+ I18n.t("yes_value"), result => {
if (result) {
- self.set('saving', true);
- self.get('content').changeUsername(self.get('newUsername')).then(function() {
- DiscourseURL.redirectTo("/users/" + self.get('newUsername').toLowerCase() + "/preferences");
- }, function() {
- // error
- self.set('error', true);
- self.set('saving', false);
- });
+ this.set('saving', true);
+ this.get('content').changeUsername(this.get('newUsername')).then(() => {
+ DiscourseURL.redirectTo("/users/" + this.get('newUsername').toLowerCase() + "/preferences");
+ })
+ .catch(() => this.set('error', true))
+ .finally(() => this.set('saving', false));
}
});
}
diff --git a/app/assets/javascripts/discourse/templates/preferences-about.hbs b/app/assets/javascripts/discourse/templates/preferences-about.hbs
new file mode 100644
index 00000000000..6613c077327
--- /dev/null
+++ b/app/assets/javascripts/discourse/templates/preferences-about.hbs
@@ -0,0 +1,25 @@
+
diff --git a/app/assets/javascripts/discourse/templates/user/username.hbs b/app/assets/javascripts/discourse/templates/preferences-username.hbs
similarity index 83%
rename from app/assets/javascripts/discourse/templates/user/username.hbs
rename to app/assets/javascripts/discourse/templates/preferences-username.hbs
index afe66232923..ae27149d9d2 100644
--- a/app/assets/javascripts/discourse/templates/user/username.hbs
+++ b/app/assets/javascripts/discourse/templates/preferences-username.hbs
@@ -18,13 +18,15 @@
- {{text-field value=newUsername id="change_username" classNames="input-xxlarge" maxlength=maxLength}}
+ {{text-field value=newUsername id="change_username" classNames="input-xxlarge" maxlength=maxLength autofocus="autofocus" insert-newline="changeUsername"}}
-
+
+
{{#if taken}}
{{i18n 'user.change_username.taken'}}
{{/if}}
- {{ errorMessage }}
+ {{errorMessage}}
+
diff --git a/app/assets/javascripts/discourse/templates/user/about.hbs b/app/assets/javascripts/discourse/templates/user/about.hbs
deleted file mode 100644
index 2d1e162db1e..00000000000
--- a/app/assets/javascripts/discourse/templates/user/about.hbs
+++ /dev/null
@@ -1,24 +0,0 @@
-
diff --git a/app/assets/javascripts/discourse/views/preferences-about.js.es6 b/app/assets/javascripts/discourse/views/preferences-about.js.es6
deleted file mode 100644
index 63d6600ebfe..00000000000
--- a/app/assets/javascripts/discourse/views/preferences-about.js.es6
+++ /dev/null
@@ -1,11 +0,0 @@
-export default Ember.View.extend({
- templateName: 'user/about',
- classNames: ['user-preferences'],
-
- _focusAbout: function() {
- var self = this;
- Ember.run.schedule('afterRender', function() {
- self.$('textarea').focus();
- });
- }.on('didInsertElement')
-});
diff --git a/app/assets/javascripts/discourse/views/preferences-username.js.es6 b/app/assets/javascripts/discourse/views/preferences-username.js.es6
deleted file mode 100644
index 14a36a5e9bb..00000000000
--- a/app/assets/javascripts/discourse/views/preferences-username.js.es6
+++ /dev/null
@@ -1,21 +0,0 @@
-export default Ember.View.extend({
- templateName: 'user/username',
- classNames: ['user-preferences'],
-
- _focusUsername: function() {
- Em.run.schedule('afterRender', function() {
- $('#change_username').focus();
- });
- }.on('didInsertElement'),
-
- keyDown: function(e) {
- if (e.keyCode === 13) {
- if (!this.get('controller').get('saveDisabled')) {
- return this.get('controller').send('changeUsername');
- } else {
- e.preventDefault();
- return false;
- }
- }
- }
-});
diff --git a/test/javascripts/acceptance/preferences-test.js.es6 b/test/javascripts/acceptance/preferences-test.js.es6
index 49ac4947139..feb69443341 100644
--- a/test/javascripts/acceptance/preferences-test.js.es6
+++ b/test/javascripts/acceptance/preferences-test.js.es6
@@ -18,3 +18,18 @@ test("update some fields", () => {
ok(exists('.saved-user'), 'it displays the saved message');
});
});
+
+test("about me", () => {
+ visit("/users/eviltrout/preferences/username");
+ andThen(() => {
+ ok(exists("#change_username"), "it has the input element for the bio");
+ });
+});
+
+test("username", () => {
+ visit("/users/eviltrout/preferences/about-me");
+ andThen(() => {
+ ok(exists(".raw-bio"), "it has the input element for the bio");
+ });
+});
+