"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DateFloatingFilter = void 0;
var aurelia_framework_1 = require("aurelia-framework");
var aurelia_i18n_1 = require("aurelia-i18n");
var base_floating_filter_1 = __importDefault(require("../base-floating-filter"));
var data_context_1 = require("../../../data/data-context");
var date_filter_helper_1 = require("./date-filter-helper");
var DateFloatingFilter = (function (_super) {
    __extends(DateFloatingFilter, _super);
    function DateFloatingFilter() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DateFloatingFilter.prototype.init = function (params) {
        var _this = this;
        this.filterHelper = new date_filter_helper_1.DateFilterHelper(function (newVal, oldVal) { return _this._propertyChangedHelper(newVal, oldVal); });
        _super.prototype.init.call(this, params);
        this.i18n = aurelia_framework_1.Container.instance.get(aurelia_i18n_1.I18N);
        this.datacontext = aurelia_framework_1.Container.instance.get(data_context_1.Datacontext);
        this.DROPDOWN_NAME = this.getModelAsString();
        this.DROPDOWN_ICON = 'digi-calendar';
        _super.prototype.setupGui.call(this);
    };
    DateFloatingFilter.prototype._propertyChangedHelper = function (newVal, oldVal) {
        if (!this.firstTime) {
            this.DROPDOWN_NAME = this.getModelAsString();
            this.setModel();
        }
    };
    DateFloatingFilter.prototype.setModel = function () {
        var _this = this;
        this.params.parentFilterInstance(function (instance) {
            instance.setModel(_this.getModel());
        });
    };
    DateFloatingFilter.prototype.getModelAsString = function () {
        return this.filterHelper.getModelAsString();
    };
    DateFloatingFilter.prototype.getModel = function () {
        return this.filterHelper.getModel('greaterThan');
    };
    DateFloatingFilter.prototype.setupContentGui = function () {
        return this.getFilter();
    };
    DateFloatingFilter.prototype.setupContentGuiSideFilter = function () {
        return this.getFilter();
    };
    DateFloatingFilter.prototype.getFilter = function () {
        return this.filterHelper.getFilter();
    };
    DateFloatingFilter.prototype.isFilterActive = function () {
        return this.filterHelper.isFilterActive();
    };
    DateFloatingFilter.prototype.resetFilter = function () {
        this.filterHelper.resetFilter();
    };
    DateFloatingFilter.prototype.onParentModelChanged = function (parentModel, filterChangedEvent) {
        if (parentModel != null) {
            var datePreFilter = parentModel.datePreFilter;
            if (datePreFilter != null && datePreFilter != this.filterHelper.selectedDatePreFilter) {
                this.filterHelper.selectedDatePreFilter = datePreFilter;
            }
            else {
                this.filterHelper.fromDate = parentModel.dateFrom;
                this.filterHelper.toDate = parentModel.dateTo;
            }
            this.filterHelper.isDateNullable = parentModel.isDateNullable;
            this.filterHelper.isLastMonth = parentModel.isLastMonth;
            this.filterHelper.isLastWeek = parentModel.isLastWeek;
            this.filterHelper.isThisWeek = parentModel.isThisWeek;
            this.filterHelper.isThisMonth = parentModel.isThisMonth;
            this.filterHelper.isNextWeek = parentModel.isNextWeek;
            this.filterHelper.isNextMonth = parentModel.isNextMonth;
            this.DROPDOWN_NAME = this.getModelAsString();
        }
        else {
            this.resetFilter();
        }
    };
    return DateFloatingFilter;
}(base_floating_filter_1.default));
exports.DateFloatingFilter = DateFloatingFilter;

//# sourceMappingURL=date-floating-filter.js.map
