UX: Focus on usernames if creating a PM from your user page
This commit is contained in:
parent
af266acac1
commit
c28dd826fe
|
@ -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';
|
import InputValidation from 'discourse/models/input-validation';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNames: ['title-input'],
|
classNames: ['title-input'],
|
||||||
|
|
||||||
@on('didInsertElement')
|
didInsertElement() {
|
||||||
_focusOnTitle() {
|
this._super();
|
||||||
if (!this.capabilities.isIOS) {
|
if (this.get('focusTarget') === 'title') {
|
||||||
this.$('input').putCursorAtEnd();
|
this.$('input').putCursorAtEnd();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,14 @@ export default Ember.Component.extend({
|
||||||
shouldHide: false,
|
shouldHide: false,
|
||||||
defaultUsernameCount: 0,
|
defaultUsernameCount: 0,
|
||||||
|
|
||||||
|
didInsertElement() {
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
if (this.get('focusTarget') === 'usernames') {
|
||||||
|
this.$('input').putCursorAtEnd();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
@observes('usernames')
|
@observes('usernames')
|
||||||
_checkWidth() {
|
_checkWidth() {
|
||||||
let width = 0;
|
let width = 0;
|
||||||
|
|
|
@ -64,6 +64,21 @@ export default Ember.Controller.extend({
|
||||||
topic: null,
|
topic: null,
|
||||||
linkLookup: 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({
|
showToolbar: Em.computed({
|
||||||
get(){
|
get(){
|
||||||
const keyValueStore = this.container.lookup('key-value-store:main');
|
const keyValueStore = this.container.lookup('key-value-store:main');
|
||||||
|
|
|
@ -49,9 +49,9 @@
|
||||||
<div class='form-element clearfix'>
|
<div class='form-element clearfix'>
|
||||||
{{#if model.creatingPrivateMessage}}
|
{{#if model.creatingPrivateMessage}}
|
||||||
{{composer-user-selector topicId=topicModel.id
|
{{composer-user-selector topicId=topicModel.id
|
||||||
usernames=model.targetUsernames
|
usernames=model.targetUsernames
|
||||||
hasGroups=model.hasTargetGroups
|
hasGroups=model.hasTargetGroups
|
||||||
}}
|
focusTarget=focusTarget}}
|
||||||
{{#if showWarning}}
|
{{#if showWarning}}
|
||||||
<div class='add-warning'>
|
<div class='add-warning'>
|
||||||
<label>
|
<label>
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{composer-title composer=model lastValidatedAt=lastValidatedAt}}
|
{{composer-title composer=model lastValidatedAt=lastValidatedAt focusTarget=focusTarget}}
|
||||||
|
|
||||||
{{#if model.showCategoryChooser}}
|
{{#if model.showCategoryChooser}}
|
||||||
<div class="category-input">
|
<div class="category-input">
|
||||||
|
|
Loading…
Reference in New Issue