@glowgreen/gg-questionnaire-v2 0.0.12 → 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 -1131
  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 +2 -2
  25. package/esm2015/lib/services/form-constructor.service.js +2 -2
  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 +6 -6
  48. package/esm5/lib/services/form-constructor.service.js +5 -5
  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 +96 -22
  52. package/fesm2015/glowgreen-gg-questionnaire-v2.js.map +1 -1
  53. package/fesm5/glowgreen-gg-questionnaire-v2.js +108 -33
  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,94 +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
- continue;
200
- }
201
- /** @type {?} */
202
- var filteredQuestions = [];
203
- try {
204
- for (var _d = __values(section.questions), _e = _d.next(); !_e.done; _e = _d.next()) {
205
- var question = _e.value;
206
- if (!this.meetsConditionGroups(question.conditionGroups, currentQuestionnaireForm, additionalData)) {
207
- continue;
208
- }
209
- if (question.repeaterQuestions) {
210
- try {
211
- for (var _f = __values(question.repeaterQuestions), _g = _f.next(); !_g.done; _g = _f.next()) {
212
- var repeaterQuestion = _g.value;
213
- if (this.meetsConditionGroups(repeaterQuestion.conditionGroups, currentQuestionnaireForm, additionalData)) ;
214
- }
215
- }
216
- catch (e_3_1) {
217
- e_3 = { error: e_3_1 };
218
- }
219
- finally {
220
- try {
221
- if (_g && !_g.done && (_c = _f.return))
222
- _c.call(_f);
223
- }
224
- finally {
225
- if (e_3)
226
- throw e_3.error;
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);
227
290
  }
228
291
  }
229
292
  }
230
- if (question.fetchPath) {
231
- /** @type {?} */
232
- var options = additionalData[question.fetchPath];
233
- if (question.fetchSelectors && question.fetchSelectors.length > 0) {
234
- /** @type {?} */
235
- var values = this.getValuesForArray(question.fetchSelectors, currentQuestionnaireForm, additionalData);
236
- options = _.get(additionalData[question.fetchPath], values);
237
- }
238
- options = this.getFinalFetchArray(options);
239
- if (!question.selectOptions) {
240
- question.selectOptions = [];
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);
241
297
  }
242
- question.selectOptions = question.selectOptions.concat(options);
298
+ finally { if (e_3) throw e_3.error; }
243
299
  }
244
- filteredQuestions.push(question);
245
300
  }
246
- }
247
- catch (e_2_1) {
248
- e_2 = { error: e_2_1 };
249
- }
250
- finally {
251
- try {
252
- if (_e && !_e.done && (_b = _d.return))
253
- _b.call(_d);
254
- }
255
- finally {
256
- if (e_2)
257
- throw e_2.error;
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);
308
+ }
309
+ options = this.getFinalFetchArray(options);
310
+ if (!question.selectOptions) {
311
+ question.selectOptions = [];
312
+ }
313
+ question.selectOptions = question.selectOptions.concat(options);
258
314
  }
315
+ filteredQuestions.push(question);
259
316
  }
260
- section.questions = filteredQuestions;
261
- filteredSections.push(section);
262
- }
263
- }
264
- catch (e_1_1) {
265
- e_1 = { error: e_1_1 };
266
- }
267
- finally {
268
- try {
269
- if (sections_1_1 && !sections_1_1.done && (_a = sections_1.return))
270
- _a.call(sections_1);
271
317
  }
318
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
272
319
  finally {
273
- if (e_1)
274
- 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; }
275
324
  }
325
+ section.questions = filteredQuestions;
326
+ filteredSections.push(section);
276
327
  }
277
- return filteredSections;
278
- };
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
+ };
279
338
  /**
280
339
  * @private
281
340
  * @param {?} items
@@ -286,47 +345,41 @@
286
345
  * @param {?} items
287
346
  * @return {?}
288
347
  */
289
- function (items) {
290
- var e_4, _a;
291
- if (!items) {
292
- return null;
293
- }
294
- if (!Array.isArray(items)) {
295
- items = _.keys(items);
296
- }
297
- if (items.length <= 0) {
298
- return null;
299
- }
300
- /** @type {?} */
301
- var convertedArray = [];
302
- try {
303
- for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
304
- var item = items_1_1.value;
305
- if (item) {
306
- if (item instanceof Object && item.value && item.label) {
307
- convertedArray.push(item);
308
- }
309
- else {
310
- convertedArray.push({ label: this.uppercase(item), value: item });
311
- }
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 });
312
370
  }
313
371
  }
314
372
  }
315
- catch (e_4_1) {
316
- e_4 = { error: e_4_1 };
317
- }
318
- finally {
319
- try {
320
- if (items_1_1 && !items_1_1.done && (_a = items_1.return))
321
- _a.call(items_1);
322
- }
323
- finally {
324
- if (e_4)
325
- throw e_4.error;
326
- }
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);
327
378
  }
328
- return convertedArray;
329
- };
379
+ finally { if (e_4) throw e_4.error; }
380
+ }
381
+ return convertedArray;
382
+ };
330
383
  /**
331
384
  * @private
332
385
  * @param {?} item
@@ -337,9 +390,9 @@
337
390
  * @param {?} item
338
391
  * @return {?}
339
392
  */
340
- function (item) {
341
- return item.charAt(0).toUpperCase() + item.slice(1);
342
- };
393
+ function (item) {
394
+ return item.charAt(0).toUpperCase() + item.slice(1);
395
+ };
343
396
  /**
344
397
  * Checks if each condition groups conditions have been met.
345
398
  * @param conditionGroups The array of condition groups.
@@ -365,18 +418,19 @@
365
418
  * @param {?=} additionalData
366
419
  * @return {?} A boolean stating if the condition groups conditions has been met.
367
420
  */
368
- function (conditionGroups, currentQuestionnaireForm, additionalData) {
369
- var _this = this;
370
- if (!conditionGroups || conditionGroups.length === 0) {
371
- return true;
372
- }
373
- return conditionGroups.every(( /**
374
- * @param {?} x
375
- * @return {?}
376
- */function (x) {
377
- return _this.meetsConditionGroup(x, currentQuestionnaireForm, additionalData) === true;
378
- }));
379
- };
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
+ };
380
434
  /**
381
435
  * Checks if a condition groups conditions have been met.
382
436
  * @param conditionGroup The condition group to check.
@@ -402,51 +456,47 @@
402
456
  * @param {?=} additionalData
403
457
  * @return {?} A boolean stating if the condition group conditions has been met.
404
458
  */
405
- function (conditionGroup, currentQuestionnaireForm, additionalData) {
406
- var e_5, _a;
407
- if (!conditionGroup.conditions || conditionGroup.conditions.length === 0) {
408
- 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));
409
470
  }
