ws-form-builder
Version:
Ionic 2 Form Builder
73 lines (71 loc) • 3.12 kB
JavaScript
"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 ionic_angular_1 = require("ionic-angular");
var WsDatePickerComponent = (function () {
function WsDatePickerComponent(formBuilder, modalCtrl
//private datePickerProvider: DatePickerProvider
) {
this.formBuilder = formBuilder;
this.modalCtrl = modalCtrl;
this.answerGiven = new core_1.EventEmitter();
this.fieldValue = '';
this.isFieldValid = false;
this.showError = false;
this.dateFormat = 'DD/MM/YYYY';
this.fieldClass = '';
this.fieldValue = '';
}
WsDatePickerComponent.prototype.ngOnInit = function () {
if (typeof this.question.value !== 'undefined') {
this.fieldValue = this.question.value;
}
if (typeof this.question.dateFormat !== 'undefined') {
this.dateFormat = this.question.dateFormat;
}
if (typeof this.question.inputClass !== 'undefined') {
this.fieldClass = this.question.inputClass;
}
};
WsDatePickerComponent.prototype.setAnswer = function (event, question) {
//let data = moment(date).format('DD/MM/YYYY');
question.date = this.fieldValue;
question.value = this.fieldValue;
question.valid = true;
//this.fieldValue = data;
this.answerGiven.emit(question);
//let isStringValid = this.validateAnswer(date);
/*if(!isStringValid){
this.isFieldValid = false;
this.showError = true;
}else{
this.isFieldValid = true;
this.showError = false;
}
if(this.isFieldValid){*/
//}
};
WsDatePickerComponent.prototype.validateAnswer = function (question, string) {
return this.formBuilder.validateAnswer(question, string);
};
WsDatePickerComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'ws-date-picker',
template: "\n <ion-item class=\"ws-input {{fieldClass}}\" [ngClass]=\"(!isFieldValid && showError) ? 'field-error' : ''\">\n <ion-label color=\"primary\" floating>{{question.question}}</ion-label>\n <ion-datetime displayFormat=\"{{dateFormat}}\" (ionChange)=\"setAnswer($event,question)\" [(ngModel)]=\"fieldValue\"></ion-datetime>\n </ion-item>\n ",
styles: ["\n\n "]
},] },
];
/** @nocollapse */
WsDatePickerComponent.ctorParameters = function () { return [
{ type: form_builder_1.FormBuilderProvider, },
{ type: ionic_angular_1.ModalController, },
]; };
WsDatePickerComponent.propDecorators = {
"question": [{ type: core_1.Input, args: ['question',] },],
"answerGiven": [{ type: core_1.Output },],
};
return WsDatePickerComponent;
}());
exports.WsDatePickerComponent = WsDatePickerComponent;
//# sourceMappingURL=ws-date-picker.js.map