/// class PD.Manage.Modules.DataLoadDownloadJobOutputFileCommand

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

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

    setDefaults: function () {
        this.props("id", "job/download-output-file");
        this.props("enabled", false);
        this.props("icon", PD.Path.to16x16("inbox_out.png"));
        this.props("label", "Download Output");
        this.props("tooltip", "Download the Output 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/GetOutputFile", {
            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;

    }

});