UX: hide support categories from selectors

This commit is contained in:
Régis Hanol 2015-11-24 19:29:48 +01:00
parent 9ef8397164
commit 578e15224b
6 changed files with 19 additions and 9 deletions

View File

@ -21,6 +21,7 @@ export default ComboboxView.extend({
return categories.filter(c => {
if (scopedCategoryId && c.get('id') !== scopedCategoryId && c.get('parent_category_id') !== scopedCategoryId) { return false; }
if (c.get('isUncategorizedCategory')) { return false; }
if (c.get('is_support')) { return false; }
return c.get('permission') === Discourse.PermissionType.FULL;
});
},

View File

@ -78,6 +78,13 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
this.set('selectedReplies', []);
}.on('init'),
@computed("model.isPrivateMessage", "model.category_id")
showCategoryChooser(isPrivateMessage, categoryId) {
const category = Discourse.Category.findById(categoryId);
const isSupport = category && category.get("is_support");
return !isPrivateMessage && !isSupport;
},
actions: {
showTopicAdminMenu() {
this.set('adminMenuVisible', true);

View File

@ -67,11 +67,13 @@ const Composer = RestModel.extend({
creatingPrivateMessage: Em.computed.equal('action', PRIVATE_MESSAGE),
notCreatingPrivateMessage: Em.computed.not('creatingPrivateMessage'),
showCategoryChooser: function(){
@computed("privateMessage", "archetype.hasOptions", "categoryId")
showCategoryChooser(isPrivateMessage, hasOptions, categoryId) {
const manyCategories = Discourse.Category.list().length > 1;
const hasOptions = this.get('archetype.hasOptions');
return !this.get('privateMessage') && (hasOptions || manyCategories);
}.property('privateMessage'),
const category = Discourse.Category.findById(categoryId);
const isSupport = category && category.get("is_support");
return !isPrivateMessage && !isSupport && (hasOptions || manyCategories);
},
privateMessage: function(){
return this.get('creatingPrivateMessage') || this.get('topic.archetype') === 'private_message';

View File

@ -15,9 +15,9 @@
{{#if editingTopic}}
{{#if model.isPrivateMessage}}
<span class="private-message-glyph">{{fa-icon "envelope"}}</span>
{{autofocus-text-field id="edit-title" value=buffered.title maxlength=siteSettings.max_topic_title_length}}
{{else}}
{{autofocus-text-field id="edit-title" value=buffered.title maxlength=siteSettings.max_topic_title_length}}
{{/if}}
{{autofocus-text-field id="edit-title" value=buffered.title maxlength=siteSettings.max_topic_title_length}}
{{#if showCategoryChooser}}
<br>
{{category-chooser valueAttribute="id" value=buffered.category_id source=buffered.category_id}}
{{/if}}

View File

@ -19,7 +19,8 @@ class BasicCategorySerializer < ApplicationSerializer
:background_url,
:can_edit,
:topic_template,
:has_children
:has_children,
:is_support
def include_parent_category_id?
parent_category_id

View File

@ -8,7 +8,6 @@ class CategorySerializer < BasicCategorySerializer
:position,
:email_in,
:email_in_allow_strangers,
:is_support,
:suppress_from_homepage,
:can_delete,
:cannot_delete_reason,