/// class PD.Manage.Modules.DocumentTypeEditDialogCommand

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

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

    setDefaults: function () {

        this.props("id", "document-type/edit-dialog");
        this.props("icon", PD.Path.to16x16("pencil.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the selected Document Type.");

        this.state("documentType", null);

    },

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

    isEnabled: function () {
        return this.state("documentType") != null
            && this.state("documentType").id != null;
    },

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

        var documentType = this.state("documentType");

        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: "Edit Document Type",
            height: "550px",
            width: "550px",
            args: {
                targetId: documentType.id,
                targetType: "ProspectDirector.Web.Shared.Modules.DocumentTypes.DocumentTypeUIO",
                arbiterType: "ProspectDirector.Web.Manage.Modules.DocumentTypes.DocumentTypeArbiter"
            },
            callbacks: {
                "ok": (sender, e) => {

                    PD.context
                        .get_default()
                        .get_events()
                        .publish("document-type/edit", {
                            id: documentType.id
                        });

                }
            }
        });

    }

});