import { __assign, __decorate, __metadata } from "tslib";
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ClaimVO } from '../../../vo/claim.vo';
import { API } from '../../../../../api';
var IdentityClientsUpdateClaimComponent = /** @class */ (function () {
    function IdentityClientsUpdateClaimComponent() {
        this.claims = [];
        this.claimsFetching = false;
        this.clientId = '';
        this.identityClientsUpdateClaimCreateComponentProp = { visible: false };
        this.visible = false;
        this.visibleChange = new EventEmitter();
    }
    IdentityClientsUpdateClaimComponent.prototype.deleteClaim = function (item) {
        var _this = this;
        item.deleting = true;
        API.Identity.ClientController.RemoveClaim(new API.Identity.ClientController.RemoveClaimParam(__assign(__assign({}, item), { client: this.clientId }))).subscribe({
            next: function () {
                item.deleting = false;
                _this.fetchClaims();
            },
            error: function () {
                item.deleting = false;
            },
        });
    };
    IdentityClientsUpdateClaimComponent.prototype.fetchClaims = function () {
        var _this = this;
        this.claimsFetching = true;
        API.Identity.ClientController.Claims({
            client: this.clientId,
        }).subscribe({
            next: function (data) {
                _this.claims = ClaimVO.fromArray(data);
                _this.claimsFetching = false;
            },
            error: function () {
                _this.claimsFetching = false;
            },
        });
    };
    IdentityClientsUpdateClaimComponent.prototype.handleAfterOpen = function () {
        this.fetchClaims();
    };
    IdentityClientsUpdateClaimComponent.prototype.handleCancel = function () {
        this.visibleChange.emit(false);
    };
    IdentityClientsUpdateClaimComponent.prototype.handleIdentityClientsUpdateClaimCreateComponentOk = function () {
        this.fetchClaims();
    };
    IdentityClientsUpdateClaimComponent.prototype.openIdentityClientsUpdateClaimCreateComponent = function () {
        this.identityClientsUpdateClaimCreateComponentProp.visible = true;
    };
    __decorate([
        Input(),
        __metadata("design:type", String)
    ], IdentityClientsUpdateClaimComponent.prototype, "clientId", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Boolean)
    ], IdentityClientsUpdateClaimComponent.prototype, "visible", void 0);
    __decorate([
        Output(),
        __metadata("design:type", EventEmitter)
    ], IdentityClientsUpdateClaimComponent.prototype, "visibleChange", void 0);
    IdentityClientsUpdateClaimComponent = __decorate([
        Component({
            selector: 'kg---identity--clients--update--claim',
            template: "<nz-modal\n  (nzAfterOpen)=\"handleAfterOpen()\"\n  (nzOnCancel)=\"handleCancel()\"\n  [nzBodyStyle]=\"{\n    padding: '12px 16px 6px 16px'\n  }\"\n  [nzKeyboard]=\"false\"\n  [nzMaskClosable]=\"false\"\n  [nzTitle]=\"'projects/fe-ng/src/lib/page/identity/clients/update/claim/identity--clients--update--claim.title' | i18n\"\n  [nzVisible]=\"visible\"\n  nzWidth=\"1198px\"\n>\n  <div>\n    <button\n      (click)=\"fetchClaims()\"\n      [ngStyle]=\"{\n        float: 'left',\n        marginBottom: '10px'\n      }\"\n      [nzLoading]=\"claimsFetching\"\n      class=\"btn-outline-primary\"\n      nz-button\n    >\n      <i nz-icon nzTheme=\"outline\" nzType=\"reload\"></i>\n      {{ 'app__refresh' | i18n }}\n    </button>\n\n    <button\n      (click)=\"openIdentityClientsUpdateClaimCreateComponent()\"\n      [ngStyle]=\"{\n        float: 'left',\n        marginBottom: '10px'\n      }\"\n      nz-button\n      nzType=\"primary\"\n    >\n      <i nz-icon nzTheme=\"outline\" nzType=\"plus-circle\"></i>\n      {{ 'app__create' | i18n }}\n    </button>\n  </div>\n\n  <nz-table\n    #table\n    [ngStyle]=\"{ marginTop: '10px', clear: 'both' }\"\n    [nzData]=\"claims\"\n    [nzFrontPagination]=\"false\"\n    [nzLoadingIndicator]=\"loadingIndicatorTpl\"\n    [nzLoading]=\"claimsFetching\"\n    [nzScroll]=\"{ x: '600px' }\"\n    [nzShowPagination]=\"false\"\n    [nzWidthConfig]=\"['200px', '300px', '100px']\"\n    nzSize=\"small\"\n  >\n    <thead>\n      <tr>\n        <th>\n          {{ 'projects/fe-ng/src/lib/page/identity/clients/update/claim/identity--clients--update--claim.type' | i18n }}\n        </th>\n        <th>\n          {{ 'projects/fe-ng/src/lib/page/identity/clients/update/claim/identity--clients--update--claim.value' | i18n }}\n        </th>\n        <th [nzRight]=\"'0px'\" class=\"text-center\">{{ 'app__action' | i18n }}</th>\n      </tr>\n    </thead>\n\n    <tbody>\n      <ng-container *ngFor=\"let item of table.data\">\n        <tr>\n          <td [nzBreakWord]=\"true\">{{ item.type }}</td>\n\n          <td [nzBreakWord]=\"true\">{{ item.value }}</td>\n\n          <td [nzRight]=\"'0px'\" class=\"text-right\">\n            <button\n              (nzOnConfirm)=\"deleteClaim(item)\"\n              [ngStyle]=\"{ height: '28px' }\"\n              [nzLoading]=\"item.deleting\"\n              [nzPopconfirmTitle]=\"'app__confirm_delete_message' | i18n\"\n              class=\"btn-outline-warning\"\n              nz-button\n              nz-popconfirm\n              nzPopconfirmPlacement=\"topRight\"\n              nzSize=\"small\"\n            >\n              <i nz-icon nzTheme=\"outline\" nzType=\"delete\"></i>\n              {{ 'app__delete' | i18n }}\n            </button>\n          </td>\n        </tr>\n      </ng-container>\n    </tbody>\n\n    <ng-template #loadingIndicatorTpl>\n      <i\n        [ngStyle]=\"{\n          fontSize: '24px',\n          marginTop: '10px'\n        }\"\n        nz-icon\n        nzTheme=\"outline\"\n        nzType=\"loading\"\n      ></i>\n    </ng-template>\n  </nz-table>\n\n  <div *nzModalFooter>\n    <button (click)=\"handleCancel()\" nz-button nzType=\"default\">\n      <i nz-icon nzTheme=\"outline\" nzType=\"stop\"></i>\n      {{ 'app__cancel' | i18n }}\n    </button>\n  </div>\n</nz-modal>\n\n<kg---identity--clients--update--claim--create\n  (ok)=\"handleIdentityClientsUpdateClaimCreateComponentOk()\"\n  [(visible)]=\"identityClientsUpdateClaimCreateComponentProp.visible\"\n  [clientId]=\"clientId\"\n></kg---identity--clients--update--claim--create>\n"
        })
    ], IdentityClientsUpdateClaimComponent);
    return IdentityClientsUpdateClaimComponent;
}());
export { IdentityClientsUpdateClaimComponent };
//# sourceMappingURL=data:application/json;base64, 