UX: Focus on usernames if creating a PM from your user page

This commit is contained in:
Robin Ward 2016-07-22 13:56:17 -04:00
parent af266acac1
commit c28dd826fe
4 changed files with 31 additions and 8 deletions

View File

@ -1,12 +1,12 @@
import { default as computed, on } from 'ember-addons/ember-computed-decorators';
import computed from 'ember-addons/ember-computed-decorators';
import InputValidation from 'discourse/models/input-validation';
export default Ember.Component.extend({
classNames: ['title-input'],
@on('didInsertElement')
_focusOnTitle() {
if (!this.capabilities.isIOS) {
didInsertElement() {
this._super();
if (this.get('focusTarget') === 'title') {
this.$('input').putCursorAtEnd();
}
},

View File

@ -5,6 +5,14 @@ export default Ember.Component.extend({
shouldHide: false,
defaultUsernameCount: 0,
didInsertElement() {
this._super();
if (this.get('focusTarget') === 'usernames') {
this.$('input').putCursorAtEnd();
}
},
@observes('usernames')
_checkWidth() {
let width = 0;

View File

@ -64,6 +64,21 @@ export default Ember.Controller.extend({
topic: null,
linkLookup: null,
@computed('model.replyingToTopic', 'model.creatingPrivateMessage', 'model.targetUsernames')
focusTarget(replyingToTopic, creatingPM, usernames) {
if (this.capabilities.isIOS) { return "none"; }
if (creatingPM && usernames === this.currentUser.get('username')) {
return 'usernames';
}
if (replyingToTopic) {
return 'reply';
}
return 'title';
},
showToolbar: Em.computed({
get(){
const keyValueStore = this.container.lookup('key-value-store:main');

View File

@ -51,7 +51,7 @@
{{composer-user-selector topicId=topicModel.id
usernames=model.targetUsernames
hasGroups=model.hasTargetGroups
}}
focusTarget=focusTarget}}
{{#if showWarning}}
<div class='add-warning'>
<label>
@ -62,7 +62,7 @@
{{/if}}
{{/if}}
{{composer-title composer=model lastValidatedAt=lastValidatedAt}}
{{composer-title composer=model lastValidatedAt=lastValidatedAt focusTarget=focusTarget}}
{{#if model.showCategoryChooser}}
<div class="category-input">