UNPKG

ws-form-builder

Version:
105 lines 4.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var form_builder_1 = require("../../providers/form-builder/form-builder"); var WsPasswordInputComponent = (function () { function WsPasswordInputComponent(formBuilder) { this.formBuilder = formBuilder; this.answerGiven = new core_1.EventEmitter(); this.fieldValue = ''; this.fieldConfirmValue = ''; this.isFieldValid = false; this.showError = false; this.isConfirmFieldValid = false; this.showConfirmError = false; this.showConfirmField = false; this.confirmLabel = ''; this.errorMessage = ''; this.fieldClass = ''; this.fieldValue = ''; this.fieldConfirmValue = ''; } WsPasswordInputComponent.prototype.ngOnInit = function () { if (typeof this.question.addConfirmField !== 'undefined') { this.showConfirmField = this.question.addConfirmField; } if (typeof this.question.confirmLabel !== 'undefined') { this.confirmLabel = this.question.confirmLabel; } if (typeof this.question.inputClass !== 'undefined') { this.fieldClass = this.question.inputClass; } }; WsPasswordInputComponent.prototype.setConfirmAnswer = function (event, question) { this.fieldConfirmValue = event.value; this.errorMessage = ''; var isStringValid = this.validateAnswer(question, event.value); question.valid = false; //compare password fields if (!isStringValid) { this.isConfirmFieldValid = false; this.showConfirmError = true; } else { this.isConfirmFieldValid = true; this.showConfirmError = false; } if (this.fieldValue !== this.fieldConfirmValue && this.showConfirmField !== false) { this.errorMessage = 'Passwords do no match!'; this.isConfirmFieldValid = false; this.showConfirmError = true; } else { this.isFieldValid = true; this.showError = false; } if (this.isConfirmFieldValid) { question.value = event.value; question.valid = true; this.answerGiven.emit(question); } }; WsPasswordInputComponent.prototype.setAnswer = function (event, question) { this.fieldValue = event.value; this.errorMessage = ''; question.valid = false; var isStringValid = this.validateAnswer(question, event.value); //compare password fields if (!isStringValid) { this.isFieldValid = false; this.showError = true; } else { this.isFieldValid = true; this.showError = false; } if (this.isFieldValid) { question.value = event.value; if (this.showConfirmField === false) { question.valid = true; } this.answerGiven.emit(question); } }; WsPasswordInputComponent.prototype.validateAnswer = function (question, string) { return this.formBuilder.validateAnswer(question, string); }; WsPasswordInputComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'ws-password-input', template: "\n <ion-item class=\"ws-input {{fieldClass}}\" [ngClass]=\"(!isFieldValid && showError) ? 'field-error' : ''\">\n <ion-label color=\"primary\" floating *ngIf=\"!question.hideQuestion\">{{question.question}}</ion-label>\n <ion-input placeholder=\"{{question.placeholder}}\" type=\"password\" value=\"\" (ionChange)=\"setAnswer($event, question)\" ></ion-input>\n </ion-item>\n\n\n <span *ngIf=\"showConfirmField\">\n \t<ion-item class=\"ws-input {{fieldClass}}\" [ngClass]=\"(!isConfirmFieldValid && showConfirmError) ? 'field-error' : ''\">\n \t <ion-label color=\"primary\" floating *ngIf=\"!question.hideQuestion\">{{confirmLabel}}</ion-label>\n \t <ion-input placeholder=\"{{question.placeholder}}\" type=\"password\" [ngModel]=\"fieldConfirmValue\" (ionChange)=\"setConfirmAnswer($event, question)\" ></ion-input>\n \t</ion-item>\n\n </span>\n ", styles: ["\n\n "] },] }, ]; /** @nocollapse */ WsPasswordInputComponent.ctorParameters = function () { return [ { type: form_builder_1.FormBuilderProvider, }, ]; }; WsPasswordInputComponent.propDecorators = { "question": [{ type: core_1.Input, args: ['question',] },], "answerGiven": [{ type: core_1.Output },], }; return WsPasswordInputComponent; }()); exports.WsPasswordInputComponent = WsPasswordInputComponent; //# sourceMappingURL=ws-password-input.js.map