@hmcts/ccd-case-ui-toolkit 7.1.14 → 7.1.15

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.
@@ -9535,42 +9535,48 @@ class CaseEditComponent {
9535
9535
  if (caseField && caseField.retain_hidden_value &&
9536
9536
  (caseField.hidden || (caseField.hidden !== false && parentField && parentField.hidden))) {
9537
9537
  if (caseField.field_type.type === 'Complex') {
9538
- // Note: Deliberate use of equality (==) and non-equality (!=) operators for null checks throughout, to
9539
- // handle both null and undefined values
9540
- if (caseField.value != null) {
9541
- // Call this function recursively to replace the Complex field's sub-fields as necessary, passing the
9542
- // CaseField itself (the sub-fields do not contain any values, so these need to be obtained from the
9543
- // parent)
9544
- // Update rawFormValueData for this field
9545
- // creating form group and adding control into it in case caseField is of complext type and and part of formGroup
9546
- const form = new FormGroup({});
9547
- if (formGroup.controls[key].value) {
9548
- Object.keys(formGroup.controls[key].value).forEach((item) => {
9549
- form.addControl(item, new FormControl(formGroup.controls[key].value[item]));
9550
- });
9551
- }
9552
- rawFormValueData[key] = this.replaceHiddenFormValuesWithOriginalCaseData(form, caseField.field_type.complex_fields, caseField);
9553
- }
9538
+ this.handleComplexField(caseField, formGroup, key, rawFormValueData);
9554
9539
  }
9555
9540
  else {
9556
- // Default case also handles collections of *all* types; the entire collection in rawFormValueData will be
9557
- // replaced with the original from formatted_value
9558
- // Use the CaseField's existing *formatted_value* from the parent, if available. (This is necessary for
9559
- // Complex fields, whose sub-fields do not hold any values in the model.) Otherwise, use formatted_value
9560
- // from the CaseField itself.
9561
- if (parentField && parentField.formatted_value) {
9562
- rawFormValueData[key] = parentField.formatted_value[caseField.id];
9563
- }
9564
- else {
9565
- if (!(caseField.hidden && caseField.retain_hidden_value)) {
9566
- rawFormValueData[key] = caseField.formatted_value;
9567
- }
9568
- }
9541
+ this.handleNonComplexField(parentField, rawFormValueData, key, caseField);
9569
9542
  }
9570
9543
  }
9571
9544
  });
9572
9545
  return rawFormValueData;
9573
9546
  }
