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');
|
||||
},
|
||||
|
||||
_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) {
|
||||
const self = this;
|
||||
Object.keys(obj).forEach(function(k) {
|
||||
const m = /(.+)\_id$/.exec(k);
|
||||
if (m) {
|
||||
const subType = m[1];
|
||||
const collection = root[self.pluralize(subType)];
|
||||
if (collection) {
|
||||
const found = collection.findProperty('id', obj[k]);
|
||||
if (found) {
|
||||
const hydrated = self._hydrate(subType, found, root);
|
||||
if (hydrated) {
|
||||
obj[subType] = hydrated;
|
||||
delete obj[k];
|
||||
}
|
||||
}
|
||||
const hydrated = self._lookupSubType(subType, obj[k], root);
|
||||
if (hydrated) {
|
||||
obj[subType] = hydrated;
|
||||
delete obj[k];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
{{else}}
|
||||
{{post.post_options.title}}
|
||||
{{/if}}
|
||||
{{category-badge post.category}}
|
||||
</span>
|
||||
|
||||
{{{cook-text post.raw}}}
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
.post-title {
|
||||
color: darken(scale-color-diff(), 50%);
|
||||
font-weight: bold;
|
||||
|
||||
.badge-wrapper {
|
||||
margin-left: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
border-bottom: 1px solid darken(scale-color-diff(), 10%);
|
||||
|
|
|
@ -38,7 +38,8 @@ class UserHistory < ActiveRecord::Base
|
|||
:change_username,
|
||||
:custom,
|
||||
:custom_staff,
|
||||
:anonymize_user)
|
||||
:anonymize_user,
|
||||
:reviewed_post)
|
||||
end
|
||||
|
||||
# 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,
|
||||
:change_username,
|
||||
:custom_staff,
|
||||
:anonymize_user]
|
||||
:anonymize_user,
|
||||
:reviewed_post]
|
||||
end
|
||||
|
||||
def self.staff_action_ids
|
||||
|
|
|
@ -9,9 +9,19 @@ class QueuedPostSerializer < ApplicationSerializer
|
|||
:rejected_by_id,
|
||||
:raw,
|
||||
:post_options,
|
||||
:created_at
|
||||
:created_at,
|
||||
:category_id
|
||||
|
||||
has_one :user, serializer: BasicUserSerializer, embed: :object
|
||||
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
|
||||
|
|
|
@ -98,7 +98,7 @@ describe QueuedPost do
|
|||
expect(topic.category).to eq(category)
|
||||
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
|
||||
|
||||
qp.reject!(admin)
|
||||
|
|
Loading…
Reference in New Issue