/// 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", PD.Path.to16x16("navigate_left.png"));
        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: PDJS.Shared.Views.ViewComponentType.Design,
            viewStateId: this.get_viewStateId(),
            callbacks: {
                ok: (sender, e) => {
                    callback(e);
                }
            }
        });

    }

});