"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 __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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CountryList = void 0;
var aurelia_router_1 = require("aurelia-router");
var aurelia_i18n_1 = require("aurelia-i18n");
var aurelia_framework_1 = require("aurelia-framework");
var service_base_1 = require("../../data/service-base");
var common_model_1 = require("../../model/common-model");
var list_view_model_base_1 = require("../list-view-model-base");
var grid_helper_1 = require("../../resources/elements/ag-grid/grid-helper");
var custom_logger_1 = require("../../modules/custom-logger");
var constants_1 = require("../../constants/constants");
var CountryList = exports.CountryList = (function (_super) {
    __extends(CountryList, _super);
    function CountryList(router, logger, i18n) {
        var _this = _super.call(this, router, logger, new service_base_1.ServiceBase(constants_1.EntityTypeNames.Country)) || this;
        _this.ressourceName = common_model_1.LocalityRessourceName;
        return _this;
    }
    CountryList.prototype.addLocality = function () {
        this.navigateTo(this.routePrefix + common_model_1.Various.NewId);
    };
    CountryList.prototype.getDetailsUrl = function (self, entity) {
        if (entity && entity.id) {
            return this.routePrefix + entity.id;
        }
        return null;
    };
    Object.defineProperty(CountryList.prototype, "routePrefix", {
        get: function () {
            return this.router.routes.find(function (x) { return x.name == 'country-detail'; }).href.replace('' + common_model_1.Various.NewId, '');
        },
        enumerable: false,
        configurable: true
    });
    CountryList.prototype.getDataGridColumns = function () {
        var isSelectedCol = grid_helper_1.GridHelper.getSelectedColDef(this);
        var defs = [
            isSelectedCol,
            {
                headerName: this.i18n.tr("common:country.code"),
                field: "code",
                type: common_model_1.FieldType.String
            },
            {
                headerName: this.i18n.tr("common:country.region"),
                field: "region",
                type: common_model_1.FieldType.String
            },
            {
                headerName: this.i18n.tr("common:country.isFavorite"),
                field: "isFavorite",
                type: common_model_1.FieldType.Boolean
            },
            {
                headerName: this.i18n.tr("common:country.isEU"),
                field: "isEU",
                type: common_model_1.FieldType.Boolean
            },
            {
                headerName: this.i18n.tr("common:locality.name") + this.i18n.tr("general.inBracketsFR"),
                field: "name.lang1",
                type: common_model_1.FieldType.String
            },
            {
                headerName: this.i18n.tr("common:locality.name") + this.i18n.tr("general.inBracketsNL"),
                field: "name.lang2",
                type: common_model_1.FieldType.String
            },
            {
                headerName: this.i18n.tr("common:locality.name") + this.i18n.tr("general.inBracketsEN"),
                field: "name.lang3",
                type: common_model_1.FieldType.String
            },
            {
                headerName: this.i18n.tr("general.createdTime"),
                field: "createdTime",
                hide: true,
                type: common_model_1.FieldType.Date
            },
            {
                headerName: this.i18n.tr("general.updatedTime"),
                field: "updatedTime",
                hide: true,
                type: common_model_1.FieldType.Date
            },
            {
                headerName: this.i18n.tr("general.createdByFullName"),
                field: "createdByFullName",
                hide: true,
                type: common_model_1.FieldType.String
            },
            {
                headerName: this.i18n.tr("general.updatedByFullName"),
                field: "updatedByFullName",
                hide: true,
                type: common_model_1.FieldType.String
            }
        ];
        return defs;
    };
    CountryList.prototype.importCountries = function () {
        this.router.navigateToRoute('import-data', { "context": "country", "errorView": "/node_modules/digiwall-lib/src/vm/countries/country-error.html" });
    };
    CountryList = __decorate([
        aurelia_framework_1.autoinject,
        __metadata("design:paramtypes", [aurelia_router_1.Router, custom_logger_1.CustomLogger, aurelia_i18n_1.I18N])
    ], CountryList);
    return CountryList;
}(list_view_model_base_1.ListViewModelBase));

//# sourceMappingURL=country-list.js.map
