/// class PD.Manage.Modules.UserEditDialogCommand

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

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

    setDefaults: function () {
        this.props("id", "user/edit-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("pencil.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the selected User.");
        this.state("users", null);
    },

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

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

        var user = _.first(this.state("users"));

        this._showDialog(user.id, user.name);

    },

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

    _isEnabled: function () {
        return _.isArray(this.state("users"))
            && this.state("users").length == 1;
    },

    _showDialog: function (id, name) {

        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: `User | ${name}`,
            args: {
                targetId: id,
                targetType: "ProspectDirector.Web.Manage.Modules.Security.UserUIO",
                arbiterType: "ProspectDirector.Web.Manage.Modules.Security.UserArbiter"
            },
            callbacks: {
                "ok": (sender, e) => {

                    PD.context
                        .get_default()
                        .get_events()
                        .publish("user/edit", {
                            id: e.target.id
                        });

                }
            }
        }, {
            height: 550,
            width: 650,
        });


    }

});