FIX: Load categories with post revisions (#26496)
When lazy load categories is enabled, categories should be loaded with post revisions because the categories may not be preloaded on the client side.
This commit is contained in:
parent
bd7823cc70
commit
6c2c1a43ae
|
@ -74,9 +74,10 @@ export default class Post extends RestModel {
|
|||
}
|
||||
|
||||
static loadRevision(postId, version) {
|
||||
return ajax(`/posts/${postId}/revisions/${version}.json`).then((result) =>
|
||||
EmberObject.create(result)
|
||||
);
|
||||
return ajax(`/posts/${postId}/revisions/${version}.json`).then((result) => {
|
||||
result.categories?.forEach((c) => Site.current().updateCategory(c));
|
||||
return EmberObject.create(result);
|
||||
});
|
||||
}
|
||||
|
||||
static hideRevision(postId, version) {
|
||||
|
|
|
@ -28,6 +28,12 @@ class PostRevision < ActiveRecord::Base
|
|||
SQL
|
||||
end
|
||||
|
||||
def categories
|
||||
return [] if modifications["category_id"].blank?
|
||||
|
||||
@categories ||= Category.where(id: modifications["category_id"])
|
||||
end
|
||||
|
||||
def hide!
|
||||
update_column(:hidden, true)
|
||||
end
|
||||
|
|
|
@ -28,6 +28,8 @@ class PostRevisionSerializer < ApplicationSerializer
|
|||
:wiki,
|
||||
:can_edit
|
||||
|
||||
has_many :categories, serializer: BasicCategorySerializer, embed: :objects
|
||||
|
||||
# Creates a field called field_name_changes with previous and
|
||||
# current members if a field has changed in this revision
|
||||
def self.add_compared_field(field)
|
||||
|
|
Loading…
Reference in New Issue