mirror of
https://github.com/discourse/discourse.git
synced 2025-03-25 05:07:53 +08:00
FIX: Show uncategorized with badge/description in the category chooser
This commit is contained in:
parent
c9262a8390
commit
30b102aa98
app/assets/javascripts/discourse
@ -188,6 +188,8 @@ Discourse.Category = Discourse.Model.extend({
|
|||||||
}.property('id')
|
}.property('id')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var _uncategorized;
|
||||||
|
|
||||||
Discourse.Category.reopenClass({
|
Discourse.Category.reopenClass({
|
||||||
|
|
||||||
NotificationLevel: {
|
NotificationLevel: {
|
||||||
@ -197,6 +199,11 @@ Discourse.Category.reopenClass({
|
|||||||
MUTED: 0
|
MUTED: 0
|
||||||
},
|
},
|
||||||
|
|
||||||
|
findUncategorized: function() {
|
||||||
|
_uncategorized = _uncategorized || Discourse.Category.list().findBy('id', Discourse.Site.currentProp('uncategorized_category_id'));
|
||||||
|
return _uncategorized;
|
||||||
|
},
|
||||||
|
|
||||||
slugFor: function(category) {
|
slugFor: function(category) {
|
||||||
if (!category) return "";
|
if (!category) return "";
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ export default ComboboxView.extend({
|
|||||||
if (this.get('rootNone')) {
|
if (this.get('rootNone')) {
|
||||||
return "category.none";
|
return "category.none";
|
||||||
} else {
|
} else {
|
||||||
return Discourse.Category.list().findBy('id', Discourse.Site.currentProp('uncategorized_category_id'));
|
return Discourse.Category.findUncategorized();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return 'category.choose';
|
return 'category.choose';
|
||||||
@ -42,9 +42,20 @@ export default ComboboxView.extend({
|
|||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
template: function(item) {
|
template: function(item) {
|
||||||
var category = Discourse.Category.findById(parseInt(item.id,10));
|
|
||||||
if (!category) return item.text;
|
|
||||||
|
|
||||||
|
var category;
|
||||||
|
|
||||||
|
// If we have no id, but text with the uncategorized name, we can use that badge.
|
||||||
|
if (Em.empty(item.id)) {
|
||||||
|
var uncat = Discourse.Category.findUncategorized();
|
||||||
|
if (uncat && uncat.get('name') === item.text) {
|
||||||
|
category = uncat;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
category = Discourse.Category.findById(parseInt(item.id,10));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!category) return item.text;
|
||||||
var result = badgeHtml(category, {showParent: false, link: false, allowUncategorized: true}),
|
var result = badgeHtml(category, {showParent: false, link: false, allowUncategorized: true}),
|
||||||
parentCategoryId = category.get('parent_category_id');
|
parentCategoryId = category.get('parent_category_id');
|
||||||
if (parentCategoryId) {
|
if (parentCategoryId) {
|
||||||
@ -56,7 +67,6 @@ export default ComboboxView.extend({
|
|||||||
var description = category.get('description');
|
var description = category.get('description');
|
||||||
// TODO wtf how can this be null?;
|
// TODO wtf how can this be null?;
|
||||||
if (description && description !== 'null') {
|
if (description && description !== 'null') {
|
||||||
|
|
||||||
result += '<div class="category-desc">' +
|
result += '<div class="category-desc">' +
|
||||||
description.substr(0,200) +
|
description.substr(0,200) +
|
||||||
(description.length > 200 ? '…' : '') +
|
(description.length > 200 ? '…' : '') +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user