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);
};
import { Router } from 'aurelia-router';
import { I18N } from 'aurelia-i18n';
import { autoinject } from "aurelia-framework";
import { ServiceBase } from "../../data/service-base";
import { FieldType, LocalityRessourceName, Various } from "../../model/common-model";
import { ListViewModelBase } from "../list-view-model-base";
import { GridHelper } from '../../resources/elements/ag-grid/grid-helper';
import { CustomLogger } from '../../modules/custom-logger';
import { EntityTypeNames } from '../../constants/constants';
export var LocalityList = (function (_super) {
    __extends(LocalityList, _super);
    function LocalityList(router, logger, i18n) {
        var _this = _super.call(this, router, logger, new ServiceBase(EntityTypeNames.Locality)) || this;
        _this.ressourceName = LocalityRessourceName;
        _this.service.gridDataSource.expands = ['country', 'commune'];
        return _this;
    }
    LocalityList.prototype.addLocality = function () {
        this.navigateTo(this.routePrefix + Various.NewId);
    };
    LocalityList.prototype.getDetailsUrl = function (self, entity) {
        if (entity && entity.id) {
            return this.routePrefix + entity.id;
        }
        return null;
    };
    Object.defineProperty(LocalityList.prototype, "routePrefix", {
        get: function () {
            return this.router.routes.find(function (x) { return x.name == 'locality-detail'; }).href.replace('' + Various.NewId, '');
        },
        enumerable: false,
        configurable: true
    });
    LocalityList.prototype.getDataGridColumns = function () {
        var isSelectedCol = GridHelper.getSelectedColDef(this);
        var defs = [
            isSelectedCol,
            {
                headerName: this.i18n.tr("locality.zipCode"),
                field: "zipCode",
                type: FieldType.String
            },
            {
                headerName: this.i18n.tr("locality.provincieName"),
                field: "provincieName",
                type: FieldType.String
            },
            {
                headerName: this.i18n.tr("locality.isSubCommune"),
                field: "isSubCommune",
                type: FieldType.Boolean
            },
            {
                headerName: this.i18n.tr("locality.name") + this.i18n.tr("general.inBracketsFR"),
                field: "name.lang1",
                type: FieldType.String
            },
            {
                headerName: this.i18n.tr("locality.name") + this.i18n.tr("general.inBracketsNL"),
                field: "name.lang2",
                type: FieldType.String
            },
            {
                headerName: this.i18n.tr("locality.name") + this.i18n.tr("general.inBracketsEN"),
                field: "name.lang3",
                type: FieldType.String
            },
            {
                headerName: this.i18n.tr("country.country"),
                field: "country.name._translation",
                type: FieldType.String
            },
            {
                headerName: this.i18n.tr("locality.communeId"),
                field: "commune.name._translation",
                type: FieldType.String
            },
            {
                headerName: this.i18n.tr("general.createdTime"),
                field: "createdTime",
                hide: true,
                type: FieldType.Date
            },
            {
                headerName: this.i18n.tr("general.updatedTime"),
                field: "updatedTime",
                hide: true,
                type: FieldType.Date
            },
            {
                headerName: this.i18n.tr("general.createdByFullName"),
                field: "createdByFullName",
                hide: true,
                type: FieldType.String
            },
            {
                headerName: this.i18n.tr("general.updatedByFullName"),
                field: "updatedByFullName",
                hide: true,
                type: FieldType.String
            }
        ];
        return defs;
    };
    LocalityList.prototype.importLocalities = function () {
        this.router.navigateToRoute('import-data', { "context": "locality", "errorView": "/node_modules/digiwall-lib/src/vm/localities/locality-error.html" });
    };
    LocalityList = __decorate([
        autoinject,
        __metadata("design:paramtypes", [Router, CustomLogger, I18N])
    ], LocalityList);
    return LocalityList;
}(ListViewModelBase));

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