/**
 * @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 { API, DEF } from '../../../../../api';
import { SettingsService } from '@delon/theme';
var IdentityRoleRolesUpdateComponent = /** @class */ (function () {
    function IdentityRoleRolesUpdateComponent(nzModalRef, settingService) {
        this.nzModalRef = nzModalRef;
        this.settingService = settingService;
        this.saving = false;
        this.formGroup = new FormGroup({
            description: new FormControl('', {
                validators: Validators.required,
            }),
            name: new FormControl({ value: '', disabled: true }),
            showName: new FormControl('', {
                validators: Validators.required,
            }),
        });
    }
    /**
     * @return {?}
     */
    IdentityRoleRolesUpdateComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.formGroup.patchValue(this.record);
    };
    /**
     * @return {?}
     */
    IdentityRoleRolesUpdateComponent.prototype.handleOk = /**
     * @return {?}
     */
    function () {
        var _this = this;
        if (this.formGroup.invalid) {
            return;
        }
        this.saving = true;
        /** @type {?} */
        var rolePermissions = new DEF.Iwms.RolePermissions(tslib_1.__assign({}, this.formGroup.getRawValue(), { warehouse: this.settingService.user.sub }));
        API.Iwms.RoleController.UpdateRole(undefined, rolePermissions).subscribe((/**
         * @return {?}
         */
        function () {
            _this.formGroup.reset();
            _this.saving = false;
            _this.nzModalRef.close(tslib_1.__assign({}, _this.record, rolePermissions));
        }), (/**
         * @return {?}
         */
        function () {
            _this.saving = false;
        }));
    };
    /**
     * @return {?}
     */
    IdentityRoleRolesUpdateComponent.prototype.handleCancel = /**
     * @return {?}
     */
    function () {
        this.nzModalRef.destroy();
    };
    IdentityRoleRolesUpdateComponent.decorators = [
        { type: Component, args: [{
                    selector: 'kg---identity--role--roles--update',
                    template: "<div class=\"modal-header\">\r\n  <div class=\"modal-title\">\r\n    {{ 'projects/fe-ng/src/lib/page/identity/role/roles/update/role-roles-update.update-role' | i18n }}\r\n  </div>\r\n</div>\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'\"> {{ 'app.common.name' | i18n }}: </nz-form-label>\r\n        <nz-form-control>\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\r\n<div class=\"modal-footer\">\r\n  <button nz-button [nzType]=\"'default'\" [disabled]=\"saving\" (click)=\"handleCancel()\">\r\n    {{ 'app.common.cancel' | i18n }}\r\n  </button>\r\n  <button\r\n    nz-button\r\n    [nzType]=\"'primary'\"\r\n    [nzLoading]=\"saving\"\r\n    [disabled]=\"!formGroup.valid || saving\"\r\n    (click)=\"handleOk()\"\r\n  >\r\n    {{ 'app.common.save' | i18n }}\r\n  </button>\r\n</div>\r\n"
                }] }
    ];
    /** @nocollapse */
    IdentityRoleRolesUpdateComponent.ctorParameters = function () { return [
        { type: NzModalRef },
        { type: SettingsService }
    ]; };
    IdentityRoleRolesUpdateComponent.propDecorators = {
        record: [{ type: Input }]
    };
    return IdentityRoleRolesUpdateComponent;
}());
export { IdentityRoleRolesUpdateComponent };
if (false) {
    /** @type {?} */
    IdentityRoleRolesUpdateComponent.prototype.record;
    /** @type {?} */
    IdentityRoleRolesUpdateComponent.prototype.saving;
    /** @type {?} */
    IdentityRoleRolesUpdateComponent.prototype.formGroup;
    /**
     * @type {?}
     * @private
     */
    IdentityRoleRolesUpdateComponent.prototype.nzModalRef;
    /**
     * @type {?}
     * @private
     */
    IdentityRoleRolesUpdateComponent.prototype.settingService;
}
//# sourceMappingURL=data:application/json;base64, 