Commit cc939e35 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Implement deleting of tags.

parent 6e8f97e6
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ Ext.define('Docs.model.Comment', {
    /**
     * Marks the comment as read.
     */
    markRead: function(cfg) {
    markRead: function() {
        this.request({
            url: '/comments/' + this.get("id") + '/read',
            method: 'POST',
@@ -116,6 +116,25 @@ Ext.define('Docs.model.Comment', {
        });
    },

    /**
     * Removes tag from comment.
     * @param {String} tagname
     */
    removeTag: function(tagname) {
        this.request({
            url: '/comments/' + this.get("id") + '/remove_tag',
            method: 'POST',
            params: {
                tagname: tagname
            },
            success: function() {
                Ext.Array.remove(this.get("tags"), tagname);
                this.commit();
            },
            scope: this
        });
    },

    request: function(cfg) {
        Docs.Comments.request("ajax", {
            url: cfg.url,
+15 −3
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ Ext.define('Docs.view.comments.List', {
        this.delegateClick("a.voteCommentDown", function(el, r) {
            this.vote(el, r, "down");
        }, this);

        this.delegateClick("a.editComment", function(el, r) {
            this.edit(el, r);
        }, this);
@@ -64,9 +65,11 @@ Ext.define('Docs.view.comments.List', {
        this.delegateClick("a.undoDeleteComment", function(el, r) {
            this.setDeleted(el, r, false);
        }, this);
        this.delegateClick("a.readComment", function(el, r) {
            this.markRead(el, r);
        }, this);

        this.delegateClick("a.readComment", this.markRead, this);

        this.delegateClick("a.add-tag", this.addTag, this);
        this.delegateClick("a.remove-tag", this.removeTag, this);
    },

    delegateClick: function(selector, callback, scope) {
@@ -129,6 +132,15 @@ Ext.define('Docs.view.comments.List', {
        comment.markRead();
    },

    addTag: function(el, comment) {
        // TODO...
    },

    removeTag: function(el, comment) {
        var tagname = Ext.get(el).up(".tag").down("b").getHTML();
        comment.removeTag(tagname);
    },

    /**
     * Loads array of comments into the view.
     * @param {Object[]} comments
+2 −2
Original line number Diff line number Diff line
@@ -53,8 +53,8 @@ Ext.define('Docs.view.comments.Template', {
                            '<div class="top-right">',
                                '<tpl for="tags">',
                                    '<span href="#" class="tag">',
                                        '{.}',
                                        '<tpl if="this.isMod()"><a href="#" class="delete" title="Delete tag">&ndash;</a></tpl>',
                                        '<b>{.}</b>',
                                        '<tpl if="this.isMod()"><a href="#" class="remove-tag" title="Delete tag">&ndash;</a></tpl>',
                                    '</span>',
                                '</tpl>',
                                '<tpl if="this.isMod()">',