/// class PD.Manage.Modules.ObjectModel.EntityTypeEditDialogCommand

PD.Manage.Modules.ObjectModel.EntityTypeEditDialogCommand =
PD.Commands.Command.extend({

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

    setDefaults: function () {

        this.props("id", "entity-type/edit-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("PENCIL.PNG"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the properties of<br/>the selected Entity Type.");

        this.state("entityTypeId", null);

    },

    setState: function (state) {
        this._super(state);
        this.props("enabled", this.state("entityTypeId") != null)
    },

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

        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: "Entity Type Edit",
            args: {
                targetId: this.state("entityTypeId"),
                targetType: "ProspectDirector.Web.Shared.Modules.EntityTypes.EntityTypeUIO",
                arbiterType: "ProspectDirector.Web.Manage.Modules.EntityTypes.EntityTypeArbiter"
            },
            callbacks: {
                ok: () => {
                    PD.context.get_default().get_events().publish("entity-type/update", {
                        id: e.id,
                        name: e.name
                    });
                }
            }
        });

    }

});