410
- /** @type {?} */
411
- var results = [];
471
+ }
472
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
473
+ finally {
412
474
  try {
413
- for (var _b = __values(conditionGroup.conditions), _c = _b.next(); !_c.done; _c = _b.next()) {
414
- var condition = _c.value;
415
- results.push(this.meetsCondition(condition, currentQuestionnaireForm, additionalData));
416
- }
417
- }
418
- catch (e_5_1) {
419
- e_5 = { error: e_5_1 };
475
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
420
476
  }
421
- finally {
422
- try {
423
- if (_c && !_c.done && (_a = _b.return))
424
- _a.call(_b);
425
- }
426
- finally {
427
- if (e_5)
428
- throw e_5.error;
429
- }
430
- }
431
- switch (conditionGroup.relationship) {
432
- case ConditionRelationship.Every:
433
- return results.every(( /**
434
- * @param {?} x
435
- * @return {?}
436
- */function (x) {
437
- return x === true;
438
- }));
439
- case ConditionRelationship.Any:
440
- return !!results.find(( /**
441
- * @param {?} x
442
- * @return {?}
443
- */function (x) {
444
- return x === true;
445
- }));
446
- default:
447
- return true;
448
- }
449
- };
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
+ };
450
500
  /**
451
501
  * Checks if a condition has been met.
452
502
  * @param condition The condition to check.
@@ -472,100 +522,90 @@
472
522
  * @param {?=} additionalData
473
523
  * @return {?} A boolean stating if the condition group conditions has been met.
474
524
  */
475
- function (condition, currentQuestionnaireForm, additionalData) {
476
- var e_6, _a, e_7, _b;
477
- /** @type {?} */
478
- var v1s = this.getValuesForArray(condition.v1s, currentQuestionnaireForm, additionalData);
479
- /** @type {?} */
480
- var v2s = this.getValuesForArray(condition.v2s, currentQuestionnaireForm, additionalData);
481
- /** @type {?} */
482
- var result = false;
483
- switch (condition.type) {
484
- case ConditionType.Excludes:
485
- result = v1s.filter(( /**
486
- * @param {?} v1
487
- * @return {?}
488
- */function (v1) {
489
- return v2s.indexOf(v1) > -1;
490
- })).length === 0;
491
- break;
492
- case ConditionType.Includes:
493
- result = v1s.filter(( /**
494
- * @param {?} v1
495
- * @return {?}
496
- */function (v1) {
497
- return v2s.indexOf(v1) > -1;
498
- })).length !== 0;
499
- break;
500
- default: try {
501
- for (var v2s_1 = __values(v2s), v2s_1_1 = v2s_1.next(); !v2s_1_1.done; v2s_1_1 = v2s_1.next()) {
502
- var v2 = v2s_1_1.value;
503
- try {
504
- for (var v1s_1 = __values(v1s), v1s_1_1 = v1s_1.next(); !v1s_1_1.done; v1s_1_1 = v1s_1.next()) {
505
- var v1 = v1s_1_1.value;
506
- switch (condition.type) {
507
- case ConditionType.EqualTo:
508
- v1 = this.getStringForValue(v1);
509
- v2 = this.getStringForValue(v2);
510
- if (v1 === v2) {
511
- result = true;
512
- }
513
- break;
514
- case ConditionType.NotEqualTo:
515
- v1 = this.getStringForValue(v1);
516
- v2 = this.getStringForValue(v2);
517
- if (v1 !== v2) {
518
- result = true;
519
- }
520
- break;
521
- case ConditionType.GreaterThan:
522
- v1 = parseFloat(v1);
523
- v2 = parseFloat(v2);
524
- if (v1 >= v2) {
525
- result = true;
526
- }
527
- break;
528
- case ConditionType.LessThan:
529
- v1 = parseFloat(v1);
530
- v2 = parseFloat(v2);
531
- if (v1 <= v2) {
532
- result = true;
533
- }
534
- break;
535
- }
536
- }
537
- }
538
- catch (e_7_1) {
539
- e_7 = { error: e_7_1 };
540
- }
541
- finally {
542
- try {
543
- if (v1s_1_1 && !v1s_1_1.done && (_b = v1s_1.return))
544
- _b.call(v1s_1);
545
- }
546
- finally {
547
- if (e_7)
548
- 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;
549
587
  }
550
588
  }
551
589
  }
552
- }
553
- catch (e_6_1) {
554
- e_6 = { error: e_6_1 };
555
- }
556
- finally {
557
- try {
558
- if (v2s_1_1 && !v2s_1_1.done && (_a = v2s_1.return))
559
- _a.call(v2s_1);
560
- }
590
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
561
591
  finally {
562
- if (e_6)
563
- 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; }
564
596
  }
565
597
  }
566
598
  }
567
- return result;
568
- };
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
+ };
569
609
  /**
570
610
  * @private
571
611
  * @param {?} value
@@ -576,14 +616,14 @@
576
616
  * @param {?} value
577
617
  * @return {?}
578
618
  */
579
- function (value) {
580
- switch (value) {
581
- case null:
582
- return 'null';
583
- default:
584
- return value.toString();
585
- }
586
- };
619
+ function (value) {
620
+ switch (value) {
621
+ case null:
622
+ return 'null';
623
+ default:
624
+ return value.toString();
625
+ }
626
+ };
587
627
  /**
588
628
  * Gets the current values for an array of strings.
589
629
  * @param paths The array of strings to check.
@@ -609,38 +649,32 @@
609
649
  * @param {?=} additionalData
610
650
  * @return {?} An array of strings/values
611
651
  */
612
- function (paths, currentQuestionnaireForm, additionalData) {
613
- var e_8, _a;
614
- if (currentQuestionnaireForm) {
615
- /** @type {?} */
616
- var values = [];
617
- try {
618
- for (var paths_1 = __values(paths), paths_1_1 = paths_1.next(); !paths_1_1.done; paths_1_1 = paths_1.next()) {
619
- var path = paths_1_1.value;
620
- /** @type {?} */
621
- var value = this.getValueForString(path, currentQuestionnaireForm, additionalData);
622
- values.push(value);
623
- }
624
- }
625
- catch (e_8_1) {
626
- e_8 = { error: e_8_1 };
627
- }
628
- finally {
629
- try {
630
- if (paths_1_1 && !paths_1_1.done && (_a = paths_1.return))
631
- _a.call(paths_1);
632
- }
633
- finally {
634
- if (e_8)
635
- throw e_8.error;
636
- }
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);
637
663
  }
638
- return values;
639
664
  }
640
- else {
641
- 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; }
642
671
  }
643
- };
672
+ return values;
673
+ }
674
+ else {
675
+ return paths;
676
+ }
677
+ };
644
678
  /**
645
679
  * Gets a current value for a string.
646
680
  * @param path The string value to check.
@@ -666,21 +700,21 @@
666
700
  * @param {?=} additionalData
667
701
  * @return {?} A string/value.
668
702
  */
