From 2a3a365776cb58eb98091d3458bd05b24f6da6f3 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Wed, 24 Oct 2012 11:55:02 +0300 Subject: [PATCH] Unify the responses of /users /targets /tags requests. This change breaks compatibility with comments API of previous JSDuck release. But the only effect of this is that the Users and Targets lists on comments index page will be empty, so I consider it OK to make this change as it will only make the comments index page a bit less useful while the transition happens, but won't break anything badly. --- comments/app.js | 8 ++++---- template/app/view/comments/TagEditor.js | 2 +- template/app/view/comments/Tags.js | 2 +- template/app/view/comments/Targets.js | 2 +- template/app/view/comments/Users.js | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/comments/app.js b/comments/app.js index cde265d0..70ccd5f3 100644 --- a/comments/app.js +++ b/comments/app.js @@ -125,21 +125,21 @@ app.get('/auth/:sdk/:version/comments_recent', function(req, res) { // Returns top users (with most upvotes or with most comments). app.get('/auth/:sdk/:version/users', function(req, res) { new Request(req).getTopUsers(req.query.sortBy, function(users) { - res.json(users); + res.json({ success: true, data: users }); }); }); // Returns the most commented targets. app.get('/auth/:sdk/:version/targets', function(req, res) { - new Request(req).getTopTargets(function(users) { - res.json(users); + new Request(req).getTopTargets(function(targets) { + res.json({ success: true, data: targets }); }); }); // Returns the most used tags. app.get('/auth/:sdk/:version/tags', function(req, res) { new Request(req).getTopTags(function(tags) { - res.send({ success: true, tags: tags }); + res.send({ success: true, data: tags }); }); }); diff --git a/template/app/view/comments/TagEditor.js b/template/app/view/comments/TagEditor.js index b0e83f57..0584c5d2 100644 --- a/template/app/view/comments/TagEditor.js +++ b/template/app/view/comments/TagEditor.js @@ -19,7 +19,7 @@ Ext.define("Docs.view.comments.TagEditor", { url: Docs.Comments.buildRequestUrl("/tags"), reader: { type: "json", - root: "tags" + root: "data" } }, listeners: { diff --git a/template/app/view/comments/Tags.js b/template/app/view/comments/Tags.js index 6e882239..670a3198 100644 --- a/template/app/view/comments/Tags.js +++ b/template/app/view/comments/Tags.js @@ -114,6 +114,6 @@ Ext.define('Docs.view.comments.Tags', { }, loadTags: function(tags) { - this.list.getStore().loadData(tags.tags); + this.list.getStore().loadData(tags.data); } }); diff --git a/template/app/view/comments/Targets.js b/template/app/view/comments/Targets.js index 76945443..84727aca 100644 --- a/template/app/view/comments/Targets.js +++ b/template/app/view/comments/Targets.js @@ -114,7 +114,7 @@ Ext.define('Docs.view.comments.Targets', { }, loadTargets: function(targets) { - this.list.getStore().loadData(Ext.Array.map(targets, this.convertTarget, this)); + this.list.getStore().loadData(Ext.Array.map(targets.data, this.convertTarget, this)); }, // Adds text field to target record. diff --git a/template/app/view/comments/Users.js b/template/app/view/comments/Users.js index 791ecae4..fee1684d 100644 --- a/template/app/view/comments/Users.js +++ b/template/app/view/comments/Users.js @@ -137,7 +137,7 @@ Ext.define('Docs.view.comments.Users', { }, loadUsers: function(users) { - this.list.getStore().loadData(users); + this.list.getStore().loadData(users.data); if (this.selectedUser) { var index = this.list.getStore().findExact("userName", this.selectedUser.get("userName")); this.list.getSelectionModel().select(index, false, true); -- GitLab