9547
+ handleNonComplexField(parentField, rawFormValueData, key, caseField) {
9548
+ // Default case also handles collections of *all* types; the entire collection in rawFormValueData will be
9549
+ // replaced with the original from formatted_value
9550
+ // Use the CaseField's existing *formatted_value* from the parent, if available. (This is necessary for
9551
+ // Complex fields, whose sub-fields do not hold any values in the model.) Otherwise, use formatted_value
9552
+ // from the CaseField itself.
9553
+ if (parentField && parentField.formatted_value) {
9554
+ rawFormValueData[key] = parentField.formatted_value[caseField.id];
9555
+ }
9556
+ else {
9557
+ if (!(caseField.hidden && caseField.retain_hidden_value)) {
9558
+ rawFormValueData[key] = caseField.formatted_value;
9559
+ }
9560
+ }
9561
+ }
9562
+ handleComplexField(caseField, formGroup, key, rawFormValueData) {
9563
+ // Note: Deliberate use of equality (==) and non-equality (!=) operators for null checks throughout, to
9564
+ // handle both null and undefined values
9565
+ if (caseField.value != null) {
9566
+ // Call this function recursively to replace the Complex field's sub-fields as necessary, passing the
9567
+ // CaseField itself (the sub-fields do not contain any values, so these need to be obtained from the
9568
+ // parent)
9569
+ // Update rawFormValueData for this field
9570
+ // creating form group and adding control into it in case caseField is of complext type and and part of formGroup
9571
+ const form = new FormGroup({});
9572
+ if (formGroup.controls[key].value) {
9573
+ Object.keys(formGroup.controls[key].value).forEach((item) => {
9574
+ form.addControl(item, new FormControl(formGroup.controls[key].value[item]));
9575
+ });
9576
+ }
9577
+ rawFormValueData[key] = this.replaceHiddenFormValuesWithOriginalCaseData(form, caseField.field_type.complex_fields, caseField);
9578
+ }
9579
+ }
9574
9580
  caseSubmit({ form, caseEventData, submit }) {
9575
9581
  const loadingSpinnerToken = this.loadingService.register();
9576
9582
  // keep the initial event response to finalise process after task completion
@@ -20338,26 +20344,32 @@ class QueryCheckYourAnswersComponent {
20338
20344
  if (data.field_type.id === this.CASE_QUERIES_COLLECTION_ID && data.field_type.type === this.FIELD_TYPE_COMPLEX) {
20339
20345
  if (this.queryCreateContext === QueryCreateContext.NEW_QUERY) {
20340
20346
  //if number qmCaseQueriesCollection is more then filter out the right qmCaseQueriesCollection
20341
- if (count > 1) {
20342
- const matchingRole = acls?.find((acl) => acl.role === this.roleName);
20343
- if (matchingRole) {
20344
- this.fieldId = id;
20345
- }
20346
- }
20347
- else {
20348
- // Set the field ID dynamically based on the extracted data
20349
- this.fieldId = id; // Store the ID for use in generating newQueryData
20350
- }
20347
+ this.setFieldId(count, acls, id);
20351
20348
  }
20352
20349
  // If messageId is present, find the corresponding case message
20353
- if (messageId && value?.caseMessages) {
20354
- // If a matching message is found, set the fieldId to the corresponding id
20355
- const matchedMessage = value?.caseMessages?.find((message) => message.value.id === messageId);
20356
- if (matchedMessage) {
20357
- this.fieldId = id;
20358
- }
20350
+ this.setMessageFieldId(messageId, value, id);
20351
+ }
20352
+ }
20353
+ setMessageFieldId(messageId, value, id) {
20354
+ if (messageId && value?.caseMessages) {
20355
+ // If a matching message is found, set the fieldId to the corresponding id
20356
+ const matchedMessage = value?.caseMessages?.find((message) => message.value.id === messageId);
20357
+ if (matchedMessage) {
20358
+ this.fieldId = id;
20359
+ }
20360
+ }
20361
+ }
20362
+ setFieldId(count, acls, id) {
20363
+ if (count > 1) {
20364
+ const matchingRole = acls?.find((acl) => acl.role === this.roleName);
20365
+ if (matchingRole) {
20366
+ this.fieldId = id;
20359
20367
  }
20360
20368
  }
20369
+ else {
20370
+ // Set the field ID dynamically based on the extracted data
20371
+ this.fieldId = id; // Store the ID for use in generating newQueryData
20372
+ }
20361
20373
  }
20362
20374
  getDocumentAttachments() {
20363
20375
  const attachmentsValue = this.formGroup.get('attachments').value;
@@ -20453,7 +20465,7 @@ class QueryCheckYourAnswersComponent {
20453
20465
  }], querySubmitted: [{
20454
20466
  type: Output
20455
20467
  }] }); })();
20456
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(QueryCheckYourAnswersComponent, { className: "QueryCheckYourAnswersComponent", filePath: "lib/shared/components/palette/query-management/components/query-check-your-answers/query-check-your-answers.component.ts", lineNumber: 26 }); })();
20468
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(QueryCheckYourAnswersComponent, { className: "QueryCheckYourAnswersComponent", filePath: "lib/shared/components/palette/query-management/components/query-check-your-answers/query-check-your-answers.component.ts", lineNumber: 27 }); })();
20457
20469
 
20458
20470
  function QueryDetailsComponent_ng_container_0_tr_46_Template(rf, ctx) { if (rf & 1) {
20459
20471
  i0.ɵɵelementStart(0, "tr", 11)(1, "th", 7);