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

Show target of comments in FullList view.

parent c75dd878
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -52,7 +52,8 @@ Ext.define('Docs.view.comments.FullList', {
            items: [
                {
                    xtype: 'commentsList',
                    id: 'recentcomments'
                    id: 'recentcomments',
                    showTarget: true
                },
                {
                    xtype: 'commentsPager'
+7 −1
Original line number Diff line number Diff line
@@ -17,6 +17,12 @@ Ext.define('Docs.view.comments.List', {
    emptyText: '<div class="loading">Loading...</div>',
    deferEmptyText: false,

    /**
     * @cfg {Boolean} showTarget
     * True to show a link to the target in each comment.
     * Used in Docs.view.comments.FullList.
     */

    initComponent: function() {
        this.store = Ext.create('Ext.data.Store', {
            fields: [
@@ -33,7 +39,7 @@ Ext.define('Docs.view.comments.List', {
            ]
        });

        this.tpl = Docs.view.comments.Template;
        this.tpl = Docs.view.comments.Template.create({showTarget: this.showTarget});

        this.callParent(arguments);

+30 −2
Original line number Diff line number Diff line
@@ -3,12 +3,36 @@
 */
Ext.define('Docs.view.comments.Template', {
    extend: 'Ext.XTemplate',
    singleton: true,
    requires: [
        'Docs.Auth',
        'Docs.Comments'
    ],

    statics: {
        /**
         * A factory method to get an instance of the template.  For
         * every different config object, returns a cached instance of
         * the template, avoiding creating a new each time.
         *
         * @param {Object} cfg An additional configuration to
         * apply to the template object.
         * @return {Docs.view.comments.Template}
         */
        create: function(cfg) {
            var key = "tpl-" + Ext.JSON.encode(cfg);
            if (!this[key]) {
                this[key] = new this();
                Ext.apply(this[key], cfg);
            }
            return this[key];
        }
    },

    /**
     * @cfg {Boolean} showTarget
     * True to show a link to the target in each comment.
     */

    constructor: function() {
        this.callParent([
            '<div class="comment-list">',
@@ -18,7 +42,7 @@ Ext.define('Docs.view.comments.Template', {
                        '{[Docs.Comments.avatar(values.emailHash)]}',
                        '<div class="author<tpl if="moderator"> moderator" title="Sencha Engineer</tpl>">',
                            '{author}',
                            '<tpl if="showCls">',
                            '<tpl if="this.isTargetVisible()">',
                                '<span class="target"> on {[this.target(values.target)]}</span>',
                            '</tpl>',
                        '</div>',
@@ -47,6 +71,10 @@ Ext.define('Docs.view.comments.Template', {
        ]);
    },

    isTargetVisible: function() {
        return this.showTarget;
    },

    dateStr: function(date) {
        try {
            var now = Math.ceil(Number(new Date()) / 1000);