UNPKG

ws-form-builder

Version:
60 lines 2.69 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 WsSelectDropdownComponent = (function () { function WsSelectDropdownComponent(formBuilder) { this.formBuilder = formBuilder; this.answerGiven = new core_1.EventEmitter(); this.fieldValue = ''; this.isFieldValid = false; this.showError = false; this.fieldClass = ''; this.fieldValue = ''; } WsSelectDropdownComponent.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; } }; WsSelectDropdownComponent.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); } }; WsSelectDropdownComponent.prototype.validateAnswer = function (question, string) { return this.formBuilder.validateAnswer(question, string); }; WsSelectDropdownComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'ws-select-dropdown', template: "\n <ion-item class=\"{{fieldClass}}\">\n <ion-label color=\"primary\" floating *ngIf=\"!question.hideQuestion\">{{question.question}}</ion-label>\n <ion-select [(ngModel)]=\"fieldValue\" (ionChange)='selectOption($event, question)'>\n <ion-option *ngFor=\"let option of question.options\" value=\"{{option.value}}\">{{option.label}}</ion-option>\n </ion-select>\n </ion-item>\n ", styles: ["\n\n "] },] }, ]; /** @nocollapse */ WsSelectDropdownComponent.ctorParameters = function () { return [ { type: form_builder_1.FormBuilderProvider, }, ]; }; WsSelectDropdownComponent.propDecorators = { "question": [{ type: core_1.Input, args: ['question',] },], "answerGiven": [{ type: core_1.Output },], }; return WsSelectDropdownComponent; }()); exports.WsSelectDropdownComponent = WsSelectDropdownComponent; //# sourceMappingURL=ws-select-dropdown.js.map