/**
 * The ApiList View
 *
 * List view that displays each of the APIs in a list.
 * When the user taps on an API the we show the view for that API.
 *
 *  
 *
 * @extends Ext.Panel
 */
KitchenSink.views.ApiList = Ext.extend(Ext.Panel, {
    layout: 'fit',
    id: "apiList",

    // This function is run when initializing the component
    initComponent: function() {
    

        Ext.regModel('Section', { fields: ['section', 'page'] });

        var store = new Ext.data.JsonStore({
            model: 'Section',
            data: [
               /* { section: 'oAuth', page: 'attOAuth' }, */
                { section: 'Device Info', page: 'attDeviceInfo' },
                { section: 'Device Location', page: 'attDeviceLocation' },
               /* { section: 'Payments', page: 'attPayments' },
                { section: 'Payment Notifications', page: 'attPaymentNotifications' }, */
                { section: 'SMS', page: 'attSMS' },
                { section: 'MMS', page: 'attMMS' },
                { section: 'WAP', page: 'attWAP' }
            ]
        });

        this.items = {
            dockedItems: [{ xtype: 'toolbar', dock: 'top', title: 'AT&T APIs' }],
            xtype: 'panel',
            layout: 'fit',
            items: {
                xtype: 'list',
                id: 'api-list',
                itemTpl: '{section}',
                store: store,
                listeners: {
                    itemtap: function(dataView, idx) {
                      console.log("one");
                        var xtype = dataView.getStore().getAt(idx).get('page');
                        var viewport = Ext.getCmp('viewport');
                        viewport.add({xtype: xtype, id: xtype});
                        viewport.setActiveItem(xtype);
                    }
                }
            }

        };

        // This should always be called as the last item in the 'initComponent' method.
        // It ensures that superclass initComponent methods are also called
        KitchenSink.views.ApiList.superclass.initComponent.apply(this, arguments);
    }
});

Ext.reg('attApiList', KitchenSink.views.ApiList);

