REFACTOR: use rest serializer for tag-info categories

But the "synonyms" can't use the TagSerializer yet. We still have some
code from the discourse-tagging plugin that uses "text" instead of
"name", "count" instead of "topic_count", etc. We should make the js
consistent with the TagSerializer and then stop using tag_counts_json.
This commit is contained in:
Neil Lalonde 2019-12-10 14:57:59 -05:00
parent f921909595
commit 81a43f2c1e
4 changed files with 8 additions and 6 deletions

View File

@ -5,7 +5,6 @@ import { default as discourseComputed } from "discourse-common/utils/decorators"
import Component from "@ember/component";
import { reads, and } from "@ember/object/computed";
import { isEmpty } from "@ember/utils";
import Category from "discourse/models/category";
export default Component.extend({
tagName: "",
@ -58,10 +57,6 @@ export default Component.extend({
"tagInfo.synonyms",
result.synonyms.map(s => this.store.createRecord("tag", s))
);
this.set(
"tagInfo.categories",
result.category_ids.map(id => Category.findById(id))
);
})
.finally(() => this.set("loading", false))
.catch(popupAjaxError);

View File

@ -51,6 +51,7 @@ flushMap();
export default EmberObject.extend({
_plurals: {
category: "categories",
"post-reply": "post-replies",
"post-reply-history": "post_reply_histories",
reviewable_history: "reviewable_histories"

View File

@ -106,7 +106,12 @@ class TagsController < ::ApplicationController
end
def info
render_serialized(@tag, DetailedTagSerializer, root: :tag_info)
render_serialized(
@tag,
DetailedTagSerializer,
rest_serializer: true,
root: :tag_info
)
end
def update

View File

@ -217,6 +217,7 @@ acceptance("Tag info", {
server.get("/tags/planters/info", () => {
return helper.response({
__rest_serializer: "1",
tag_info: {
id: 12,
name: "planters",