"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = require("@angular/core");
var lodash_1 = require("lodash");
var typescript_angular_utilities_1 = require("typescript-angular-utilities");
var __genericSearchFilter = typescript_angular_utilities_1.services.genericSearchFilter;
var dataSourceBuilderOld_service_1 = require("./dataSourceBuilderOld.service");
var filterBuilderOld_service_1 = require("./filterBuilderOld.service");
var CardContainerTypeOld;
(function (CardContainerTypeOld) {
    CardContainerTypeOld[CardContainerTypeOld["old"] = 0] = "old";
    CardContainerTypeOld[CardContainerTypeOld["standard"] = 1] = "standard";
    CardContainerTypeOld[CardContainerTypeOld["selectable"] = 2] = "selectable";
})(CardContainerTypeOld = exports.CardContainerTypeOld || (exports.CardContainerTypeOld = {}));
var CardContainerBuilderOld = (function () {
    function CardContainerBuilderOld(injector, dataSourceBuilder, filterBuilder) {
        this.injector = injector;
        this.dataSource = lodash_1.clone(dataSourceBuilder);
        this.dataSource.init(this);
        this.filters = lodash_1.clone(filterBuilder);
        this.filters.init(this);
        this._columns = [];
    }
    CardContainerBuilderOld.prototype.useSearch = function (tokenized) {
        var factory = this.injector.get(__genericSearchFilter.GenericSearchFilterFactory);
        this._searchFilter = factory.getInstance(tokenized);
        return this._searchFilter;
    };
    CardContainerBuilderOld.prototype.searchFilter = function (filter) {
        this._searchFilter = filter;
        return this._searchFilter;
    };
    CardContainerBuilderOld.prototype.usePaging = function () {
        this._paging = true;
    };
    CardContainerBuilderOld.prototype.addColumn = function (column) {
        this._columns.push(column);
    };
    CardContainerBuilderOld.prototype.findColumnByFieldName = function (fieldName) {
        return this._columns.find(function (column) { return column.fieldName === fieldName; });
    };
    CardContainerBuilderOld.prototype.useClickableCards = function () {
        this._clickableCards = true;
    };
    CardContainerBuilderOld.prototype.usePermanentFooters = function () {
        this._permanentFooters = true;
    };
    CardContainerBuilderOld.prototype.useSelection = function () {
        this._selectableCards = true;
    };
    CardContainerBuilderOld.prototype.renderFilters = function () {
        this._renderFilters = true;
    };
    CardContainerBuilderOld.prototype.saveWhenInvalid = function () {
        this._saveWhenInvalid = true;
    };
    Object.defineProperty(CardContainerBuilderOld.prototype, "disableSelection", {
        set: function (value) {
            if (!this._selectableCards) {
                this.useSelection();
            }
            this._disableSelection = value;
        },
        enumerable: true,
        configurable: true
    });
    CardContainerBuilderOld.prototype.setCardContainerProperties = function (cardContainer) {
        if (this._searchFilter != null) {
            this._filters.push(this._searchFilter);
        }
        cardContainer.dataSource = this._dataSource;
        cardContainer.filters = this._filters;
        cardContainer.searchFilter = this._searchFilter;
        cardContainer.paging = this._paging;
        cardContainer.columns = this._columns;
        cardContainer.clickableCards = this._clickableCards;
        cardContainer.maxColumnSorts = this.maxColumnSorts;
        cardContainer.permanentFooters = this._permanentFooters;
        cardContainer.saveWhenInvalid = this._saveWhenInvalid;
        // cardContainer.renderFilters = this._renderFilters;
        // if (cardContainer.type === CardContainerType.selectable) {
        // 	const selectableCardContainer: SelectableCardContainerComponent<any> = <SelectableCardContainerComponent<any>>cardContainer;
        // 	selectableCardContainer.disableSelection = this._disableSelection;
        // }
        if (cardContainer.type === CardContainerTypeOld.old) {
            var cardContainerOld = cardContainer;
            cardContainerOld.selectableCards = this._selectableCards;
            cardContainerOld.disableSelection = this._disableSelection;
            cardContainerOld.renderFilters = this._renderFilters;
            cardContainerOld.saveWhenInvalid = this._saveWhenInvalid;
            cardContainerOld.containerData = this.containerData;
            if (cardContainerOld.cardController == null) {
                cardContainerOld.cardController = this.cardController;
            }
            if (cardContainerOld.cardControllerAs == null) {
                cardContainerOld.cardControllerAs = this.cardControllerAs;
            }
            if (cardContainerOld.cardAs == null) {
                cardContainerOld.cardAs = this.cardAs;
            }
        }
    };
    return CardContainerBuilderOld;
}());
CardContainerBuilderOld = __decorate([
    core_1.Injectable(),
    __metadata("design:paramtypes", [core_1.Injector,
        dataSourceBuilderOld_service_1.DataSourceBuilderOld,
        filterBuilderOld_service_1.FilterBuilderOld])
], CardContainerBuilderOld);
exports.CardContainerBuilderOld = CardContainerBuilderOld;
//# sourceMappingURL=data:application/json;base64, 