/// class PD.Manage.Modules.ExtensionColumnPropertiesDialogCommand

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

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

    init: function (options) {
        this._super(options);

        this.props("id", "extension-column/properties-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("table_selection_column_edit.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the selected Column.");
        this.props("visible", true);

        this.state("extensionColumns", null);

    },

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

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

        var extensionColumn = _.first(this.state("extensionColumns"));

        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: `Column | ${extensionColumn.name}`,
            height: "550px",
            width: "500px",
            args: {
                targetId: extensionColumn.id,
                arbiterType: "ProspectDirector.Web.Manage.Modules.Extensions.ColumnArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Extensions.ColumnUIO"
            },
            callbacks: {
                ok: (sender, e) => {
                    PD.context
                        .get_default()
                        .get_events()
                        .publish("extension/update", {
                            id: extensionColumn.id
                        });
                }
            }
        });

    },

    isEnabled: function () {

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

        return extensionColumns != null
            && _.isArray(extensionColumns)
            && extensionColumns.length === 1;

    }

});
