"use strict";
Vue.component("costom-text-column-filter", {
    template: "\n        <div class=\"ibiz-ag-filter text-filter\">\n            <input type=\"text\" :value=\"value\" @change=\"valueChanged($event)\"/>\n            <Icon :class=\"{selectClear: value != ''}\" type=\"ios-close-circle\" @click=\"clear\"/>\n        </div>\n    ",
    data: function () {
        return {
            value: "",
            grid: null,
            searchName: ''
        };
    },
    beforeMount: function () {
        var column = this.params.column.colDef;
        this.searchName = column.searchName;
        this.grid = this.params.grid;
    },
    mounted: function () {
        var _this = this;
        this.$nextTick(function () {
            if (_this.grid && _this.grid.colFilterParams) {
                _this.value = _this.grid.colFilterParams[_this.searchName];
                if (_this.value) {
                    _this.params.onFloatingFilterChanged({
                        model: _this.buildModel()
                    });
                }
            }
        });
    },
    methods: {
        valueChanged: function (event) {
            this.value = event.target.value;
            this.params.onFloatingFilterChanged({
                model: this.buildModel()
            });
        },
        // onParentModelChanged(parentModel) {
        // 	if(parentModel) {
        // 		this.value = !parentModel ? "" : parentModel.filter
        // 	} else {
        //         if(this.value) {
        //             setTimeout(() => {
        //                 this.params.onFloatingFilterChanged({
        //                     model: this.buildModel()
        //                 });
        //             }, 50)
        //         }
        //     }
        // },
        clear: function () {
            this.value = "";
            this.params.onFloatingFilterChanged({
                model: this.buildModel()
            });
        },
        buildModel: function () {
            return {
                filterType: 'text',
                type: 'contains',
                filter: this.value ? this.value : 'undefined'
            };
        }
    }
});
