/// class PD.Manage.Modules.ViewEditDialogCommand

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

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

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

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

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

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

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

    },

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

    _isEnabled: function () {
        return this.state("view") != null;
    },

    _showDialog: function (id, name) {

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

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

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

    }

});
