/// class PD.Manage.Modules.DataLoadDeleteAllJobsCommand

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

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

    setDefaults: function () {
        this.props("id", "job/delete-all");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("delete.png"));
        this.props("label", "Delete All");
        this.props("tooltip", "Delete all jobs.");
    },

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

        var service = new PD.Manage.Services.DataLoadService();

        this._showConfirmationDialog(function (e) {

            service.deleteAllJobs(function (e) {
                PD.context.get_default().get_events().publish("jobs/delete");
            });

        });

    },

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

    _showConfirmationDialog: function (callback) {

        Jade.UI.MessageDialog.open({
            dialogStyle: Jade.UI.MessageDialogStyle.Warning,
            dialogButtons: Jade.UI.MessageDialogButtonStyle.OKCancel,
            allowClose: true,
            title: "Delete All Jobs?",
            message: "Delete all of the data import jobs?",
            select: (e) => {
                e.close();
                if (e.button === Jade.UI.MessageDialogButton.ok) {
                    callback(e);
                }
            }
        });

    }

});