UNPKG

ws-form-builder

Version:
60 lines 2.68 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 WsRadioGroupComponent = (function () { function WsRadioGroupComponent(formBuilder) { this.formBuilder = formBuilder; this.answerGiven = new core_1.EventEmitter(); this.fieldValue = ''; this.isFieldValid = false; this.showError = false; this.fieldClass = ''; this.fieldValue = ''; } WsRadioGroupComponent.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; } }; WsRadioGroupComponent.prototype.selectOption = function (event, question) { var isStringValid = this.validateAnswer(question, event); if (!isStringValid) { this.isFieldValid = false; this.showError = true; } else { this.isFieldValid = true; this.showError = false; } if (this.isFieldValid) { question.value = event; question.valid = true; this.answerGiven.emit(question); } }; WsRadioGroupComponent.prototype.validateAnswer = function (question, string) { return this.formBuilder.validateAnswer(question, string); }; WsRadioGroupComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'ws-radio-group', template: "\n <div class=\"{{fieldClass}}\">\n \t<strong *ngIf=\"!question.hideQuestion\">{{question.question}}</strong>\n \t<ion-list radio-group [(ngModel)]='fieldValue'>\n \t <ion-item *ngFor=\"let option of question.options\">\n \t <ion-label>{{option.label}}</ion-label>\n \t <ion-radio value=\"{{option.value}}\" (ionSelect)='selectOption($event, question)'></ion-radio>\n \t </ion-item>\n \t</ion-list>\n\n </div>\n ", styles: ["\n\n "] },] }, ]; /** @nocollapse */ WsRadioGroupComponent.ctorParameters = function () { return [ { type: form_builder_1.FormBuilderProvider, }, ]; }; WsRadioGroupComponent.propDecorators = { "question": [{ type: core_1.Input, args: ['question',] },], "answerGiven": [{ type: core_1.Output },], }; return WsRadioGroupComponent; }()); exports.WsRadioGroupComponent = WsRadioGroupComponent; //# sourceMappingURL=ws-radio-group.js.map