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

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

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

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

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

        this._showDialog((e) => {

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

            service.addColumnsRight(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);
                }
            }
        });

    }

});