/// 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);

        let service = new PDJS.Services.Views.ViewFilterService();

        service.clearInline({
            viewStateId: this.get_viewStateId(),
            success: (e) => {
                this.get_viewGrid().refresh();
            }
        });

    },

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

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

});
