@glowgreen/gg-questionnaire-v2 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/bundles/glowgreen-gg-questionnaire-v2.umd.js +1186 -1130
  2. package/bundles/glowgreen-gg-questionnaire-v2.umd.js.map +1 -1
  3. package/bundles/glowgreen-gg-questionnaire-v2.umd.min.js +1 -1
  4. package/bundles/glowgreen-gg-questionnaire-v2.umd.min.js.map +1 -1
  5. package/esm2015/glowgreen-gg-questionnaire-v2.js +1 -1
  6. package/esm2015/lib/enums/condition-relationship.enum.js +1 -1
  7. package/esm2015/lib/enums/condition-type.enum.js +1 -1
  8. package/esm2015/lib/enums/input-type.enum.js +1 -1
  9. package/esm2015/lib/enums/question-type.enum.js +1 -1
  10. package/esm2015/lib/enums/repeater-question-type.enum.js +1 -1
  11. package/esm2015/lib/enums/validation-type.enum.js +1 -1
  12. package/esm2015/lib/gg-questionnaire-v2.module.js +1 -1
  13. package/esm2015/lib/interfaces/attachment.js +1 -1
  14. package/esm2015/lib/interfaces/checklist-item.js +1 -1
  15. package/esm2015/lib/interfaces/condition-group.js +1 -1
  16. package/esm2015/lib/interfaces/condition.js +1 -1
  17. package/esm2015/lib/interfaces/question.js +1 -1
  18. package/esm2015/lib/interfaces/questionnaire-options.js +1 -1
  19. package/esm2015/lib/interfaces/questionnaire.js +1 -1
  20. package/esm2015/lib/interfaces/repeater-question.js +1 -1
  21. package/esm2015/lib/interfaces/section.js +1 -1
  22. package/esm2015/lib/interfaces/select-option.js +1 -1
  23. package/esm2015/lib/interfaces/validator.js +1 -1
  24. package/esm2015/lib/services/filter.service.js +35 -33
  25. package/esm2015/lib/services/form-constructor.service.js +5 -6
  26. package/esm2015/lib/services/questionnaire.service.js +3 -3
  27. package/esm2015/public_api.js +1 -1
  28. package/esm5/glowgreen-gg-questionnaire-v2.js +1 -1
  29. package/esm5/lib/enums/condition-relationship.enum.js +1 -1
  30. package/esm5/lib/enums/condition-type.enum.js +1 -1
  31. package/esm5/lib/enums/input-type.enum.js +1 -1
  32. package/esm5/lib/enums/question-type.enum.js +1 -1
  33. package/esm5/lib/enums/repeater-question-type.enum.js +1 -1
  34. package/esm5/lib/enums/validation-type.enum.js +1 -1
  35. package/esm5/lib/gg-questionnaire-v2.module.js +1 -1
  36. package/esm5/lib/interfaces/attachment.js +1 -1
  37. package/esm5/lib/interfaces/checklist-item.js +1 -1
  38. package/esm5/lib/interfaces/condition-group.js +1 -1
  39. package/esm5/lib/interfaces/condition.js +1 -1
  40. package/esm5/lib/interfaces/question.js +1 -1
  41. package/esm5/lib/interfaces/questionnaire-options.js +1 -1
  42. package/esm5/lib/interfaces/questionnaire.js +1 -1
  43. package/esm5/lib/interfaces/repeater-question.js +1 -1
  44. package/esm5/lib/interfaces/section.js +1 -1
  45. package/esm5/lib/interfaces/select-option.js +1 -1
  46. package/esm5/lib/interfaces/validator.js +1 -1
  47. package/esm5/lib/services/filter.service.js +52 -50
  48. package/esm5/lib/services/form-constructor.service.js +7 -8
  49. package/esm5/lib/services/questionnaire.service.js +11 -10
  50. package/esm5/public_api.js +1 -1
  51. package/fesm2015/glowgreen-gg-questionnaire-v2.js +125 -50
  52. package/fesm2015/glowgreen-gg-questionnaire-v2.js.map +1 -1
  53. package/fesm5/glowgreen-gg-questionnaire-v2.js +151 -75
  54. package/fesm5/glowgreen-gg-questionnaire-v2.js.map +1 -1
  55. package/lib/services/questionnaire.service.d.ts +8 -8
  56. package/package.json +3 -3
@@ -1,126 +1,199 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), require('@angular/core'), require('@angular/forms')) :
3
- typeof define === 'function' && define.amd ? define('@glowgreen/gg-questionnaire-v2', ['exports', 'lodash', '@angular/core', '@angular/forms'], factory) :
4
- (factory((global.glowgreen = global.glowgreen || {}, global.glowgreen['gg-questionnaire-v2'] = {}),global._,global.ng.core,global.ng.forms));
5
- }(this, (function (exports,_,i0,i1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('lodash')) :
3
+ typeof define === 'function' && define.amd ? define('@glowgreen/gg-questionnaire-v2', ['exports', '@angular/core', '@angular/forms', 'lodash'], factory) :
4
+ (global = global || self, factory((global.glowgreen = global.glowgreen || {}, global.glowgreen['gg-questionnaire-v2'] = {}), global.ng.core, global.ng.forms, global.lodash));
5
+ }(this, function (exports, core, forms, lodash) { 'use strict';
6
6
 
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation. All rights reserved.
9
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10
- this file except in compliance with the License. You may obtain a copy of the
11
- License at http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16
- MERCHANTABLITY OR NON-INFRINGEMENT.
17
-
18
- See the Apache Version 2.0 License for specific language governing permissions
19
- and limitations under the License.
20
- ***************************************************************************** */
21
- function __awaiter(thisArg, _arguments, P, generator) {
22
- return new (P || (P = Promise))(function (resolve, reject) {
23
- function fulfilled(value) { try {
24
- step(generator.next(value));
25
- }
26
- catch (e) {
27
- reject(e);
28
- } }
29
- function rejected(value) { try {
30
- step(generator["throw"](value));
31
- }
32
- catch (e) {
33
- reject(e);
34
- } }
35
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
36
- step((generator = generator.apply(thisArg, _arguments || [])).next());
37
- });
38
- }
39
- function __generator(thisArg, body) {
40
- var _$$1 = { label: 0, sent: function () { if (t[0] & 1)
41
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
42
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
43
- function verb(n) { return function (v) { return step([n, v]); }; }
44
- function step(op) {
45
- if (f)
46
- throw new TypeError("Generator is already executing.");
47
- while (_$$1)
48
- try {
49
- 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)
50
- return t;
51
- if (y = 0, t)
52
- op = [op[0] & 2, t.value];
53
- switch (op[0]) {
54
- case 0:
55
- case 1:
56
- t = op;
57
- break;
58
- case 4:
59
- _$$1.label++;
60
- return { value: op[1], done: false };
61
- case 5:
62
- _$$1.label++;
63
- y = op[1];
64
- op = [0];
65
- continue;
66
- case 7:
67
- op = _$$1.ops.pop();
68
- _$$1.trys.pop();
69
- continue;
70
- default:
71
- if (!(t = _$$1.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
72
- _$$1 = 0;
73
- continue;
74
- }
75
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
76
- _$$1.label = op[1];
77
- break;
78
- }
79
- if (op[0] === 6 && _$$1.label < t[1]) {
80
- _$$1.label = t[1];
81
- t = op;
82
- break;
83
- }
84
- if (t && _$$1.label < t[2]) {
85
- _$$1.label = t[2];
86
- _$$1.ops.push(op);
87
- break;
88
- }
89
- if (t[2])
90
- _$$1.ops.pop();
91
- _$$1.trys.pop();
92
- continue;
93
- }
94
- op = body.call(thisArg, _$$1);
95
- }
96
- catch (e) {
97
- op = [6, e];
98
- y = 0;
99
- }
100
- finally {
101
- f = t = 0;
102
- }
103
- if (op[0] & 5)
104
- throw op[1];
105
- return { value: op[0] ? op[1] : void 0, done: true };
106
- }
107
- }
108
- function __values(o) {
109
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
110
- if (m)
111
- return m.call(o);
112
- return {
113
- next: function () {
114
- if (o && i >= o.length)
115
- o = void 0;
116
- return { value: o && o[i++], done: !o };
117
- }
118
- };
7
+ /*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation. All rights reserved.
9
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10
+ this file except in compliance with the License. You may obtain a copy of the
11
+ License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16
+ MERCHANTABLITY OR NON-INFRINGEMENT.
17
+
18
+ See the Apache Version 2.0 License for specific language governing permissions
19
+ and limitations under the License.
20
+ ***************************************************************************** */
21
+ /* global Reflect, Promise */
22
+
23
+ var extendStatics = function(d, b) {
24
+ extendStatics = Object.setPrototypeOf ||
25
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27
+ return extendStatics(d, b);
28
+ };
29
+
30
+ function __extends(d, b) {
31
+ extendStatics(d, b);
32
+ function __() { this.constructor = d; }
33
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
+ }
35
+
36
+ var __assign = function() {
37
+ __assign = Object.assign || function __assign(t) {
38
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
39
+ s = arguments[i];
40
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41
+ }
42
+ return t;
43
+ };
44
+ return __assign.apply(this, arguments);
45
+ };
46
+
47
+ function __rest(s, e) {
48
+ var t = {};
49
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
50
+ t[p] = s[p];
51
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
52
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
53
+ t[p[i]] = s[p[i]];
54
+ return t;
55
+ }
56
+
57
+ function __decorate(decorators, target, key, desc) {
58
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
59
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
60
+ 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;
61
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
62
+ }
63
+
64
+ function __param(paramIndex, decorator) {
65
+ return function (target, key) { decorator(target, key, paramIndex); }
66
+ }
67
+
68
+ function __metadata(metadataKey, metadataValue) {
69
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
70
+ }
71
+
72
+ function __awaiter(thisArg, _arguments, P, generator) {
73
+ return new (P || (P = Promise))(function (resolve, reject) {
74
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
75
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
76
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
77
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
78
+ });
79
+ }
80
+
81
+ function __generator(thisArg, body) {
82
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
83
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
84
+ function verb(n) { return function (v) { return step([n, v]); }; }
85
+ function step(op) {
86
+ if (f) throw new TypeError("Generator is already executing.");
87
+ while (_) try {
88
+ 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;
89
+ if (y = 0, t) op = [op[0] & 2, t.value];
90
+ switch (op[0]) {
91
+ case 0: case 1: t = op; break;
92
+ case 4: _.label++; return { value: op[1], done: false };
93
+ case 5: _.label++; y = op[1]; op = [0]; continue;
94
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
95
+ default:
96
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
97
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
98
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
99
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
100
+ if (t[2]) _.ops.pop();
101
+ _.trys.pop(); continue;
102
+ }
103
+ op = body.call(thisArg, _);
104
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
105
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
106
+ }
107
+ }
108
+
109
+ function __exportStar(m, exports) {
110
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
111
+ }
112
+
113
+ function __values(o) {
114
+ var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
115
+ if (m) return m.call(o);
116
+ return {
117
+ next: function () {
118
+ if (o && i >= o.length) o = void 0;
119
+ return { value: o && o[i++], done: !o };
120
+ }
121
+ };
122
+ }
123
+
124
+ function __read(o, n) {
125
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
126
+ if (!m) return o;
127
+ var i = m.call(o), r, ar = [], e;
128
+ try {
129
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
130
+ }
131
+ catch (error) { e = { error: error }; }
132
+ finally {
133
+ try {
134
+ if (r && !r.done && (m = i["return"])) m.call(i);
135
+ }
136
+ finally { if (e) throw e.error; }
137
+ }
138
+ return ar;
139
+ }
140
+
141
+ function __spread() {
142
+ for (var ar = [], i = 0; i < arguments.length; i++)
143
+ ar = ar.concat(__read(arguments[i]));
144
+ return ar;
145
+ }
146
+
147
+ function __await(v) {
148
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
149
+ }
150
+
151
+ function __asyncGenerator(thisArg, _arguments, generator) {
152
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
153
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
154
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
155
+ 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); }); }; }
156
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
157
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
158
+ function fulfill(value) { resume("next", value); }
159
+ function reject(value) { resume("throw", value); }
160
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
161
+ }
162
+
163
+ function __asyncDelegator(o) {
164
+ var i, p;
165
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
166
+ 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; }
167
+ }
168
+
169
+ function __asyncValues(o) {
170
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
171
+ var m = o[Symbol.asyncIterator], i;
172
+ 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);
173
+ 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); }); }; }
174
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
175
+ }
176
+
177
+ function __makeTemplateObject(cooked, raw) {
178
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
179
+ return cooked;
180
+ };
181
+
182
+ function __importStar(mod) {
183
+ if (mod && mod.__esModule) return mod;
184
+ var result = {};
185
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
186
+ result.default = mod;
187
+ return result;
188
+ }
189
+
190
+ function __importDefault(mod) {
191
+ return (mod && mod.__esModule) ? mod : { default: mod };
119
192
  }
120
193
 
121
194
  /**
122
195
  * @fileoverview added by tsickle
123
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
196
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
124
197
  */
125
198
  /** @enum {string} */
