UNPKG

sl-questionnaire

Version:
920 lines (882 loc) 86.9 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('ng2-semantic-ui-v9'), require('lodash-es')) : typeof define === 'function' && define.amd ? define('sl-questionnaire', ['exports', '@angular/common', '@angular/core', '@angular/forms', 'ng2-semantic-ui-v9', 'lodash-es'], factory) : (global = global || self, factory(global['sl-questionnaire'] = {}, global.ng.common, global.ng.core, global.ng.forms, global.ng2SemanticUiV9, global.lodashEs)); }(this, (function (exports, common, core, forms, ng2SemanticUiV9, lodashEs) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __createBinding(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; } function __exportStar(m, exports) { for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p]; } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result.default = mod; return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); } function __classPrivateFieldSet(receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; } var SlTranslateService = /** @class */ (function () { function SlTranslateService() { } SlTranslateService.ɵprov = core.ɵɵdefineInjectable({ factory: function SlTranslateService_Factory() { return new SlTranslateService(); }, token: SlTranslateService, providedIn: "root" }); SlTranslateService = __decorate([ core.Injectable({ providedIn: 'root', }) ], SlTranslateService); return SlTranslateService; }()); (function (ResponseType) { ResponseType["TEXT"] = "text"; ResponseType["NUMBER"] = "number"; ResponseType["RADIO"] = "radio"; ResponseType["MULTISELECT"] = "multiselect"; ResponseType["DATE"] = "date"; ResponseType["SLIDER"] = "slider"; ResponseType["PAGEQUESTIONS"] = "pageQuestions"; ResponseType["MATRIX"] = "matrix"; })(exports.ResponseType || (exports.ResponseType = {})); var SlQuestionnaireService = /** @class */ (function () { function SlQuestionnaireService() { var _this = this; this.validate = function (data) { return function (control) { if (typeof data.validation == 'string') { return null; } if (!data.validation.required) { return null; } if (data.validation.regex) { var forbidden = _this.testRegex(data.validation.regex, control.value); return forbidden ? null : { err: 'Invalid character found' }; } if (data.validation.IsNumber) { if (!control.value) { return { err: 'Number not entered' }; } var forbidden = !isNaN(control.value); return forbidden ? null : { err: 'Only numbers allowed' }; } if (data.validation.required) { if (!control.value) { return { err: 'Required field' }; } if (data.responseType == exports.ResponseType.MULTISELECT) { return control.value.some(function (v) { return v != ''; }) ? null : { err: 'Select at least one option' }; } if (data.responseType == exports.ResponseType.SLIDER) { var min = data.validation.min; var max = data.validation.max; return min <= control.value && control.value <= max ? null : { err: 'Selected value not within range' }; } } }; }; } SlQuestionnaireService.prototype.testRegex = function (regexExpression, value) { var regex = new RegExp(regexExpression); return regex.test(value); }; SlQuestionnaireService.prototype.setSubmissionId = function (submissionId) { this._submissionId = submissionId; }; SlQuestionnaireService.prototype.getSubmissionId = function () { return this._submissionId; }; SlQuestionnaireService.prototype.mapSubmissionToAssessment = function (data) { var e_1, _a, e_2, _b, e_3, _c, e_4, _d; var assessment = data.assessment; try { for (var _e = __values(assessment.evidences), _f = _e.next(); !_f.done; _f = _e.next()) { var evidence = _f.value; var validSubmission = assessment.submissions[evidence.externalId]; if (validSubmission) { evidence.notApplicable = validSubmission.notApplicable; if (evidence.notApplicable) { continue; } try { for (var _g = (e_2 = void 0, __values(evidence.sections)), _h = _g.next(); !_h.done; _h = _g.next()) { var section = _h.value; try { for (var _j = (e_3 = void 0, __values(section.questions)), _k = _j.next(); !_k.done; _k = _j.next()) { var question = _k.value; if (question.responseType === 'pageQuestions') { try { for (var _l = (e_4 = void 0, __values(question.pageQuestions)), _m = _l.next(); !_m.done; _m = _l.next()) { var questions = _m.value; questions.value = questions.responseType !== 'matrix' ? validSubmission.answers[questions._id].value : this.constructMatrixValue(validSubmission, questions, evidence.externalId); questions.remarks = validSubmission.answers[questions._id] ? validSubmission.answers[questions._id].remarks : ''; questions.fileName = validSubmission.answers[questions._id] ? validSubmission.answers[questions._id].fileName : []; } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_m && !_m.done && (_d = _l.return)) _d.call(_l); } finally { if (e_4) throw e_4.error; } } } else if (validSubmission.answers && validSubmission.answers[question._id]) { question.value = question.responseType !== 'matrix' ? validSubmission.answers[question._id].value : this.constructMatrixValue(validSubmission, question, evidence.externalId); question.remarks = validSubmission.answers[question._id] ? validSubmission.answers[question._id].remarks : ''; question.fileName = validSubmission.answers[question._id] ? validSubmission.answers[question._id].fileName : []; } } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_k && !_k.done && (_c = _j.return)) _c.call(_j); } finally { if (e_3) throw e_3.error; } } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_h && !_h.done && (_b = _g.return)) _b.call(_g); } finally { if (e_2) throw e_2.error; } } } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_f && !_f.done && (_a = _e.return)) _a.call(_e); } finally { if (e_1) throw e_1.error; } } this.setSubmissionId(assessment.submissionId); return data; }; SlQuestionnaireService.prototype.constructMatrixValue = function (validSubmission, matrixQuestion, ecmId) { var e_5, _a; matrixQuestion.value = []; if (validSubmission.answers && validSubmission.answers[matrixQuestion._id] && validSubmission.answers[matrixQuestion._id].value) { try { for (var _b = __values(validSubmission.answers[matrixQuestion._id].value), _c = _b.next(); !_c.done; _c = _b.next()) { var answer = _c.value; matrixQuestion.value.push(JSON.parse(JSON.stringify(matrixQuestion.instanceQuestions))); } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_5) throw e_5.error; } } matrixQuestion.value.forEach(function (instance, index) { instance.forEach(function (question, instanceIndex) { if (validSubmission.answers[matrixQuestion._id] && validSubmission.answers[matrixQuestion._id].value[index][question._id]) { question.value = validSubmission.answers[matrixQuestion._id].value[index][question._id].value; question.remarks = validSubmission.answers[matrixQuestion._id].value[index][question._id].remarks; question.fileName = validSubmission.answers[matrixQuestion._id].value[index][question._id].fileName; } }); }); return matrixQuestion.value; } else { return []; } }; SlQuestionnaireService.prototype.getEvidenceData = function (evidence, formValues) { var sections = evidence.sections; var answers = this.getSectionData(sections, formValues); var payloadData = { externalId: evidence.externalId, answers: answers, startTime: evidence.startTime, endTime: Date.now(), }; return payloadData; }; SlQuestionnaireService.prototype.getSectionData = function (sections, formValues) { var answers = {}; for (var index = 0; index < sections.length; index++) { answers = __assign(__assign({}, answers), this.createpayload(sections[index].questions, formValues)); } return answers; }; SlQuestionnaireService.prototype.createpayload = function (questions, formValues) { var answers = {}; for (var index = 0; index < questions.length; index++) { var currentQuestion = questions[index]; if (currentQuestion.responseType == 'pageQuestions') { answers = __assign(__assign({}, answers), this.createpayload(currentQuestion.pageQuestions, formValues)); continue; } if (currentQuestion.responseType == 'matrix') { for (var index_1 = 0; index_1 < currentQuestion.value.length; index_1++) { formValues[currentQuestion._id][index_1] = this.createpayload(currentQuestion.value[index_1], formValues[currentQuestion._id][index_1]); } } var perQuestionData = this.formatToPayload(currentQuestion, formValues); answers[currentQuestion._id] = perQuestionData; } return answers; }; SlQuestionnaireService.prototype.formatToPayload = function (currentQuestion, formValues) { var value = currentQuestion.responseType != 'matrix' ? currentQuestion.value : formValues[currentQuestion._id]; return { qid: currentQuestion._id, value: value, remarks: currentQuestion.remarks, fileName: currentQuestion.fileName, gpsLocation: '', payload: { question: currentQuestion.question, labels: formValues[currentQuestion._id], responseType: currentQuestion.responseType, filesNotUploaded: [], }, startTime: currentQuestion.startTime, endTime: currentQuestion.endTime, criteriaId: currentQuestion.payload.criteriaId, responseType: currentQuestion.responseType, evidenceMethod: currentQuestion.evidenceMethod, rubricLevel: '', }; }; SlQuestionnaireService.ɵprov = core.ɵɵdefineInjectable({ factory: function SlQuestionnaireService_Factory() { return new SlQuestionnaireService(); }, token: SlQuestionnaireService, providedIn: "root" }); SlQuestionnaireService = __decorate([ core.Injectable({ providedIn: 'root', }) ], SlQuestionnaireService); return SlQuestionnaireService; }()); var TextInputComponent = /** @class */ (function () { function TextInputComponent(qService, translate) { this.qService = qService; this.translate = translate; } TextInputComponent.prototype.ngOnInit = function () { var _this = this; this.placeholder = this.translate['frmelmnts'].lbl.enterResponse; setTimeout(function () { _this.questionnaireForm.addControl(_this.question._id, new forms.FormControl(_this.question.value || null, [ _this.qService.validate(_this.question), ])); _this.question.startTime = _this.question.startTime ? _this.question.startTime : Date.now(); }); }; Object.defineProperty(TextInputComponent.prototype, "isValid", { get: function () { return this.questionnaireForm.controls[this.question._id].valid; }, enumerable: true, configurable: true }); Object.defineProperty(TextInputComponent.prototype, "isTouched", { get: function () { return this.questionnaireForm.controls[this.question._id].touched; }, enumerable: true, configurable: true }); TextInputComponent.prototype.onChange = function (e) { var value = e.target.value; this.question.value = value; this.question.endTime = Date.now(); }; TextInputComponent.ctorParameters = function () { return [ { type: SlQuestionnaireService }, { type: SlTranslateService } ]; }; __decorate([ core.Input() ], TextInputComponent.prototype, "questionnaireForm", void 0); __decorate([ core.Input() ], TextInputComponent.prototype, "question", void 0); TextInputComponent = __decorate([ core.Component({ selector: 'sl-text-input', template: "<div\n [formGroup]=\"questionnaireForm\"\n *ngIf=\"questionnaireForm?.contains(question._id)\"\n>\n <input\n type=\"text\"\n [formControlName]=\"question?._id\"\n [ngClass]=\"!isValid && isTouched ? 'is-invalid ' : 'is-valid'\"\n class=\"sb-form-control\"\n [placeholder]=\"placeholder\"\n (change)=\"onChange($event)\"\n [value]=\"question.value\"\n />\n</div>\n", styles: [""] }) ], TextInputComponent); return TextInputComponent; }()); var DateInputComponent = /** @class */ (function () { function DateInputComponent(qService, translate) { this.qService = qService; this.translate = translate; } DateInputComponent.prototype.ngOnInit = function () { var _this = this; var _a; this.autoCaptureText = (_a = this.translate['frmelmnts'].btn) === null || _a === void 0 ? void 0 : _a.autoCapture; setTimeout(function () { _this.questionnaireForm.addControl(_this.question._id, new forms.FormControl(_this.question.value ? new Date(_this.question.value) : null, [_this.qService.validate(_this.question)])); _this.question.startTime = _this.question.startTime ? _this.question.startTime : Date.now(); }); this.min = this.question.validation.min ? new Date(this.question.validation.min) : null; this.max = this.question.validation.max ? new Date(this.question.validation.max) : null; }; DateInputComponent.prototype.onChange = function (e) { var value = e; this.question.value = value; this.question.endTime = Date.now(); }; DateInputComponent.prototype.autoCapture = function () { this.questionnaireForm.controls[this.question._id].patchValue(new Date(Date.now())); }; DateInputComponent.ctorParameters = function () { return [ { type: SlQuestionnaireService }, { type: SlTranslateService } ]; }; __decorate([ core.Input() ], DateInputComponent.prototype, "questionnaireForm", void 0); __decorate([ core.Input() ], DateInputComponent.prototype, "question", void 0); __decorate([ core.Input() ], DateInputComponent.prototype, "autoCaptureText", void 0); DateInputComponent = __decorate([ core.Component({ selector: 'sl-date-input', template: "<div\n [formGroup]=\"questionnaireForm\"\n *ngIf=\"questionnaireForm?.contains(question._id)\"\n class=\"d-flex flex-ai-center flex-jc-space-between\"\n>\n <div class=\"ui left icon input\">\n <i class=\"calendar icon\"></i>\n <input\n suiDatepicker\n [pickerMode]=\"'date'\"\n [pickerUseNativeOnMobile]=\"false\"\n [formControlName]=\"question?._id\"\n (pickerSelectedDateChange)=\"onChange($event)\"\n class=\"question-date-input\"\n [pickerMinDate]=\"min\"\n [pickerMaxDate]=\"max\"\n />\n </div>\n <div *ngIf=\"question?.autoCapture && !question?.value\">\n <button class=\"sb-btn sb-btn-normal sb-btn-primary\" (click)=\"autoCapture()\">\n\t\t{{autoCaptureText}}\n </button>\n </div>\n</div>\n", styles: [""] }) ], DateInputComponent); return DateInputComponent; }()); var NumberInputComponent = /** @class */ (function () { function NumberInputComponent(qService, translate) { this.qService = qService; this.translate = translate; } NumberInputComponent.prototype.ngOnInit = function () { var _this = this; var _a, _b; this.placeholder = (_b = (_a = this.translate['frmelmnts']) === null || _a === void 0 ? void 0 : _a.lbl) === null || _b === void 0 ? void 0 : _b.enterResponse; setTimeout(function () { _this.questionnaireForm.addControl(_this.question._id, new forms.FormControl(_this.question.value || null, [ _this.qService.validate(_this.question), ])); _this.question.startTime = _this.question.startTime ? _this.question.startTime : Date.now(); }); }; NumberInputComponent.prototype.onChange = function (e) { var value = e.target.value; this.question.value = value; this.question.endTime = Date.now(); }; Object.defineProperty(NumberInputComponent.prototype, "isValid", { get: function () { return this.questionnaireForm.controls[this.question._id].valid; }, enumerable: true, configurable: true }); Object.defineProperty(NumberInputComponent.prototype, "isTouched", { get: function () { return this.questionnaireForm.controls[this.question._id].touched; }, enumerable: true, configurable: true }); NumberInputComponent.ctorParameters = function () { return [ { type: SlQuestionnaireService }, { type: SlTranslateService } ]; }; __decorate([ core.Input() ], NumberInputComponent.prototype, "questionnaireForm", void 0); __decorate([ core.Input() ], NumberInputComponent.prototype, "question", void 0); NumberInputComponent = __decorate([ core.Component({ selector: 'sl-number-input', template: "<div\n [formGroup]=\"questionnaireForm\"\n *ngIf=\"questionnaireForm?.contains(question._id)\"\n>\n <input\n type=\"number\"\n [formControlName]=\"question?._id\"\n class=\"sb-form-control\"\n [placeholder]=\"placeholder\"\n (change)=\"onChange($event)\"\n [value]=\"question.value\"\n />\n</div>\n", styles: [""] }) ], NumberInputComponent); return NumberInputComponent; }()); var RangeInputComponent = /** @class */ (function () { function RangeInputComponent(qService) { this.qService = qService; } RangeInputComponent.prototype.ngOnInit = function () { var _this = this; setTimeout(function () { _this.questionnaireForm.addControl(_this.question._id, new forms.FormControl(_this.question.value || null, [ _this.qService.validate(_this.question), ])); _this.question.startTime = _this.question.startTime ? _this.question.startTime : Date.now(); }); }; RangeInputComponent.prototype.onChange = function (e) { var value = e.target.value; this.question.value = value; this.question.endTime = Date.now(); }; Object.defineProperty(RangeInputComponent.prototype, "isValid", { get: function () { return this.questionnaireForm.controls[this.question._id].valid; }, enumerable: true, configurable: true }); Object.defineProperty(RangeInputComponent.prototype, "isTouched", { get: function () { return this.questionnaireForm.controls[this.question._id].touched; }, enumerable: true, configurable: true }); Object.defineProperty(RangeInputComponent.prototype, "min", { get: function () { if (typeof this.question.validation == 'string') { return null; } return this.question.validation.min; }, enumerable: true, configurable: true }); Object.defineProperty(RangeInputComponent.prototype, "max", { get: function () { if (typeof this.question.validation == 'string') { return null; } return this.question.validation.max; }, enumerable: true, configurable: true }); RangeInputComponent.ctorParameters = function () { return [ { type: SlQuestionnaireService } ]; }; __decorate([ core.Input() ], RangeInputComponent.prototype, "questionnaireForm", void 0); __decorate([ core.Input() ], RangeInputComponent.prototype, "question", void 0); RangeInputComponent = __decorate([ core.Component({ selector: 'sl-range-input', template: "<div\n class=\"\n d-flex\n flex-ai-center flex-dc\n mt-30\n ng-dirty ng-invalid ng-touched\n range-wrap\n \"\n [formGroup]=\"questionnaireForm\"\n *ngIf=\"questionnaireForm?.contains(question._id)\"\n>\n <div class=\"range-value\" id=\"rangeV\">{{ this.question.value }}</div>\n\n <input\n id=\"range\"\n type=\"range\"\n [min]=\"min\"\n [max]=\"max\"\n [ngClass]=\"isValid && isTouched ? 'is-invalid' : 'is-valid'\"\n step=\"1\"\n [formControlName]=\"question?._id\"\n class=\"w-100\"\n (change)=\"onChange($event)\"\n [value]=\"question.value\"\n />\n</div>\n", styles: [".range-value{width:50px;height:50px;line-height:50px;border-radius:50%;font-size:20px;color:#0274fd;text-align:center;background:#e9e8d9;margin-bottom:17px}input[type=range]{height:34px;-webkit-appearance:none;margin:10px 0;width:100%}input[type=range]:focus{outline:0}input[type=range]::-webkit-slider-runnable-track{width:100%;height:11px;cursor:pointer;animate:.2s;box-shadow:1px 1px 1px #000;background:#74a9d8;border-radius:1px;border:0 solid #010101}input[type=range]::-webkit-slider-thumb{box-shadow:1px 1px 1px #000031;border:1px solid #00001e;height:26px;width:26px;border-radius:15px;background:#fff;cursor:pointer;-webkit-appearance:none;margin-top:-8px}input[type=range]:focus::-webkit-slider-runnable-track{background:#74a9d8}input[type=range]::-moz-range-track{width:100%;height:11px;cursor:pointer;animate:.2s;box-shadow:1px 1px 1px #000;background:#74a9d8;border-radius:1px;border:0 solid #010101}input[type=range]::-moz-range-thumb{box-shadow:1px 1px 1px #000031;border:1px solid #00001e;height:26px;width:26px;border-radius:15px;background:#fff;cursor:pointer}input[type=range]::-ms-track{width:100%;height:11px;cursor:pointer;animate:.2s;background:0 0;border-color:transparent;color:transparent}input[type=range]::-ms-fill-lower{background:#74a9d8;border:0 solid #010101;border-radius:2px;box-shadow:1px 1px 1px #000}input[type=range]::-ms-fill-upper{background:#74a9d8;border:0 solid #010101;border-radius:2px;box-shadow:1px 1px 1px #000}input[type=range]::-ms-thumb{margin-top:1px;box-shadow:1px 1px 1px #000031;border:1px solid #00001e;height:26px;width:26px;border-radius:15px;background:#fff;cursor:pointer}input[type=range]:focus::-ms-fill-lower{background:#74a9d8}input[type=range]:focus::-ms-fill-upper{background:#74a9d8}"] }) ], RangeInputComponent); return RangeInputComponent; }()); var RadioInputComponent = /** @class */ (function () { function RadioInputComponent(qService, translate) { this.qService = qService; this.translate = translate; this.dependentParent = new core.EventEmitter(); } RadioInputComponent.prototype.ngOnInit = function () { var _this = this; var _a; this.hintCloseText = (_a = this.translate['frmelmnts'].btn) === null || _a === void 0 ? void 0 : _a.close; setTimeout(function () { _this.questionnaireForm.addControl(_this.question._id, new forms.FormControl(_this.question.value || null, _this.qService.validate(_this.question))); _this.question.startTime = _this.question.startTime ? _this.question.startTime : Date.now(); if (_this.question.value) { if (_this.question.children.length) { _this.dependentParent.emit(_this.question); } } }); }; Object.defineProperty(RadioInputComponent.prototype, "isValid", { get: function () { return this.questionnaireForm.controls[this.question._id].valid; }, enumerable: true, configurable: true }); Object.defineProperty(RadioInputComponent.prototype, "isTouched", { get: function () { return this.questionnaireForm.controls[this.question._id].touched; }, enumerable: true, configurable: true }); RadioInputComponent.prototype.onChange = function (value) { this.questionnaireForm.controls[this.question._id].setValue(value); this.question.value = value; this.question.endTime = Date.now(); if (this.question.children.length) { this.dependentParent.emit(this.question); } }; RadioInputComponent.ctorParameters = function () { return [ { type: SlQuestionnaireService }, { type: SlTranslateService } ]; }; __decorate([ core.Input() ], RadioInputComponent.prototype, "options", void 0); __decorate([ core.Input() ], RadioInputComponent.prototype, "questionnaireForm", void 0); __decorate([ core.Input() ], RadioInputComponent.prototype, "question", void 0); __decorate([ core.Output() ], RadioInputComponent.prototype, "dependentParent", void 0); RadioInputComponent = __decorate([ core.Component({ selector: 'sl-radio-input', template: "<div *ngIf=\"questionnaireForm?.contains(question._id)\">\n <div\n *ngFor=\"let o of options; let optionIndex = index\"\n [formGroup]=\"questionnaireForm\"\n class=\"\n mb-15\n sb-radio-btn-checkbox sb-radio-btn-primary\n d-flex\n flex-ai-baseline\n \"\n >\n <input\n type=\"radio\"\n (change)=\"onChange(o.value)\"\n [name]=\"question._id\"\n [ngClass]=\"isValid && isTouched ? 'is-invalid' : 'is-valid'\"\n [value]=\"o.value\"\n [formControlName]=\"question._id\"\n />\n <label>{{ o.label }}</label>\n <div *ngIf=\"question?.option && question?.option[optionIndex]?.hint\">\n <i\n class=\"icon large lightbulb\"\n (click)=\"\n isDimmed = !isDimmed; hint = question?.option[optionIndex]?.hint\n \"\n ></i>\n </div>\n </div>\n</div>\n\n<sui-dimmer [(isDimmed)]=\"isDimmed\" [isClickable]=\"true\">\n <h4 class=\"ui inverted header\">{{ hint }}</h4>\n <button\n type=\"button\"\n class=\"sb-btn sb-btn-sm sb-btn-white text-uppercase flex-basis-1\"\n type=\"submit\"\n >\n {{ hintCloseText}}\n </button>\n</sui-dimmer>\n", styles: [""] }) ], RadioInputComponent); return RadioInputComponent; }()); var CheckboxInputComponent = /** @class */ (function () { function CheckboxInputComponent(qService, translate) { this.qService = qService; this.translate = translate; this.dependentParent = new core.EventEmitter(); } CheckboxInputComponent.prototype.ngOnInit = function () { var _this = this; var _a; this.hintCloseText = (_a = this.translate['frmelmnts'].btn) === null || _a === void 0 ? void 0 : _a.close; setTimeout(function () { var optionControl = _this.options.map(function (v) { if (_this.question.value && _this.question.value.find(function (_v) { return _v == v.value; })) { return new forms.FormControl(v.value); } return new forms.FormControl(''); }); _this.questionnaireForm.addControl(_this.question._id, new forms.FormArray(optionControl, _this.qService.validate(_this.question))); _this.question.startTime = _this.question.startTime ? _this.question.startTime : Date.now(); if (_this.question.value.length) { if (_this.question.children.length) { _this.dependentParent.emit(_this.question); } } }); }; CheckboxInputComponent.prototype.onChange = function (oId, isChecked, oIndex) { var formArray = this.questionnaireForm.get(this.question._id); if (isChecked) { formArray.controls[oIndex].patchValue(oId); } this.question.value = this.questionnaireForm.controls[this.question._id].value; this.question.value = this.question.value.filter(Boolean); this.question.endTime = Date.now(); if (this.question.children.length) { this.dependentParent.emit(this.question); } }; Object.defineProperty(CheckboxInputComponent.prototype, "isValid", { get: function () { return this.questionnaireForm.controls[this.question._id].valid; }, enumerable: true, configurable: true }); Object.defineProperty(CheckboxInputComponent.prototype, "isTouched", { get: function () { return this.questionnaireForm.controls[this.question._id].touched; }, enumerable: true, configurable: true }); CheckboxInputComponent.ctorParameters = function () { return [ { type: SlQuestionnaireService }, { type: SlTranslateService } ]; }; __decorate([ core.Input() ], CheckboxInputComponent.prototype, "options", void 0); __decorate([ core.Input() ], CheckboxInputComponent.prototype, "questionnaireForm", void 0); __decorate([ core.Input() ], CheckboxInputComponent.prototype, "question", void 0); __decorate([ core.Output() ], CheckboxInputComponent.prototype, "dependentParent", void 0); CheckboxInputComponent = __decorate([ core.Component({ selector: 'sl-checkbox-input', template: "<div *ngIf=\"questionnaireForm?.contains(question._id)\">\n <div\n *ngFor=\"let o of options; let i = index\"\n [formGroup]=\"questionnaireForm\"\n class=\"mb-15 sb-checkbox sb-checkbox-secondary d-flex flex-ai-baseline\"\n >\n <div [formArrayName]=\"question._id\">\n <sui-checkbox\n (checkChange)=\"onChange(o.value, $event, i)\"\n [formControlName]=\"i\"\n >\n {{ o.label }}\n </sui-checkbox>\n </div>\n <div *ngIf=\"question?.option && question?.option[i]?.hint\">\n <i\n class=\"icon large lightbulb\"\n (click)=\"isDimmed = !isDimmed; hint = question?.option[i]?.hint\"\n ></i>\n </div>\n </div>\n</div>\n\n<sui-dimmer [(isDimmed)]=\"isDimmed\" [isClickable]=\"true\">\n <h4 class=\"ui inverted header\">{{ hint }}</h4>\n <button\n type=\"button\"\n class=\"sb-btn sb-btn-sm sb-btn-white text-uppercase flex-basis-1\"\n type=\"submit\"\n >\n {{ hintCloseText }}\n </button>\n</sui-dimmer>\n", styles: [""] }) ], CheckboxInputComponent); return CheckboxInputComponent; }()); var QuesRemarksComponent = /** @class */ (function () { function QuesRemarksComponent(translate) { this.translate = translate; this.remark = ''; this.saveClicked = new core.EventEmitter(); } QuesRemarksComponent.prototype.ngOnInit = function () { var _a; this.title = (_a = this.translate['frmelmnts'].lbl) === null || _a === void 0 ? void 0 : _a.remark_title; this.remarksAddText = this.translate['frmelmnts'].btn.add; this.remark = this.question.remarks; this.remark ? (this.showRemarks = true) : false; }; QuesRemarksComponent.prototype.saveRemark = function () { this.question.remarks = this.remark; this.saveClicked.emit({ value: this.remark }); }; QuesRemarksComponent.prototype.deleteRemark = function () { this.remark = ''; this.saveRemark(); this.showRemarks = false; }; QuesRemarksComponent.ctorParameters = function () { return [ { type: SlTranslateService } ]; }; __decorate([ core.Output() ], QuesRemarksComponent.prototype, "saveClicked", void 0); __decorate([ core.Input() ], QuesRemarksComponent.prototype, "question", void 0); QuesRemarksComponent = __decorate([ core.Component({ selector: 'sl-ques-remarks', template: "<div class=\"d-flex flex-ai-center flex-jc-space-between my-10\">\n <h5 class=\"my-10\">{{ title }}</h5>\n <button\n class=\"sb-btn sb-btn-normal sb-btn-primary\"\n *ngIf=\"!remark.length\"\n (click)=\"showRemarks = true\"\n >\n {{ remarksAddText }}\n </button>\n <span *ngIf=\"remark.length\" (click)=\"deleteRemark()\"\n ><i class=\"trash large icon\"></i\n ></span>\n</div>\n\n<div class=\"d-flex flex-ai-end\" *ngIf=\"showRemarks\">\n <textarea\n rows=\"3\"\n class=\"w-100\"\n [(ngModel)]=\"remark\"\n (ngModelChange)=\"saveRema