FEATURE: if there is only one category, don't show the category picker
This commit is contained in:
parent
d0199bb717
commit
e0562894a8
|
@ -67,6 +67,12 @@ const Composer = RestModel.extend({
|
|||
creatingPrivateMessage: Em.computed.equal('action', PRIVATE_MESSAGE),
|
||||
notCreatingPrivateMessage: Em.computed.not('creatingPrivateMessage'),
|
||||
|
||||
showCategoryChooser: function(){
|
||||
const manyCategories = Discourse.Category.list().length > 1;
|
||||
const hasOptions = this.get('archetype.hasOptions');
|
||||
return !this.get('privateMessage') && (hasOptions || manyCategories);
|
||||
}.property('privateMessage'),
|
||||
|
||||
privateMessage: function(){
|
||||
return this.get('creatingPrivateMessage') || this.get('topic.archetype') === 'private_message';
|
||||
}.property('creatingPrivateMessage', 'topic'),
|
||||
|
@ -434,6 +440,13 @@ const Composer = RestModel.extend({
|
|||
// We set the category id separately for topic templates on opening of composer
|
||||
this.set('categoryId', opts.categoryId || this.get('topic.category.id'));
|
||||
|
||||
if (!this.get('categoryId') && this.get('creatingTopic')) {
|
||||
const categories = Discourse.Category.list();
|
||||
if (categories.length === 1) {
|
||||
this.set('categoryId', categories[0].get('id'));
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.postId) {
|
||||
this.set('loading', true);
|
||||
this.store.find('post', opts.postId).then(function(post) {
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
{{popup-input-tip validation=view.titleValidation shownAt=view.showTitleTip}}
|
||||
</div>
|
||||
|
||||
{{#unless model.privateMessage}}
|
||||
{{#if model.showCategoryChooser}}
|
||||
<div class="category-input">
|
||||
{{category-chooser valueAttribute="id" value=model.categoryId scopedCategoryId=scopedCategoryId tabindex="3"}}
|
||||
{{popup-input-tip validation=view.categoryValidation shownAt=view.showCategoryTip}}
|
||||
|
@ -57,7 +57,7 @@
|
|||
<button class='btn' {{action "showOptions"}}>{{i18n 'topic.options'}}</button>
|
||||
{{/if}}
|
||||
{{render "additional-composer-buttons" model}}
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue