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.clientId = '';
        this.identityClientsUpdatePropertyCreateComponentProp = { visible: false };
        this.properties = [];
        this.propertiesFetching = false;
        this.visible = false;
        this.visibleChange = new EventEmitter();
    }
    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.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.handleAfterOpen = function () {
        this.fetchProperties();
    };
    IdentityClientsUpdatePropertyComponent.prototype.handleCancel = function () {
        this.visibleChange.emit(false);
    };
    IdentityClientsUpdatePropertyComponent.prototype.handleIdentityClientsUpdatePropertyCreateComponentOk = function () {
        this.fetchProperties();
    };
    IdentityClientsUpdatePropertyComponent.prototype.openIdentityClientsUpdatePropertyCreateComponent = function () {
        this.identityClientsUpdatePropertyCreateComponentProp.visible = true;
    };
    __decorate([
        Input(),
        __metadata("design:type", String)
    ], IdentityClientsUpdatePropertyComponent.prototype, "clientId", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Boolean)
    ], IdentityClientsUpdatePropertyComponent.prototype, "visible", void 0);
    __decorate([
        Output(),
        __metadata("design:type", EventEmitter)
    ], IdentityClientsUpdatePropertyComponent.prototype, "visibleChange", void 0);
    IdentityClientsUpdatePropertyComponent = __decorate([
        Component({
            selector: 'kg---identity--clients--update--property',
            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/property/identity--clients--update--property.title' | i18n\"\n  [nzVisible]=\"visible\"\n  nzWidth=\"1198px\"\n>\n  <div>\n    <button\n      (click)=\"fetchProperties()\"\n      [ngStyle]=\"{\n        float: 'left',\n        marginBottom: '10px'\n      }\"\n      [nzLoading]=\"propertiesFetching\"\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)=\"openIdentityClientsUpdatePropertyCreateComponent()\"\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]=\"properties\"\n    [nzFrontPagination]=\"false\"\n    [nzLoadingIndicator]=\"loadingIndicatorTpl\"\n    [nzLoading]=\"propertiesFetching\"\n    [nzScroll]=\"{ x: '700px' }\"\n    [nzShowPagination]=\"false\"\n    [nzWidthConfig]=\"['300px', '300px', '100px']\"\n    nzSize=\"small\"\n  >\n    <thead>\n      <tr>\n        <th>\n          {{ 'projects/fe-ng/src/lib/page/identity/clients/update/property/identity--clients--update--property.key' | i18n }}\n        </th>\n        <th>\n          {{ 'projects/fe-ng/src/lib/page/identity/clients/update/property/identity--clients--update--property.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.key }}</td>\n\n          <td [nzBreakWord]=\"true\">{{ item.value }}</td>\n\n          <td [nzRight]=\"'0px'\" class=\"text-right\">\n            <button\n              (nzOnConfirm)=\"deleteProperty(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--property--create\n  (ok)=\"handleIdentityClientsUpdatePropertyCreateComponentOk()\"\n  [(visible)]=\"identityClientsUpdatePropertyCreateComponentProp.visible\"\n  [clientId]=\"clientId\"\n></kg---identity--clients--update--property--create>\n"
        })
    ], IdentityClientsUpdatePropertyComponent);
    return IdentityClientsUpdatePropertyComponent;
}());
export { IdentityClientsUpdatePropertyComponent };
//# sourceMappingURL=data:application/json;base64, 