/**
 * @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 { pick } from 'lodash';
import { API, DEF } from '../../../../api';
var IdentityWorkingGroupCreateComponent = /** @class */ (function () {
    function IdentityWorkingGroupCreateComponent() {
        this.visible = false;
        this.visibleChange = new EventEmitter();
        this.ok = new EventEmitter();
        this.saving = false;
        this.formGroup = new FormGroup({
            workingGroupName: new FormControl('', {
                validators: Validators.required,
            }),
            workingGroupCode: new FormControl('', {
                validators: Validators.required,
            }),
        });
    }
    /**
     * @return {?}
     */
    IdentityWorkingGroupCreateComponent.prototype.handleOk = /**
     * @return {?}
     */
    function () {
        var _this = this;
        if (this.formGroup.invalid) {
            return;
        }
        this.saving = true;
        API.Identity.WorkingGroupController.AddRWorkingGroup(undefined, (/** @type {?} */ (pick(new DEF.Identity.WorkingGroup(this.formGroup.getRawValue()), ['workingGroupName', 'workingGroupCode'])))).subscribe((/**
         * @return {?}
         */
        function () {
            _this.formGroup.reset();
            _this.saving = false;
            _this.visibleChange.emit(false);
            _this.ok.emit();
        }), (/**
         * @return {?}
         */
        function () {
            _this.saving = false;
        }));
    };
    /**
     * @return {?}
     */
    IdentityWorkingGroupCreateComponent.prototype.handleCancel = /**
     * @return {?}
     */
    function () {
        this.formGroup.reset();
        this.visibleChange.emit(false);
    };
    IdentityWorkingGroupCreateComponent.decorators = [
        { type: Component, args: [{
                    selector: 'kg---identity--working-group--create',
                    template: "<nz-modal\r\n  (nzOnCancel)=\"handleCancel()\"\r\n  (nzOnOk)=\"handleOk()\"\r\n  [nzCancelDisabled]=\"saving\"\r\n  [nzClosable]=\"!saving\"\r\n  [nzKeyboard]=\"false\"\r\n  [nzMaskClosable]=\"false\"\r\n  [nzOkDisabled]=\"!formGroup.valid || saving\"\r\n  [nzOkLoading]=\"saving\"\r\n  [nzVisible]=\"visible\"\r\n  nzTitle=\"{{ 'projects/fe-ng/src/lib/page/identity/working-group/create/working-group-create.title' | i18n }}\"\r\n  nzWidth=\"748px\"\r\n>\r\n  <form (ngSubmit)=\"handleOk()\" [formGroup]=\"formGroup\" [nzNoAnimation]=\"true\" nz-form nzLayout=\"vertical\">\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]=\"'workingGroupName'\" [nzRequired]=\"true\">\r\n            {{ 'app.common.name' | i18n }}:\r\n          </nz-form-label>\r\n          <nz-form-control nzErrorTip=\"{{ 'app.common.form.name.required' | i18n }}\">\r\n            <input nz-input [formControlName]=\"'workingGroupName'\" [attr.id]=\"'workingGroupName'\" />\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]=\"'workingGroupCode'\" [nzRequired]=\"true\">\r\n            {{ 'app.common.code' | i18n }}:\r\n          </nz-form-label>\r\n          <nz-form-control nzErrorTip=\"{{ 'app.common.form.code.required' | i18n }}\">\r\n            <input nz-input [formControlName]=\"'workingGroupCode'\" [attr.id]=\"'workingGroupCode'\" />\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"
                }] }
    ];
    IdentityWorkingGroupCreateComponent.propDecorators = {
        visible: [{ type: Input }],
        visibleChange: [{ type: Output }],
        ok: [{ type: Output }]
    };
    return IdentityWorkingGroupCreateComponent;
}());
export { IdentityWorkingGroupCreateComponent };
if (false) {
    /** @type {?} */
    IdentityWorkingGroupCreateComponent.prototype.visible;
    /** @type {?} */
    IdentityWorkingGroupCreateComponent.prototype.visibleChange;
    /** @type {?} */
    IdentityWorkingGroupCreateComponent.prototype.ok;
    /** @type {?} */
    IdentityWorkingGroupCreateComponent.prototype.saving;
    /** @type {?} */
    IdentityWorkingGroupCreateComponent.prototype.formGroup;
}
//# sourceMappingURL=data:application/json;base64, 