UNPKG

ws-form-builder

Version:
50 lines 2.13 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 WsToggleComponent = (function () { function WsToggleComponent(formBuilder) { this.formBuilder = formBuilder; this.answerGiven = new core_1.EventEmitter(); this.fieldValue = false; this.isFieldValid = true; this.showError = false; this.fieldClass = ''; } WsToggleComponent.prototype.ngOnInit = function () { if (typeof this.question.value !== 'undefined') { this.fieldValue = this.question.value; } if (typeof this.question.inputClass !== 'undefined') { this.fieldClass = this.question.inputClass; } }; WsToggleComponent.prototype.setAnswer = function (event) { if (this.isFieldValid) { this.question.value = this.fieldValue; this.question.valid = true; this.answerGiven.emit(this.question); } }; WsToggleComponent.prototype.validateAnswer = function (question, string) { return this.formBuilder.validateAnswer(question, string); }; WsToggleComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'ws-toggle', template: "\n <ion-item class=\"{{fieldClass}}\">\n \t<ion-label *ngIf=\"!question.hideQuestion\">{{question.question}}</ion-label>\n \t<ion-toggle [(ngModel)]=\"fieldValue\" (ionChange)=\"setAnswer($event)\"></ion-toggle>\n </ion-item>\n ", styles: ["\n\n "] },] }, ]; /** @nocollapse */ WsToggleComponent.ctorParameters = function () { return [ { type: form_builder_1.FormBuilderProvider, }, ]; }; WsToggleComponent.propDecorators = { "question": [{ type: core_1.Input, args: ['question',] },], "answerGiven": [{ type: core_1.Output },], }; return WsToggleComponent; }()); exports.WsToggleComponent = WsToggleComponent; //# sourceMappingURL=ws-toggle.js.map