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:
parent
f921909595
commit
81a43f2c1e
|
@ -5,7 +5,6 @@ import { default as discourseComputed } from "discourse-common/utils/decorators"
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { reads, and } from "@ember/object/computed";
|
import { reads, and } from "@ember/object/computed";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import Category from "discourse/models/category";
|
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: "",
|
tagName: "",
|
||||||
|
@ -58,10 +57,6 @@ export default Component.extend({
|
||||||
"tagInfo.synonyms",
|
"tagInfo.synonyms",
|
||||||
result.synonyms.map(s => this.store.createRecord("tag", s))
|
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))
|
.finally(() => this.set("loading", false))
|
||||||
.catch(popupAjaxError);
|
.catch(popupAjaxError);
|
||||||
|
|
|
@ -51,6 +51,7 @@ flushMap();
|
||||||
|
|
||||||
export default EmberObject.extend({
|
export default EmberObject.extend({
|
||||||
_plurals: {
|
_plurals: {
|
||||||
|
category: "categories",
|
||||||
"post-reply": "post-replies",
|
"post-reply": "post-replies",
|
||||||
"post-reply-history": "post_reply_histories",
|
"post-reply-history": "post_reply_histories",
|
||||||
reviewable_history: "reviewable_histories"
|
reviewable_history: "reviewable_histories"
|
||||||
|
|
|
@ -106,7 +106,12 @@ class TagsController < ::ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def info
|
def info
|
||||||
render_serialized(@tag, DetailedTagSerializer, root: :tag_info)
|
render_serialized(
|
||||||
|
@tag,
|
||||||
|
DetailedTagSerializer,
|
||||||
|
rest_serializer: true,
|
||||||
|
root: :tag_info
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
@ -217,6 +217,7 @@ acceptance("Tag info", {
|
||||||
|
|
||||||
server.get("/tags/planters/info", () => {
|
server.get("/tags/planters/info", () => {
|
||||||
return helper.response({
|
return helper.response({
|
||||||
|
__rest_serializer: "1",
|
||||||
tag_info: {
|
tag_info: {
|
||||||
id: 12,
|
id: 12,
|
||||||
name: "planters",
|
name: "planters",
|
||||||
|
|
Loading…
Reference in New Issue