bia-framework
Version:
Bia Framework to work with angular 2
71 lines • 3.14 kB
JavaScript
;
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 common_1 = require("@angular/common");
var odisseia_form_1 = require("./odisseia-form");
var CoreControl_1 = require("./CoreControl");
var CoreControlFormBase = (function () {
function CoreControlFormBase(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.focused = true;
};
this.OnBlur = function () {
_this.control.focused = false;
_this.control.wasTouched = true;
};
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 = [];
}
CoreControlFormBase.prototype.ngAfterContentInit = function () {
var _this = this;
if (this.formHost != null) {
this.control = new CoreControl_1.CoreControl(this.bind, common_1.Validators.compose(this.controlValidators));
this.control.valueChanges.subscribe(function (a) {
_this.controlValueChange(a);
_this.bindChange.emit(a);
});
this.controlValueChange(this.bind);
this.formHost.addControl(this.name, this.control);
}
return undefined;
};
CoreControlFormBase = __decorate([
core_1.Injectable(),
__metadata('design:paramtypes', [odisseia_form_1.CoreForm])
], CoreControlFormBase);
return CoreControlFormBase;
}());
exports.CoreControlFormBase = CoreControlFormBase;
//# sourceMappingURL=CoreControlFormBase.js.map