@glowgreen/gg-questionnaire-v2 0.0.44 → 0.0.46

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.
@@ -264,7 +264,7 @@
264
264
  * @return {?} An array of filtered sections with their filtered questions.
265
265
  */
266
266
  function (sections, currentQuestionnaireForm, additionalData) {
267
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
267
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
268
268
  /** @type {?} */
269
269
  var filteredSections = [];
270
270
  try {
@@ -276,8 +276,8 @@
276
276
  /** @type {?} */
277
277
  var filteredQuestions = [];
278
278
  try {
279
- for (var _f = (e_2 = void 0, __values(section.questions)), _g = _f.next(); !_g.done; _g = _f.next()) {
280
- var question = _g.value;
279
+ for (var _e = (e_2 = void 0, __values(section.questions)), _f = _e.next(); !_f.done; _f = _e.next()) {
280
+ var question = _f.value;
281
281
  if (!this.meetsConditionGroups(question.conditionGroups, currentQuestionnaireForm, additionalData)) {
282
282
  continue;
283
283
  }
@@ -285,69 +285,56 @@
285
285
  if (question.type === 'repeater') {
286
286
  /** @type {?} */
287
287
  var items = (/** @type {?} */ (currentQuestionnaireForm.get([section.name, question.name])));
288
- try {
289
- for (var _h = (e_3 = void 0, __values(items.controls)), _j = _h.next(); !_j.done; _j = _h.next()) {
290
- var repeaterItem = _j.value;
291
- /** @type {?} */
292
- var filteredRepeaterItemQuestions = [];
293
- try {
294
- for (var _k = (e_4 = void 0, __values(question.repeaterQuestions)), _l = _k.next(); !_l.done; _l = _k.next()) {
295
- var repeaterQuestion = _l.value;
296
- /** @type {?} */
297
- var meetsConditions = this.meetsConditionGroups(repeaterQuestion.conditionGroups, currentQuestionnaireForm, additionalData, (/** @type {?} */ (repeaterItem)));
298
- if (meetsConditions) {
299
- this.setFetchForQuestion(repeaterQuestion, additionalData, currentQuestionnaireForm, (/** @type {?} */ (repeaterItem)));
300
- filteredRepeaterItemQuestions.push(repeaterQuestion);
301
- }
302
- }
303
- }
304
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
305
- finally {
288
+ if (items && items.controls) {
289
+ try {
290
+ for (var _g = (e_3 = void 0, __values(items.controls)), _h = _g.next(); !_h.done; _h = _g.next()) {
291
+ var repeaterItem = _h.value;
292
+ /** @type {?} */
293
+ var filteredRepeaterItemQuestions = [];
294
+ console.log('Filtering repeater item questions');
306
295
  try {
307
- if (_l && !_l.done && (_d = _k.return)) _d.call(_k);
296
+ for (var _j = (e_4 = void 0, __values(question.repeaterQuestions)), _k = _j.next(); !_k.done; _k = _j.next()) {
297
+ var repeaterQuestion = _k.value;
298
+ /** @type {?} */
299
+ var meetsConditions = this.meetsConditionGroups(repeaterQuestion.conditionGroups, currentQuestionnaireForm, additionalData, (/** @type {?} */ (repeaterItem)));
300
+ if (meetsConditions) {
301
+ repeaterQuestion.selectOptions = this.getFetchOptionsForQuestion(repeaterQuestion, additionalData, currentQuestionnaireForm, (/** @type {?} */ (repeaterItem)));
302
+ filteredRepeaterItemQuestions.push(repeaterQuestion);
303
+ }
304
+ }
308
305
  }
309
- finally { if (e_4) throw e_4.error; }
310
- }
311
- try {
312
- for (var filteredRepeaterItemQuestions_1 = (e_5 = void 0, __values(filteredRepeaterItemQuestions)), filteredRepeaterItemQuestions_1_1 = filteredRepeaterItemQuestions_1.next(); !filteredRepeaterItemQuestions_1_1.done; filteredRepeaterItemQuestions_1_1 = filteredRepeaterItemQuestions_1.next()) {
313
- var filteredRepeaterItemQuestion = filteredRepeaterItemQuestions_1_1.value;
314
- if (filteredRepeaterItemQuestion.type !== 'select') {
315
- continue;
306
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
307
+ finally {
308
+ try {
309
+ if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
316
310
  }
317
- this.setFetchForQuestion(filteredRepeaterItemQuestion, additionalData, currentQuestionnaireForm);
311
+ finally { if (e_4) throw e_4.error; }
318
312
  }
319
- }
320
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
321
- finally {
322
- try {
323
- if (filteredRepeaterItemQuestions_1_1 && !filteredRepeaterItemQuestions_1_1.done && (_e = filteredRepeaterItemQuestions_1.return)) _e.call(filteredRepeaterItemQuestions_1);
313
+ /** @type {?} */
314
+ var index = items.controls.indexOf(repeaterItem);
315
+ if (!question.filteredRepeaterQuestions) {
316
+ question.filteredRepeaterQuestions = [];
324
317
  }
325
- finally { if (e_5) throw e_5.error; }
326
- }
327
- /** @type {?} */
328
- var index = items.controls.indexOf(repeaterItem);
329
- if (!question.filteredRepeaterQuestions) {
330
- question.filteredRepeaterQuestions = [];
318
+ question.filteredRepeaterQuestions[index] = filteredRepeaterItemQuestions;
331
319
  }
332
- question.filteredRepeaterQuestions[index] = filteredRepeaterItemQuestions;
333
320
  }
334
- }
335
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
336
- finally {
337
- try {
338
- if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
321
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
322
+ finally {
323
+ try {
324
+ if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
325
+ }
326
+ finally { if (e_3) throw e_3.error; }
339
327
  }
340
- finally { if (e_3) throw e_3.error; }
341
328
  }
342
329
  }
343
- this.setFetchForQuestion(question, additionalData, currentQuestionnaireForm);
330
+ question.selectOptions = this.getFetchOptionsForQuestion(question, additionalData, currentQuestionnaireForm);
344
331
  filteredQuestions.push(question);
345
332
  }
346
333
  }
347
334
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
348
335
  finally {
349
336
  try {
350
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
337
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
351
338
  }
352
339
  finally { if (e_2) throw e_2.error; }
353
340
  }
@@ -375,7 +362,7 @@
375
362
  * @param {?=} repeaterItem
376
363
  * @return {?}
377
364
  */
378
- FilterService.prototype.setFetchForQuestion = /**
365
+ FilterService.prototype.getFetchOptionsForQuestion = /**
379
366
  * @private
380
367
  * @param {?} question
381
368
  * @param {?} additionalData
@@ -384,8 +371,8 @@
384
371
  * @return {?}
385
372
  */
386
373
  function (question, additionalData, currentQuestionnaireForm, repeaterItem) {
387
- if (question.fetchPath) {
388
- return;
374
+ if (!question.fetchPath) {
375
+ return question.selectOptions;
389
376
  }
390
377
  /** @type {?} */
391
378
  var options = additionalData[question.fetchPath];
@@ -398,7 +385,7 @@
398
385
  if (!question.selectOptions) {
399
386
  question.selectOptions = [];
400
387
  }
401
- question.selectOptions = question.selectOptions.concat(options);
388
+ return question.selectOptions.concat(options);
402
389
  };
403
390
  /**
404
391
  * @private
@@ -411,7 +398,7 @@
411
398
  * @return {?}
412
399
  */
413
400
  function (items) {
414
- var e_6, _a;
401
+ var e_5, _a;
415
402
  if (!items) {
416
403
  return null;
417
404
  }
@@ -436,12 +423,12 @@
436
423
  }
437
424
  }
438
425
  }
439
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
426
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
440
427
  finally {
441
428
  try {
442
429
  if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
443
430
  }
444
- finally { if (e_6) throw e_6.error; }
431
+ finally { if (e_5) throw e_5.error; }
445
432
  }
446
433
  return convertedArray;
447
434
  };
@@ -526,7 +513,7 @@
526
513
  * @return {?} A boolean stating if the condition group conditions has been met.
527
514
  */
528
515
  function (conditionGroup, currentQuestionnaireForm, additionalData, repeaterItem) {
529
- var e_7, _a;
516
+ var e_6, _a;
530
517
  if (!conditionGroup.conditions || conditionGroup.conditions.length === 0) {
531
518
  return true;
532
519
  }
@@ -538,12 +525,12 @@
538
525
  results.push(this.meetsCondition(condition, currentQuestionnaireForm, additionalData, repeaterItem));
539
526
  }
540
527
  }
541
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
528
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
542
529
  finally {
543
530
  try {
544
531
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
545
532
  }
546
- finally { if (e_7) throw e_7.error; }
533
+ finally { if (e_6) throw e_6.error; }
547
534
  }
548
535
  switch (conditionGroup.relationship) {
549
536
  case ConditionRelationship.Every:
@@ -594,7 +581,7 @@
594
581
  * @return {?} A boolean stating if the condition group conditions has been met.
595
582
  */
596
583
  function (condition, currentQuestionnaireForm, additionalData, repeaterItem) {
597
- var e_8, _a, e_9, _b;
584
+ var e_7, _a, e_8, _b;
598
585
  /** @type {?} */
599
586
  var v1s = this.getValuesForArray(condition.v1s, currentQuestionnaireForm, additionalData, repeaterItem);
600
587
  /** @type {?} */
@@ -624,7 +611,7 @@
624
611
  for (var v2s_1 = __values(v2s), v2s_1_1 = v2s_1.next(); !v2s_1_1.done; v2s_1_1 = v2s_1.next()) {
625
612
  var v2 = v2s_1_1.value;
626
613
  try {
627
- for (var v1s_1 = (e_9 = void 0, __values(v1s)), v1s_1_1 = v1s_1.next(); !v1s_1_1.done; v1s_1_1 = v1s_1.next()) {
614
+ for (var v1s_1 = (e_8 = void 0, __values(v1s)), v1s_1_1 = v1s_1.next(); !v1s_1_1.done; v1s_1_1 = v1s_1.next()) {
628
615
  var v1 = v1s_1_1.value;
629
616
  switch (condition.type) {
630
617
  case ConditionType.EqualTo:
@@ -658,21 +645,21 @@
658
645
  }
659
646
  }
660
647
  }
661
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
648
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
662
649
  finally {
663
650
  try {
664
651
  if (v1s_1_1 && !v1s_1_1.done && (_b = v1s_1.return)) _b.call(v1s_1);
665
652
  }
666
- finally { if (e_9) throw e_9.error; }
653
+ finally { if (e_8) throw e_8.error; }
667
654
  }
668
655
  }
669
656
  }
670
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
657
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
671
658
  finally {
672
659
  try {
673
660
  if (v2s_1_1 && !v2s_1_1.done && (_a = v2s_1.return)) _a.call(v2s_1);
674
661
  }
675
- finally { if (e_8) throw e_8.error; }
662
+ finally { if (e_7) throw e_7.error; }
676
663
  }
677
664
  }
678
665
  return result;
@@ -723,7 +710,7 @@
723
710
  * @return {?} An array of strings/values
724
711
  */
725
712
  function (paths, currentQuestionnaireForm, additionalData, repeaterItem) {
726
- var e_10, _a;
713
+ var e_9, _a;
727
714
  if (currentQuestionnaireForm) {
728
715
  /** @type {?} */
729
716
  var values = [];
@@ -735,12 +722,12 @@
735
722
  values.push(value);
736
723
  }
737
724
  }
738
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
725
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
739
726
  finally {
740
727
  try {
741
728
  if (paths_1_1 && !paths_1_1.done && (_a = paths_1.return)) _a.call(paths_1);
742
729
  }
743
- finally { if (e_10) throw e_10.error; }
730
+ finally { if (e_9) throw e_9.error; }
744
731
  }
745
732
  return values;
746
733
  }