/// class PD.Web.UI.Controls.ViewGridColumnAddColumnsLeftCommand
/// using PD.Web.UI.Controls.ViewGridColumnCommand

PD.Web.UI.Controls.ViewGridColumnAddColumnsLeftCommand =
PD.Web.UI.Controls.ViewGridColumnCommand.extend({

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

    setDefaults: function () {
        this._super();
        this.props("id", "column/add-columns-left");
        this.props("enabled", true);
        this.props("visible", true);
        this.props("icon", "simple-left.18px.font");
        this.props("label", "Add Columns Left...");
        this.props("tooltip", "Add Columns Left");
    },

    execute: function (e) {
        this._super(e);
        
        var service = new PD.Web.UI.Controls.ViewGridService();

        this._showDialog((e) => {

            var columnIds = _.map(e, "id")

            service.addColumnsLeft(this.get_viewStateId(), this.get_columnId(), columnIds, () => {
                this.get_viewGrid().build();
            });

        });
        
    },

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

    _showDialog: function (callback) {

        PDJS.Shared.Views.ColumnsFinderDialog.open({
            componentType: "design",
            viewStateId: this.get_viewStateId(),
            select: {
                ok: (sender, e) => {
                    callback(e.columns);
                }
            }
        });

    }

});