import { __assign, __decorate, __metadata } from "tslib";
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { PropertyVO } from '../../../vo/property.vo';
import { API } from '../../../../../api';
var IdentityClientsUpdatePropertyComponent = /** @class */ (function () {
    function IdentityClientsUpdatePropertyComponent() {
        this.visible = false;
        this.visibleChange = new EventEmitter();
        this.clientId = '';
        this.properties = [];
        this.propertiesFetching = false;
        this.identityClientsUpdatePropertyCreateComponentProp = { visible: false };
    }
    IdentityClientsUpdatePropertyComponent.prototype.fetchProperties = function () {
        var _this = this;
        this.propertiesFetching = true;
        API.Identity.ClientController.Properties({
            client: this.clientId,
        }).subscribe({
            next: function (data) {
                _this.properties = PropertyVO.fromArray(data);
                _this.propertiesFetching = false;
            },
            error: function () {
                _this.propertiesFetching = false;
            },
        });
    };
    IdentityClientsUpdatePropertyComponent.prototype.deleteProperty = function (item) {
        var _this = this;
        item.deleting = true;
        API.Identity.ClientController.RemoveProperty(new API.Identity.ClientController.RemovePropertyParam(__assign(__assign({}, item), { client: this.clientId }))).subscribe({
            next: function () {
                item.deleting = false;
                _this.fetchProperties();
            },
            error: function () {
                item.deleting = false;
            },
        });
    };
    IdentityClientsUpdatePropertyComponent.prototype.openIdentityClientsUpdatePropertyCreateComponent = function () {
        this.identityClientsUpdatePropertyCreateComponentProp.visible = true;
    };
    IdentityClientsUpdatePropertyComponent.prototype.handleIdentityClientsUpdatePropertyCreateComponentOk = function () {
        this.fetchProperties();
    };
    IdentityClientsUpdatePropertyComponent.prototype.handleCancel = function () {
        this.visibleChange.emit(false);
    };
    IdentityClientsUpdatePropertyComponent.prototype.handleAfterOpen = function () {
        this.fetchProperties();
    };
    __decorate([
        Input(),
        __metadata("design:type", Boolean)
    ], IdentityClientsUpdatePropertyComponent.prototype, "visible", void 0);
    __decorate([
        Output(),
        __metadata("design:type", EventEmitter)
    ], IdentityClientsUpdatePropertyComponent.prototype, "visibleChange", void 0);
    __decorate([
        Input(),
        __metadata("design:type", String)
    ], IdentityClientsUpdatePropertyComponent.prototype, "clientId", void 0);
    IdentityClientsUpdatePropertyComponent = __decorate([
        Component({
            selector: 'kg---identity--clients--update--property',
            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]=\"\r\n    'projects/fe-ng/src/lib/page/identity/clients/update/property/identity--clients--update--property.title' | i18n\r\n  \"\r\n  [nzVisible]=\"visible\"\r\n  nzWidth=\"1198px\"\r\n>\r\n  <div>\r\n    <button\r\n      (click)=\"fetchProperties()\"\r\n      [ngStyle]=\"{\r\n        float: 'left',\r\n        marginBottom: '10px'\r\n      }\"\r\n      [nzLoading]=\"propertiesFetching\"\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)=\"openIdentityClientsUpdatePropertyCreateComponent()\"\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]=\"properties\"\r\n    [nzFrontPagination]=\"false\"\r\n    [nzLoadingIndicator]=\"loadingIndicatorTpl\"\r\n    [nzLoading]=\"propertiesFetching\"\r\n    [nzScroll]=\"{ x: '700px' }\"\r\n    [nzShowPagination]=\"false\"\r\n    [nzWidthConfig]=\"['300px', '300px', '100px']\"\r\n    nzSize=\"small\"\r\n  >\r\n    <thead>\r\n      <tr>\r\n        <th>\r\n          {{\r\n            'projects/fe-ng/src/lib/page/identity/clients/update/property/identity--clients--update--property.key'\r\n              | i18n\r\n          }}\r\n        </th>\r\n        <th>\r\n          {{\r\n            'projects/fe-ng/src/lib/page/identity/clients/update/property/identity--clients--update--property.value'\r\n              | 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.key }}</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)=\"deleteProperty(item)\"\r\n              [ngStyle]=\"{ height: '28px' }\"\r\n              [nzLoading]=\"item.deleting\"\r\n              [nzTitle]=\"'app.common.confirm-deletion' | i18n\"\r\n              class=\"btn-outline-warning\"\r\n              nz-button\r\n              nz-popconfirm\r\n              nzPlacement=\"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--property--create\r\n  (ok)=\"handleIdentityClientsUpdatePropertyCreateComponentOk()\"\r\n  [(visible)]=\"identityClientsUpdatePropertyCreateComponentProp.visible\"\r\n  [clientId]=\"clientId\"\r\n></kg---identity--clients--update--property--create>\r\n"
        })
    ], IdentityClientsUpdatePropertyComponent);
    return IdentityClientsUpdatePropertyComponent;
}());
export { IdentityClientsUpdatePropertyComponent };
//# sourceMappingURL=data:application/json;base64, 