mirror of
https://github.com/discourse/discourse.git
synced 2025-03-30 13:55:39 +08:00
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),
|
creatingPrivateMessage: Em.computed.equal('action', PRIVATE_MESSAGE),
|
||||||
notCreatingPrivateMessage: Em.computed.not('creatingPrivateMessage'),
|
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(){
|
privateMessage: function(){
|
||||||
return this.get('creatingPrivateMessage') || this.get('topic.archetype') === 'private_message';
|
return this.get('creatingPrivateMessage') || this.get('topic.archetype') === 'private_message';
|
||||||
}.property('creatingPrivateMessage', 'topic'),
|
}.property('creatingPrivateMessage', 'topic'),
|
||||||
@ -434,6 +440,13 @@ const Composer = RestModel.extend({
|
|||||||
// We set the category id separately for topic templates on opening of composer
|
// We set the category id separately for topic templates on opening of composer
|
||||||
this.set('categoryId', opts.categoryId || this.get('topic.category.id'));
|
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) {
|
if (opts.postId) {
|
||||||
this.set('loading', true);
|
this.set('loading', true);
|
||||||
this.store.find('post', opts.postId).then(function(post) {
|
this.store.find('post', opts.postId).then(function(post) {
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
{{popup-input-tip validation=view.titleValidation shownAt=view.showTitleTip}}
|
{{popup-input-tip validation=view.titleValidation shownAt=view.showTitleTip}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#unless model.privateMessage}}
|
{{#if model.showCategoryChooser}}
|
||||||
<div class="category-input">
|
<div class="category-input">
|
||||||
{{category-chooser valueAttribute="id" value=model.categoryId scopedCategoryId=scopedCategoryId tabindex="3"}}
|
{{category-chooser valueAttribute="id" value=model.categoryId scopedCategoryId=scopedCategoryId tabindex="3"}}
|
||||||
{{popup-input-tip validation=view.categoryValidation shownAt=view.showCategoryTip}}
|
{{popup-input-tip validation=view.categoryValidation shownAt=view.showCategoryTip}}
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<button class='btn' {{action "showOptions"}}>{{i18n 'topic.options'}}</button>
|
<button class='btn' {{action "showOptions"}}>{{i18n 'topic.options'}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{render "additional-composer-buttons" model}}
|
{{render "additional-composer-buttons" model}}
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user