/// class PD.Manage.Modules.DataLoadDownloadJobInputFileCommand

PD.Manage.Modules.DataLoadDownloadJobInputFileCommand =
PD.Commands.Command.extend({

    //===================================
    // PUBLIC METHODS
    //===================================

    setDefaults: function () {
        this.props("id", "job/download-input-file");
        this.props("enabled", false);
        this.props("icon", PD.Path.to16x16("inbox_into.png"));
        this.props("label", "Download Input");
        this.props("tooltip", "Download the Input File of the selected job.");
        this.state("jobs", null);
    },

    setState: function (state) {
        this._super(state);
        this.props("enabled", this._isEnabled());
    },

    execute: function (e) {
        this._super(e);

        var job = _.first(this.state("jobs"));

        PD.Web.Utilities.DownloadManager.download("~/Manage/DataLoad/GetSourceFile", {
            id: job.id
        });

    },

    //===================================
    // PRIVATE METHODS
    //===================================

    _isEnabled: function () {
        return this._selectedJobs().length > 0;
    },

    _selectedJobs: function () {

        var result = [];

        if (_.isArray(this.state("jobs"))) {
            result = this.state("jobs");
        }

        return result;

    }

});