669
- function (path, currentQuestionnaireForm, additionalData) {
670
- if (currentQuestionnaireForm) {
671
- if (!additionalData) {
672
- additionalData = {};
673
- }
674
- /** @type {?} */
675
- var control = currentQuestionnaireForm.get(path);
676
- /** @type {?} */
677
- var value = control ? control.value : this.convertStringToValue(path);
678
- return _.get(additionalData, path, value);
703
+ function (path, currentQuestionnaireForm, additionalData) {
704
+ if (currentQuestionnaireForm) {
705
+ if (!additionalData) {
706
+ additionalData = {};
679
707
  }
680
- else {
681
- return this.convertStringToValue(path);
682
- }
683
- };
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
+ };
684
718
  /**
685
719
  * Converts a string to a value.
686
720
  * Eg. true/false.
@@ -704,32 +738,32 @@
704
738
  * @param {?} path The string value to check for conversion;
705
739
  * @return {?} Either a string or the converted value.
706
740
  */
707
- function (path) {
708
- switch (path) {
709
- case 'true':
710
- return true;
711
- case 'false':
712
- return false;
713
- case 'null':
714
- return null;
715
- default:
716
- return path;
717
- }
718
- };
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
+ };
719
753
  FilterService.decorators = [
720
- { type: i0.Injectable, args: [{
754
+ { type: core.Injectable, args: [{
721
755
  providedIn: 'root'
722
756
  },] }
723
757
  ];
724
758
  /** @nocollapse */
725
759
  FilterService.ctorParameters = function () { return []; };
726
- /** @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" });
727
761
  return FilterService;
728
762
  }());
729
763
 
730
764
  /**
731
765
  * @fileoverview added by tsickle
732
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
766
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
733
767
  */
734
768
  /** @enum {string} */
735
769
  var ValidationType = {
@@ -743,7 +777,7 @@
743
777
 
744
778
  /**
745
779
  * @fileoverview added by tsickle
746
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
780
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
747
781
  */
748
782
  var FormConstructorService = /** @class */ (function () {
749
783
  function FormConstructorService(fb, filterService) {
@@ -777,15 +811,15 @@
777
811
  * @param {?=} skipFilter
778
812
  * @return {?} A filted form group.
779
813
  */
780
- function (questionnaire, currentQuestionnaireForm, additionalData, skipFilter) {
781
- /** @type {?} */
782
- var sections = skipFilter ?
783
- questionnaire.sections :
784
- this.filterService.filterSections(questionnaire.sections, currentQuestionnaireForm, additionalData);
785
- /** @type {?} */
786
- var questionnaireForms = this.generateFormsForSections(sections, currentQuestionnaireForm);
787
- return { sections: sections, forms: questionnaireForms };
788
- };
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
+ };
789
823
  /**
790
824
  * @private
791
825
  * @param {?} sections
@@ -798,33 +832,27 @@
798
832
  * @param {?} currentQuestionnaireForm
799
833
  * @return {?}
800
834
  */
801
- function (sections, currentQuestionnaireForm) {
802
- var e_1, _a;
803
- /** @type {?} */
804
- var questionnaireForms = this.fb.group({});
805
- try {
806
- for (var sections_1 = __values(sections), sections_1_1 = sections_1.next(); !sections_1_1.done; sections_1_1 = sections_1.next()) {
807
- var section = sections_1_1.value;
808
- /** @type {?} */
809
- var sectionForms = this.generateFormsForSection(section, currentQuestionnaireForm);
810
- questionnaireForms.addControl(section.name, sectionForms);
811
- }
812
- }
813
- catch (e_1_1) {
814
- 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);
815
845
  }
816
- finally {
817
- try {
818
- if (sections_1_1 && !sections_1_1.done && (_a = sections_1.return))
819
- _a.call(sections_1);
820
- }
821
- finally {
822
- if (e_1)
823
- throw e_1.error;
824
- }
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);
825
851
  }
826
- return questionnaireForms;
827
- };
852
+ finally { if (e_1) throw e_1.error; }
853
+ }
854
+ return questionnaireForms;
855
+ };
828
856
  /**
829
857
  * Constructs a form group based on the section data.
830
858
  * This form group has been filtered down based on the conditions of the questions.
@@ -850,33 +878,27 @@
850
878
  * @param {?} currentQuestionnaireForm
851
879
  * @return {?} A filtered form group.
852
880
  */
853
- function (section, currentQuestionnaireForm) {
854
- var e_2, _a;
855
- /** @type {?} */
856
- var sectionForms = this.fb.group({});
857
- try {
858
- for (var _b = __values(section.questions), _c = _b.next(); !_c.done; _c = _b.next()) {
859
- var question = _c.value;
860
- /** @type {?} */
861
- var questionControl = this.generateControlForQuestion(question, section, currentQuestionnaireForm);
862
- sectionForms.addControl(question.name, questionControl);
863
- }
864
- }
865
- catch (e_2_1) {
866
- 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);
867
891
  }
868
- finally {
869
- try {
870
- if (_c && !_c.done && (_a = _b.return))
871
- _a.call(_b);
872
- }
873
- finally {
874
- if (e_2)
875
- throw e_2.error;
876
- }
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);
877
897
  }
878
- return sectionForms;
879
- };
898
+ finally { if (e_2) throw e_2.error; }
899
+ }
900
+ return sectionForms;
901
+ };
880
902
  /**
881
903
  * Constructs an astract form control based on the question data.
882
904
  * @param question The question data to build the abstract control on.
@@ -901,20 +923,20 @@
901
923
  * @param {?} currentQuestionnaireForm
902
924
  * @return {?} An abstract control.
903
925
  */
904
- function (question, section, currentQuestionnaireForm) {
905
- /** @type {?} */
906
- var convertedValidators = this.convertValidators(question.validators);
907
- switch (question.type) {
908
- case QuestionType.Repeater:
909
- /** @type {?} */
910
- var currentArray = currentQuestionnaireForm ? (( /** @type {?} */(currentQuestionnaireForm.get([section.name, question.name])))) : false;
911
- return currentArray ? currentArray : this.fb.array([], 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
- }
954
- }
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
- }
980
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
967
981
  }
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 };
1006
- }
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
- }
1023
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1016
1024
  }
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,105 +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 each item that used to be there push a new empty template there to be populated.
1166
- for (var repeaterArray_1 = __values(repeaterArray), repeaterArray_1_1 = repeaterArray_1.next(); !repeaterArray_1_1.done; repeaterArray_1_1 = repeaterArray_1.next()) {
1167
- var repeaterItem = repeaterArray_1_1.value;
1168
- /** @type {?} */
1169
- var repeaterItemTemplate = this.generateFormsForRepeater(question);
1170
- repeaterFormArray.push(repeaterItemTemplate);
1171
- }
1172
- }
1173
- catch (e_8_1) {
1174
- e_8 = { error: e_8_1 };
1175
- }
1176
- finally {
1177
- try {
1178
- if (repeaterArray_1_1 && !repeaterArray_1_1.done && (_c = repeaterArray_1.return))
1179
- _c.call(repeaterArray_1);
1180
- }
1181
- finally {
1182
- if (e_8)
1183
- throw e_8.error;
1184
- }
1185
- }
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;
1186
1167
  }
