/// 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", PD.Path.resolve("~/application/icons/misc/filter.png"));
        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);
        
        var that = this,
            service = new PD.Web.UI.Controls.ViewGridService();

        this._showDialog(function (sender, e) {

            service.addInlineFilter(that.get_viewStateId(), e, function () {
                that.get_viewGrid().refresh();
            });

        });
        
    },

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

    _showDialog: function (callback) {

        ProspectDirector.Types.Core.Dialogs.QuickFilterEditor.show({
            params: {
                viewStateId: this.get_viewStateId(),
                filterId: this.get_columnId()
            },
            callbacks: {
                ok: callback
            }
        });

    },

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

});