126
199
  var QuestionType = {
@@ -136,7 +209,7 @@
136
209
 
137
210
  /**
138
211
  * @fileoverview added by tsickle
139
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
212
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
140
213
  */
141
214
  /** @enum {string} */
142
215
  var ConditionType = {
@@ -150,7 +223,7 @@
150
223
 
151
224
  /**
152
225
  * @fileoverview added by tsickle
153
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
226
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
154
227
  */
155
228
  /** @enum {string} */
156
229
  var ConditionRelationship = {
@@ -160,7 +233,7 @@
160
233
 
161
234
  /**
162
235
  * @fileoverview added by tsickle
163
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
236
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
164
237
  */
165
238
  var FilterService = /** @class */ (function () {
166
239
  function FilterService() {
@@ -188,92 +261,80 @@
188
261
  * @param {?=} additionalData
189
262
  * @return {?} An array of filtered sections with their filtered questions.
190
263
  */
191
- function (sections, currentQuestionnaireForm, additionalData) {
192
- var e_1, _a, e_2, _b, e_3, _c;
193
- /** @type {?} */
194
- var filteredSections = [];
195
- try {
196
- for (var sections_1 = __values(sections), sections_1_1 = sections_1.next(); !sections_1_1.done; sections_1_1 = sections_1.next()) {
197
- var section = sections_1_1.value;
198
- if (this.meetsConditionGroups(section.conditionGroups, currentQuestionnaireForm, additionalData)) {
199
- /** @type {?} */
200
- var filteredQuestions = [];
201
- try {
202
- for (var _d = __values(section.questions), _e = _d.next(); !_e.done; _e = _d.next()) {
203
- var question = _e.value;
204
- if (this.meetsConditionGroups(question.conditionGroups, currentQuestionnaireForm, additionalData)) {
205
- if (question.repeaterQuestions) {
206
- try {
207
- for (var _f = __values(question.repeaterQuestions), _g = _f.next(); !_g.done; _g = _f.next()) {
208
- var repeaterQuestion = _g.value;
209
- if (this.meetsConditionGroups(repeaterQuestion.conditionGroups, currentQuestionnaireForm, additionalData)) ;
210
- }
211
- }
212
- catch (e_3_1) {
213
- e_3 = { error: e_3_1 };
214
- }
215
- finally {
216
- try {
217
- if (_g && !_g.done && (_c = _f.return))
218
- _c.call(_f);
219
- }
220
- finally {
221
- if (e_3)
222
- throw e_3.error;
223
- }
224
- }
225
- }
226
- if (question.fetchPath) {
227
- /** @type {?} */
228
- var options = additionalData[question.fetchPath];
229
- if (question.fetchSelectors && question.fetchSelectors.length > 0) {
230
- /** @type {?} */
231
- var values = this.getValuesForArray(question.fetchSelectors, currentQuestionnaireForm, additionalData);
232
- options = _.get(additionalData[question.fetchPath], values);
233
- }
234
- options = this.getFinalFetchArray(options);
235
- if (!question.selectOptions) {
236
- question.selectOptions = [];
237
- }
238
- question.selectOptions = question.selectOptions.concat(options);
264
+ function (sections, currentQuestionnaireForm, additionalData) {
265
+ var e_1, _a, e_2, _b, e_3, _c;
266
+ /** @type {?} */
267
+ var filteredSections = [];
268
+ try {
269
+ for (var sections_1 = __values(sections), sections_1_1 = sections_1.next(); !sections_1_1.done; sections_1_1 = sections_1.next()) {
270
+ var section = sections_1_1.value;
271
+ if (!this.meetsConditionGroups(section.conditionGroups, currentQuestionnaireForm, additionalData)) {
272
+ continue;
273
+ }
274
+ /** @type {?} */
275
+ var filteredQuestions = [];
276
+ try {
277
+ for (var _d = (e_2 = void 0, __values(section.questions)), _e = _d.next(); !_e.done; _e = _d.next()) {
278
+ var question = _e.value;
279
+ if (!this.meetsConditionGroups(question.conditionGroups, currentQuestionnaireForm, additionalData)) {
280
+ continue;
281
+ }
282
+ if (question.repeaterQuestions) {
283
+ /** @type {?} */
284
+ var filteredRepeaterQuestions = [];
285
+ try {
286
+ for (var _f = (e_3 = void 0, __values(question.repeaterQuestions)), _g = _f.next(); !_g.done; _g = _f.next()) {
287
+ var repeaterQuestion = _g.value;
288
+ if (this.meetsConditionGroups(repeaterQuestion.conditionGroups, currentQuestionnaireForm, additionalData)) {
289
+ filteredRepeaterQuestions.push(repeaterQuestion);
239
290
  }
240
- filteredQuestions.push(question);
241
291
  }
242
292
  }
293
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
294
+ finally {
295
+ try {
296
+ if (_g && !_g.done && (_c = _f.return)) _c.call(_f);
297
+ }
298
+ finally { if (e_3) throw e_3.error; }
299
+ }
243
300
  }
244
- catch (e_2_1) {
245
- e_2 = { error: e_2_1 };
246
- }
247
- finally {
248
- try {
249
- if (_e && !_e.done && (_b = _d.return))
250
- _b.call(_d);
301
+ if (question.fetchPath) {
302
+ /** @type {?} */
303
+ var options = additionalData[question.fetchPath];
304
+ if (question.fetchSelectors && question.fetchSelectors.length > 0) {
305
+ /** @type {?} */
306
+ var values = this.getValuesForArray(question.fetchSelectors, currentQuestionnaireForm, additionalData);
307
+ options = lodash.get(additionalData[question.fetchPath], values);
251
308
  }
252
- finally {
253
- if (e_2)
254
- throw e_2.error;
309
+ options = this.getFinalFetchArray(options);
310
+ if (!question.selectOptions) {
311
+ question.selectOptions = [];
255
312
  }
313
+ question.selectOptions = question.selectOptions.concat(options);
256
314
  }
257
- section.questions = filteredQuestions;
258
- filteredSections.push(section);
315
+ filteredQuestions.push(question);
259
316
  }
260
317
  }
261
- }
262
- catch (e_1_1) {
263
- e_1 = { error: e_1_1 };
264
- }
265
- finally {
266
- try {
267
- if (sections_1_1 && !sections_1_1.done && (_a = sections_1.return))
268
- _a.call(sections_1);
269
- }
318
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
270
319
  finally {
271
- if (e_1)
272
- throw e_1.error;
320
+ try {
321
+ if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
322
+ }
323
+ finally { if (e_2) throw e_2.error; }
273
324
  }
325
+ section.questions = filteredQuestions;
326
+ filteredSections.push(section);
274
327
  }
275
- return filteredSections;
276
- };
328
+ }
329
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
330
+ finally {
331
+ try {
332
+ if (sections_1_1 && !sections_1_1.done && (_a = sections_1.return)) _a.call(sections_1);
333
+ }
334
+ finally { if (e_1) throw e_1.error; }
335
+ }
336
+ return filteredSections;
337
+ };
277
338
  /**
278
339
  * @private
279
340
  * @param {?} items
@@ -284,47 +345,41 @@
284
345
  * @param {?} items
285
346
  * @return {?}
286
347
  */
287
- function (items) {
288
- var e_4, _a;
289
- if (!items) {
290
- return null;
291
- }
292
- if (!Array.isArray(items)) {
293
- items = _.keys(items);
294
- }
295
- if (items.length <= 0) {
296
- return null;
297
- }
298
- /** @type {?} */
299
- var convertedArray = [];
300
- try {
301
- for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
302
- var item = items_1_1.value;
303
- if (item) {
304
- if (item instanceof Object && item.value && item.label) {
305
- convertedArray.push(item);
306
- }
307
- else {
308
- convertedArray.push({ label: this.uppercase(item), value: item });
309
- }
348
+ function (items) {
349
+ var e_4, _a;
350
+ if (!items) {
351
+ return null;
352
+ }
353
+ if (!Array.isArray(items)) {
354
+ items = lodash.keys(items);
355
+ }
356
+ if (items.length <= 0) {
357
+ return null;
358
+ }
359
+ /** @type {?} */
360
+ var convertedArray = [];
361
+ try {
362
+ for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
363
+ var item = items_1_1.value;
364
+ if (item) {
365
+ if (item instanceof Object && item.value && item.label) {
366
+ convertedArray.push(item);
367
+ }
368
+ else {
369
+ convertedArray.push({ label: this.uppercase(item), value: item });
310
370
  }
311
371
  }
312
372
  }
313
- catch (e_4_1) {
314
- e_4 = { error: e_4_1 };
315
- }
316
- finally {
317
- try {
318
- if (items_1_1 && !items_1_1.done && (_a = items_1.return))
319
- _a.call(items_1);
320
- }
321
- finally {
322
- if (e_4)
323
- throw e_4.error;
324
- }
373
+ }
374
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
375
+ finally {
376
+ try {
377
+ if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
325
378
  }
326
- return convertedArray;
327
- };
379
+ finally { if (e_4) throw e_4.error; }
380
+ }
381
+ return convertedArray;
382
+ };
328
383
  /**
329
384
  * @private
330
385
  * @param {?} item
@@ -335,9 +390,9 @@
335
390
  * @param {?} item
336
391
  * @return {?}
337
392
  */
338
- function (item) {
339
- return item.charAt(0).toUpperCase() + item.slice(1);
340
- };
393
+ function (item) {
394
+ return item.charAt(0).toUpperCase() + item.slice(1);
395
+ };
341
396
  /**
342
397
  * Checks if each condition groups conditions have been met.
343
398
  * @param conditionGroups The array of condition groups.
@@ -363,18 +418,19 @@
363
418
  * @param {?=} additionalData
364
419
  * @return {?} A boolean stating if the condition groups conditions has been met.
365
420
  */
366
- function (conditionGroups, currentQuestionnaireForm, additionalData) {
367
- var _this = this;
368
- if (!conditionGroups || conditionGroups.length === 0) {
369
- return true;
370
- }
371
- return conditionGroups.every(( /**
372
- * @param {?} x
373
- * @return {?}
374
- */function (x) {
375
- return _this.meetsConditionGroup(x, currentQuestionnaireForm, additionalData) === true;
376
- }));
377
- };
421
+ function (conditionGroups, currentQuestionnaireForm, additionalData) {
422
+ var _this = this;
423
+ if (!conditionGroups || conditionGroups.length === 0) {
424
+ return true;
425
+ }
426
+ return conditionGroups.every((/**
427
+ * @param {?} x
428
+ * @return {?}
429
+ */
430
+ function (x) {
431
+ return _this.meetsConditionGroup(x, currentQuestionnaireForm, additionalData) === true;
432
+ }));
433
+ };
378
434
  /**
379
435
  * Checks if a condition groups conditions have been met.
380
436
  * @param conditionGroup The condition group to check.
@@ -400,51 +456,47 @@
400
456
  * @param {?=} additionalData
401
457
  * @return {?} A boolean stating if the condition group conditions has been met.
402
458
  */
403
- function (conditionGroup, currentQuestionnaireForm, additionalData) {
404
- var e_5, _a;
405
- if (!conditionGroup.conditions || conditionGroup.conditions.length === 0) {
406
- return true;
459
+ function (conditionGroup, currentQuestionnaireForm, additionalData) {
460
+ var e_5, _a;
461
+ if (!conditionGroup.conditions || conditionGroup.conditions.length === 0) {
462
+ return true;
463
+ }
464
+ /** @type {?} */
465
+ var results = [];
466
+ try {
467
+ for (var _b = __values(conditionGroup.conditions), _c = _b.next(); !_c.done; _c = _b.next()) {
468
+ var condition = _c.value;
469
+ results.push(this.meetsCondition(condition, currentQuestionnaireForm, additionalData));
407
470
  }
408
- /** @type {?} */
409
- var results = [];
471
+ }
472
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
473
+ finally {
410
474
  try {
411
- for (var _b = __values(conditionGroup.conditions), _c = _b.next(); !_c.done; _c = _b.next()) {
412
- var condition = _c.value;
413
- results.push(this.meetsCondition(condition, currentQuestionnaireForm, additionalData));
414
- }
415
- }
416
- catch (e_5_1) {
417
- e_5 = { error: e_5_1 };
418
- }
419
- finally {
420
- try {
421
- if (_c && !_c.done && (_a = _b.return))
422
- _a.call(_b);
423
- }
424
- finally {
425
- if (e_5)
426
- throw e_5.error;
427
- }
475
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
428
476
  }
429
- switch (conditionGroup.relationship) {
430
- case ConditionRelationship.Every:
431
- return results.every(( /**
432
- * @param {?} x
433
- * @return {?}
434
- */function (x) {
435
- return x === true;
436
- }));
437
- case ConditionRelationship.Any:
438
- return !!results.find(( /**
439
- * @param {?} x
440
- * @return {?}
441
- */function (x) {
442
- return x === true;
443
- }));
444
- default:
445
- return true;
446
- }
447
- };
477
+ finally { if (e_5) throw e_5.error; }
478
+ }
479
+ switch (conditionGroup.relationship) {
480
+ case ConditionRelationship.Every:
481
+ return results.every((/**
482
+ * @param {?} x
483
+ * @return {?}
484
+ */
485
+ function (x) {
486
+ return x === true;
487
+ }));
488
+ case ConditionRelationship.Any:
489
+ return !!results.find((/**
490
+ * @param {?} x
491
+ * @return {?}
492
+ */
493
+ function (x) {
494
+ return x === true;
495
+ }));
496
+ default:
497
+ return true;
498
+ }
499
+ };
448
500
  /**
449
501
  * Checks if a condition has been met.
450
502
  * @param condition The condition to check.
@@ -470,100 +522,90 @@
470
522
  * @param {?=} additionalData
471
523
  * @return {?} A boolean stating if the condition group conditions has been met.
472
524
  */
473
- function (condition, currentQuestionnaireForm, additionalData) {
474
- var e_6, _a, e_7, _b;
475
- /** @type {?} */
476
- var v1s = this.getValuesForArray(condition.v1s, currentQuestionnaireForm, additionalData);
477
- /** @type {?} */
478
- var v2s = this.getValuesForArray(condition.v2s, currentQuestionnaireForm, additionalData);
479
- /** @type {?} */
480
- var result = false;
481
- switch (condition.type) {
482
- case ConditionType.Excludes:
483
- result = v1s.filter(( /**
484
- * @param {?} v1
485
- * @return {?}
486
- */function (v1) {
487
- return v2s.indexOf(v1) > -1;
488
- })).length === 0;
489
- break;
490
- case ConditionType.Includes:
491
- result = v1s.filter(( /**
492
- * @param {?} v1
493
- * @return {?}
494
- */function (v1) {
495
- return v2s.indexOf(v1) > -1;
496
- })).length !== 0;
497
- break;
498
- default: try {
499
- for (var v2s_1 = __values(v2s), v2s_1_1 = v2s_1.next(); !v2s_1_1.done; v2s_1_1 = v2s_1.next()) {
500
- var v2 = v2s_1_1.value;
501
- try {
502
- for (var v1s_1 = __values(v1s), v1s_1_1 = v1s_1.next(); !v1s_1_1.done; v1s_1_1 = v1s_1.next()) {
503
- var v1 = v1s_1_1.value;
504
- switch (condition.type) {
505
- case ConditionType.EqualTo:
506
- v1 = this.getStringForValue(v1);
507
- v2 = this.getStringForValue(v2);
508
- if (v1 === v2) {
509
- result = true;
510
- }
511
- break;
512
- case ConditionType.NotEqualTo:
513
- v1 = this.getStringForValue(v1);
514
- v2 = this.getStringForValue(v2);
515
- if (v1 !== v2) {
516
- result = true;
517
- }
518
- break;
519
- case ConditionType.GreaterThan:
520
- v1 = parseFloat(v1);
521
- v2 = parseFloat(v2);
522
- if (v1 >= v2) {
523
- result = true;
524
- }
525
- break;
526
- case ConditionType.LessThan:
527
- v1 = parseFloat(v1);
528
- v2 = parseFloat(v2);
529
- if (v1 <= v2) {
530
- result = true;
531
- }
532
- break;
533
- }
534
- }
535
- }
536
- catch (e_7_1) {
537
- e_7 = { error: e_7_1 };
538
- }
539
- finally {
540
- try {
541
- if (v1s_1_1 && !v1s_1_1.done && (_b = v1s_1.return))
542
- _b.call(v1s_1);
543
- }
544
- finally {
545
- if (e_7)
546
- throw e_7.error;
525
+ function (condition, currentQuestionnaireForm, additionalData) {
526
+ var e_6, _a, e_7, _b;
527
+ /** @type {?} */
528
+ var v1s = this.getValuesForArray(condition.v1s, currentQuestionnaireForm, additionalData);
529
+ /** @type {?} */
530
+ var v2s = this.getValuesForArray(condition.v2s, currentQuestionnaireForm, additionalData);
531
+ /** @type {?} */
532
+ var result = false;
533
+ switch (condition.type) {
534
+ case ConditionType.Excludes:
535
+ result = v1s.filter((/**
536
+ * @param {?} v1
537
+ * @return {?}
538
+ */
539
+ function (v1) {
540
+ return v2s.indexOf(v1) > -1;
541
+ })).length === 0;
542
+ break;
543
+ case ConditionType.Includes:
544
+ result = v1s.filter((/**
545
+ * @param {?} v1
546
+ * @return {?}
547
+ */
548
+ function (v1) {
549
+ return v2s.indexOf(v1) > -1;
550
+ })).length !== 0;
551
+ break;
552
+ default: try {
553
+ for (var v2s_1 = __values(v2s), v2s_1_1 = v2s_1.next(); !v2s_1_1.done; v2s_1_1 = v2s_1.next()) {
554
+ var v2 = v2s_1_1.value;
555
+ try {
556
+ for (var v1s_1 = (e_7 = void 0, __values(v1s)), v1s_1_1 = v1s_1.next(); !v1s_1_1.done; v1s_1_1 = v1s_1.next()) {
557
+ var v1 = v1s_1_1.value;
558
+ switch (condition.type) {
559
+ case ConditionType.EqualTo:
560
+ v1 = this.getStringForValue(v1);
561
+ v2 = this.getStringForValue(v2);
562
+ if (v1 === v2) {
563
+ result = true;
564
+ }
565
+ break;
566
+ case ConditionType.NotEqualTo:
567
+ v1 = this.getStringForValue(v1);
568
+ v2 = this.getStringForValue(v2);
569
+ if (v1 !== v2) {
570
+ result = true;
571
+ }
572
+ break;
573
+ case ConditionType.GreaterThan:
574
+ v1 = parseFloat(v1);
575
+ v2 = parseFloat(v2);
576
+ if (v1 >= v2) {
577
+ result = true;
578
+ }
579
+ break;
580
+ case ConditionType.LessThan:
581
+ v1 = parseFloat(v1);
582
+ v2 = parseFloat(v2);
583
+ if (v1 <= v2) {
584
+ result = true;
585
+ }
586
+ break;
547
587
  }
548
588
  }
549
589
  }
550
- }
551
- catch (e_6_1) {
552
- e_6 = { error: e_6_1 };
553
- }
554
- finally {
555
- try {
556
- if (v2s_1_1 && !v2s_1_1.done && (_a = v2s_1.return))
557
- _a.call(v2s_1);
558
- }
590
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
559
591
  finally {
560
- if (e_6)
561
- throw e_6.error;
592
+ try {
593
+ if (v1s_1_1 && !v1s_1_1.done && (_b = v1s_1.return)) _b.call(v1s_1);
594
+ }
595
+ finally { if (e_7) throw e_7.error; }
562
596
  }
563
597
  }
564
598
  }
565
- return result;
566
- };
599
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
600
+ finally {
601
+ try {
602
+ if (v2s_1_1 && !v2s_1_1.done && (_a = v2s_1.return)) _a.call(v2s_1);
603
+ }
604
+ finally { if (e_6) throw e_6.error; }
605
+ }
606
+ }
607
+ return result;
608
+ };
567
609
  /**
568
610
  * @private
569
611
  * @param {?} value
@@ -574,14 +616,14 @@
574
616
  * @param {?} value
575
617
  * @return {?}
576
618
  */
577
- function (value) {
578
- switch (value) {
579
- case null:
580
- return 'null';
581
- default:
582
- return value.toString();
583
- }
584
- };
619
+ function (value) {
620
+ switch (value) {
621
+ case null:
622
+ return 'null';
623
+ default:
624
+ return value.toString();
625
+ }
626
+ };
585
627
  /**
586
628
  * Gets the current values for an array of strings.
587
629
  * @param paths The array of strings to check.
@@ -607,38 +649,32 @@
607
649
  * @param {?=} additionalData
608
650
  * @return {?} An array of strings/values
609
651
  */
610
- function (paths, currentQuestionnaireForm, additionalData) {
611
- var e_8, _a;
612
- if (currentQuestionnaireForm) {
613
- /** @type {?} */
614
- var values = [];
615
- try {
616
- for (var paths_1 = __values(paths), paths_1_1 = paths_1.next(); !paths_1_1.done; paths_1_1 = paths_1.next()) {
617
- var path = paths_1_1.value;
618
- /** @type {?} */
619
- var value = this.getValueForString(path, currentQuestionnaireForm, additionalData);
620
- values.push(value);
621
- }
622
- }
623
- catch (e_8_1) {
624
- e_8 = { error: e_8_1 };
625
- }
626
- finally {
627
- try {
628
- if (paths_1_1 && !paths_1_1.done && (_a = paths_1.return))
629
- _a.call(paths_1);
630
- }
631
- finally {
632
- if (e_8)
633
- throw e_8.error;
634
- }
652
+ function (paths, currentQuestionnaireForm, additionalData) {
653
+ var e_8, _a;
654
+ if (currentQuestionnaireForm) {
655
+ /** @type {?} */
656
+ var values = [];
657
+ try {
658
+ for (var paths_1 = __values(paths), paths_1_1 = paths_1.next(); !paths_1_1.done; paths_1_1 = paths_1.next()) {
659
+ var path = paths_1_1.value;
660
+ /** @type {?} */
661
+ var value = this.getValueForString(path, currentQuestionnaireForm, additionalData);
662
+ values.push(value);
635
663
  }
636
- return values;
637
664
  }
638
- else {
639
- return paths;
665
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
666
+ finally {
667
+ try {
668
+ if (paths_1_1 && !paths_1_1.done && (_a = paths_1.return)) _a.call(paths_1);
669
+ }
670
+ finally { if (e_8) throw e_8.error; }
640
671
  }
641
- };
672
+ return values;
673
+ }
674
+ else {
675
+ return paths;
676
+ }
677
+ };
642
678
  /**
643
679
  * Gets a current value for a string.
644
680
  * @param path The string value to check.
@@ -664,21 +700,21 @@
664
700
  * @param {?=} additionalData
665
701
  * @return {?} A string/value.
666
702
  */
667
- function (path, currentQuestionnaireForm, additionalData) {
668
- if (currentQuestionnaireForm) {
669
- if (!additionalData) {
670
- additionalData = {};
671
- }
672
- /** @type {?} */
673
- var control = currentQuestionnaireForm.get(path);
674
- /** @type {?} */
675
- var value = control ? control.value : this.convertStringToValue(path);
676
- return _.get(additionalData, path, value);
677
- }
678
- else {
679
- return this.convertStringToValue(path);
703
+ function (path, currentQuestionnaireForm, additionalData) {
704
+ if (currentQuestionnaireForm) {
705
+ if (!additionalData) {
706
+ additionalData = {};
680
707
  }
681
- };
708
+ /** @type {?} */
709
+ var control = currentQuestionnaireForm.get(path);
710
+ /** @type {?} */
711
+ var value = control ? control.value : this.convertStringToValue(path);
712
+ return lodash.get(additionalData, path, value);
713
+ }
714
+ else {
715
+ return this.convertStringToValue(path);
716
+ }
717
+ };
682
718
  /**
683
719
  * Converts a string to a value.
684
720
  * Eg. true/false.
@@ -702,32 +738,32 @@
702
738
  * @param {?} path The string value to check for conversion;
703
739
  * @return {?} Either a string or the converted value.
704
740
  */
705
- function (path) {
706
- switch (path) {
707
- case 'true':
708
- return true;
709
- case 'false':
710
- return false;
711
- case 'null':
712
- return null;
713
- default:
714
- return path;
715
- }
716
- };
741
+ function (path) {
742
+ switch (path) {
743
+ case 'true':
744
+ return true;
745
+ case 'false':
746
+ return false;
747
+ case 'null':
748
+ return null;
749
+ default:
750
+ return path;
751
+ }
752
+ };
717
753
  FilterService.decorators = [
718
- { type: i0.Injectable, args: [{
754
+ { type: core.Injectable, args: [{
719
755
  providedIn: 'root'
720
756
  },] }
721
757
  ];
722
758
  /** @nocollapse */
723
759
  FilterService.ctorParameters = function () { return []; };
724
- /** @nocollapse */ FilterService.ngInjectableDef = i0.defineInjectable({ factory: function FilterService_Factory() { return new FilterService(); }, token: FilterService, providedIn: "root" });
760
+ /** @nocollapse */ FilterService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function FilterService_Factory() { return new FilterService(); }, token: FilterService, providedIn: "root" });
725
761
  return FilterService;
726
762
  }());
727
763
 
728
764
  /**
729
765
  * @fileoverview added by tsickle
730
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
766
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
731
767
  */
732
768
  /** @enum {string} */
733
769
  var ValidationType = {
@@ -741,7 +777,7 @@
741
777
 
742
778
  /**
743
779
  * @fileoverview added by tsickle
744
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
780
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
745
781
  */
746
782
  var FormConstructorService = /** @class */ (function () {
747
783
  function FormConstructorService(fb, filterService) {
@@ -775,15 +811,15 @@
775
811
  * @param {?=} skipFilter
776
812
  * @return {?} A filted form group.
777
813
  */
778
- function (questionnaire, currentQuestionnaireForm, additionalData, skipFilter) {
779
- /** @type {?} */
780
- var sections = skipFilter ?
781
- questionnaire.sections :
782
- this.filterService.filterSections(questionnaire.sections, currentQuestionnaireForm, additionalData);
783
- /** @type {?} */
784
- var questionnaireForms = this.generateFormsForSections(sections, currentQuestionnaireForm);
785
- return { sections: sections, forms: questionnaireForms };
786
- };
814
+ function (questionnaire, currentQuestionnaireForm, additionalData, skipFilter) {
815
+ /** @type {?} */
816
+ var sections = skipFilter ?
817
+ questionnaire.sections :
818
+ this.filterService.filterSections(questionnaire.sections, currentQuestionnaireForm, additionalData);
819
+ /** @type {?} */
820
+ var questionnaireForms = this.generateFormsForSections(sections, currentQuestionnaireForm);
821
+ return { sections: sections, forms: questionnaireForms };
822
+ };
787
823
  /**
788
824
  * @private
789
825
  * @param {?} sections
@@ -796,33 +832,27 @@
796
832
  * @param {?} currentQuestionnaireForm
797
833
  * @return {?}
798
834
  */
799
- function (sections, currentQuestionnaireForm) {
800
- var e_1, _a;
801
- /** @type {?} */
802
- var questionnaireForms = this.fb.group({});
803
- try {
804
- for (var sections_1 = __values(sections), sections_1_1 = sections_1.next(); !sections_1_1.done; sections_1_1 = sections_1.next()) {
805
- var section = sections_1_1.value;
806
- /** @type {?} */
807
- var sectionForms = this.generateFormsForSection(section, currentQuestionnaireForm);
808
- questionnaireForms.addControl(section.name, sectionForms);
809
- }
810
- }
811
- catch (e_1_1) {
812
- e_1 = { error: e_1_1 };
835
+ function (sections, currentQuestionnaireForm) {
836
+ var e_1, _a;
837
+ /** @type {?} */
838
+ var questionnaireForms = this.fb.group({});
839
+ try {
840
+ for (var sections_1 = __values(sections), sections_1_1 = sections_1.next(); !sections_1_1.done; sections_1_1 = sections_1.next()) {
841
+ var section = sections_1_1.value;
842
+ /** @type {?} */
843
+ var sectionForms = this.generateFormsForSection(section, currentQuestionnaireForm);
844
+ questionnaireForms.addControl(section.name, sectionForms);
813
845
  }
814
- finally {
815
- try {
816
- if (sections_1_1 && !sections_1_1.done && (_a = sections_1.return))
817
- _a.call(sections_1);
818
- }
819
- finally {
820
- if (e_1)
821
- throw e_1.error;
822
- }
846
+ }
847
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
848
+ finally {
849
+ try {
850
+ if (sections_1_1 && !sections_1_1.done && (_a = sections_1.return)) _a.call(sections_1);
823
851
  }
824
- return questionnaireForms;
825
- };
852
+ finally { if (e_1) throw e_1.error; }
853
+ }
854
+ return questionnaireForms;
855
+ };
826
856
  /**
827
857
  * Constructs a form group based on the section data.
828
858
  * This form group has been filtered down based on the conditions of the questions.
@@ -848,33 +878,27 @@
848
878
  * @param {?} currentQuestionnaireForm
849
879
  * @return {?} A filtered form group.
850
880
  */
851
- function (section, currentQuestionnaireForm) {
852
- var e_2, _a;
853
- /** @type {?} */
854
- var sectionForms = this.fb.group({});
855
- try {
856
- for (var _b = __values(section.questions), _c = _b.next(); !_c.done; _c = _b.next()) {
857
- var question = _c.value;
858
- /** @type {?} */
859
- var questionControl = this.generateControlForQuestion(question, section, currentQuestionnaireForm);
860
- sectionForms.addControl(question.name, questionControl);
861
- }
862
- }
863
- catch (e_2_1) {
864
- e_2 = { error: e_2_1 };
881
+ function (section, currentQuestionnaireForm) {
882
+ var e_2, _a;
883
+ /** @type {?} */
884
+ var sectionForms = this.fb.group({});
885
+ try {
886
+ for (var _b = __values(section.questions), _c = _b.next(); !_c.done; _c = _b.next()) {
887
+ var question = _c.value;
888
+ /** @type {?} */
889
+ var questionControl = this.generateControlForQuestion(question, section, currentQuestionnaireForm);
890
+ sectionForms.addControl(question.name, questionControl);
865
891
  }
866
- finally {
867
- try {
868
- if (_c && !_c.done && (_a = _b.return))
869
- _a.call(_b);
870
- }
871
- finally {
872
- if (e_2)
873
- throw e_2.error;
874
- }
892
+ }
893
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
894
+ finally {
895
+ try {
896
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
875
897
  }
876
- return sectionForms;
877
- };
898
+ finally { if (e_2) throw e_2.error; }
899
+ }
900
+ return sectionForms;
901
+ };
878
902
  /**
879
903
  * Constructs an astract form control based on the question data.
880
904
  * @param question The question data to build the abstract control on.
@@ -899,22 +923,20 @@
899
923
  * @param {?} currentQuestionnaireForm
900
924
  * @return {?} An abstract control.
901
925
  */
902
- function (question, section, currentQuestionnaireForm) {
903
- /** @type {?} */
904
- var convertedValidators = this.convertValidators(question.validators);
905
- switch (question.type) {
906
- case QuestionType.Repeater:
907
- /** @type {?} */
908
- var currentArray = currentQuestionnaireForm ? (( /** @type {?} */(currentQuestionnaireForm.get([section.name, question.name])))) : false;
909
- /** @type {?} */
910
- var newArray = currentArray ? currentArray.controls : [];
911
- return this.fb.array(newArray, convertedValidators);
912
- case QuestionType.Checklist:
913
- return this.generateGroupForChecklist(question, convertedValidators);
914
- default:
915
- return this.fb.control(null, { validators: convertedValidators, updateOn: 'blur' });
916
- }
917
- };
926
+ function (question, section, currentQuestionnaireForm) {
927
+ /** @type {?} */
928
+ var convertedValidators = this.convertValidators(question.validators);
929
+ switch (question.type) {
930
+ case QuestionType.Repeater:
931
+ /** @type {?} */
932
+ var currentArray = currentQuestionnaireForm ? ((/** @type {?} */ (currentQuestionnaireForm.get([section.name, question.name])))) : false;
933
+ return currentArray ? currentArray : this.fb.array([], convertedValidators);
934
+ case QuestionType.Checklist:
935
+ return this.generateGroupForChecklist(question, convertedValidators);
936
+ default:
937
+ return this.fb.control(null, { validators: convertedValidators, updateOn: 'blur' });
938
+ }
939
+ };
918
940
  /**
919
941
  * Generates the form group for a checklist question.
920
942
  * @param question The question. Must be of type checklist or else null is returned.
@@ -937,36 +959,30 @@
937
959
  * @param {?} convertedValidators
938
960
  * @return {?} A form group.
939
961
  */
940
- function (question, convertedValidators) {
941
- var e_3, _a;
942
- if (question.type !== QuestionType.Checklist || question.checklistItems.length === 0) {
943
- return null;
962
+ function (question, convertedValidators) {
963
+ var e_3, _a;
964
+ if (question.type !== QuestionType.Checklist || question.checklistItems.length === 0) {
965
+ return null;
966
+ }
967
+ /** @type {?} */
968
+ var checklistForms = this.fb.group({});
969
+ try {
970
+ for (var _b = __values(question.checklistItems), _c = _b.next(); !_c.done; _c = _b.next()) {
971
+ var checklistItem = _c.value;
972
+ /** @type {?} */
973
+ var checklistItemControl = this.fb.control(null, convertedValidators);
974
+ checklistForms.addControl(checklistItem.name, checklistItemControl);
944
975
  }
945
- /** @type {?} */
946
- var checklistForms = this.fb.group({});
976
+ }
977
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
978
+ finally {
947
979
  try {
948
- for (var _b = __values(question.checklistItems), _c = _b.next(); !_c.done; _c = _b.next()) {
949
- var checklistItem = _c.value;
950
- /** @type {?} */
951
- var checklistItemControl = this.fb.control(null, convertedValidators);
952
- checklistForms.addControl(checklistItem.name, checklistItemControl);
953
- }
980
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
954
981
  }
955
- catch (e_3_1) {
956
- e_3 = { error: e_3_1 };
957
- }
958
- finally {
959
- try {
960
- if (_c && !_c.done && (_a = _b.return))
961
- _a.call(_b);
962
- }
963
- finally {
964
- if (e_3)
965
- throw e_3.error;
966
- }
967
- }
968
- return checklistForms;
969
- };
982
+ finally { if (e_3) throw e_3.error; }
983
+ }
984
+ return checklistForms;
985
+ };
970
986
  /**
971
987
  * Generates the form template for a repeater question.
972
988
  * @param question The question. Must be of type repeater or else null is returned.
@@ -985,37 +1001,31 @@
985
1001
  * @param {?} question The question. Must be of type repeater or else null is returned.
986
1002
  * @return {?} A form group.
987
1003
  */
988
- function (question) {
989
- var e_4, _a;
990
- if (question.type !== QuestionType.Repeater || question.repeaterQuestions.length === 0) {
991
- console.log('Question isnt a repeater or has no questions, returning null');
992
- return null;
1004
+ function (question) {
1005
+ var e_4, _a;
1006
+ if (question.type !== QuestionType.Repeater || question.repeaterQuestions.length === 0) {
1007
+ console.log('Question isnt a repeater or has no questions, returning null');
1008
+ return null;
1009
+ }
1010
+ /** @type {?} */
1011
+ var repeaterForms = this.fb.group({});
1012
+ try {
1013
+ for (var _b = __values(question.repeaterQuestions), _c = _b.next(); !_c.done; _c = _b.next()) {
1014
+ var repeaterQuestion = _c.value;
1015
+ /** @type {?} */
1016
+ var repeaterQuestionControl = this.generateControlForRepeaterQuestion(repeaterQuestion);
1017
+ repeaterForms.addControl(repeaterQuestion.name, repeaterQuestionControl);
993
1018
  }
994
- /** @type {?} */
995
- var repeaterForms = this.fb.group({});
1019
+ }
1020
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1021
+ finally {
996
1022
  try {
997
- for (var _b = __values(question.repeaterQuestions), _c = _b.next(); !_c.done; _c = _b.next()) {
998
- var repeaterQuestion = _c.value;
999
- /** @type {?} */
1000
- var repeaterQuestionControl = this.generateControlForRepeaterQuestion(repeaterQuestion);
1001
- repeaterForms.addControl(repeaterQuestion.name, repeaterQuestionControl);
1002
- }
1003
- }
1004
- catch (e_4_1) {
1005
- e_4 = { error: e_4_1 };
1023
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1006
1024
  }
1007
- finally {
1008
- try {
1009
- if (_c && !_c.done && (_a = _b.return))
1010
- _a.call(_b);
1011
- }
1012
- finally {
1013
- if (e_4)
1014
- throw e_4.error;
1015
- }
1016
- }
1017
- return repeaterForms;
1018
- };
1025
+ finally { if (e_4) throw e_4.error; }
1026
+ }
1027
+ return repeaterForms;
1028
+ };
1019
1029
  /**
1020
1030
  * Generates a control for a repeaters question.
1021
1031
  * @param repeaterQuestion A repeater question.
@@ -1036,11 +1046,11 @@
1036
1046
  * @param {?} repeaterQuestion A repeater question.
1037
1047
  * @return {?} An abstract control.
1038
1048
  */
1039
- function (repeaterQuestion) {
1040
- /** @type {?} */
1041
- var convertedValidators = this.convertValidators(repeaterQuestion.validators);
1042
- return this.fb.control(null, { validators: convertedValidators, updateOn: 'blur' });
1043
- };
1049
+ function (repeaterQuestion) {
1050
+ /** @type {?} */
1051
+ var convertedValidators = this.convertValidators(repeaterQuestion.validators);
1052
+ return this.fb.control(null, { validators: convertedValidators, updateOn: 'blur' });
1053
+ };
1044
1054
  /**
1045
1055
  * Converts an array of validators into form validators.
1046
1056
  * @param validators The uncoverted array of validators.
@@ -1061,38 +1071,32 @@
1061
1071
  * @param {?} validators The uncoverted array of validators.
1062
1072
  * @return {?} A convered array of form validators.
1063
1073
  */
1064
- function (validators) {
1065
- var e_5, _a;
1066
- if (!validators || validators.length === 0) {
1067
- return [];
1068
- }
1069
- /** @type {?} */
1070
- var convertedValidators = [];
1071
- try {
1072
- for (var validators_1 = __values(validators), validators_1_1 = validators_1.next(); !validators_1_1.done; validators_1_1 = validators_1.next()) {
1073
- var validator = validators_1_1.value;
1074
- /** @type {?} */
1075
- var convertedValidator = this.convertValidator(validator);
1076
- if (convertedValidator) {
1077
- convertedValidators.push(convertedValidator);
1078
- }
1074
+ function (validators) {
1075
+ var e_5, _a;
1076
+ if (!validators || validators.length === 0) {
1077
+ return [];
1078
+ }
1079
+ /** @type {?} */
1080
+ var convertedValidators = [];
1081
+ try {
1082
+ for (var validators_1 = __values(validators), validators_1_1 = validators_1.next(); !validators_1_1.done; validators_1_1 = validators_1.next()) {
1083
+ var validator = validators_1_1.value;
1084
+ /** @type {?} */
1085
+ var convertedValidator = this.convertValidator(validator);
1086
+ if (convertedValidator) {
1087
+ convertedValidators.push(convertedValidator);
1079
1088
  }
1080
1089
  }
1081
- catch (e_5_1) {
1082
- e_5 = { error: e_5_1 };
1083
- }
1084
- finally {
1085
- try {
1086
- if (validators_1_1 && !validators_1_1.done && (_a = validators_1.return))
1087
- _a.call(validators_1);
1088
- }
1089
- finally {
1090
- if (e_5)
1091
- throw e_5.error;
1092
- }
1090
+ }
1091
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1092
+ finally {
1093
+ try {
1094
+ if (validators_1_1 && !validators_1_1.done && (_a = validators_1.return)) _a.call(validators_1);
1093
1095
  }
1094
- return convertedValidators;
1095
- };
1096
+ finally { if (e_5) throw e_5.error; }
1097
+ }
1098
+ return convertedValidators;
1099
+ };
1096
1100
  /**
1097
1101
  * Converts a single validator into a form validator.
1098
1102
  * @param validator The unconverted validator.
@@ -1113,14 +1117,14 @@
1113
1117
  * @param {?} validator The unconverted validator.
1114
1118
  * @return {?} A converted form validator.
1115
1119
  */
1116
- function (validator) {
1117
- switch (validator.type) {
1118
- case ValidationType.Required:
1119
- return i1.Validators.required;
1120
- default:
1121
- return null;
1122
- }
1123
- };
1120
+ function (validator) {
1121
+ switch (validator.type) {
1122
+ case ValidationType.Required:
1123
+ return forms.Validators.required;
1124
+ default:
1125
+ return null;
1126
+ }
1127
+ };
1124
1128
  /**
1125
1129
  * Constructs the forms for repeaters from saved state.
1126
1130
  * @param savedState The saved state to load.
@@ -1140,104 +1144,97 @@
1140
1144
  * @param {?} currentQuestionnaireForm
1141
1145
  * @return {?}
1142
1146
  */
1143
- function (savedState, sections, currentQuestionnaireForm) {
1144
- var e_6, _a, e_7, _b, e_8, _c;
1145
- try {
1146
- for (var sections_2 = __values(sections), sections_2_1 = sections_2.next(); !sections_2_1.done; sections_2_1 = sections_2.next()) {
1147
- var section = sections_2_1.value;
1148
- try {
1149
- for (var _d = __values(section.questions), _e = _d.next(); !_e.done; _e = _d.next()) {
1150
- var question = _e.value;
1151
- if (question.type !== QuestionType.Repeater) {
1152
- continue;
1153
- }
1154
- /** @type {?} */
1155
- var repeaterArray = savedState[section.name][question.name];
1156
- if (!repeaterArray || repeaterArray.length === 0) {
1157
- continue;
1158
- }
1159
- /** @type {?} */
1160
- var repeaterFormArray = ( /** @type {?} */(currentQuestionnaireForm.get([section.name, question.name])));
1161
- if (repeaterFormArray.controls.length === repeaterArray.length) {
1162
- continue;
1163
- }
1164
- try {
1165
- for (var repeaterArray_1 = __values(repeaterArray), repeaterArray_1_1 = repeaterArray_1.next(); !repeaterArray_1_1.done; repeaterArray_1_1 = repeaterArray_1.next()) {
1166
- var repeaterItem = repeaterArray_1_1.value;
1167
- /** @type {?} */
1168
- var repeaterItemTemplate = this.generateFormsForRepeater(question);
1169
- repeaterFormArray.push(repeaterItemTemplate);
1170
- }
1171
- }
1172
- catch (e_8_1) {
1173
- e_8 = { error: e_8_1 };
1174
- }
1175
- finally {
1176
- try {
1177
- if (repeaterArray_1_1 && !repeaterArray_1_1.done && (_c = repeaterArray_1.return))
1178
- _c.call(repeaterArray_1);
1179
- }
1180
- finally {
1181
- if (e_8)
1182
- throw e_8.error;
1183
- }
1184
- }
1147
+ function (savedState, sections, currentQuestionnaireForm) {
1148
+ var e_6, _a, e_7, _b, e_8, _c;
1149
+ try {
1150
+ for (var sections_2 = __values(sections), sections_2_1 = sections_2.next(); !sections_2_1.done; sections_2_1 = sections_2.next()) {
1151
+ var section = sections_2_1.value;
1152
+ try {
1153
+ for (var _d = (e_7 = void 0, __values(section.questions)), _e = _d.next(); !_e.done; _e = _d.next()) {
1154
+ var question = _e.value;
1155
+ if (question.type !== QuestionType.Repeater) {
1156
+ continue;
1157
+ }
1158
+ /** @type {?} */
1159
+ var repeaterArray = savedState[section.name][question.name];
1160
+ if (!repeaterArray || repeaterArray.length === 0) {
1161
+ continue;
1162
+ }
1163
+ /** @type {?} */
1164
+ var repeaterFormArray = (/** @type {?} */ (currentQuestionnaireForm.get([section.name, question.name])));
1165
+ if (repeaterFormArray.controls.length === repeaterArray.length) {
1166
+ continue;
1185
1167
  }
1186
- }
1187
- catch (e_7_1) {
1188
- e_7 = { error: e_7_1 };
1189
- }
1190
- finally {
1191
1168
  try {
1192
- if (_e && !_e.done && (_b = _d.return))
1193
- _b.call(_d);
1169
+ // For each item that used to be there push a new empty template there to be populated.
1170
+ for (var repeaterArray_1 = (e_8 = void 0, __values(repeaterArray)), repeaterArray_1_1 = repeaterArray_1.next(); !repeaterArray_1_1.done; repeaterArray_1_1 = repeaterArray_1.next()) {
1171
+ var repeaterItem = repeaterArray_1_1.value;
1172
+ /** @type {?} */
1173
+ var repeaterItemTemplate = this.generateFormsForRepeater(question);
1174
+ repeaterFormArray.push(repeaterItemTemplate);
1175
+ }
1194
1176
  }
1177
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
1195
1178
  finally {
1196
- if (e_7)
1197
- throw e_7.error;
1179
+ try {
1180
+ if (repeaterArray_1_1 && !repeaterArray_1_1.done && (_c = repeaterArray_1.return)) _c.call(repeaterArray_1);
1181
+ }
1182
+ finally { if (e_8) throw e_8.error; }
1198
1183
  }
1199
1184
  }
1200
1185
  }
1201
- }
1202
- catch (e_6_1) {
1203
- e_6 = { error: e_6_1 };
1204
- }
1205
- finally {
1206
- try {
1207
- if (sections_2_1 && !sections_2_1.done && (_a = sections_2.return))
1208
- _a.call(sections_2);
1209
- }
1186
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1210
1187
  finally {
1211
- if (e_6)
1212
- throw e_6.error;
1188
+ try {
1189
+ if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
1190
+ }
1191
+ finally { if (e_7) throw e_7.error; }
1213
1192
  }
1214
1193
  }
1215
- };
1194
+ }
1195
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1196
+ finally {
1197
+ try {
1198
+ if (sections_2_1 && !sections_2_1.done && (_a = sections_2.return)) _a.call(sections_2);
1199
+ }
1200
+ finally { if (e_6) throw e_6.error; }
1201
+ }
1202
+ };
1216
1203
  FormConstructorService.decorators = [
1217
- { type: i0.Injectable, args: [{
1204
+ { type: core.Injectable, args: [{
1218
1205
  providedIn: 'root'
1219
1206
  },] }
1220
1207
  ];
1221
1208
  /** @nocollapse */
1222
- FormConstructorService.ctorParameters = function () {
1223
- return [
1224
- { type: i1.FormBuilder },
1225
- { type: FilterService }
1226
- ];
1227
- };
1228
- /** @nocollapse */ FormConstructorService.ngInjectableDef = i0.defineInjectable({ factory: function FormConstructorService_Factory() { return new FormConstructorService(i0.inject(i1.FormBuilder), i0.inject(FilterService)); }, token: FormConstructorService, providedIn: "root" });
1209
+ FormConstructorService.ctorParameters = function () { return [
1210
+ { type: forms.FormBuilder },
1211
+ { type: FilterService }
1212
+ ]; };
1213
+ /** @nocollapse */ FormConstructorService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function FormConstructorService_Factory() { return new FormConstructorService(core.ɵɵinject(forms.FormBuilder), core.ɵɵinject(FilterService)); }, token: FormConstructorService, providedIn: "root" });
1229
1214
  return FormConstructorService;
1230
1215
  }());
1216
+ if (false) {
1217
+ /**
1218
+ * @type {?}
1219
+ * @private
1220
+ */
1221
+ FormConstructorService.prototype.fb;
1222
+ /**
1223
+ * @type {?}
1224
+ * @private
1225
+ */
1226
+ FormConstructorService.prototype.filterService;
1227
+ }
1231
1228
 
1232
1229
  /**
1233
1230
  * @fileoverview added by tsickle
1234
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1231
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1235
1232
  */
1236
1233
  var QuestionnaireService = /** @class */ (function () {
1237
1234
  function QuestionnaireService(formConstuctor, options) {
1238
1235
  this.formConstuctor = formConstuctor;
1239
1236
  this.options = options;
1240
- this.dataChangedEvent = new i0.EventEmitter();
1237
+ this.dataChangedEvent = new core.EventEmitter();
1241
1238
  this.skippable = false;
1242
1239
  }
1243
1240
  /**
@@ -1263,75 +1260,64 @@
1263
1260
  * @param {?=} additionalData
1264
1261
  * @return {?} null
1265
1262
  */
1266
- function (questionnaire, savedState, additionalData) {
1267
- return __awaiter(this, void 0, void 0, function () {
1268
- var e_1, _a, e_2, _b, newData, _c, _d, section, _e, _f, question, control;
1269
- return __generator(this, function (_g) {
1270
- switch (_g.label) {
1271
- case 0:
1272
- this.originalQuestionnaire = _.cloneDeep(questionnaire);
1273
- this.currentQuestionnaire = _.cloneDeep(questionnaire);
1274
- this.additionalData = additionalData;
1275
- if (savedState && Object.keys(savedState).length > 0) {
1276
- newData = this.formConstuctor.generateFormsForQuestionnaire(_.cloneDeep(this.originalQuestionnaire), this.currentQuestionnaireForm, this.additionalData, true);
1277
- this.formConstuctor.constructRepeaterFromsFromState(savedState, newData.sections, newData.forms);
1278
- this.currentQuestionnaireForm = newData.forms;
1279
- this.currentQuestionnaireForm.patchValue(savedState);
1280
- }
1281
- return [4 /*yield*/, this.updateQuestionnaire(savedState)];
1282
- case 1:
1283
- _g.sent();
1284
- try {
1285
- for (_c = __values(this.currentQuestionnaire.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
1286
- section = _d.value;
1287
- try {
1288
- for (_e = __values(section.questions), _f = _e.next(); !_f.done; _f = _e.next()) {
1289
- question = _f.value;
1290
- control = this.currentQuestionnaireForm.get([section.name, question.name]);
1291
- if (!control.value && question.defaultValue) {
1292
- control.setValue(question.defaultValue);
1293
- }
1294
- }
1295
- }
1296
- catch (e_2_1) {
1297
- e_2 = { error: e_2_1 };
1298
- }
1299
- finally {
1300
- try {
1301
- if (_f && !_f.done && (_b = _e.return))
1302
- _b.call(_e);
1303
- }
1304
- finally {
1305
- if (e_2)
1306
- throw e_2.error;
1263
+ function (questionnaire, savedState, additionalData) {
1264
+ return __awaiter(this, void 0, void 0, function () {
1265
+ var newData, _a, _b, section, _c, _d, question, control;
1266
+ var e_1, _e, e_2, _f;
1267
+ return __generator(this, function (_g) {
1268
+ switch (_g.label) {
1269
+ case 0:
1270
+ this.originalQuestionnaire = lodash.cloneDeep(questionnaire);
1271
+ this.currentQuestionnaire = lodash.cloneDeep(questionnaire);
1272
+ this.additionalData = additionalData;
1273
+ if (savedState && Object.keys(savedState).length > 0) {
1274
+ newData = this.formConstuctor.generateFormsForQuestionnaire(lodash.cloneDeep(this.originalQuestionnaire), this.currentQuestionnaireForm, this.additionalData, true);
1275
+ this.formConstuctor.constructRepeaterFromsFromState(savedState, newData.sections, newData.forms);
1276
+ this.currentQuestionnaireForm = newData.forms;
1277
+ this.currentQuestionnaireForm.patchValue(savedState);
1278
+ }
1279
+ return [4 /*yield*/, this.updateQuestionnaire(savedState)];
1280
+ case 1:
1281
+ _g.sent();
1282
+ try {
1283
+ for (_a = __values(this.currentQuestionnaire.sections), _b = _a.next(); !_b.done; _b = _a.next()) {
1284
+ section = _b.value;
1285
+ try {
1286
+ for (_c = (e_2 = void 0, __values(section.questions)), _d = _c.next(); !_d.done; _d = _c.next()) {
1287
+ question = _d.value;
1288
+ control = this.currentQuestionnaireForm.get([section.name, question.name]);
1289
+ if (!control.value && question.defaultValue) {
1290
+ control.setValue(question.defaultValue);
1307
1291
  }
1308
1292
  }
1309
1293
  }
1310
- }
1311
- catch (e_1_1) {
1312
- e_1 = { error: e_1_1 };
1313
- }
1314
- finally {
1315
- try {
1316
- if (_d && !_d.done && (_a = _c.return))
1317
- _a.call(_c);
1318
- }
1294
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1319
1295
  finally {
1320
- if (e_1)
1321
- throw e_1.error;
1296
+ try {
1297
+ if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
1298
+ }
1299
+ finally { if (e_2) throw e_2.error; }
1322
1300
  }
1323
1301
  }
1324
- if (this.options.skipToFirstSection) {
1325
- this.currentSectionName = Object.keys(this.currentQuestionnaireForm.controls)[0];
1326
- }
1327
- if (this.options.skipToFirstQuestion) {
1328
- this.currentQuestionName = Object.keys(this.currentSection.formGroup.controls)[0];
1302
+ }
1303
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1304
+ finally {
1305
+ try {
1306
+ if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
1329
1307
  }
1330
- return [2 /*return*/];
1331
- }
1332
- });
1308
+ finally { if (e_1) throw e_1.error; }
1309
+ }
1310
+ if (this.options.skipToFirstSection) {
1311
+ this.currentSectionName = Object.keys(this.currentQuestionnaireForm.controls)[0];
1312
+ }
1313
+ if (this.options.skipToFirstQuestion) {
1314
+ this.currentQuestionName = Object.keys(this.currentSection.formGroup.controls)[0];
1315
+ }
1316
+ return [2 /*return*/];
1317
+ }
1333
1318
  });
1334
- };
1319
+ });
1320
+ };
1335
1321
  /**
1336
1322
  * Updates the current questionnaire, used when a value is updated to check conditions.
1337
1323
  * @param savedState The saved state of the questionnaire, often from localstorage.
@@ -1348,42 +1334,45 @@
1348
1334
  * Updates the current questionnaire, used when a value is updated to check conditions.
1349
1335
  * @author Will Poulson
1350
1336
  * @param {?=} savedState The saved state of the questionnaire, often from localstorage.
1351
- * @return {?} null
1352
- */
1353
- function (savedState) {
1354
- var _this = this;
1355
- /** @type {?} */
1356
- var newData = this.formConstuctor.generateFormsForQuestionnaire(_.cloneDeep(this.originalQuestionnaire), this.currentQuestionnaireForm, this.additionalData);
1357
- this.currentQuestionnaireForm = newData.forms;
1358
- this.currentQuestionnaire.sections = newData.sections;
1359
- if (savedState && Object.keys(savedState).length > 0) {
1360
- this.currentQuestionnaireForm.patchValue(savedState);
1361
- }
1362
- if (this.questionnaireValueChangeSubscription) {
1363
- this.questionnaireValueChangeSubscription.unsubscribe();
1364
- }
1365
- if (this.questionValueChangeSubscription) {
1366
- this.questionValueChangeSubscription.unsubscribe();
1367
- }
1368
- this.questionnaireValueChangeSubscription = this.currentQuestionnaireForm.valueChanges.subscribe(( /**
1337
+ * @return {?} null
1338
+ */
1339
+ function (savedState) {
1340
+ var _this = this;
1341
+ /** @type {?} */
1342
+ var newData = this.formConstuctor.generateFormsForQuestionnaire(lodash.cloneDeep(this.originalQuestionnaire), this.currentQuestionnaireForm, this.additionalData);
1343
+ this.currentQuestionnaireForm = newData.forms;
1344
+ this.currentQuestionnaire.sections = newData.sections;
1345
+ if (savedState && Object.keys(savedState).length > 0) {
1346
+ this.currentQuestionnaireForm.patchValue(savedState);
1347
+ }
1348
+ if (this.questionnaireValueChangeSubscription) {
1349
+ this.questionnaireValueChangeSubscription.unsubscribe();
1350
+ }
1351
+ if (this.questionValueChangeSubscription) {
1352
+ this.questionValueChangeSubscription.unsubscribe();
1353
+ }
1354
+ this.questionnaireValueChangeSubscription = this.currentQuestionnaireForm.valueChanges.subscribe((/**
1355
+ * @return {?}
1356
+ */
1357
+ function () {
1358
+ _this.dataChangedEvent.emit();
1359
+ _this.updateQuestionnaire(_this.currentQuestionnaireForm.getRawValue());
1360
+ }));
1361
+ if (this.currentQuestion) {
1362
+ this.questionValueChangeSubscription = this.currentQuestion.formControl.valueChanges.subscribe((/**
1369
1363
  * @return {?}
1370
- */function () {
1371
- _this.dataChangedEvent.emit();
1372
- _this.updateQuestionnaire(_this.currentQuestionnaireForm.getRawValue());
1364
+ */
1365
+ function () {
1366
+ _this.clearFields(_this.currentQuestion.data.clearfields);
1373
1367
  }));
1374
- if (this.currentQuestion) {
1375
- this.questionValueChangeSubscription = this.currentQuestion.formControl.valueChanges.subscribe(( /**
1376
- * @return {?}
1377
- */function () {
1378
- _this.clearFields(_this.currentQuestion.data.clearfields);
1379
- }));
1380
- }
1381
- return;
1382
- };
1368
+ }
1369
+ return;
1370
+ };
1383
1371
  Object.defineProperty(QuestionnaireService.prototype, "isValid", {
1384
1372
  get: /**
1385
1373
  * @return {?}
1386
- */ function () {
1374
+ */
1375
+ function () {
1387
1376
  return this.currentQuestionnaireForm.valid;
1388
1377
  },
1389
1378
  enumerable: true,
@@ -1397,9 +1386,9 @@
1397
1386
  * @param {?} name
1398
1387
  * @return {?}
1399
1388
  */
1400
- function (name) {
1401
- return this.currentQuestionnaireForm.get(name).valid;
1402
- };
1389
+ function (name) {
1390
+ return this.currentQuestionnaireForm.get(name).valid;
1391
+ };
1403
1392
  /**
1404
1393
  * Clears all the fields parsed
1405
1394
  * @param clearfields An array of strings, paths to clear.
@@ -1419,35 +1408,29 @@
1419
1408
  * @param {?} clearfields An array of strings, paths to clear.
1420
1409
  * @return {?}
1421
1410
  */
1422
- function (clearfields) {
1423
- var e_3, _a;
1424
- if (!clearfields || clearfields.length === 0) {
1425
- return;
1426
- }
1427
- try {
1428
- for (var clearfields_1 = __values(clearfields), clearfields_1_1 = clearfields_1.next(); !clearfields_1_1.done; clearfields_1_1 = clearfields_1.next()) {
1429
- var clearfield = clearfields_1_1.value;
1430
- /** @type {?} */
1431
- var control = this.currentQuestionnaireForm.get(clearfield);
1432
- if (control) {
1433
- control.reset(undefined);
1434
- }
1411
+ function (clearfields) {
1412
+ var e_3, _a;
1413
+ if (!clearfields || clearfields.length === 0) {
1414
+ return;
1415
+ }
1416
+ try {
1417
+ for (var clearfields_1 = __values(clearfields), clearfields_1_1 = clearfields_1.next(); !clearfields_1_1.done; clearfields_1_1 = clearfields_1.next()) {
1418
+ var clearfield = clearfields_1_1.value;
1419
+ /** @type {?} */
1420
+ var control = this.currentQuestionnaireForm.get(clearfield);
1421
+ if (control) {
1422
+ control.reset(undefined);
1435
1423
  }
1436
1424
  }
1437
- catch (e_3_1) {
1438
- e_3 = { error: e_3_1 };
1439
- }
1440
- finally {
1441
- try {
1442
- if (clearfields_1_1 && !clearfields_1_1.done && (_a = clearfields_1.return))
1443
- _a.call(clearfields_1);
1444
- }
1445
- finally {
1446
- if (e_3)
1447
- throw e_3.error;
1448
- }
1425
+ }
1426
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1427
+ finally {
1428
+ try {
1429
+ if (clearfields_1_1 && !clearfields_1_1.done && (_a = clearfields_1.return)) _a.call(clearfields_1);
1449
1430
  }
1450
- };
1431
+ finally { if (e_3) throw e_3.error; }
1432
+ }
1433
+ };
1451
1434
  /**
1452
1435
  * Unloads the current questionnaire.
1453
1436
  * Useful when exiting a questionnaire page or completing a questionnaire.
@@ -1465,14 +1448,14 @@
1465
1448
  * @author Will Poulson
1466
1449
  * @return {?}
1467
1450
  */
1468
- function () {
1469
- this.originalQuestionnaire = undefined;
1470
- this.currentQuestionnaireForm = undefined;
1471
- this.currentQuestionnaire = undefined;
1472
- this.currentSectionName = undefined;
1473
- this.currentQuestionName = undefined;
1474
- this.additionalData = undefined;
1475
- };
1451
+ function () {
1452
+ this.originalQuestionnaire = undefined;
1453
+ this.currentQuestionnaireForm = undefined;
1454
+ this.currentQuestionnaire = undefined;
1455
+ this.currentSectionName = undefined;
1456
+ this.currentQuestionName = undefined;
1457
+ this.additionalData = undefined;
1458
+ };
1476
1459
  Object.defineProperty(QuestionnaireService.prototype, "currentSection", {
1477
1460
  /**
1478
1461
  * Gets the current selected section.
@@ -1483,16 +1466,18 @@
1483
1466
  * Gets the current selected section.
1484
1467
  * @author Will Poulson
1485
1468
  * @return {?} An object containing the section data and the related form group.
1486
- */ function () {
1469
+ */
1470
+ function () {
1487
1471
  var _this = this;
1488
1472
  if (!this.currentSectionName) {
1489
1473
  return null;
1490
1474
  }
1491
1475
  /** @type {?} */
1492
- var data = this.currentQuestionnaire.sections.find(( /**
1476
+ var data = this.currentQuestionnaire.sections.find((/**
1493
1477
  * @param {?} x
1494
1478
  * @return {?}
1495
- */function (x) {
1479
+ */
1480
+ function (x) {
1496
1481
  return x.name === _this.currentSectionName;
1497
1482
  }));
1498
1483
  if (!data) {
@@ -1500,7 +1485,7 @@
1500
1485
  }
1501
1486
  return {
1502
1487
  data: data,
1503
- formGroup: ( /** @type {?} */(this.currentQuestionnaireForm.get(data.name)))
1488
+ formGroup: (/** @type {?} */ (this.currentQuestionnaireForm.get(data.name)))
1504
1489
  };
1505
1490
  },
1506
1491
  enumerable: true,
@@ -1516,7 +1501,8 @@
1516
1501
  * Gets all the avaialble sections.
1517
1502
  * @author Will Poulson
1518
1503
  * @return {?} An array of all avaialble sections.
1519
- */ function () {
1504
+ */
1505
+ function () {
1520
1506
  if (!this.currentQuestionnaire || !this.currentQuestionnaire.sections) {
1521
1507
  return [];
1522
1508
  }
@@ -1535,7 +1521,8 @@
1535
1521
  * Gets the current data for the entire questionnaire.
1536
1522
  * @author Will Poulson
1537
1523
  * @return {?} An object of data.
1538
- */ function () {
1524
+ */
1525
+ function () {
1539
1526
  return this.currentQuestionnaireForm.getRawValue();
1540
1527
  },
1541
1528
  enumerable: true,
@@ -1551,16 +1538,18 @@
1551
1538
  * Gets the current selected question.
1552
1539
  * @author Will Poulson
1553
1540
  * @return {?} An object containing the question data and the related form control.
1554
- */ function () {
1541
+ */
1542
+ function () {
1555
1543
  var _this = this;
1556
1544
  if (!this.currentQuestionName) {
1557
1545
  return null;
1558
1546
  }
1559
1547
  /** @type {?} */
1560
- var data = this.currentSection.data.questions.find(( /**
1548
+ var data = this.currentSection.data.questions.find((/**
1561
1549
  * @param {?} x
1562
1550
  * @return {?}
1563
- */function (x) {
1551
+ */
1552
+ function (x) {
1564
1553
  return x.name === _this.currentQuestionName;
1565
1554
  }));
1566
1555
  if (!data) {
@@ -1568,7 +1557,7 @@
1568
1557
  }
1569
1558
  return {
1570
1559
  data: data,
1571
- formControl: ( /** @type {?} */(this.currentSection.formGroup.get(data.name)))
1560
+ formControl: (/** @type {?} */ (this.currentSection.formGroup.get(data.name)))
1572
1561
  };
1573
1562
  },
1574
1563
  enumerable: true,
@@ -1598,42 +1587,47 @@
1598
1587
  * @author Will Poulson
1599
1588
  * @return {?} A promise which will resolve when the question has been navigated to.
1600
1589
  */
1601
- function () {
1602
- var _this = this;
1603
- return new Promise(( /**
1604
- * @param {?} resolve
1605
- * @param {?} reject
1606
- * @return {?}
1607
- */function (resolve, reject) {
1608
- if (!_this.options.allowSkipRequiredField) {
1609
- if (!_this.currentQuestion.formControl.valid) {
1610
- return reject('Current question is invalid');
1611
- }
1590
+ function () {
1591
+ var _this = this;
1592
+ return new Promise((/**
1593
+ * @param {?} resolve
1594
+ * @param {?} reject
1595
+ * @return {?}
1596
+ */
1597
+ function (resolve, reject) {
1598
+ if (!_this.options.allowSkipRequiredField) {
1599
+ if (!_this.currentQuestion.formControl.valid) {
1600
+ return reject('Current question is invalid');
1612
1601
  }
1613
- _this.getCurrentQuestionIndex().then(( /**
1614
- * @param {?} currentIndex
1602
+ }
1603
+ _this.getCurrentQuestionIndex().then((/**
1604
+ * @param {?} currentIndex
1605
+ * @return {?}
1606
+ */
1607
+ function (currentIndex) {
1608
+ /** @type {?} */
1609
+ var newIndex = currentIndex + 1;
1610
+ _this.navigateToQuestion(newIndex).then((/**
1615
1611
  * @return {?}
1616
- */function (currentIndex) {
1617
- /** @type {?} */
1618
- var newIndex = currentIndex + 1;
1619
- _this.navigateToQuestion(newIndex).then(( /**
1620
- * @return {?}
1621
- */function () {
1622
- return resolve();
1623
- })).catch(( /**
1624
- * @param {?} error
1625
- * @return {?}
1626
- */function (error) {
1627
- return reject(error);
1628
- }));
1629
- })).catch(( /**
1612
+ */
1613
+ function () {
1614
+ return resolve();
1615
+ })).catch((/**
1630
1616
  * @param {?} error
1631
1617
  * @return {?}
1632
- */function (error) {
1618
+ */
1619
+ function (error) {
1633
1620
  return reject(error);
1634
1621
  }));
1622
+ })).catch((/**
1623
+ * @param {?} error
1624
+ * @return {?}
1625
+ */
1626
+ function (error) {
1627
+ return reject(error);
1635
1628
  }));
1636
- };
1629
+ }));
1630
+ };
1637
1631
  /**
1638
1632
  * Navigates to the previous question.
1639
1633
  * If there is no question to navigate to it will reject with a out of bounds exception.
@@ -1655,40 +1649,45 @@
1655
1649
  * @author Will Poulson
1656
1650
  * @return {?} A promise which will resolve when the question has been navigated to.
1657
1651
  */
1658
- function () {
1659
- var _this = this;
1660
- return new Promise(( /**
1661
- * @param {?} resolve
1662
- * @param {?} reject
1652
+ function () {
1653
+ var _this = this;
1654
+ return new Promise((/**
1655
+ * @param {?} resolve
1656
+ * @param {?} reject
1657
+ * @return {?}
1658
+ */
1659
+ function (resolve, reject) {
1660
+ if (!_this.options.allowNavigateBackwards) {
1661
+ return reject('This questionnaire does not allow for backwards navigation');
1662
+ }
1663
+ _this.getCurrentQuestionIndex().then((/**
1664
+ * @param {?} currentIndex
1663
1665
  * @return {?}
1664
- */function (resolve, reject) {
1665
- if (!_this.options.allowNavigateBackwards) {
1666
- return reject('This questionnaire does not allow for backwards navigation');
1667
- }
1668
- _this.getCurrentQuestionIndex().then(( /**
1669
- * @param {?} currentIndex
1666
+ */
1667
+ function (currentIndex) {
1668
+ /** @type {?} */
1669
+ var newIndex = currentIndex - 1;
1670
+ _this.navigateToQuestion(newIndex).then((/**
1670
1671
  * @return {?}
1671
- */function (currentIndex) {
1672
- /** @type {?} */
1673
- var newIndex = currentIndex - 1;
1674
- _this.navigateToQuestion(newIndex).then(( /**
1675
- * @return {?}
1676
- */function () {
1677
- return resolve();
1678
- })).catch(( /**
1679
- * @param {?} error
1680
- * @return {?}
1681
- */function (error) {
1682
- return reject(error);
1683
- }));
1684
- })).catch(( /**
1672
+ */
1673
+ function () {
1674
+ return resolve();
1675
+ })).catch((/**
1685
1676
  * @param {?} error
1686
1677
  * @return {?}
1687
- */function (error) {
1678
+ */
1679
+ function (error) {
1688
1680
  return reject(error);
1689
1681
  }));
1682
+ })).catch((/**
1683
+ * @param {?} error
1684
+ * @return {?}
1685
+ */
1686
+ function (error) {
1687
+ return reject(error);
1690
1688
  }));
1691
- };
1689
+ }));
1690
+ };
1692
1691
  /**
1693
1692
  * Gets the current questions index.
1694
1693
  * @returns A promise which resolves a number.
@@ -1706,21 +1705,22 @@
1706
1705
  * @private
1707
1706
  * @return {?} A promise which resolves a number.
1708
1707
  */
1709
- function () {
1710
- var _this = this;
1711
- return new Promise(( /**
1712
- * @param {?} resolve
1713
- * @param {?} reject
1714
- * @return {?}
1715
- */function (resolve, reject) {
1716
- /** @type {?} */
1717
- var currentIndex = _this.currentSection.data.questions.indexOf(_this.currentQuestion.data);
1718
- if (currentIndex === -1) {
1719
- return reject('Could not find current question');
1720
- }
1721
- return resolve(currentIndex);
1722
- }));
1723
- };
1708
+ function () {
1709
+ var _this = this;
1710
+ return new Promise((/**
1711
+ * @param {?} resolve
1712
+ * @param {?} reject
1713
+ * @return {?}
1714
+ */
1715
+ function (resolve, reject) {
1716
+ /** @type {?} */
1717
+ var currentIndex = _this.currentSection.data.questions.indexOf(_this.currentQuestion.data);
1718
+ if (currentIndex === -1) {
1719
+ return reject('Could not find current question');
1720
+ }
1721
+ return resolve(currentIndex);
1722
+ }));
1723
+ };
1724
1724
  /**
1725
1725
  * Checks a question is in bounds then navigates to it.
1726
1726
  * @param index The index to navigate to.
@@ -1739,20 +1739,21 @@
1739
1739
  * @param {?} index The index to navigate to.
1740
1740
  * @return {?} A promise which will resolve when the question has been navigated to.
1741
1741
  */
1742
- function (index) {
1743
- var _this = this;
1744
- return new Promise(( /**
1745
- * @param {?} resolve
1746
- * @param {?} reject
1747
- * @return {?}
1748
- */function (resolve, reject) {
1749
- if (_this.currentSection.data.questions.length - 1 < index || index < 0) {
1750
- return reject('Out of bounds exception');
1751
- }
1752
- _this.currentQuestionName = _this.currentSection.data.questions[index].name;
1753
- return resolve();
1754
- }));
1755
- };
1742
+ function (index) {
1743
+ var _this = this;
1744
+ return new Promise((/**
1745
+ * @param {?} resolve
1746
+ * @param {?} reject
1747
+ * @return {?}
1748
+ */
1749
+ function (resolve, reject) {
1750
+ if (_this.currentSection.data.questions.length - 1 < index || index < 0) {
1751
+ return reject('Out of bounds exception');
1752
+ }
1753
+ _this.currentQuestionName = _this.currentSection.data.questions[index].name;
1754
+ return resolve();
1755
+ }));
1756
+ };
1756
1757
  /**
1757
1758
  * Navigates to the next section.
1758
1759
  * @returns A promise which will resolve when the section has been navigated to.
@@ -1768,37 +1769,42 @@
1768
1769
  * @author Will Poulson
1769
1770
  * @return {?} A promise which will resolve when the section has been navigated to.
1770
1771
  */
1771
- function () {
1772
- var _this = this;
1773
- return new Promise(( /**
1774
- * @param {?} resolve
1775
- * @param {?} reject
1772
+ function () {
1773
+ var _this = this;
1774
+ return new Promise((/**
1775
+ * @param {?} resolve
1776
+ * @param {?} reject
1777
+ * @return {?}
1778
+ */
1779
+ function (resolve, reject) {
1780
+ _this.getCurrentSectionIndex().then((/**
1781
+ * @param {?} currentIndex
1776
1782
  * @return {?}
1777
- */function (resolve, reject) {
1778
- _this.getCurrentSectionIndex().then(( /**
1779
- * @param {?} currentIndex
1783
+ */
1784
+ function (currentIndex) {
1785
+ /** @type {?} */
1786
+ var newIndex = currentIndex + 1;
1787
+ _this.navigateToSection(newIndex).then((/**
1780
1788
  * @return {?}
1781
- */function (currentIndex) {
1782
- /** @type {?} */
1783
- var newIndex = currentIndex + 1;
1784
- _this.navigateToSection(newIndex).then(( /**
1785
- * @return {?}
1786
- */function () {
1787
- return resolve();
1788
- })).catch(( /**
1789
- * @param {?} error
1790
- * @return {?}
1791
- */function (error) {
1792
- return reject(error);
1793
- }));
1794
- })).catch(( /**
1789
+ */
1790
+ function () {
1791
+ return resolve();
1792
+ })).catch((/**
1795
1793
  * @param {?} error
1796
1794
  * @return {?}
1797
- */function (error) {
1795
+ */
1796
+ function (error) {
1798
1797
  return reject(error);
1799
1798
  }));
1799
+ })).catch((/**
1800
+ * @param {?} error
1801
+ * @return {?}
1802
+ */
1803
+ function (error) {
1804
+ return reject(error);
1800
1805
  }));
1801
- };
1806
+ }));
1807
+ };
1802
1808
  /**
1803
1809
  * Navigates to the previous section.
1804
1810
  * @returns A promise which will resolve when the section has been navigated to.
@@ -1814,37 +1820,42 @@
1814
1820
  * @author Will Poulson
1815
1821
  * @return {?} A promise which will resolve when the section has been navigated to.
1816
1822
  */
1817
- function () {
1818
- var _this = this;
1819
- return new Promise(( /**
1820
- * @param {?} resolve
1821
- * @param {?} reject
1823
+ function () {
1824
+ var _this = this;
1825
+ return new Promise((/**
1826
+ * @param {?} resolve
1827
+ * @param {?} reject
1828
+ * @return {?}
1829
+ */
1830
+ function (resolve, reject) {
1831
+ _this.getCurrentSectionIndex().then((/**
1832
+ * @param {?} currentIndex
1822
1833
  * @return {?}
1823
- */function (resolve, reject) {
1824
- _this.getCurrentSectionIndex().then(( /**
1825
- * @param {?} currentIndex
1834
+ */
1835
+ function (currentIndex) {
1836
+ /** @type {?} */
1837
+ var newIndex = currentIndex - 1;
1838
+ _this.navigateToQuestion(newIndex).then((/**
1826
1839
  * @return {?}
1827
- */function (currentIndex) {
1828
- /** @type {?} */
1829
- var newIndex = currentIndex - 1;
1830
- _this.navigateToQuestion(newIndex).then(( /**
1831
- * @return {?}
1832
- */function () {
1833
- return resolve();
1834
- })).catch(( /**
1835
- * @param {?} error
1836
- * @return {?}
1837
- */function (error) {
1838
- return reject(error);
1839
- }));
1840
- })).catch(( /**
1840
+ */
1841
+ function () {
1842
+ return resolve();
1843
+ })).catch((/**
1841
1844
  * @param {?} error
1842
1845
  * @return {?}
1843
- */function (error) {
1846
+ */
1847
+ function (error) {
1844
1848
  return reject(error);
1845
1849
  }));
1850
+ })).catch((/**
1851
+ * @param {?} error
1852
+ * @return {?}
1853
+ */
1854
+ function (error) {
1855
+ return reject(error);
1846
1856
  }));
1847
- };
1857
+ }));
1858
+ };
1848
1859
  /**
1849
1860
  * Gets the current section index.
1850
1861
  * @returns A promise which resolves a number.
@@ -1862,21 +1873,22 @@
1862
1873
  * @private
1863
1874
  * @return {?} A promise which resolves a number.
1864
1875
  */
1865
- function () {
1866
- var _this = this;
1867
- return new Promise(( /**
1868
- * @param {?} resolve
1869
- * @param {?} reject
1870
- * @return {?}
1871
- */function (resolve, reject) {
1872
- /** @type {?} */
1873
- var currentIndex = _this.currentQuestionnaire.sections.indexOf(_this.currentSection.data);
1874
- if (currentIndex === -1) {
1875
- return reject('Could not find current section');
1876
- }
1877
- return resolve(currentIndex);
1878
- }));
1879
- };
1876
+ function () {
1877
+ var _this = this;
1878
+ return new Promise((/**
1879
+ * @param {?} resolve
1880
+ * @param {?} reject
1881
+ * @return {?}
1882
+ */
1883
+ function (resolve, reject) {
1884
+ /** @type {?} */
1885
+ var currentIndex = _this.currentQuestionnaire.sections.indexOf(_this.currentSection.data);
1886
+ if (currentIndex === -1) {
1887
+ return reject('Could not find current section');
1888
+ }
1889
+ return resolve(currentIndex);
1890
+ }));
1891
+ };
1880
1892
  /**
1881
1893
  * Checks a section is in bounds then navigates to it.
1882
1894
  * @param index The index to navigate to.
@@ -1895,20 +1907,21 @@
1895
1907
  * @param {?} index The index to navigate to.
1896
1908
  * @return {?} A promise which will resolve when the section has been navigated to.
1897
1909
  */
1898
- function (index) {
1899
- var _this = this;
1900
- return new Promise(( /**
1901
- * @param {?} resolve
1902
- * @param {?} reject
1903
- * @return {?}
1904
- */function (resolve, reject) {
1905
- if (_this.currentQuestionnaire.sections.length - 1 < index || index < 0) {
1906
- return reject('Out of bounds exception');
1907
- }
1908
- _this.currentSectionName = _this.currentQuestionnaire.sections[index].name;
1909
- return resolve();
1910
- }));
1911
- };
1910
+ function (index) {
1911
+ var _this = this;
1912
+ return new Promise((/**
1913
+ * @param {?} resolve
1914
+ * @param {?} reject
1915
+ * @return {?}
1916
+ */
1917
+ function (resolve, reject) {
1918
+ if (_this.currentQuestionnaire.sections.length - 1 < index || index < 0) {
1919
+ return reject('Out of bounds exception');
1920
+ }
1921
+ _this.currentSectionName = _this.currentQuestionnaire.sections[index].name;
1922
+ return resolve();
1923
+ }));
1924
+ };
1912
1925
  /**
1913
1926
  * Answers the current question with the parsed value.
1914
1927
  * @param answer The value to answer the question with.
@@ -1928,19 +1941,20 @@
1928
1941
  * @param {?=} sendToNextQuestion
1929
1942
  * @return {?}
1930
1943
  */
1931
- function (answer, sendToNextQuestion) {
1932
- var _this = this;
1933
- this.currentQuestion.formControl.setValue(answer);
1934
- if (sendToNextQuestion && this.skippable) { // Timeout to prevent skipping glitch.
1935
- this.skippable = false;
1936
- setTimeout(( /**
1937
- * @return {?}
1938
- */function () {
1939
- _this.nextQuestion();
1940
- _this.skippable = true;
1941
- }), 150);
1942
- }
1943
- };
1944
+ function (answer, sendToNextQuestion) {
1945
+ var _this = this;
1946
+ this.currentQuestion.formControl.setValue(answer);
1947
+ if (sendToNextQuestion && this.skippable) { // Timeout to prevent skipping glitch.
1948
+ this.skippable = false;
1949
+ setTimeout((/**
1950
+ * @return {?}
1951
+ */
1952
+ function () {
1953
+ _this.nextQuestion();
1954
+ _this.skippable = true;
1955
+ }), 150);
1956
+ }
1957
+ };
1944
1958
  /**
1945
1959
  * Adds a repeater item to the current question.
1946
1960
  * Current question must be of type Repeater.
@@ -1959,28 +1973,29 @@
1959
1973
  * @author Will Poulson
1960
1974
  * @return {?} A promise which resolves when the repeater item has been added.
1961
1975
  */
1962
- function () {
1963
- var _this = this;
1964
- return new Promise(( /**
1965
- * @param {?} resolve
1966
- * @param {?} reject
1967
- * @return {?}
1968
- */function (resolve, reject) {
1969
- if (_this.currentQuestion.data.type !== QuestionType.Repeater) {
1970
- return reject("Current question isn't a repeater");
1971
- }
1972
- /** @type {?} */
1973
- var repeaterForm = _this.formConstuctor.generateFormsForRepeater(_this.currentQuestion.data);
1974
- if (!repeaterForm) {
1975
- return reject("Repeater template failed to generate. May be due to the repeater having no items in the editor.");
1976
- }
1977
- if (!(_this.currentQuestion.formControl instanceof i1.FormArray)) {
1978
- return reject("The current questions control isn't of type FormArray");
1979
- }
1980
- _this.currentQuestion.formControl.push(repeaterForm);
1981
- return resolve();
1982
- }));
1983
- };
1976
+ function () {
1977
+ var _this = this;
1978
+ return new Promise((/**
1979
+ * @param {?} resolve
1980
+ * @param {?} reject
1981
+ * @return {?}
1982
+ */
1983
+ function (resolve, reject) {
1984
+ if (_this.currentQuestion.data.type !== QuestionType.Repeater) {
1985
+ return reject("Current question isn't a repeater");
1986
+ }
1987
+ /** @type {?} */
1988
+ var repeaterForm = _this.formConstuctor.generateFormsForRepeater(_this.currentQuestion.data);
1989
+ if (!repeaterForm) {
1990
+ return reject("Repeater template failed to generate. May be due to the repeater having no items in the editor.");
1991
+ }
1992
+ if (!(_this.currentQuestion.formControl instanceof forms.FormArray)) {
1993
+ return reject("The current questions control isn't of type FormArray");
1994
+ }
1995
+ _this.currentQuestion.formControl.push(repeaterForm);
1996
+ return resolve();
1997
+ }));
1998
+ };
1984
1999
  /**
1985
2000
  * Removes a repeater item on the current question.
1986
2001
  * Current question must be of type Repeater.
@@ -2002,23 +2017,24 @@
2002
2017
  * @param {?} index The index at which to remove.
2003
2018
  * @return {?} A promise which resolves when the repeater item has been removed.
2004
2019
  */
2005
- function (index) {
2006
- var _this = this;
2007
- return new Promise(( /**
2008
- * @param {?} resolve
2009
- * @param {?} reject
2010
- * @return {?}
2011
- */function (resolve, reject) {
2012
- if (_this.currentQuestion.data.type !== QuestionType.Repeater) {
2013
- return reject("Current question isn't a repeater");
2014
- }
2015
- if (!(_this.currentQuestion.formControl instanceof i1.FormArray)) {
2016
- return reject("The current questions control isn't of type FormArray");
2017
- }
2018
- _this.currentQuestion.formControl.removeAt(index);
2019
- return resolve();
2020
- }));
2021
- };
2020
+ function (index) {
2021
+ var _this = this;
2022
+ return new Promise((/**
2023
+ * @param {?} resolve
2024
+ * @param {?} reject
2025
+ * @return {?}
2026
+ */
2027
+ function (resolve, reject) {
2028
+ if (_this.currentQuestion.data.type !== QuestionType.Repeater) {
2029
+ return reject("Current question isn't a repeater");
2030
+ }
2031
+ if (!(_this.currentQuestion.formControl instanceof forms.FormArray)) {
2032
+ return reject("The current questions control isn't of type FormArray");
2033
+ }
2034
+ _this.currentQuestion.formControl.removeAt(index);
2035
+ return resolve();
2036
+ }));
2037
+ };
2022
2038
  /**
2023
2039
  * Returns the display text for a given repeater item
2024
2040
  * @param index The index at which to get the label for.
@@ -2037,75 +2053,126 @@
2037
2053
  * @param {?} index The index at which to get the label for.
2038
2054
  * @return {?} A string which is the display text.
2039
2055
  */
2040
- function (index) {
2041
- var e_4, _a;
2042
- if (!this.currentQuestion.formControl || !(this.currentQuestion.formControl instanceof i1.FormArray)) {
2043
- return '';
2044
- }
2045
- /** @type {?} */
2046
- var repeaterItem = this.currentQuestion.formControl.controls[index];
2047
- if (!repeaterItem) {
2048
- return '';
2049
- }
2050
- /** @type {?} */
2051
- var template = this.currentQuestion.data.repeaterDisplayName;
2052
- /** @type {?} */
2053
- var splitTemplate = template.split(' ');
2054
- /** @type {?} */
2055
- var displayArray = [];
2056
- try {
2057
- for (var splitTemplate_1 = __values(splitTemplate), splitTemplate_1_1 = splitTemplate_1.next(); !splitTemplate_1_1.done; splitTemplate_1_1 = splitTemplate_1.next()) {
2058
- var templateItem = splitTemplate_1_1.value;
2059
- if (templateItem.match(/\[.*?\]/)) {
2060
- /** @type {?} */
2061
- var path = templateItem.replace(/[\[\]']+/g, '');
2062
- /** @type {?} */
2063
- var item = repeaterItem.get(path);
2064
- /** @type {?} */
2065
- var value = item.value ? item.value : '?';
2066
- displayArray.push(value);
2067
- }
2068
- else {
2069
- displayArray.push(templateItem);
2070
- }
2071
- }
2072
- }
2073
- catch (e_4_1) {
2074
- e_4 = { error: e_4_1 };
2075
- }
2076
- finally {
2077
- try {
2078
- if (splitTemplate_1_1 && !splitTemplate_1_1.done && (_a = splitTemplate_1.return))
2079
- _a.call(splitTemplate_1);
2056
+ function (index) {
2057
+ var e_4, _a;
2058
+ if (!this.currentQuestion.formControl || !(this.currentQuestion.formControl instanceof forms.FormArray)) {
2059
+ return '';
2060
+ }
2061
+ /** @type {?} */
2062
+ var repeaterItem = this.currentQuestion.formControl.controls[index];
2063
+ if (!repeaterItem) {
2064
+ return '';
2065
+ }
2066
+ /** @type {?} */
2067
+ var template = this.currentQuestion.data.repeaterDisplayName;
2068
+ /** @type {?} */
2069
+ var splitTemplate = template.split(' ');
2070
+ /** @type {?} */
2071
+ var displayArray = [];
2072
+ try {
2073
+ for (var splitTemplate_1 = __values(splitTemplate), splitTemplate_1_1 = splitTemplate_1.next(); !splitTemplate_1_1.done; splitTemplate_1_1 = splitTemplate_1.next()) {
2074
+ var templateItem = splitTemplate_1_1.value;
2075
+ if (templateItem.match(/\[.*?\]/)) {
2076
+ /** @type {?} */
2077
+ var path = templateItem.replace(/[\[\]']+/g, '');
2078
+ /** @type {?} */
2079
+ var item = repeaterItem.get(path);
2080
+ /** @type {?} */
2081
+ var value = item.value ? item.value : '?';
2082
+ displayArray.push(value);
2080
2083
  }
2081
- finally {
2082
- if (e_4)
2083
- throw e_4.error;
2084
+ else {
2085
+ displayArray.push(templateItem);
2084
2086
  }
2085
2087
  }
2086
- /** @type {?} */
2087
- var display = displayArray.join(' ');
2088
- return display;
2089
- };
2088
+ }
2089
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
2090
+ finally {
2091
+ try {
2092
+ if (splitTemplate_1_1 && !splitTemplate_1_1.done && (_a = splitTemplate_1.return)) _a.call(splitTemplate_1);
2093
+ }
2094
+ finally { if (e_4) throw e_4.error; }
2095
+ }
2096
+ /** @type {?} */
2097
+ var display = displayArray.join(' ');
2098
+ return display;
2099
+ };
2090
2100
  QuestionnaireService.decorators = [
2091
- { type: i0.Injectable, args: [{
2101
+ { type: core.Injectable, args: [{
2092
2102
  providedIn: 'root'
2093
2103
  },] }
2094
2104
  ];
2095
2105
  /** @nocollapse */
2096
- QuestionnaireService.ctorParameters = function () {
2097
- return [
2098
- { type: FormConstructorService },
2099
- { type: undefined, decorators: [{ type: i0.Inject, args: ['options',] }] }
2100
- ];
2101
- };
2102
- /** @nocollapse */ QuestionnaireService.ngInjectableDef = i0.defineInjectable({ factory: function QuestionnaireService_Factory() { return new QuestionnaireService(i0.inject(FormConstructorService), i0.inject("options")); }, token: QuestionnaireService, providedIn: "root" });
2106
+ QuestionnaireService.ctorParameters = function () { return [
2107
+ { type: FormConstructorService },
2108
+ { type: undefined, decorators: [{ type: core.Inject, args: ['options',] }] }
2109
+ ]; };
2110
+ /** @nocollapse */ QuestionnaireService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function QuestionnaireService_Factory() { return new QuestionnaireService(core.ɵɵinject(FormConstructorService), core.ɵɵinject("options")); }, token: QuestionnaireService, providedIn: "root" });
2103
2111
  return QuestionnaireService;
2104
2112
  }());
2113
+ if (false) {
2114
+ /** @type {?} */
2115
+ QuestionnaireService.prototype.dataChangedEvent;
2116
+ /**
2117
+ * @type {?}
2118
+ * @private
2119
+ */
2120
+ QuestionnaireService.prototype.originalQuestionnaire;
2121
+ /**
2122
+ * @type {?}
2123
+ * @private
2124
+ */
2125
+ QuestionnaireService.prototype.currentQuestionnaire;
2126
+ /**
2127
+ * @type {?}
2128
+ * @private
2129
+ */
2130
+ QuestionnaireService.prototype.currentQuestionnaireForm;
2131
+ /**
2132
+ * @type {?}
2133
+ * @private
2134
+ */
2135
+ QuestionnaireService.prototype.currentSectionName;
2136
+ /**
2137
+ * @type {?}
2138
+ * @private
2139
+ */
2140
+ QuestionnaireService.prototype.currentQuestionName;
2141
+ /**
2142
+ * @type {?}
2143
+ * @private
2144
+ */
2145
+ QuestionnaireService.prototype.questionnaireValueChangeSubscription;
2146
+ /**
2147
+ * @type {?}
2148
+ * @private
2149
+ */
2150
+ QuestionnaireService.prototype.questionValueChangeSubscription;
2151
+ /**
2152
+ * @type {?}
2153
+ * @private
2154
+ */
2155
+ QuestionnaireService.prototype.additionalData;
2156
+ /**
2157
+ * @type {?}
2158
+ * @private
2159
+ */
2160
+ QuestionnaireService.prototype.skippable;
2161
+ /**
2162
+ * @type {?}
2163
+ * @private
2164
+ */
2165
+ QuestionnaireService.prototype.formConstuctor;
2166
+ /**
2167
+ * @type {?}
2168
+ * @private
2169
+ */
2170
+ QuestionnaireService.prototype.options;
2171
+ }
2105
2172
 
2106
2173
  /**
2107
2174
  * @fileoverview added by tsickle
2108
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2175
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2109
2176
  */
2110
2177
  var GgQuestionnaireV2Module = /** @class */ (function () {
2111
2178
  function GgQuestionnaireV2Module() {
@@ -2118,28 +2185,28 @@
2118
2185
  * @param {?} options
2119
2186
  * @return {?}
2120
2187
  */
2121
- function (options) {
2122
- return {
2123
- ngModule: GgQuestionnaireV2Module,
2124
- providers: [
2125
- QuestionnaireService,
2126
- {
2127
- provide: 'options',
2128
- useValue: options
2129
- }
2130
- ]
2131
- };
2188
+ function (options) {
2189
+ return {
2190
+ ngModule: GgQuestionnaireV2Module,
2191
+ providers: [
2192
+ QuestionnaireService,
2193
+ {
2194
+ provide: 'options',
2195
+ useValue: options
2196
+ }
2197
+ ]
2132
2198
  };
2199
+ };
2133
2200
  GgQuestionnaireV2Module.decorators = [
2134
- { type: i0.NgModule, args: [{
2201
+ { type: core.NgModule, args: [{
2135
2202
  declarations: [],
2136
2203
  providers: [
2137
2204
  FormConstructorService,
2138
2205
  FilterService
2139
2206
  ],
2140
2207
  imports: [
2141
- i1.FormsModule,
2142
- i1.ReactiveFormsModule
2208
+ forms.FormsModule,
2209
+ forms.ReactiveFormsModule
2143
2210
  ],
2144
2211
  },] }
2145
2212
  ];
@@ -2148,7 +2215,7 @@
2148
2215
 
2149
2216
  /**
2150
2217
  * @fileoverview added by tsickle
2151
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2218
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2152
2219
  */
2153
2220
  /** @enum {string} */
2154
2221
  var InputType = {
@@ -2167,7 +2234,7 @@
2167
2234
 
2168
2235
  /**
2169
2236
  * @fileoverview added by tsickle
2170
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2237
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2171
2238
  */
2172
2239
  /** @enum {string} */
2173
2240
  var RepeaterQuestionType = {
@@ -2175,29 +2242,18 @@
2175
2242
  Select: 'select',
2176
2243
  };
2177
2244
 
2178
- /**
2179
- * @fileoverview added by tsickle
2180
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2181
- */
2182
-
2183
- /**
2184
- * @fileoverview added by tsickle
2185
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2186
- */
2187
-
2188
- exports.QuestionnaireService = QuestionnaireService;
2189
- exports.GgQuestionnaireV2Module = GgQuestionnaireV2Module;
2190
2245
  exports.ConditionRelationship = ConditionRelationship;
2191
2246
  exports.ConditionType = ConditionType;
2192
- exports.QuestionType = QuestionType;
2193
- exports.ValidationType = ValidationType;
2247
+ exports.GgQuestionnaireV2Module = GgQuestionnaireV2Module;
2194
2248
  exports.InputType = InputType;
2249
+ exports.QuestionType = QuestionType;
2250
+ exports.QuestionnaireService = QuestionnaireService;
2195
2251
  exports.RepeaterQuestionType = RepeaterQuestionType;
2196
- exports.ɵb = FilterService;
2252
+ exports.ValidationType = ValidationType;
2197
2253
  exports.ɵa = FormConstructorService;
2254
+ exports.ɵb = FilterService;
2198
2255
 
2199
2256
  Object.defineProperty(exports, '__esModule', { value: true });
2200
2257
 
2201
- })));
2202
-
2203
- //# sourceMappingURL=glowgreen-gg-questionnaire-v2.umd.js.map
2258
+ }));
2259
+ //# sourceMappingURL=glowgreen-gg-questionnaire-v2.umd.js.map