/// 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");

        ProspectDirector.Web.UI.FeatureSets.NHibTargetEditorDialog.open({
            config: {
                title: "Edit Document Type",
                height: "550px",
                width: "550px"
            },
            data: {
                targetId: documentType.id,
                targetArbiter: "ProspectDirector.Web.Manage.Modules.DocumentTypes.DocumentTypeArbiter",
                targetType: "ProspectDirector.Web.Shared.Modules.DocumentTypes.DocumentTypeUIO",
                layoutType: ProspectDirector.Web.UI.FeatureSets.Layouts.TabStripLayout
            },
            callbacks: {
                ok: function (sender, e) {

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

                }
            }
        });

    }

});