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