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

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

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

    setDefaults: function () {
        this._super();
        this.props("id", "column/remove-filter");
        this.props("enabled", true);
        this.props("label", "Remove Filter");
        this.props("tooltip", "Remove Filter");
    },

    setState: function (state) {
        this._super(state);
        this.props("visible", this._isFiltered());
    },

    execute: function (e) {
        this._super(e);
        
        let service = new PDJS.Services.Views.ViewFilterService();

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

    },

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

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

});