Loading template/app/model/Comment.js 0 → 100644 +23 −0 Original line number Diff line number Diff line /** * A comment model. */ Ext.define('Docs.model.Comment', { extend: 'Ext.data.Model', fields: [ {name: "id", mapping: "_id"}, "author", "emailHash", "moderator", "createdAt", "target", "score", "upVote", "downVote", "contentHtml", "deleted" ], proxy: { type: "ajax", reader: "json" } }); template/app/view/comments/List.js +9 −19 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ Ext.define('Docs.view.comments.List', { 'Docs.Comments', 'Docs.view.comments.Template', 'Docs.view.comments.Form', 'Docs.model.Comment', 'Docs.Tip' ], Loading @@ -26,19 +27,7 @@ Ext.define('Docs.view.comments.List', { initComponent: function() { this.store = Ext.create('Ext.data.Store', { fields: [ "_id", "author", "emailHash", "moderator", "createdAt", "target", "score", "upVote", "downVote", "contentHtml", "deleted" ] model: "Docs.model.Comment" }); this.tpl = Docs.view.comments.Template.create({showTarget: this.showTarget}); Loading Loading @@ -89,7 +78,7 @@ Ext.define('Docs.view.comments.List', { } Docs.Comments.request("ajax", { url: '/comments/' + record.get("_id"), url: '/comments/' + record.get("id"), method: 'POST', params: { vote: direction }, callback: function(options, success, response) { Loading Loading @@ -135,12 +124,12 @@ Ext.define('Docs.view.comments.List', { // re-renders the comment, discarding the form. refreshComment: function(comment) { this.refreshNode(this.getStore().findExact("_id", comment.get("_id"))); this.refreshNode(this.getStore().findExact("id", comment.get("id"))); }, loadContent: function(comment, callback, scope) { Docs.Comments.request("ajax", { url: '/comments/' + comment.get("_id"), url: '/comments/' + comment.get("id"), method: 'GET', callback: function(options, success, response) { var data = Ext.JSON.decode(response.responseText); Loading @@ -154,7 +143,7 @@ Ext.define('Docs.view.comments.List', { saveContent: function(comment, newContent, callback, scope) { Docs.Comments.request("ajax", { url: '/comments/' + comment.get("_id"), url: '/comments/' + comment.get("id"), method: 'POST', params: { content: newContent Loading @@ -172,7 +161,7 @@ Ext.define('Docs.view.comments.List', { // marks the comment as deleted or undoes the delete setDeleted: function(el, comment, deleted) { Docs.Comments.request("ajax", { url: '/comments/' + comment.get("_id") + (deleted ? '/delete' : '/undo_delete'), url: '/comments/' + comment.get("id") + (deleted ? '/delete' : '/undo_delete'), method: 'POST', callback: function(options, success, response) { var data = Ext.JSON.decode(response.responseText); Loading @@ -199,7 +188,8 @@ Ext.define('Docs.view.comments.List', { this.emptyText = ""; } this.store.loadData(comments, append); var processedComments = this.store.getProxy().getReader().readRecords(comments).records; this.store.loadData(processedComments, append); } }); Loading
template/app/model/Comment.js 0 → 100644 +23 −0 Original line number Diff line number Diff line /** * A comment model. */ Ext.define('Docs.model.Comment', { extend: 'Ext.data.Model', fields: [ {name: "id", mapping: "_id"}, "author", "emailHash", "moderator", "createdAt", "target", "score", "upVote", "downVote", "contentHtml", "deleted" ], proxy: { type: "ajax", reader: "json" } });
template/app/view/comments/List.js +9 −19 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ Ext.define('Docs.view.comments.List', { 'Docs.Comments', 'Docs.view.comments.Template', 'Docs.view.comments.Form', 'Docs.model.Comment', 'Docs.Tip' ], Loading @@ -26,19 +27,7 @@ Ext.define('Docs.view.comments.List', { initComponent: function() { this.store = Ext.create('Ext.data.Store', { fields: [ "_id", "author", "emailHash", "moderator", "createdAt", "target", "score", "upVote", "downVote", "contentHtml", "deleted" ] model: "Docs.model.Comment" }); this.tpl = Docs.view.comments.Template.create({showTarget: this.showTarget}); Loading Loading @@ -89,7 +78,7 @@ Ext.define('Docs.view.comments.List', { } Docs.Comments.request("ajax", { url: '/comments/' + record.get("_id"), url: '/comments/' + record.get("id"), method: 'POST', params: { vote: direction }, callback: function(options, success, response) { Loading Loading @@ -135,12 +124,12 @@ Ext.define('Docs.view.comments.List', { // re-renders the comment, discarding the form. refreshComment: function(comment) { this.refreshNode(this.getStore().findExact("_id", comment.get("_id"))); this.refreshNode(this.getStore().findExact("id", comment.get("id"))); }, loadContent: function(comment, callback, scope) { Docs.Comments.request("ajax", { url: '/comments/' + comment.get("_id"), url: '/comments/' + comment.get("id"), method: 'GET', callback: function(options, success, response) { var data = Ext.JSON.decode(response.responseText); Loading @@ -154,7 +143,7 @@ Ext.define('Docs.view.comments.List', { saveContent: function(comment, newContent, callback, scope) { Docs.Comments.request("ajax", { url: '/comments/' + comment.get("_id"), url: '/comments/' + comment.get("id"), method: 'POST', params: { content: newContent Loading @@ -172,7 +161,7 @@ Ext.define('Docs.view.comments.List', { // marks the comment as deleted or undoes the delete setDeleted: function(el, comment, deleted) { Docs.Comments.request("ajax", { url: '/comments/' + comment.get("_id") + (deleted ? '/delete' : '/undo_delete'), url: '/comments/' + comment.get("id") + (deleted ? '/delete' : '/undo_delete'), method: 'POST', callback: function(options, success, response) { var data = Ext.JSON.decode(response.responseText); Loading @@ -199,7 +188,8 @@ Ext.define('Docs.view.comments.List', { this.emptyText = ""; } this.store.loadData(comments, append); var processedComments = this.store.getProxy().getReader().readRecords(comments).records; this.store.loadData(processedComments, append); } });