/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd';
import { TranslateService } from '@ngx-translate/core';
import { API, DEF } from '../../../../../../api';
var IdentityClientsUpdatePropertyCreateComponent = /** @class */ (function () {
    function IdentityClientsUpdatePropertyCreateComponent(nzMessageService, translateService) {
        this.nzMessageService = nzMessageService;
        this.translateService = translateService;
        this.visible = false;
        this.visibleChange = new EventEmitter();
        this.clientId = '';
        this.ok = new EventEmitter();
        this.propertyCreating = false;
        this.formGroup = new FormGroup({
            key: new FormControl('', {
                validators: [Validators.required],
            }),
            value: new FormControl('', {
                validators: Validators.required,
            }),
        });
    }
    /**
     * @return {?}
     */
    IdentityClientsUpdatePropertyCreateComponent.prototype.handleOk = /**
     * @return {?}
     */
    function () {
        var _this = this;
        if (this.formGroup.invalid) {
            return;
        }
        this.propertyCreating = true;
        API.Identity.ClientController.SaveProperty({ client: this.clientId }, new DEF.Identity.SaveClientPropertyQuery(tslib_1.__assign({}, this.formGroup.getRawValue(), { clientId: this.clientId }))).subscribe({
            next: (/**
             * @return {?}
             */
            function () {
                _this.propertyCreating = false;
                _this.visibleChange.emit(false);
                _this.ok.emit();
                _this.nzMessageService.success(_this.translateService.instant('projects/fe-ng/src/lib/page/identity/clients/update/property/create/identity--clients--update--property--create.create_successfully'));
            }),
            error: (/**
             * @return {?}
             */
            function () {
                _this.propertyCreating = false;
            }),
        });
    };
    /**
     * @return {?}
     */
    IdentityClientsUpdatePropertyCreateComponent.prototype.handleCancel = /**
     * @return {?}
     */
    function () {
        this.visibleChange.emit(false);
    };
    /**
     * @return {?}
     */
    IdentityClientsUpdatePropertyCreateComponent.prototype.handleAfterClose = /**
     * @return {?}
     */
    function () {
        this.formGroup.reset();
    };
    IdentityClientsUpdatePropertyCreateComponent.decorators = [
        { type: Component, args: [{
                    selector: 'kg---identity--clients--update--property--create',
                    template: "<nz-modal\r\n  (nzAfterClose)=\"handleAfterClose()\"\r\n  (nzOnCancel)=\"handleCancel()\"\r\n  [nzBodyStyle]=\"{\r\n    padding: '12px 16px 6px 16px'\r\n  }\"\r\n  [nzCancelDisabled]=\"propertyCreating\"\r\n  [nzClosable]=\"!propertyCreating\"\r\n  [nzKeyboard]=\"false\"\r\n  [nzMaskClosable]=\"false\"\r\n  [nzTitle]=\"\r\n    'projects/fe-ng/src/lib/page/identity/clients/update/property/create/identity--clients--update--property--create.title'\r\n      | i18n\r\n  \"\r\n  [nzVisible]=\"visible\"\r\n  nzWidth=\"748px\"\r\n>\r\n  <form (ngSubmit)=\"handleOk()\" [formGroup]=\"formGroup\" nz-form nzLayout=\"vertical\">\r\n    <nz-form-item>\r\n      <nz-form-label [nzFor]=\"'key'\" [nzRequired]=\"true\">\r\n        {{\r\n          'projects/fe-ng/src/lib/page/identity/clients/update/property/create/identity--clients--update--property--create.key'\r\n            | i18n\r\n        }}:\r\n      </nz-form-label>\r\n      <nz-form-control [nzErrorTip]=\"'app.common.required' | i18n\">\r\n        <input nz-input [formControlName]=\"'key'\" [attr.id]=\"'key'\" />\r\n      </nz-form-control>\r\n    </nz-form-item>\r\n\r\n    <nz-form-item>\r\n      <nz-form-label [nzFor]=\"'value'\" [nzRequired]=\"true\">\r\n        {{\r\n          'projects/fe-ng/src/lib/page/identity/clients/update/property/create/identity--clients--update--property--create.value'\r\n            | i18n\r\n        }}:\r\n      </nz-form-label>\r\n      <nz-form-control [nzErrorTip]=\"'app.common.required' | i18n\">\r\n        <input nz-input [formControlName]=\"'value'\" [attr.id]=\"'value'\" />\r\n      </nz-form-control>\r\n    </nz-form-item>\r\n\r\n    <button [hidden]=\"true\"></button>\r\n  </form>\r\n\r\n  <div *nzModalFooter>\r\n    <button (click)=\"handleCancel()\" [disabled]=\"propertyCreating\" 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\r\n    <button\r\n      (click)=\"handleOk()\"\r\n      [disabled]=\"formGroup.invalid\"\r\n      [nzLoading]=\"propertyCreating\"\r\n      nz-button\r\n      nzType=\"primary\"\r\n    >\r\n      <i nz-icon nzType=\"check\" nzTheme=\"outline\"></i>\r\n      {{ 'app.common.ok' | i18n }}\r\n    </button>\r\n  </div>\r\n</nz-modal>\r\n"
                }] }
    ];
    /** @nocollapse */
    IdentityClientsUpdatePropertyCreateComponent.ctorParameters = function () { return [
        { type: NzMessageService },
        { type: TranslateService }
    ]; };
    IdentityClientsUpdatePropertyCreateComponent.propDecorators = {
        visible: [{ type: Input }],
        visibleChange: [{ type: Output }],
        clientId: [{ type: Input }],
        ok: [{ type: Output }]
    };
    return IdentityClientsUpdatePropertyCreateComponent;
}());
export { IdentityClientsUpdatePropertyCreateComponent };
if (false) {
    /** @type {?} */
    IdentityClientsUpdatePropertyCreateComponent.prototype.visible;
    /** @type {?} */
    IdentityClientsUpdatePropertyCreateComponent.prototype.visibleChange;
    /** @type {?} */
    IdentityClientsUpdatePropertyCreateComponent.prototype.clientId;
    /** @type {?} */
    IdentityClientsUpdatePropertyCreateComponent.prototype.ok;
    /** @type {?} */
    IdentityClientsUpdatePropertyCreateComponent.prototype.propertyCreating;
    /** @type {?} */
    IdentityClientsUpdatePropertyCreateComponent.prototype.formGroup;
    /**
     * @type {?}
     * @private
     */
    IdentityClientsUpdatePropertyCreateComponent.prototype.nzMessageService;
    /**
     * @type {?}
     * @private
     */
    IdentityClientsUpdatePropertyCreateComponent.prototype.translateService;
}
//# sourceMappingURL=data:application/json;base64, 