/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { API, DEF } from '../../../../../api';
export class IdentityRoleRolesCreateComponent {
    constructor() {
        this.visible = false;
        this.visibleChange = new EventEmitter();
        this.ok = new EventEmitter();
        this.saving = false;
        this.formGroup = new FormGroup({
            description: new FormControl('', {
                validators: Validators.required,
            }),
            name: new FormControl('', {
                validators: Validators.required,
            }),
            showName: new FormControl('', {
                validators: Validators.required,
            }),
        });
    }
    /**
     * @return {?}
     */
    handleOk() {
        if (this.formGroup.invalid) {
            return;
        }
        this.saving = true;
        /** @type {?} */
        const rolePermissions = new DEF.Identity.RolePermissions(this.formGroup.value);
        /* FIXME 后台需要使用单独的 DTO */
        delete rolePermissions.id;
        delete rolePermissions.concurrencyStamp;
        delete rolePermissions.normalizedName;
        delete rolePermissions.permissionsInRole;
        API.Identity.RoleController.AddRole(undefined, rolePermissions).subscribe((/**
         * @return {?}
         */
        () => {
            this.formGroup.reset();
            this.saving = false;
            this.visibleChange.emit(false);
            this.ok.emit();
        }), (/**
         * @return {?}
         */
        () => {
            this.saving = false;
        }));
    }
    /**
     * @return {?}
     */
    handleCancel() {
        this.formGroup.reset();
        this.visibleChange.emit(false);
    }
}
IdentityRoleRolesCreateComponent.decorators = [
    { type: Component, args: [{
                selector: 'kg---identity--role--roles--create',
                template: "<nz-modal\r\n  [nzTitle]=\"'projects/fe-ng/src/lib/page/identity/role/roles/create/role-roles-create.create-role' | i18n\"\r\n  nzWidth=\"748px\"\r\n  [nzVisible]=\"visible\"\r\n  [nzMaskClosable]=\"false\"\r\n  [nzKeyboard]=\"false\"\r\n  [nzOkDisabled]=\"!formGroup.valid || saving\"\r\n  [nzOkLoading]=\"saving\"\r\n  [nzClosable]=\"!saving\"\r\n  [nzCancelDisabled]=\"saving\"\r\n  (nzOnCancel)=\"handleCancel()\"\r\n  (nzOnOk)=\"handleOk()\"\r\n>\r\n  <form nz-form [formGroup]=\"formGroup\" nzLayout=\"vertical\" [nzNoAnimation]=\"true\" (ngSubmit)=\"handleOk()\">\r\n    <div nz-row [nzGutter]=\"12\">\r\n      <div nz-col [nzSm]=\"24\" [nzMd]=\"12\">\r\n        <nz-form-item>\r\n          <nz-form-label [nzFor]=\"'name'\" [nzRequired]=\"true\"> {{ 'app.common.name' | i18n }}:</nz-form-label>\r\n          <nz-form-control nzErrorTip=\"{{ 'app.common.form.name.required' | i18n }}\">\r\n            <input nz-input [formControlName]=\"'name'\" [attr.id]=\"'name'\" />\r\n          </nz-form-control>\r\n        </nz-form-item>\r\n      </div>\r\n\r\n      <div nz-col [nzSm]=\"24\" [nzMd]=\"12\">\r\n        <nz-form-item>\r\n          <nz-form-label [nzFor]=\"'showName'\" [nzRequired]=\"true\">\r\n            {{ 'app.common.display-name' | i18n }}:\r\n          </nz-form-label>\r\n          <nz-form-control\r\n            nzErrorTip=\"{{\r\n              'projects/fe-ng/src/lib/page/identity/role/roles/create/role-roles-create.display-name-is-required'\r\n                | i18n\r\n            }}\"\r\n          >\r\n            <input nz-input [formControlName]=\"'showName'\" [attr.id]=\"'showName'\" />\r\n          </nz-form-control>\r\n        </nz-form-item>\r\n      </div>\r\n\r\n      <div nz-col [nzSm]=\"24\" [nzMd]=\"24\">\r\n        <nz-form-item class=\"mb-sm\">\r\n          <nz-form-label [nzFor]=\"'description'\" [nzRequired]=\"true\">\r\n            {{ 'app.common.description' | i18n }}:\r\n          </nz-form-label>\r\n          <nz-form-control\r\n            nzErrorTip=\"{{\r\n              'projects/fe-ng/src/lib/page/identity/role/roles/create/role-roles-create.description-is-required'\r\n                | i18n\r\n            }}\"\r\n          >\r\n            <textarea nz-input [rows]=\"3\" [formControlName]=\"'description'\" [attr.id]=\"'description'\"></textarea>\r\n          </nz-form-control>\r\n        </nz-form-item>\r\n      </div>\r\n    </div>\r\n\r\n    <button [hidden]=\"true\"></button>\r\n  </form>\r\n</nz-modal>\r\n"
            }] }
];
IdentityRoleRolesCreateComponent.propDecorators = {
    visible: [{ type: Input }],
    visibleChange: [{ type: Output }],
    ok: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    IdentityRoleRolesCreateComponent.prototype.visible;
    /** @type {?} */
    IdentityRoleRolesCreateComponent.prototype.visibleChange;
    /** @type {?} */
    IdentityRoleRolesCreateComponent.prototype.ok;
    /** @type {?} */
    IdentityRoleRolesCreateComponent.prototype.saving;
    /** @type {?} */
    IdentityRoleRolesCreateComponent.prototype.formGroup;
}
//# sourceMappingURL=data:application/json;base64, 