bia-framework
Version:
Bia Framework to work with angular 2
74 lines • 3.64 kB
JavaScript
System.register(["@angular/core", "@angular/common", "./CoreControl"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
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, common_1, CoreControl_1;
var CoreControlFormBase;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (common_1_1) {
common_1 = common_1_1;
},
function (CoreControl_1_1) {
CoreControl_1 = CoreControl_1_1;
}],
execute: function() {
/**
* Created by jd on 29/04/2016.
*/
CoreControlFormBase = (function () {
function CoreControlFormBase(formHost) {
var _this = this;
this.formHost = formHost;
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)
_this.control.hasValue = true;
else
_this.control.hasValue = false;
};
this.controlValidators = [];
this.validationList = [];
}
CoreControlFormBase.prototype.ngOnInit = 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) { return _this.controlValueChange(a); });
this.controlValueChange(this.bind);
this.formHost.addControl(this.name, this.control);
}
return undefined;
};
__decorate([
core_1.Input(),
__metadata('design:type', String)
], CoreControlFormBase.prototype, "name", void 0);
__decorate([
core_1.Input(),
__metadata('design:type', Object)
], CoreControlFormBase.prototype, "bind", void 0);
return CoreControlFormBase;
}());
exports_1("CoreControlFormBase", CoreControlFormBase);
}
}
});
//# sourceMappingURL=CoreFormBase.js.map