Remove some preferences views, add extra tests
This commit is contained in:
parent
a94f06ff78
commit
d98aa48f0d
|
@ -205,6 +205,10 @@ export default Ember.Component.extend({
|
|||
|
||||
_readyNow() {
|
||||
this.set('ready', true);
|
||||
|
||||
if (this.get('autofocus')) {
|
||||
this.$('textarea').focus();
|
||||
}
|
||||
},
|
||||
|
||||
init() {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<div class="user-preferences">
|
||||
<form class="form-horizontal">
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<h3>{{i18n 'user.change_about.title'}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{i18n 'user.bio'}}</label>
|
||||
<div class="controls">
|
||||
{{d-editor value=model.bio_raw class="raw-bio" autofocus="autofocus"}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
{{#d-button action="changeAbout" class="btn btn-primary"}}
|
||||
{{saveButtonText}}
|
||||
{{/d-button}}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
|
@ -18,13 +18,15 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label">{{i18n 'user.username.title'}}</label>
|
||||
<div class="controls">
|
||||
{{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"}}
|
||||
</div>
|
||||
<div class='instructions'>
|
||||
<div class='instructions controls'>
|
||||
<p>
|
||||
{{#if taken}}
|
||||
{{i18n 'user.change_username.taken'}}
|
||||
{{/if}}
|
||||
<span>{{ errorMessage }}</span>
|
||||
<span>{{errorMessage}}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<form class="form-horizontal">
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<h3>{{i18n 'user.change_about.title'}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{i18n 'user.bio'}}</label>
|
||||
<div class="controls">
|
||||
{{d-editor value=model.bio_raw}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
{{#d-button action="changeAbout" class="btn btn-primary"}}
|
||||
{{saveButtonText}}
|
||||
{{/d-button}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
|
@ -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')
|
||||
});
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue