/// class PD.Manage.Modules.SystemSettingExportConfigCommand

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

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

    setDefaults: function (options) {

        this.props("id", "system-setting/export-config");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("inbox_into.png"));
        this.props("label", "Export Configuration");
        this.props("tooltip", "Export the application's configuration.");

    },

    execute: function (e) {
        this._super(e);
        this._showConfirmationDialog();
    },

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

    _showConfirmationDialog: function () {

        ProspectDirector.Web.UI.MessageDialog.confirm({
            title: "Export?",
            message: "Export application configuration?",
            buttons: {
                ok: {
                    label: "OK",
                    callback: _.bind(this._execute, this)
                },
                cancel: {
                    label: "Cancel"
                }
            }
        });

    },

    _execute: function () {

        PD.Shared.Dialogs.TaskStatus.open({
            config: {
                title: "Export Configuration"
            },
            showDetail: true,
            taskStart: function (args) {

                args.ajax({
                    type: "POST",
                    url: PD.Path.resolve("~/Manage/Settings/ExportConfig")
                });

            },
            taskSuccess: function (args) {
                if (args.tags.path != null) {
                    ProspectDirector.RUNTIME.iframeRequest("~/Manage/Settings/DownloadConfigFile?path=" + args.tags.path);
                    //args.close();
                }
            }
        });

    }

});
