@hmcts/ccd-case-ui-toolkit 6.19.16-rc1 → 6.19.16-rc3

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.
@@ -4113,6 +4113,11 @@
4113
4113
  var FieldsUtils = /** @class */ (function () {
4114
4114
  function FieldsUtils() {
4115
4115
  }
4116
+ FieldsUtils.isValidDisplayContext = function (ctx) {
4117
+ return (ctx === 'MANDATORY' || ctx === 'READONLY'
4118
+ || ctx === 'OPTIONAL' || ctx === 'HIDDEN'
4119
+ || ctx === 'COMPLEX');
4120
+ };
4116
4121
  FieldsUtils.convertToCaseField = function (obj) {
4117
4122
  if (!(obj instanceof CaseField)) {
4118
4123
  return classTransformer.plainToClassFromExist(new CaseField(), obj);
@@ -6409,7 +6414,7 @@
6409
6414
  if (!FormValueService.isLabel(field) && FormValueService.isReadOnly(field)) {
6410
6415
  return "continue";
6411
6416
  }
6412
- if (field.hidden === true && field.display_context !== 'HIDDEN' && field.id !== 'caseLinks' && !field.retain_hidden_value) {
6417
+ if (field.hidden === true && field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP' && field.id !== 'caseLinks' && !field.retain_hidden_value) {
6413
6418
  // Delete anything that is hidden (that is NOT readonly), and that
6414
6419
  // hasn't had its display_context overridden to make it hidden.
6415
6420
  delete data[field.id];
@@ -8642,7 +8647,7 @@
8642
8647
  var caseFieldLeaf;
8643
8648
  var children = this.getCaseFieldChildren(caseField);
8644
8649
  if (children.length > 0) {
8645
- var _b = __read(caseFieldIds), _ = _b[0], tail = _b.slice(1);
8650
+ var _a = __read(caseFieldIds), _ = _a[0], tail = _a.slice(1);
8646
8651
  caseFieldLeaf = this.getCaseFieldLeaf(tail, children);
8647
8652
  }
8648
8653
  else {
@@ -8680,7 +8685,7 @@
8680
8685
  return pathPrefix.length === 0 ? caseField : pathPrefix + "." + caseField;
8681
8686
  };
8682
8687
  WizardPageFieldToCaseFieldMapper.prototype.getCaseFieldLeaf = function (caseFieldId, caseFields) {
8683
- var _b = __read(caseFieldId), head = _b[0], tail = _b.slice(1);
8688
+ var _a = __read(caseFieldId), head = _a[0], tail = _a.slice(1);
8684
8689
  if (caseFieldId.length === 1) {
8685
8690
  var caseLeaf = caseFields.find(function (e) { return e.id === head; });
8686
8691
  if (!caseLeaf) {
@@ -8702,15 +8707,12 @@
8702
8707
  };
8703
8708
  WizardPageFieldToCaseFieldMapper.prototype.hideParentIfAllChildrenHidden = function (caseField) {
8704
8709
  var _this = this;
8705
- var _a;
8706
8710
  var childrenCaseFields = this.getCaseFieldChildren(caseField);
8707
8711
  childrenCaseFields.forEach(function (e) { return _this.hideParentIfAllChildrenHidden(e); });
8708
- // filter out judicialuser field to avoid issue with the field to be hide/unhide based on the selection
8709
8712
  if (childrenCaseFields.length > 0 && this.allCaseFieldsHidden(childrenCaseFields)) {
8710
8713
  caseField.hidden = true;
8711
- if (caseField.field_type.id !== 'JudicialUser' && ((_a = caseField.field_type.collection_field_type) === null || _a === void 0 ? void 0 : _a.id) !== 'JudicialUser') {
8712
- caseField.display_context = 'HIDDEN';
8713
- }
8714
+ // marking display_context as special hidden so field not being deleted in event submission
8715
+ caseField.display_context = 'HIDDEN_TEMP';
8714
8716
  }
8715
8717
  };
8716
8718
  WizardPageFieldToCaseFieldMapper.prototype.getCaseFieldChildren = function (caseField) {
@@ -8724,7 +8726,7 @@
8724
8726
  return childrenCaseFields;
8725
8727
  };
8726
8728
  WizardPageFieldToCaseFieldMapper.prototype.allCaseFieldsHidden = function (children) {
8727
- return children.every(function (e) { return e.display_context === 'HIDDEN'; });
8729
+ return children.every(function (e) { return e.display_context === 'HIDDEN' || e.display_context === 'HIDDEN_TEMP'; });
8728
8730
  };
8729
8731
  return WizardPageFieldToCaseFieldMapper;
8730
8732
  }());
@@ -14174,7 +14176,9 @@
14174
14176
  .filter(function (f) { return keepEmpty || FieldsFilterPipe.keepField(f); })
14175
14177
  .map(function (f) {
14176
14178
  if (!f.display_context) {
14177
- f.display_context = complexField.display_context;
14179
+ if (FieldsUtils.isValidDisplayContext(complexField.display_context)) {
14180
+ f.display_context = complexField.display_context;
14181
+ }
14178
14182
  }
14179
14183
  return f;
14180
14184
  });
@@ -26591,7 +26595,9 @@
26591
26595
  })
26592
26596
  .map(function (f) {
26593
26597
  if (!f.display_context) {
26594
- f.display_context = complexField.display_context;
26598
+ if (FieldsUtils.isValidDisplayContext(complexField.display_context)) {
26599
+ f.display_context = complexField.display_context;
26600
+ }
26595
26601
  }
26596
26602
  if (setupHidden) {
26597
26603
  ReadFieldsFilterPipe.evaluateConditionalShow(f, checkConditionalShowAgainst, path, formGroupAvailable, complexField.id);