/// class PD.Manage.Modules.SyncAllUsersCommand

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

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

    setDefaults: function () {
        this.props("id", "sync/all-users");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("arrow_circle2.png"));
        this.props("label", "Sync All Users");
        this.props("tooltip", "Update all Users with data<br/>retrieved from Active Directory.");
    },

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

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

                PD.ajax({
                    type: "POST",
                    url: PD.Path.resolve("~/Manage/ActiveDirectory/SyncUsers"),
                    success: function (e) {
                        args.startPolling(e);
                    },
                    error: function (e) {
                        args.abort(e.responseJSON);
                        e.errorHandled = true;
                    }
                });

            },
            close: function (e) {

                PD.context
                    .get_default()
                    .get_events()
                    .publish("sync/refresh");

            }
        });

    }

});