1187
- }
1188
- catch (e_7_1) {
1189
- e_7 = { error: e_7_1 };
1190
- }
1191
- finally {
1192
1168
  try {
1193
- if (_e && !_e.done && (_b = _d.return))
1194
- _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
+ }
1195
1176
  }
1177
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
1196
1178
  finally {
1197
- if (e_7)
1198
- 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; }
1199
1183
  }
1200
1184
  }
1201
1185
  }
1202
- }
1203
- catch (e_6_1) {
1204
- e_6 = { error: e_6_1 };
1205
- }
1206
- finally {
1207
- try {
1208
- if (sections_2_1 && !sections_2_1.done && (_a = sections_2.return))
1209
- _a.call(sections_2);
1210
- }
1186
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1211
1187
  finally {
1212
- if (e_6)
1213
- 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; }
1214
1192
  }
1215
1193
  }
1216
- };
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
+ };
1217
1203
  FormConstructorService.decorators = [
1218
- { type: i0.Injectable, args: [{
1204
+ { type: core.Injectable, args: [{
1219
1205
  providedIn: 'root'
1220
1206
  },] }
1221
1207
  ];
1222
1208
  /** @nocollapse */
1223
- FormConstructorService.ctorParameters = function () {
1224
- return [
1225
- { type: i1.FormBuilder },
1226
- { type: FilterService }
1227
- ];
1228
- };
1229
- /** @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" });
1230
1214
  return FormConstructorService;
1231
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
+ }
1232
1228
 
1233
1229
  /**
1234
1230
  * @fileoverview added by tsickle
1235
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1231
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1236
1232
  */
1237
1233
  var QuestionnaireService = /** @class */ (function () {
1238
1234
  function QuestionnaireService(formConstuctor, options) {
1239
1235
  this.formConstuctor = formConstuctor;
1240
1236
  this.options = options;
1241
- this.dataChangedEvent = new i0.EventEmitter();
1237
+ this.dataChangedEvent = new core.EventEmitter();
1242
1238
  this.skippable = false;
1243
1239
  }
1244
1240
  /**
@@ -1264,75 +1260,64 @@
1264
1260
  * @param {?=} additionalData
1265
1261
  * @return {?} null
1266
1262
  */
1267
- function (questionnaire, savedState, additionalData) {
1268
- return __awaiter(this, void 0, void 0, function () {
1269
- var e_1, _a, e_2, _b, newData, _c, _d, section, _e, _f, question, control;
1270
- return __generator(this, function (_g) {
1271
- switch (_g.label) {
1272
- case 0:
1273
- this.originalQuestionnaire = _.cloneDeep(questionnaire);
1274
- this.currentQuestionnaire = _.cloneDeep(questionnaire);
1275
- this.additionalData = additionalData;
1276
- if (savedState && Object.keys(savedState).length > 0) {
1277
- newData = this.formConstuctor.generateFormsForQuestionnaire(_.cloneDeep(this.originalQuestionnaire), this.currentQuestionnaireForm, this.additionalData, true);
1278
- this.formConstuctor.constructRepeaterFromsFromState(savedState, newData.sections, newData.forms);
1279
- this.currentQuestionnaireForm = newData.forms;
1280
- this.currentQuestionnaireForm.patchValue(savedState);
1281
- }
1282
- return [4 /*yield*/, this.updateQuestionnaire(savedState)];
1283
- case 1:
1284
- _g.sent();
1285
- try {
1286
- for (_c = __values(this.currentQuestionnaire.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
1287
- section = _d.value;
1288
- try {
1289
- for (_e = __values(section.questions), _f = _e.next(); !_f.done; _f = _e.next()) {
1290
- question = _f.value;
1291
- control = this.currentQuestionnaireForm.get([section.name, question.name]);
1292
- if (!control.value && question.defaultValue) {
1293
- control.setValue(question.defaultValue);
1294
- }
1295
- }
1296
- }
1297
- catch (e_2_1) {
1298
- e_2 = { error: e_2_1 };
1299
- }
1300
- finally {
1301
- try {
1302
- if (_f && !_f.done && (_b = _e.return))
1303
- _b.call(_e);
1304
- }
1305
- finally {
1306
- if (e_2)
1307
- 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);
1308
1291
  }
1309
1292
  }
1310
1293
  }
1311
- }
1312
- catch (e_1_1) {
1313
- e_1 = { error: e_1_1 };
1314
- }
1315
- finally {
1316
- try {
1317
- if (_d && !_d.done && (_a = _c.return))
1318
- _a.call(_c);
1319
- }
1294
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1320
1295
  finally {
1321
- if (e_1)
1322
- 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; }
1323
1300
  }
1324
1301
  }
1325
- if (this.options.skipToFirstSection) {
1326
- this.currentSectionName = Object.keys(this.currentQuestionnaireForm.controls)[0];
1327
- }
1328
- if (this.options.skipToFirstQuestion) {
1329
- 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);
1330
1307
  }
1331
- return [2 /*return*/];
1332
- }
1333
- });
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
+ }
1334
1318
  });
1335
- };
1319
+ });
1320
+ };
1336
1321
  /**
1337
1322
  * Updates the current questionnaire, used when a value is updated to check conditions.
1338
1323
  * @param savedState The saved state of the questionnaire, often from localstorage.
@@ -1349,42 +1334,45 @@
1349
1334
  * Updates the current questionnaire, used when a value is updated to check conditions.
1350
1335
  * @author Will Poulson
1351
1336
  * @param {?=} savedState The saved state of the questionnaire, often from localstorage.
1352
- * @return {?} null
1353
- */
1354
- function (savedState) {
1355
- var _this = this;
1356
- /** @type {?} */
1357
- var newData = this.formConstuctor.generateFormsForQuestionnaire(_.cloneDeep(this.originalQuestionnaire), this.currentQuestionnaireForm, this.additionalData);
1358
- this.currentQuestionnaireForm = newData.forms;
1359
- this.currentQuestionnaire.sections = newData.sections;
1360
- if (savedState && Object.keys(savedState).length > 0) {
1361
- this.currentQuestionnaireForm.patchValue(savedState);
1362
- }
1363
- if (this.questionnaireValueChangeSubscription) {
1364
- this.questionnaireValueChangeSubscription.unsubscribe();
1365
- }
1366
- if (this.questionValueChangeSubscription) {
1367
- this.questionValueChangeSubscription.unsubscribe();
1368
- }
1369
- 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((/**
1370
1363
  * @return {?}
1371
- */function () {
1372
- _this.dataChangedEvent.emit();
1373
- _this.updateQuestionnaire(_this.currentQuestionnaireForm.getRawValue());
1364
+ */
1365
+ function () {
1366
+ _this.clearFields(_this.currentQuestion.data.clearfields);
1374
1367
  }));
1375
- if (this.currentQuestion) {
1376
- this.questionValueChangeSubscription = this.currentQuestion.formControl.valueChanges.subscribe(( /**
1377
- * @return {?}
1378
- */function () {
1379
- _this.clearFields(_this.currentQuestion.data.clearfields);
1380
- }));
1381
- }
1382
- return;
1383
- };
1368
+ }
1369
+ return;
1370
+ };
1384
1371
  Object.defineProperty(QuestionnaireService.prototype, "isValid", {
1385
1372
  get: /**
1386
1373
  * @return {?}
1387
- */ function () {
1374
+ */
1375
+ function () {
1388
1376
  return this.currentQuestionnaireForm.valid;
1389
1377
  },
1390
1378
  enumerable: true,
@@ -1398,9 +1386,9 @@
1398
1386
  * @param {?} name
1399
1387
  * @return {?}
1400
1388
  */
1401
- function (name) {
1402
- return this.currentQuestionnaireForm.get(name).valid;
1403
- };
1389
+ function (name) {
1390
+ return this.currentQuestionnaireForm.get(name).valid;
1391
+ };
1404
1392
  /**
1405
1393
  * Clears all the fields parsed
1406
1394
  * @param clearfields An array of strings, paths to clear.
@@ -1420,35 +1408,29 @@
1420
1408
  * @param {?} clearfields An array of strings, paths to clear.
1421
1409
  * @return {?}
1422
1410
  */
1423
- function (clearfields) {
1424
- var e_3, _a;
1425
- if (!clearfields || clearfields.length === 0) {
1426
- return;
1427
- }
1428
- try {
1429
- for (var clearfields_1 = __values(clearfields), clearfields_1_1 = clearfields_1.next(); !clearfields_1_1.done; clearfields_1_1 = clearfields_1.next()) {
1430
- var clearfield = clearfields_1_1.value;
1431
- /** @type {?} */
1432
- var control = this.currentQuestionnaireForm.get(clearfield);
1433
- if (control) {
1434
- control.reset(undefined);
1435
- }
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);
1436
1423
  }
1437
1424
  }
1438
- catch (e_3_1) {
1439
- e_3 = { error: e_3_1 };
1440
- }
1441
- finally {
1442
- try {
1443
- if (clearfields_1_1 && !clearfields_1_1.done && (_a = clearfields_1.return))
1444
- _a.call(clearfields_1);
1445
- }
1446
- finally {
1447
- if (e_3)
1448
- throw e_3.error;
1449
- }
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);
1450
1430
  }
1451
- };
1431
+ finally { if (e_3) throw e_3.error; }
1432
+ }
1433
+ };
1452
1434
  /**
1453
1435
  * Unloads the current questionnaire.
1454
1436
  * Useful when exiting a questionnaire page or completing a questionnaire.
@@ -1466,14 +1448,14 @@
1466
1448
  * @author Will Poulson
1467
1449
  * @return {?}
1468
1450
  */
