/// class PD.Manage.Modules.GroupEditDialogCommand

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

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

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

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

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

        var group = _.first(this.state("groups"));

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

    },

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

    _isEnabled: function () {
        return _.isArray(this.state("groups"))
            && this.state("groups") != null;
    },

    _showDialog: function (id, name) {

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

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

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

    }

});