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

Refactor store creation logic to ThumbList.

Now that all stores use the same Model structure, we can move
it up to ThumbList class, but instead of explicitly creating a
store, we simply use this.data.
parent 356a66cb
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -21,6 +21,13 @@ Ext.define('Docs.view.ThumbList', {
     */
    itemTpl: [],

    /**
     * @cfg {Object[]} data (required)
     * The data to display in this view. Each object represents one group:
     * @cfg {String} data.title The name for the group.
     * @cfg {Object[]} data.items The items inside the group.
     */

    initComponent: function() {
        this.addEvents(
            /**
@@ -31,6 +38,12 @@ Ext.define('Docs.view.ThumbList', {
            'urlclick'
        );

        // Generate ID-s for data
        Ext.Array.forEach(this.data, function(c, i) {
            c.id = 'sample-' + i;
        });

        // Place itemTpl inside main template
        this.tpl = new Ext.XTemplate(Ext.Array.flatten([
            '<div id="sample-ct">',
                '<tpl for=".">',
+1 −13
Original line number Diff line number Diff line
@@ -13,18 +13,6 @@ Ext.define('Docs.view.examples.Index', {
    autoScroll: true,

    initComponent: function() {
        var catalog = Ext.samples.samplesCatalog;

        Ext.Array.forEach(catalog, function(c, i) {
            c.id = 'sample-' + i;
        });

        var store = Ext.create('Ext.data.JsonStore', {
            idProperty: 'id',
            fields: ['id', 'title', 'items'],
            data: catalog
        });

        this.items = [
            { xtype: 'container', html: '<h1 class="eg">Examples</h1>' },
            Ext.create('Docs.view.ThumbList', {
@@ -43,7 +31,7 @@ Ext.define('Docs.view.examples.Index', {
                        '</h4><p>{desc}</p></div>',
                    '</dd>'
                ],
                store: store
                data: Ext.samples.samplesCatalog
            })
        ];

+1 −13
Original line number Diff line number Diff line
@@ -13,18 +13,6 @@ Ext.define('Docs.view.guides.Index', {
    autoScroll: true,

    initComponent: function() {
        var catalog = Docs.guides;

        Ext.Array.forEach(catalog, function(c, i) {
            c.id = 'sample-' + i;
        });

        var store = Ext.create('Ext.data.JsonStore', {
            idProperty: 'url',
            fields: ['id', 'title', 'items'],
            data: catalog
        });

        this.items = [
            { xtype: 'container', html: '<h1 class="eg">Guides</h1>' },
            Ext.create('Docs.view.ThumbList', {
@@ -33,7 +21,7 @@ Ext.define('Docs.view.guides.Index', {
                        '<div><h4>{title}</h4><p>{description}</p></div>',
                    '</dd>'
                ],
                store: store
                data: Docs.guides
            })
        ];

+1 −13
Original line number Diff line number Diff line
@@ -13,18 +13,6 @@ Ext.define('Docs.view.videos.Index', {
    autoScroll: true,

    initComponent: function() {
        var catalog = Docs.videos;

        Ext.Array.forEach(catalog, function(c, i) {
            c.id = 'sample-' + i;
        });

        var store = Ext.create('Ext.data.JsonStore', {
            idProperty: 'id',
            fields: ['id', 'title', 'items'],
            data: catalog
        });

        this.items = [
            { xtype: 'container', html: '<h1 class="eg">Videos</h1>' },
            Ext.create('Docs.view.ThumbList', {
@@ -35,7 +23,7 @@ Ext.define('Docs.view.videos.Index', {
                        '</h4><p>{[values.description.substr(0,100)]}</p></div>',
                    '</dd>'
                ],
                store: store
                data: Docs.videos
            })
        ];