UNPKG

bia-framework

Version:

Bia Framework to work with angular 2

71 lines 3.18 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var InternalControl_1 = require("./InternalControl"); var core_form_component_1 = require("./core-form/core-form.component"); var CoreFormControlBase = (function () { function CoreFormControlBase(formHost) { var _this = this; this.formHost = formHost; this.isProcessing = false; this.setupBind = function (_name, _bind, _bindChange) { _this.name = _name; _this.bind = _bind; _this.bindChange = _bindChange; }; this.OnFocus = function () { _this.control.hasFocus = true; }; this.OnBlur = function () { _this.control.hasFocus = false; _this.control.markAsTouched(); }; this.OnChange = function (a) { _this.control.updateValue(a); }; this.isInForm = function () { return _this.formHost != null; }; this.addFormValidator = function (validationDesc, validator) { _this.controlValidators.push(validator); _this.validationList.push(validationDesc); }; this.controlValueChange = function (v) { if (v != null && v != "") _this.control.hasValue = true; else _this.control.hasValue = false; }; this.controlValidators = []; this.validationList = []; } CoreFormControlBase.prototype.ngAfterContentInit = function () { var _this = this; if (this.formHost != null) { this.control = new InternalControl_1.InternalControl(this.bind, forms_1.Validators.compose(this.controlValidators)); this.control.valueChanges.subscribe(function (a) { _this.controlValueChange(a); _this.bindChange.emit(a); }); this.controlValueChange(this.bind); this.formHost.addFormControl(this.name, this.control); } return undefined; }; CoreFormControlBase = __decorate([ core_1.Injectable(), __metadata('design:paramtypes', [core_form_component_1.CoreForm]) ], CoreFormControlBase); return CoreFormControlBase; }()); exports.CoreFormControlBase = CoreFormControlBase; //# sourceMappingURL=CoreFormControlBase.js.map