Loading template/app/view/comments/List.js +27 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,8 @@ Ext.define('Docs.view.comments.List', { "score", "upVote", "downVote", "contentHtml" "contentHtml", "deleted" ] }); Loading @@ -63,6 +64,12 @@ Ext.define('Docs.view.comments.List', { this.delegateClick("a.editComment", function(el, r) { this.edit(el, r); }, this); this.delegateClick("a.deleteComment", function(el, r) { this.setDeleted(el, r, true); }, this); this.delegateClick("a.undoDeleteComment", function(el, r) { this.setDeleted(el, r, false); }, this); }, delegateClick: function(selector, callback, scope) { Loading Loading @@ -162,6 +169,25 @@ 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'), method: 'POST', callback: function(options, success, response) { var data = Ext.JSON.decode(response.responseText); if (data.success) { comment.set("deleted", deleted); comment.commit(); } else { Ext.Msg.alert('Error', data.reason || "There was an error submitting your request"); } }, scope: this }); }, /** * Loads array of comments into the view. * @param {Object[]} comments Loading template/app/view/comments/Template.js +26 −22 Original line number Diff line number Diff line Loading @@ -38,6 +38,9 @@ Ext.define('Docs.view.comments.Template', { '<div class="comment-list">', '<tpl for=".">', '<div class="comment" id="{id}">', '<tpl if="deleted">', '<div class="deleted-comment">Comment was deleted. <a href="#" class="undoDeleteComment">Undo</a>.</div>', '<tpl else>', '<div class="com-meta">', '{[Docs.Comments.avatar(values.emailHash)]}', '<div class="author<tpl if="moderator"> moderator" title="Sencha Engineer</tpl>">', Loading @@ -62,6 +65,7 @@ Ext.define('Docs.view.comments.Template', { '</div>', '</div>', '<div class="content">{contentHtml}</div>', '</tpl>', '</div>', '</tpl>', '<div class="new-comment-wrap"></div>', Loading Loading
template/app/view/comments/List.js +27 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,8 @@ Ext.define('Docs.view.comments.List', { "score", "upVote", "downVote", "contentHtml" "contentHtml", "deleted" ] }); Loading @@ -63,6 +64,12 @@ Ext.define('Docs.view.comments.List', { this.delegateClick("a.editComment", function(el, r) { this.edit(el, r); }, this); this.delegateClick("a.deleteComment", function(el, r) { this.setDeleted(el, r, true); }, this); this.delegateClick("a.undoDeleteComment", function(el, r) { this.setDeleted(el, r, false); }, this); }, delegateClick: function(selector, callback, scope) { Loading Loading @@ -162,6 +169,25 @@ 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'), method: 'POST', callback: function(options, success, response) { var data = Ext.JSON.decode(response.responseText); if (data.success) { comment.set("deleted", deleted); comment.commit(); } else { Ext.Msg.alert('Error', data.reason || "There was an error submitting your request"); } }, scope: this }); }, /** * Loads array of comments into the view. * @param {Object[]} comments Loading
template/app/view/comments/Template.js +26 −22 Original line number Diff line number Diff line Loading @@ -38,6 +38,9 @@ Ext.define('Docs.view.comments.Template', { '<div class="comment-list">', '<tpl for=".">', '<div class="comment" id="{id}">', '<tpl if="deleted">', '<div class="deleted-comment">Comment was deleted. <a href="#" class="undoDeleteComment">Undo</a>.</div>', '<tpl else>', '<div class="com-meta">', '{[Docs.Comments.avatar(values.emailHash)]}', '<div class="author<tpl if="moderator"> moderator" title="Sencha Engineer</tpl>">', Loading @@ -62,6 +65,7 @@ Ext.define('Docs.view.comments.Template', { '</div>', '</div>', '<div class="content">{contentHtml}</div>', '</tpl>', '</div>', '</tpl>', '<div class="new-comment-wrap"></div>', Loading