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

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

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

    setDefaults: function () {
        this._super();
        this.props("id", "column/filter");
        this.props("enabled", true);
        this.props("visible", true);
        this.props("icon", "filter.font");
        this.props("label", "Filter...");
        this.props("tooltip", "Filter");
    },

    setState: function (state) {
        this._super(state);
        this.props("label", this._isFiltered() ? "Edit Filter..." : "Filter...");
    },

    execute: function (e) {
        this._super(e);
        
        PDJS.Shared.Views.Filters.FilterEditorDialog.open({
            viewStateId: this.get_viewStateId(),
            filter: { id: this.get_columnId(), inline: true },
            select: {
                ok: (sender, e) => {
                    this.get_viewGrid().refresh();
                }
            }
        });
        
    },

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

    _isFiltered: function () {
        return this.get_viewGrid().getActiveFilters().contains(this.get_columnId());
    }

});