/// class PD.Manage.Modules.ExtensionColumnCreateDialogCommand

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

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

    setDefaults: function () {

        this.props("id", "extension-column/create-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("table_selection_column_plus.png"));
        this.props("label", "New");
        this.props("tooltip", "Add a new Column to the selected Extension.");

        this.state("extension", null);
        this.state("extensionColumn", null);

    },

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

        let extension = this.state("extension");
        
        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: `New Column`,
            height: "550px",
            width: "500px",
            args: {
                arbiterType: "ProspectDirector.Web.Manage.Modules.Extensions.ColumnArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Extensions.ColumnUIO",
                properties: {
                    extensionId: parseInt(extension.id)
                }
            },
            callbacks: {
                ok: (sender, e) => {
                    PD.context
                        .get_default()
                        .get_events()
                        .publish("extension-column/create", {
                            id: e.target.id
                        });
                }
            }
        });

    },

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

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

    _showExtensionColumnEditDialog: function (id) {

        ProspectDirector.Modules.Extensions.ExtensionColumnPropertiesDialog.show({
            params: {
                id: id
            },
            callbacks: {
                ok: function (sender, e) {
                    PD.context.get_default().get_events().publish("extension-column/update", {
                        id: id
                    });
                }
            }
        });

    }

});