﻿// ------------ chart entry content panel helper class ------------ //
Ext.ux.ChartEntryContentPanelHelper = Ext.extend(Ext.ux.ContentPanelHelperWrapper, {

    // do the reset click logic
    doResetClick: function() {
        this.setSearchParams("");

        // clear the grid
        if (this.m_storeList) {
            this.m_storeList.removeAll();

            // set the totalLength to 0 as it doesn't get cleared when
            // changing the store content locally (by design apparently)
            this.m_storeList.totalLength = 0;
        }

        // update the scrollbar
        if (this.m_gridPanelList) {
            this.m_gridPanelList.updateScrollbar();
        }

        // update the footer
        if (this.m_pagingBar) {
            this.m_pagingBar.updateInfo();
        }
    },

    // set the search params
    setSearchParams: function(query) {
        var params = { query: query };
        this.setListParams(params);
    },

    // determine if one or more of the currently selected tracks can be streamed
    isOneOrMoreSelectedTracksStreamable: function() {
        var isStreamable = false;

        if (this.m_gridPanelList) {
            isStreamable = this.m_gridPanelList.isOneOrMoreSelectedTracksStreamable();
        }

        return isStreamable;
    },
    
    // retrieve the ids of the selected tracks in the list
    getSelectedTrackIds: function() {
        var aSelectedIds = [];

        if (this.m_gridPanelList) {
            aSelectedIds = this.m_gridPanelList.createSelectedTrackIdArray();
        }

        return aSelectedIds;
    }
});