/// class PD.Manage.Modules.ExtensionPropertiesDialogCommand

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

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

    init: function (options) {
        this._super(options);
        this.props("id", "extension/properties-dialog");
        this.props("icon", PD.Path.to16x16("table_edit.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the selected Extension.");
        this.state("extension", null);
        this.state("isList", false);
    },

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

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

        let extension = this.state("extension");

        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: `Extension | ${extension.name}`,
            height: "400px",
            width: "450px",
            args: {
                targetId: extension.id,
                arbiterType: "ProspectDirector.Web.Manage.Modules.Extensions.ExtensionArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Extensions.ExtensionUIO",
                properties: {
                    isList: this.state("isList")
                }
            },
            callbacks: {
                ok: (sender, e) => {
                    PD.context
                        .get_default()
                        .get_events()
                        .publish("extension/update", {
                            id: e.id
                        });
                }
            }
        });

    },

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

});