UNPKG

bia-framework

Version:

Bia Framework to work with angular 2

63 lines 3.26 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 __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var core_1 = require("@angular/core"); var core_form_input_component_1 = require("../core-form-input/core-form-input.component"); var core_form_dropdown_1 = require("../core-form-dropdown/core-form-dropdown"); var CoreFormControlBase_1 = require("../CoreFormControlBase"); var CoreFormValidationMatch = (function () { function CoreFormValidationMatch(inputHost, dropDownHost, validationMatchMessage) { this.inputHost = inputHost; this.dropDownHost = dropDownHost; this.validationMatchMessage = validationMatchMessage; this.host = inputHost || dropDownHost; } CoreFormValidationMatch.prototype.ngOnInit = function () { var _this = this; if (this.host != null) this.host.addFormValidator({ ValidationName: 'validation-match', ValidationMessage: this.validationMatchMessage }, CoreFormValidationMatch.matchValidation); this.match.bindChange.subscribe(function (a) { CoreFormValidationMatch.matchValue = a; _this.host.control.updateValueAndValidity(); }); return undefined; }; CoreFormValidationMatch.matchValidation = function (c) { if (CoreFormValidationMatch.matchValue != null && c.value != null) { if (CoreFormValidationMatch.matchValue == c.value) return null; else return { "validation-match": true }; } else return null; }; __decorate([ core_1.Input("control-match"), __metadata('design:type', CoreFormControlBase_1.CoreFormControlBase) ], CoreFormValidationMatch.prototype, "match", void 0); CoreFormValidationMatch = __decorate([ core_1.Directive({ selector: 'validation-match' }), __param(0, core_1.Optional()), __param(0, core_1.Host()), __param(1, core_1.Optional()), __param(1, core_1.Host()), __param(2, core_1.Attribute("message")), __metadata('design:paramtypes', [core_form_input_component_1.CoreFormInput, core_form_dropdown_1.CoreFormDropDown, String]) ], CoreFormValidationMatch); return CoreFormValidationMatch; }()); exports.CoreFormValidationMatch = CoreFormValidationMatch; //# sourceMappingURL=core-form-validation-match.js.map