Commit 0ebf3a5e authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Show comment counts in class overview page.

parent b9f08736
Loading
Loading
Loading
Loading
+6 −21
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@ Ext.define('Docs.view.cls.Overview', {
        'Docs.view.comments.LargeExpander',
        'Docs.view.comments.MemberWrap',
        'Docs.Syntax',
        'Docs.Settings'
        'Docs.Settings',
        'Docs.CommentCounts'
    ],
    mixins: ['Docs.view.Scrolling'],

@@ -105,16 +106,18 @@ Ext.define('Docs.view.cls.Overview', {

        this.filterMembers("", Docs.Settings.get("show"));

        Docs.CommentCounts.afterLoaded(this.renderCommentCounts, this);

        this.fireEvent('afterload');
    },

    renderCommentContainers: function() {
    renderCommentCounts: function() {
        // Add comment button to toolbar
        this.toolbar.showCommentCount();
        this.toolbar.setCommentCount(Docs.CommentCounts.get("class", this.docClass.name));

        // Insert class level comment container under class intro docs
        this.clsExpander = new Docs.view.comments.LargeExpander({
            count: 0,
            name: this.docClass.name,
            el: Ext.query('.doc-contents')[0]
        });
@@ -122,30 +125,12 @@ Ext.define('Docs.view.cls.Overview', {
        // Add a comment container to each class member
        this.memberWrappers = Ext.Array.map(Ext.query('.member'), function(memberDoc) {
            return new Docs.view.comments.MemberWrap({
                count: 0,
                className: this.docClass.name,
                el: memberDoc
            });
        }, this);
    },

    updateCommentMeta: function(metaData) {
        var clsMeta = metaData['class'][this.docClass.name];

        var clsCommentsCount = (clsMeta && clsMeta['']) ? clsMeta[''] : 0;
        // Update toolbar icon
        this.toolbar.setCommentCount(clsCommentsCount);
        // Update class level comments meta
        this.clsExpander.setCount(clsCommentsCount);

        // Update class member comments meta
        Ext.Array.forEach(this.memberWrappers, function(wrapper) {
            var cls = metaData['class'][wrapper.getDefinedIn()];
            var count = cls && cls[wrapper.getMemberId()];
            wrapper.setCount(count);
        });
    },

    /**
     * Filters members by search string and inheritance.
     * @param {String} search
+1 −1
Original line number Diff line number Diff line
@@ -295,6 +295,6 @@ Ext.define('Docs.view.cls.Toolbar', {
     * @param {Number} n
     */
    setCommentCount: function(n) {
        this.commentCount.update(""+n);
        this.commentCount.update(""+(n||0));
    }
});
+5 −7
Original line number Diff line number Diff line
@@ -2,7 +2,10 @@
 * The Expander with a h3 heading "Comments".
 */
Ext.define('Docs.view.comments.LargeExpander', {
    requires: ["Docs.view.comments.Expander"],
    requires: [
        "Docs.CommentCounts",
        "Docs.view.comments.Expander"
    ],

    html: [
        '<div class="comments-section">',
@@ -27,11 +30,6 @@ Ext.define('Docs.view.comments.LargeExpander', {
     * The name of the current class, guide or video.
     */

    /**
     * @cfg {Number} count
     * The comment count of the member.
     */

    constructor: function(cfg) {
        Ext.apply(this, cfg);
        this.el = Ext.get(cfg.el);
@@ -40,7 +38,7 @@ Ext.define('Docs.view.comments.LargeExpander', {
        var expanderWrap = Ext.DomHelper.append(this.el, this.html, true).down("div");

        this.expander = new Docs.view.comments.Expander({
            count: this.count,
            count: Docs.CommentCounts.get("class", this.name),
            type: this.type,
            className: this.name,
            renderTo: expanderWrap
+11 −7
Original line number Diff line number Diff line
@@ -3,7 +3,10 @@
 * comments data inside it.
 */
Ext.define('Docs.view.comments.MemberWrap', {
    requires: ["Docs.view.comments.Expander"],
    requires: [
        "Docs.CommentCounts",
        "Docs.view.comments.Expander"
    ],

    tpl: Ext.create("Ext.XTemplate", '<span class="toggleMemberComments">{0}</span>'),

@@ -17,24 +20,22 @@ Ext.define('Docs.view.comments.MemberWrap', {
     * The name of the current class.
     */

    /**
     * @cfg {Number} count
     * The comment count of the member.
     */

    constructor: function(cfg) {
        Ext.apply(this, cfg);
        this.el = Ext.get(cfg.el);

        // The expander needs to reside inside some element.
        var expanderWrap = Ext.DomHelper.append(this.el.down('.long'), "<div></div>");
        var count = Docs.CommentCounts.get("class", this.getDefinedIn(), this.getMemberId());

        this.expander = new Docs.view.comments.Expander({
            count: this.count,
            count: Docs.CommentCounts.get("class", this.getDefinedIn(), this.getMemberId()),
            className: this.className,
            memberId: this.getMemberId(),
            renderTo: expanderWrap
        });

        this.updateCountInTitle(count);
    },

    /**
@@ -43,7 +44,10 @@ Ext.define('Docs.view.comments.MemberWrap', {
     */
    setCount: function(count) {
        this.expander.setCount(count);
        this.updateCountInTitle(count);
    },

    updateCountInTitle: function(count) {
        var titleEl = this.el.down(".title");
        var titleComments = titleEl.down('.toggleMemberComments');