/// class PD.Web.UI.Controls.ViewGridColumnClearAllFiltersCommand
/// using PD.Web.UI.Controls.ViewGridCommand

PD.Web.UI.Controls.ViewGridColumnClearAllFiltersCommand =
PD.Web.UI.Controls.ViewGridCommand.extend({

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

    setDefaults: function () {
        this._super();
        this.props("id", "column/clear-all-filters");
        this.props("enabled", true);
        this.props("visible", true);
        this.props("label", "Clear All Filters");
        this.props("tooltip", "Clear All Filters");
    },

    setState: function (state) {
        this._super(state);
        this.state("enabled", this._isEnabled());
    },

    execute: function (e) {
        this._super(e);

        var that = this,
            service = new PD.Web.UI.Controls.ViewGridService();

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

    },

    //===================================
    // PROTECTED METHODS
    //===================================

    _isEnabled: function () {
        return this._super() 
            && this.get_viewGrid().getActiveFilters().count() > 0;
    }

});
