/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { Component, Input } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { NzModalRef } from 'ng-zorro-antd';
import { pick } from 'lodash';
import { API, DEF } from '../../../../api';
var IdentityWorkingGroupUpdateComponent = /** @class */ (function () {
    //endregion
    //region Constructor
    function IdentityWorkingGroupUpdateComponent(nzModalRef) {
        this.nzModalRef = nzModalRef;
        //endregion
        //region Field
        this.saving = false;
        this.formGroup = new FormGroup({
            workingGroupName: new FormControl('', {
                validators: Validators.required,
            }),
            workingGroupCode: new FormControl({ value: '', disabled: true }),
        });
        this.cities = [];
    }
    //endregion
    //region LifeCycle
    //endregion
    //region LifeCycle
    /**
     * @return {?}
     */
    IdentityWorkingGroupUpdateComponent.prototype.ngOnInit = 
    //endregion
    //region LifeCycle
    /**
     * @return {?}
     */
    function () {
        this.formGroup.patchValue(this.record);
    };
    //endregion
    //region Method
    //endregion
    //region Method
    /**
     * @return {?}
     */
    IdentityWorkingGroupUpdateComponent.prototype.handleOk = 
    //endregion
    //region Method
    /**
     * @return {?}
     */
    function () {
        var _this = this;
        if (this.formGroup.invalid) {
            return;
        }
        this.saving = true;
        /** @type {?} */
        var workingGroup = (/** @type {?} */ (pick(new DEF.Identity.WorkingGroup(this.formGroup.getRawValue()), [
            'workingGroupName',
            'workingGroupCode',
        ])));
        API.Identity.WorkingGroupController.UpdateWorkingGroup(undefined, workingGroup).subscribe((/**
         * @return {?}
         */
        function () {
            _this.formGroup.reset();
            _this.saving = false;
            _this.nzModalRef.close(tslib_1.__assign({}, _this.record, workingGroup));
        }), (/**
         * @return {?}
         */
        function () {
            _this.saving = false;
        }));
    };
    /**
     * @return {?}
     */
    IdentityWorkingGroupUpdateComponent.prototype.handleCancel = /**
     * @return {?}
     */
    function () {
        this.nzModalRef.destroy();
    };
    IdentityWorkingGroupUpdateComponent.decorators = [
        { type: Component, args: [{
                    selector: 'kg---identity--working-group--update',
                    template: "<div class=\"modal-header\">\r\n  <div class=\"modal-title\">\r\n    {{ 'projects/fe-ng/src/lib/page/identity/working-group/update/working-group-update.title' | i18n }}\r\n  </div>\r\n</div>\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 [attr.id]=\"'workingGroupName'\" [formControlName]=\"'workingGroupName'\" nz-input />\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'\"> {{ 'app.common.code' | i18n }}: </nz-form-label>\r\n        <nz-form-control nzErrorTip=\"{{ 'app.common.form.code.required' | i18n }}\">\r\n          <input [attr.id]=\"'workingGroupCode'\" [formControlName]=\"'workingGroupCode'\" nz-input />\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\r\n<div class=\"modal-footer\">\r\n  <button (click)=\"handleCancel()\" [disabled]=\"saving\" [nzType]=\"'default'\" nz-button>\r\n    {{ 'app.common.cancel' | i18n }}\r\n  </button>\r\n\r\n  <button\r\n    (click)=\"handleOk()\"\r\n    [disabled]=\"!formGroup.valid || saving\"\r\n    [nzLoading]=\"saving\"\r\n    [nzType]=\"'primary'\"\r\n    nz-button\r\n  >\r\n    {{ 'app.common.save' | i18n }}\r\n  </button>\r\n</div>\r\n"
                }] }
    ];
    /** @nocollapse */
    IdentityWorkingGroupUpdateComponent.ctorParameters = function () { return [
        { type: NzModalRef }
    ]; };
    IdentityWorkingGroupUpdateComponent.propDecorators = {
        record: [{ type: Input }]
    };
    return IdentityWorkingGroupUpdateComponent;
}());
export { IdentityWorkingGroupUpdateComponent };
if (false) {
    /** @type {?} */
    IdentityWorkingGroupUpdateComponent.prototype.record;
    /** @type {?} */
    IdentityWorkingGroupUpdateComponent.prototype.saving;
    /** @type {?} */
    IdentityWorkingGroupUpdateComponent.prototype.formGroup;
    /** @type {?} */
    IdentityWorkingGroupUpdateComponent.prototype.cities;
    /**
     * @type {?}
     * @private
     */
    IdentityWorkingGroupUpdateComponent.prototype.nzModalRef;
}
//# sourceMappingURL=data:application/json;base64, 