1469
- function () {
1470
- this.originalQuestionnaire = undefined;
1471
- this.currentQuestionnaireForm = undefined;
1472
- this.currentQuestionnaire = undefined;
1473
- this.currentSectionName = undefined;
1474
- this.currentQuestionName = undefined;
1475
- this.additionalData = undefined;
1476
- };
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
+ };
1477
1459
  Object.defineProperty(QuestionnaireService.prototype, "currentSection", {
1478
1460
  /**
1479
1461
  * Gets the current selected section.
@@ -1484,16 +1466,18 @@
1484
1466
  * Gets the current selected section.
1485
1467
  * @author Will Poulson
1486
1468
  * @return {?} An object containing the section data and the related form group.
1487
- */ function () {
1469
+ */
1470
+ function () {
1488
1471
  var _this = this;
1489
1472
  if (!this.currentSectionName) {
1490
1473
  return null;
1491
1474
  }
1492
1475
  /** @type {?} */
1493
- var data = this.currentQuestionnaire.sections.find(( /**
1476
+ var data = this.currentQuestionnaire.sections.find((/**
1494
1477
  * @param {?} x
1495
1478
  * @return {?}
1496
- */function (x) {
1479
+ */
1480
+ function (x) {
1497
1481
  return x.name === _this.currentSectionName;
1498
1482
  }));
1499
1483
  if (!data) {
@@ -1501,7 +1485,7 @@
1501
1485
  }
1502
1486
  return {
1503
1487
  data: data,
1504
- formGroup: ( /** @type {?} */(this.currentQuestionnaireForm.get(data.name)))
1488
+ formGroup: (/** @type {?} */ (this.currentQuestionnaireForm.get(data.name)))
1505
1489
  };
1506
1490
  },
1507
1491
  enumerable: true,
@@ -1517,7 +1501,8 @@
1517
1501
  * Gets all the avaialble sections.
1518
1502
  * @author Will Poulson
1519
1503
  * @return {?} An array of all avaialble sections.
1520
- */ function () {
1504
+ */
1505
+ function () {
1521
1506
  if (!this.currentQuestionnaire || !this.currentQuestionnaire.sections) {
1522
1507
  return [];
1523
1508
  }
@@ -1536,7 +1521,8 @@
1536
1521
  * Gets the current data for the entire questionnaire.
1537
1522
  * @author Will Poulson
1538
1523
  * @return {?} An object of data.
1539
- */ function () {
1524
+ */
1525
+ function () {
1540
1526
  return this.currentQuestionnaireForm.getRawValue();
1541
1527
  },
1542
1528
  enumerable: true,
@@ -1552,16 +1538,18 @@
1552
1538
  * Gets the current selected question.
1553
1539
  * @author Will Poulson
1554
1540
  * @return {?} An object containing the question data and the related form control.
1555
- */ function () {
1541
+ */
1542
+ function () {
1556
1543
  var _this = this;
1557
1544
  if (!this.currentQuestionName) {
1558
1545
  return null;
1559
1546
  }
1560
1547
  /** @type {?} */
1561
- var data = this.currentSection.data.questions.find(( /**
1548
+ var data = this.currentSection.data.questions.find((/**
1562
1549
  * @param {?} x
1563
1550
  * @return {?}
1564
- */function (x) {
1551
+ */
1552
+ function (x) {
1565
1553
  return x.name === _this.currentQuestionName;
1566
1554
  }));
1567
1555
  if (!data) {
@@ -1569,7 +1557,7 @@
1569
1557
  }
1570
1558
  return {
1571
1559
  data: data,
1572
- formControl: ( /** @type {?} */(this.currentSection.formGroup.get(data.name)))
1560
+ formControl: (/** @type {?} */ (this.currentSection.formGroup.get(data.name)))
1573
1561
  };
1574
1562
  },
1575
1563
  enumerable: true,
@@ -1599,42 +1587,47 @@
1599
1587
  * @author Will Poulson
1600
1588
  * @return {?} A promise which will resolve when the question has been navigated to.
1601
1589
  */
1602
- function () {
1603
- var _this = this;
1604
- return new Promise(( /**
1605
- * @param {?} resolve
1606
- * @param {?} reject
1607
- * @return {?}
1608
- */function (resolve, reject) {
1609
- if (!_this.options.allowSkipRequiredField) {
1610
- if (!_this.currentQuestion.formControl.valid) {
1611
- return reject('Current question is invalid');
1612
- }
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');
1613
1601
  }
1614
- _this.getCurrentQuestionIndex().then(( /**
1615
- * @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((/**
1616
1611
  * @return {?}
1617
- */function (currentIndex) {
1618
- /** @type {?} */
1619
- var newIndex = currentIndex + 1;
1620
- _this.navigateToQuestion(newIndex).then(( /**
1621
- * @return {?}
1622
- */function () {
1623
- return resolve();
1624
- })).catch(( /**
1625
- * @param {?} error
1626
- * @return {?}
1627
- */function (error) {
1628
- return reject(error);
1629
- }));
1630
- })).catch(( /**
1612
+ */
1613
+ function () {
1614
+ return resolve();
1615
+ })).catch((/**
1631
1616
  * @param {?} error
1632
1617
  * @return {?}
1633
- */function (error) {
1618
+ */
1619
+ function (error) {
1634
1620
  return reject(error);
1635
1621
  }));
1622
+ })).catch((/**
1623
+ * @param {?} error
1624
+ * @return {?}
1625
+ */
1626
+ function (error) {
1627
+ return reject(error);
1636
1628
  }));
1637
- };
1629
+ }));
1630
+ };
1638
1631
  /**
1639
1632
  * Navigates to the previous question.
1640
1633
  * If there is no question to navigate to it will reject with a out of bounds exception.
@@ -1656,40 +1649,45 @@
1656
1649
  * @author Will Poulson
1657
1650
  * @return {?} A promise which will resolve when the question has been navigated to.
1658
1651
  */
1659
- function () {
1660
- var _this = this;
1661
- return new Promise(( /**
1662
- * @param {?} resolve
1663
- * @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
1664
1665
  * @return {?}
1665
- */function (resolve, reject) {
1666
- if (!_this.options.allowNavigateBackwards) {
1667
- return reject('This questionnaire does not allow for backwards navigation');
1668
- }
1669
- _this.getCurrentQuestionIndex().then(( /**
1670
- * @param {?} currentIndex
1666
+ */
1667
+ function (currentIndex) {
1668
+ /** @type {?} */
1669
+ var newIndex = currentIndex - 1;
1670
+ _this.navigateToQuestion(newIndex).then((/**
1671
1671
  * @return {?}
1672
- */function (currentIndex) {
1673
- /** @type {?} */
1674
- var newIndex = currentIndex - 1;
1675
- _this.navigateToQuestion(newIndex).then(( /**
1676
- * @return {?}
1677
- */function () {
1678
- return resolve();
1679
- })).catch(( /**
1680
- * @param {?} error
1681
- * @return {?}
1682
- */function (error) {
1683
- return reject(error);
1684
- }));
1685
- })).catch(( /**
1672
+ */
1673
+ function () {
1674
+ return resolve();
1675
+ })).catch((/**
1686
1676
  * @param {?} error
1687
1677
  * @return {?}
1688
- */function (error) {
1678
+ */
1679
+ function (error) {
1689
1680
  return reject(error);
1690
1681
  }));
1682
+ })).catch((/**
1683
+ * @param {?} error
1684
+ * @return {?}
1685
+ */
1686
+ function (error) {
1687
+ return reject(error);
1691
1688
  }));
1692
- };
1689
+ }));
1690
+ };
1693
1691
  /**
1694
1692
  * Gets the current questions index.
1695
1693
  * @returns A promise which resolves a number.
@@ -1707,21 +1705,22 @@
1707
1705
  * @private
1708
1706
  * @return {?} A promise which resolves a number.
1709
1707
  */
1710
- function () {
1711
- var _this = this;
1712
- return new Promise(( /**
1713
- * @param {?} resolve
1714
- * @param {?} reject
1715
- * @return {?}
1716
- */function (resolve, reject) {
1717
- /** @type {?} */
1718
- var currentIndex = _this.currentSection.data.questions.indexOf(_this.currentQuestion.data);
1719
- if (currentIndex === -1) {
1720
- return reject('Could not find current question');
1721
- }
1722
- return resolve(currentIndex);
1723
- }));
1724
- };
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
+ };
1725
1724
  /**
1726
1725
  * Checks a question is in bounds then navigates to it.
1727
1726
  * @param index The index to navigate to.
@@ -1740,20 +1739,21 @@
1740
1739
  * @param {?} index The index to navigate to.
1741
1740
  * @return {?} A promise which will resolve when the question has been navigated to.
1742
1741
  */
1743
- function (index) {
1744
- var _this = this;
1745
- return new Promise(( /**
1746
- * @param {?} resolve
1747
- * @param {?} reject
1748
- * @return {?}
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
- };
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
+ };
1757
1757
  /**
1758
1758
  * Navigates to the next section.
1759
1759
  * @returns A promise which will resolve when the section has been navigated to.
@@ -1769,37 +1769,42 @@
1769
1769
  * @author Will Poulson
1770
1770
  * @return {?} A promise which will resolve when the section has been navigated to.
1771
1771
  */
1772
- function () {
1773
- var _this = this;
1774
- return new Promise(( /**
1775
- * @param {?} resolve
1776
- * @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
1777
1782
  * @return {?}
1778
- */function (resolve, reject) {
1779
- _this.getCurrentSectionIndex().then(( /**
1780
- * @param {?} currentIndex
1783
+ */
1784
+ function (currentIndex) {
1785
+ /** @type {?} */
1786
+ var newIndex = currentIndex + 1;
1787
+ _this.navigateToSection(newIndex).then((/**
1781
1788
  * @return {?}
1782
- */function (currentIndex) {
1783
- /** @type {?} */
1784
- var newIndex = currentIndex + 1;
1785
- _this.navigateToSection(newIndex).then(( /**
1786
- * @return {?}
1787
- */function () {
1788
- return resolve();
1789
- })).catch(( /**
1790
- * @param {?} error
1791
- * @return {?}
1792
- */function (error) {
1793
- return reject(error);
1794
- }));
1795
- })).catch(( /**
1789
+ */
1790
+ function () {
1791
+ return resolve();
1792
+ })).catch((/**
1796
1793
  * @param {?} error
1797
1794
  * @return {?}
1798
- */function (error) {
1795
+ */
1796
+ function (error) {
1799
1797
  return reject(error);
1800
1798
  }));
1799
+ })).catch((/**
1800
+ * @param {?} error
1801
+ * @return {?}
1802
+ */
1803
+ function (error) {
1804
+ return reject(error);
1801
1805
  }));
1802
- };
1806
+ }));
1807
+ };
1803
1808
  /**
1804
1809
  * Navigates to the previous section.
1805
1810
  * @returns A promise which will resolve when the section has been navigated to.
@@ -1815,37 +1820,42 @@
1815
1820
  * @author Will Poulson
1816
1821
  * @return {?} A promise which will resolve when the section has been navigated to.
1817
1822
  */
1818
- function () {
1819
- var _this = this;
1820
- return new Promise(( /**
1821
- * @param {?} resolve
1822
- * @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
1823
1833
  * @return {?}
1824
- */function (resolve, reject) {
1825
- _this.getCurrentSectionIndex().then(( /**
1826
- * @param {?} currentIndex
1834
+ */
1835
+ function (currentIndex) {
1836
+ /** @type {?} */
1837
+ var newIndex = currentIndex - 1;
1838
+ _this.navigateToQuestion(newIndex).then((/**
1827
1839
  * @return {?}
1828
- */function (currentIndex) {
1829
- /** @type {?} */
1830
- var newIndex = currentIndex - 1;
1831
- _this.navigateToQuestion(newIndex).then(( /**
1832
- * @return {?}
1833
- */function () {
1834
- return resolve();
1835
- })).catch(( /**
1836
- * @param {?} error
1837
- * @return {?}
1838
- */function (error) {
1839
- return reject(error);
1840
- }));
1841
- })).catch(( /**
1840
+ */
1841
+ function () {
1842
+ return resolve();
1843
+ })).catch((/**
1842
1844
  * @param {?} error
1843
1845
  * @return {?}
1844
- */function (error) {
1846
+ */
1847
+ function (error) {
1845
1848
  return reject(error);
1846
1849
  }));
1850
+ })).catch((/**
1851
+ * @param {?} error
1852
+ * @return {?}
1853
+ */
1854
+ function (error) {
1855
+ return reject(error);
1847
1856
  }));
1848
- };
1857
+ }));
1858
+ };
1849
1859
  /**
1850
1860
  * Gets the current section index.
1851
1861
  * @returns A promise which resolves a number.
@@ -1863,21 +1873,22 @@
1863
1873
  * @private
1864
1874
  * @return {?} A promise which resolves a number.
1865
1875
  */
1866
- function () {
1867
- var _this = this;
1868
- return new Promise(( /**
1869
- * @param {?} resolve
1870
- * @param {?} reject
1871
- * @return {?}
1872
- */function (resolve, reject) {
1873
- /** @type {?} */
1874
- var currentIndex = _this.currentQuestionnaire.sections.indexOf(_this.currentSection.data);
1875
- if (currentIndex === -1) {
1876
- return reject('Could not find current section');
1877
- }
1878
- return resolve(currentIndex);
1879
- }));
1880
- };
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
+ };
1881
1892
  /**
1882
1893
  * Checks a section is in bounds then navigates to it.
1883
1894
  * @param index The index to navigate to.
@@ -1896,20 +1907,21 @@
1896
1907
  * @param {?} index The index to navigate to.
1897
1908
  * @return {?} A promise which will resolve when the section has been navigated to.
1898
1909
  */
1899
- function (index) {
1900
- var _this = this;
1901
- return new Promise(( /**
1902
- * @param {?} resolve
1903
- * @param {?} reject
1904
- * @return {?}
1905
- */function (resolve, reject) {
1906
- if (_this.currentQuestionnaire.sections.length - 1 < index || index < 0) {
1907
- return reject('Out of bounds exception');
1908
- }
1909
- _this.currentSectionName = _this.currentQuestionnaire.sections[index].name;
1910
- return resolve();
1911
- }));
1912
- };
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
+ };
1913
1925
  /**
1914
1926
  * Answers the current question with the parsed value.
1915
1927
  * @param answer The value to answer the question with.
@@ -1929,19 +1941,20 @@
1929
1941
  * @param {?=} sendToNextQuestion
1930
1942
  * @return {?}
1931
1943
  */
1932
- function (answer, sendToNextQuestion) {
1933
- var _this = this;
1934
- this.currentQuestion.formControl.setValue(answer);
1935
- if (sendToNextQuestion && this.skippable) { // Timeout to prevent skipping glitch.
1936
- this.skippable = false;
1937
- setTimeout(( /**
1938
- * @return {?}
1939
- */function () {
1940
- _this.nextQuestion();
1941
- _this.skippable = true;
1942
- }), 150);
1943
- }
1944
- };
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
+ };
1945
1958
  /**
1946
1959
  * Adds a repeater item to the current question.
1947
1960
  * Current question must be of type Repeater.
@@ -1960,28 +1973,29 @@
1960
1973
  * @author Will Poulson
1961
1974
  * @return {?} A promise which resolves when the repeater item has been added.
1962
1975
  */
1963
- function () {
1964
- var _this = this;
1965
- return new Promise(( /**
1966
- * @param {?} resolve
1967
- * @param {?} reject
1968
- * @return {?}
1969
- */function (resolve, reject) {
1970
- if (_this.currentQuestion.data.type !== QuestionType.Repeater) {
1971
- return reject("Current question isn't a repeater");
1972
- }
1973
- /** @type {?} */
1974
- var repeaterForm = _this.formConstuctor.generateFormsForRepeater(_this.currentQuestion.data);
1975
- if (!repeaterForm) {
1976
- return reject("Repeater template failed to generate. May be due to the repeater having no items in the editor.");
1977
- }
1978
- if (!(_this.currentQuestion.formControl instanceof i1.FormArray)) {
1979
- return reject("The current questions control isn't of type FormArray");
1980
- }
1981
- _this.currentQuestion.formControl.push(repeaterForm);
1982
- return resolve();
1983
- }));
1984
- };
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
+ };
1985
1999
  /**
1986
2000
  * Removes a repeater item on the current question.
1987
2001
  * Current question must be of type Repeater.
@@ -2003,23 +2017,24 @@
2003
2017
  * @param {?} index The index at which to remove.
2004
2018
  * @return {?} A promise which resolves when the repeater item has been removed.
2005
2019
  */
2006
- function (index) {
2007
- var _this = this;
2008
- return new Promise(( /**
2009
- * @param {?} resolve
2010
- * @param {?} reject
2011
- * @return {?}
2012
- */function (resolve, reject) {
2013
- if (_this.currentQuestion.data.type !== QuestionType.Repeater) {
2014
- return reject("Current question isn't a repeater");
2015
- }
2016
- if (!(_this.currentQuestion.formControl instanceof i1.FormArray)) {
2017
- return reject("The current questions control isn't of type FormArray");
2018
- }
2019
- _this.currentQuestion.formControl.removeAt(index);
2020
- return resolve();
2021
- }));
2022
- };
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
+ };
2023
2038
  /**
2024
2039
  * Returns the display text for a given repeater item
2025
2040
  * @param index The index at which to get the label for.
@@ -2038,75 +2053,126 @@
2038
2053
  * @param {?} index The index at which to get the label for.
2039
2054
  * @return {?} A string which is the display text.
2040
2055
  */
2041
- function (index) {
2042
- var e_4, _a;
2043
- if (!this.currentQuestion.formControl || !(this.currentQuestion.formControl instanceof i1.FormArray)) {
2044
- return '';
2045
- }
2046
- /** @type {?} */
2047
- var repeaterItem = this.currentQuestion.formControl.controls[index];
2048
- if (!repeaterItem) {
2049
- return '';
2050
- }
2051
- /** @type {?} */
2052
- var template = this.currentQuestion.data.repeaterDisplayName;
2053
- /** @type {?} */
2054
- var splitTemplate = template.split(' ');
2055
- /** @type {?} */
2056
- var displayArray = [];
2057
- try {
2058
- for (var splitTemplate_1 = __values(splitTemplate), splitTemplate_1_1 = splitTemplate_1.next(); !splitTemplate_1_1.done; splitTemplate_1_1 = splitTemplate_1.next()) {
2059
- var templateItem = splitTemplate_1_1.value;
2060
- if (templateItem.match(/\[.*?\]/)) {
2061
- /** @type {?} */
2062
- var path = templateItem.replace(/[\[\]']+/g, '');
2063
- /** @type {?} */
2064
- var item = repeaterItem.get(path);
2065
- /** @type {?} */
2066
- var value = item.value ? item.value : '?';
2067
- displayArray.push(value);
2068
- }
2069
- else {
2070
- displayArray.push(templateItem);
2071
- }
2072
- }
2073
- }
2074
- catch (e_4_1) {
2075
- e_4 = { error: e_4_1 };
2076
- }
2077
- finally {
2078
- try {
2079
- if (splitTemplate_1_1 && !splitTemplate_1_1.done && (_a = splitTemplate_1.return))
2080
- _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);
2081
2083
  }
2082
- finally {
2083
- if (e_4)
2084
- throw e_4.error;
2084
+ else {
2085
+ displayArray.push(templateItem);
2085
2086
  }
2086
2087
  }
2087
- /** @type {?} */
2088
- var display = displayArray.join(' ');
2089
- return display;
2090
- };
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
+ };
2091
2100
  QuestionnaireService.decorators = [
2092
- { type: i0.Injectable, args: [{
2101
+ { type: core.Injectable, args: [{
2093
2102
  providedIn: 'root'
2094
2103
  },] }
2095
2104
  ];
2096
2105
  /** @nocollapse */
2097
- QuestionnaireService.ctorParameters = function () {
2098
- return [
2099
- { type: FormConstructorService },
2100
- { type: undefined, decorators: [{ type: i0.Inject, args: ['options',] }] }
2101
- ];
2102
- };
2103
- /** @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" });
2104
2111
  return QuestionnaireService;
2105
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
+ }
2106
2172
 
2107
2173
  /**
2108
2174
  * @fileoverview added by tsickle
2109
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2175
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2110
2176
  */
2111
2177
  var GgQuestionnaireV2Module = /** @class */ (function () {
2112
2178
  function GgQuestionnaireV2Module() {
@@ -2119,28 +2185,28 @@
2119
2185
  * @param {?} options
2120
2186
  * @return {?}
2121
2187
  */
2122
- function (options) {
2123
- return {
2124
- ngModule: GgQuestionnaireV2Module,
2125
- providers: [
2126
- QuestionnaireService,
2127
- {
2128
- provide: 'options',
2129
- useValue: options
2130
- }
2131
- ]
2132
- };
2188
+ function (options) {
2189
+ return {
2190
+ ngModule: GgQuestionnaireV2Module,
2191
+ providers: [
2192
+ QuestionnaireService,
2193
+ {
2194
+ provide: 'options',
2195
+ useValue: options
2196
+ }
2197
+ ]
2133
2198
  };
2199
+ };
2134
2200
  GgQuestionnaireV2Module.decorators = [
2135
- { type: i0.NgModule, args: [{
2201
+ { type: core.NgModule, args: [{
2136
2202
  declarations: [],
2137
2203
  providers: [
2138
2204
  FormConstructorService,
2139
2205
  FilterService
2140
2206
  ],
2141
2207
  imports: [
2142
- i1.FormsModule,
2143
- i1.ReactiveFormsModule
2208
+ forms.FormsModule,
2209
+ forms.ReactiveFormsModule
2144
2210
  ],
2145
2211
  },] }
2146
2212
  ];
@@ -2149,7 +2215,7 @@
2149
2215
 
2150
2216
  /**
2151
2217
  * @fileoverview added by tsickle
2152
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2218
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2153
2219
  */
2154
2220
  /** @enum {string} */
2155
2221
  var InputType = {
@@ -2168,7 +2234,7 @@
2168
2234
 
2169
2235
  /**
2170
2236
  * @fileoverview added by tsickle
2171
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2237
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2172
2238
  */
2173
2239
  /** @enum {string} */
2174
2240
  var RepeaterQuestionType = {
@@ -2176,29 +2242,18 @@
2176
2242
  Select: 'select',
2177
2243
  };
2178
2244
 
2179
- /**
2180
- * @fileoverview added by tsickle
2181
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2182
- */
2183
-
2184
- /**
2185
- * @fileoverview added by tsickle
2186
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2187
- */
2188
-
2189
- exports.QuestionnaireService = QuestionnaireService;
2190
- exports.GgQuestionnaireV2Module = GgQuestionnaireV2Module;
2191
2245
  exports.ConditionRelationship = ConditionRelationship;
2192
2246
  exports.ConditionType = ConditionType;
2193
- exports.QuestionType = QuestionType;
2194
- exports.ValidationType = ValidationType;
2247
+ exports.GgQuestionnaireV2Module = GgQuestionnaireV2Module;
2195
2248
  exports.InputType = InputType;
2249
+ exports.QuestionType = QuestionType;
2250
+ exports.QuestionnaireService = QuestionnaireService;
2196
2251
  exports.RepeaterQuestionType = RepeaterQuestionType;
2197
- exports.ɵb = FilterService;
2252
+ exports.ValidationType = ValidationType;
2198
2253
  exports.ɵa = FormConstructorService;
2254
+ exports.ɵb = FilterService;
2199
2255
 
2200
2256
  Object.defineProperty(exports, '__esModule', { value: true });
2201
2257
 
2202
- })));
2203
-
2204
- //# sourceMappingURL=glowgreen-gg-questionnaire-v2.umd.js.map
2258
+ }));
2259
+ //# sourceMappingURL=glowgreen-gg-questionnaire-v2.umd.js.map