mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: Show category badge on enqueued posts
This commit is contained in:
parent
9ffec28076
commit
d2ed64751e
@ -111,22 +111,32 @@ export default Ember.Object.extend({
|
|||||||
return this.container.lookup('adapter:' + type) || this.container.lookup('adapter:rest');
|
return this.container.lookup('adapter:' + type) || this.container.lookup('adapter:rest');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_lookupSubType(subType, id, root) {
|
||||||
|
|
||||||
|
// cheat: we know we already have categories in memory
|
||||||
|
if (subType === 'category') {
|
||||||
|
return Discourse.Category.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
const collection = root[this.pluralize(subType)];
|
||||||
|
if (collection) {
|
||||||
|
const found = collection.findProperty('id', id);
|
||||||
|
if (found) {
|
||||||
|
return this._hydrate(subType, found, root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_hydrateEmbedded(obj, root) {
|
_hydrateEmbedded(obj, root) {
|
||||||
const self = this;
|
const self = this;
|
||||||
Object.keys(obj).forEach(function(k) {
|
Object.keys(obj).forEach(function(k) {
|
||||||
const m = /(.+)\_id$/.exec(k);
|
const m = /(.+)\_id$/.exec(k);
|
||||||
if (m) {
|
if (m) {
|
||||||
const subType = m[1];
|
const subType = m[1];
|
||||||
const collection = root[self.pluralize(subType)];
|
const hydrated = self._lookupSubType(subType, obj[k], root);
|
||||||
if (collection) {
|
if (hydrated) {
|
||||||
const found = collection.findProperty('id', obj[k]);
|
obj[subType] = hydrated;
|
||||||
if (found) {
|
delete obj[k];
|
||||||
const hydrated = self._hydrate(subType, found, root);
|
|
||||||
if (hydrated) {
|
|
||||||
obj[subType] = hydrated;
|
|
||||||
delete obj[k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
{{post.post_options.title}}
|
{{post.post_options.title}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{category-badge post.category}}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{{{cook-text post.raw}}}
|
{{{cook-text post.raw}}}
|
||||||
|
@ -14,6 +14,10 @@
|
|||||||
.post-title {
|
.post-title {
|
||||||
color: darken(scale-color-diff(), 50%);
|
color: darken(scale-color-diff(), 50%);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
||||||
|
.badge-wrapper {
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
border-bottom: 1px solid darken(scale-color-diff(), 10%);
|
border-bottom: 1px solid darken(scale-color-diff(), 10%);
|
||||||
|
@ -38,7 +38,8 @@ class UserHistory < ActiveRecord::Base
|
|||||||
:change_username,
|
:change_username,
|
||||||
:custom,
|
:custom,
|
||||||
:custom_staff,
|
:custom_staff,
|
||||||
:anonymize_user)
|
:anonymize_user,
|
||||||
|
:reviewed_post)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Staff actions is a subset of all actions, used to audit actions taken by staff users.
|
# Staff actions is a subset of all actions, used to audit actions taken by staff users.
|
||||||
@ -59,7 +60,8 @@ class UserHistory < ActiveRecord::Base
|
|||||||
:roll_up,
|
:roll_up,
|
||||||
:change_username,
|
:change_username,
|
||||||
:custom_staff,
|
:custom_staff,
|
||||||
:anonymize_user]
|
:anonymize_user,
|
||||||
|
:reviewed_post]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.staff_action_ids
|
def self.staff_action_ids
|
||||||
|
@ -9,9 +9,19 @@ class QueuedPostSerializer < ApplicationSerializer
|
|||||||
:rejected_by_id,
|
:rejected_by_id,
|
||||||
:raw,
|
:raw,
|
||||||
:post_options,
|
:post_options,
|
||||||
:created_at
|
:created_at,
|
||||||
|
:category_id
|
||||||
|
|
||||||
has_one :user, serializer: BasicUserSerializer, embed: :object
|
has_one :user, serializer: BasicUserSerializer, embed: :object
|
||||||
has_one :topic, serializer: BasicTopicSerializer
|
has_one :topic, serializer: BasicTopicSerializer
|
||||||
|
|
||||||
|
def category_id
|
||||||
|
cat_id = object.topic.try(:category_id) || object.post_options['category']
|
||||||
|
cat_id.to_i if cat_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_category_id?
|
||||||
|
category_id.present?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -98,7 +98,7 @@ describe QueuedPost do
|
|||||||
expect(topic.category).to eq(category)
|
expect(topic.category).to eq(category)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't create the post and topic" do
|
it "rejecting doesn't create the post and topic" do
|
||||||
topic_count, post_count = Topic.count, Post.count
|
topic_count, post_count = Topic.count, Post.count
|
||||||
|
|
||||||
qp.reject!(admin)
|
qp.reject!(admin)
|
||||||
|
Loading…
Reference in New Issue
Block a user