@hmcts/ccd-case-ui-toolkit 7.1.44 → 7.1.45-data-loss-cya

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 (20) hide show
  1. package/esm2022/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.mjs +6 -2
  2. package/esm2022/lib/shared/components/palette/query-management/components/query-check-your-answers/query-check-your-answers.component.mjs +18 -13
  3. package/esm2022/lib/shared/components/palette/query-management/components/query-details/query-details.component.mjs +20 -15
  4. package/esm2022/lib/shared/components/palette/query-management/components/query-write/query-write-respond-to-query/query-write-respond-to-query.component.mjs +8 -7
  5. package/esm2022/lib/shared/services/form/field-type-sanitiser.mjs +34 -3
  6. package/esm2022/lib/shared/services/form/form-value.service.mjs +19 -1
  7. package/fesm2022/hmcts-ccd-case-ui-toolkit.mjs +98 -35
  8. package/fesm2022/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
  9. package/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts.map +1 -1
  10. package/lib/shared/components/palette/query-management/components/query-check-your-answers/query-check-your-answers.component.d.ts +2 -1
  11. package/lib/shared/components/palette/query-management/components/query-check-your-answers/query-check-your-answers.component.d.ts.map +1 -1
  12. package/lib/shared/components/palette/query-management/components/query-details/query-details.component.d.ts +4 -4
  13. package/lib/shared/components/palette/query-management/components/query-details/query-details.component.d.ts.map +1 -1
  14. package/lib/shared/components/palette/query-management/components/query-write/query-write-respond-to-query/query-write-respond-to-query.component.d.ts +1 -1
  15. package/lib/shared/components/palette/query-management/components/query-write/query-write-respond-to-query/query-write-respond-to-query.component.d.ts.map +1 -1
  16. package/lib/shared/services/form/field-type-sanitiser.d.ts +4 -0
  17. package/lib/shared/services/form/field-type-sanitiser.d.ts.map +1 -1
  18. package/lib/shared/services/form/form-value.service.d.ts +1 -0
  19. package/lib/shared/services/form/form-value.service.d.ts.map +1 -1
  20. package/package.json +1 -1
@@ -17,6 +17,7 @@ import { Type, Expose, plainToClassFromExist, plainToClass } from 'class-transfo
17
17
  import moment from 'moment';
18
18
  import { __decorate, __metadata } from 'tslib';
19
19
  import * as _ from 'underscore';
20
+ import { isEqual } from 'underscore';
20
21
  import 'reflect-metadata';
21
22
  import { generate } from 'pegjs';
22
23
  import { isUndefined } from 'util';
@@ -5689,6 +5690,7 @@ class FieldTypeSanitiser {
5689
5690
  this.sanitiseLists(caseField.field_type.complex_fields, data[caseField.id]);
5690
5691
  break;
5691
5692
  case FieldTypeSanitiser.FIELD_TYPE_COLLECTION:
5693
+ this.checkValuesSetInCollection(caseField, data);
5692
5694
  if (Array.isArray(data[caseField.id])) {
5693
5695
  data[caseField.id].forEach((formElement) => {
5694
5696
  this.sanitiseLists(caseField.field_type.collection_field_type.complex_fields, formElement.value);
@@ -5698,6 +5700,35 @@ class FieldTypeSanitiser {
5698
5700
  }
5699
5701
  });
5700
5702
  }
5703
+ checkValuesSetInCollection(caseField, data) {
5704
+ for (const field in caseField.formatted_value) {
5705
+ for (const id in data[caseField.id]) {
5706
+ if (caseField.formatted_value[field]?.id === data[caseField.id][id]?.id) {
5707
+ this.updateFieldValues(caseField.formatted_value[field].value, data[caseField.id][id]?.value);
5708
+ }
5709
+ }
5710
+ }
5711
+ }
5712
+ updateFieldValues(formattedValue, dataValue) {
5713
+ for (const key in dataValue) {
5714
+ if ((typeof formattedValue[key] === 'object') && (!isEqual(formattedValue[key], dataValue[key]))) {
5715
+ this.updateObjectValue(formattedValue[key], dataValue[key]);
5716
+ }
5717
+ else {
5718
+ this.updatePrimitiveValue(formattedValue, key, dataValue[key]);
5719
+ }
5720
+ }
5721
+ }
5722
+ updateObjectValue(formattedObject, dataObject) {
5723
+ if (formattedObject?.value !== dataObject) {
5724
+ formattedObject.value = dataObject;
5725
+ }
5726
+ }
5727
+ updatePrimitiveValue(formattedValue, key, dataValue) {
5728
+ if ((!formattedValue[key]) || (formattedValue[key] !== dataValue)) {
5729
+ formattedValue[key] = dataValue;
5730
+ }
5731
+ }
5701
5732
  ensureDynamicMultiSelectListPopulated(caseFields) {
5702
5733
  return caseFields.map((field) => {
5703
5734
  if (field.field_type.type !== 'Complex') {
@@ -5738,7 +5769,7 @@ class FieldTypeSanitiser {
5738
5769
  const values = data[field.id];
5739
5770
  if (Array.isArray(values)) {
5740
5771
  const listItems = this.getListItems(field);
5741
- const matches = listItems.filter(item => values.map(v => v.code).indexOf(item.code) !== -1);
5772
+ const matches = listItems.filter((item) => values.map((v) => v.code).indexOf(item.code) !== -1);
5742
5773
  data[field.id] = {
5743
5774
  value: matches,
5744
5775
  list_items: listItems
@@ -5749,7 +5780,7 @@ class FieldTypeSanitiser {
5749
5780
  const stringValue = data[field.id];
5750
5781
  if (typeof stringValue === 'string') {
5751
5782
  const listItems = this.getListItems(field);
5752
- const matches = listItems.filter(value => value?.code === stringValue);
5783
+ const matches = listItems.filter((value) => value?.code === stringValue);
5753
5784
  if (matches && matches.length > 0) {
5754
5785
  data[field.id] = {
5755
5786
  value: matches[0],
@@ -6061,6 +6092,24 @@ class FormValueService {
6061
6092
  }
6062
6093
  }
6063
6094
  }
6095
+ checkValuesSetInCollection(caseField, data) {
6096
+ for (const field in data) {
6097
+ const fieldId = data[field].id;
6098
+ if (Array.isArray(caseField.data[fieldId])) {
6099
+ for (const subField in caseField.data[fieldId]) {
6100
+ if (data[field]?.formatted_value) {
6101
+ if (caseField.data[fieldId][subField] !== data[field]?.formatted_value[subField]) {
6102
+ caseField.data[fieldId][subField] = data[field].formatted_value[subField];
6103
+ }
6104
+ }
6105
+ }
6106
+ }
6107
+ else if ((data[field].formatted_value) && (caseField.data[fieldId] !== data[field].formatted_value)) {
6108
+ caseField.data[fieldId] = data[field].formatted_value;
6109
+ }
6110
+ }
6111
+ return caseField;
6112
+ }
6064
6113
  // TODO refactor so that this and remove unnecessary fields have a common iterator that applies functions to each node visited
6065
6114
  removeNullLabels(data, caseFields) {
6066
6115
  if (data && caseFields && caseFields.length > 0) {
@@ -10981,9 +11030,13 @@ class CaseEditPageComponent {
10981
11030
  */
10982
11031
  getFilteredCaseEventData(caseFields, formValue, clearEmpty = false, clearNonCase = false, fromPreviousPage = false) {
10983
11032
  // Get the data for the fields specified.
10984
- const formFields = this.formValueService.filterCurrentPageFields(caseFields, formValue);
11033
+ let formFields = this.formValueService.filterCurrentPageFields(caseFields, formValue);
10985
11034
  // Sort out the dynamic lists.
10986
11035
  this.formValueService.sanitiseDynamicLists(caseFields, formFields);
11036
+ // we only want to ensure this when the field_type is a collection of complex fields
11037
+ if (caseFields.find((field) => field.field_type?.type === 'Collection' && field.field_type?.collection_field_type?.type === 'Complex')) {
11038
+ formFields = this.formValueService.checkValuesSetInCollection(formFields, caseFields);
11039
+ }
10987
11040
  // Get hold of the CaseEventData.
10988
11041
  const caseEventData = this.formValueService.sanitise(formFields);
10989
11042
  // delete fields which are not part of the case event journey wizard pages case fields
@@ -20331,7 +20384,7 @@ class QueryCheckYourAnswersComponent {
20331
20384
  fieldId;
20332
20385
  attachments;
20333
20386
  errorMessages = [];
20334
- filteredTask = [];
20387
+ filteredTasks = [];
20335
20388
  constructor(route, router, casesService, caseNotifier, workAllocationService, sessionStorageService, qualifyingQuestionService) {
20336
20389
  this.route = route;
20337
20390
  this.router = router;
@@ -20361,11 +20414,11 @@ class QueryCheckYourAnswersComponent {
20361
20414
  .subscribe({
20362
20415
  next: (response) => {
20363
20416
  // Filter task by query id
20364
- if (response.tasks?.length > 1) {
20365
- this.filteredTask = response.tasks?.find((task) => task.case_id === this.tid);
20417
+ if (this.tid && response.tasks?.length > 1) {
20418
+ this.filteredTasks = response.tasks?.filter((task) => task.id === this.tid);
20366
20419
  }
20367
20420
  else {
20368
- this.filteredTask = response.tasks;
20421
+ this.filteredTasks = response.tasks;
20369
20422
  }
20370
20423
  },
20371
20424
  error: (error) => {
@@ -20397,13 +20450,18 @@ class QueryCheckYourAnswersComponent {
20397
20450
  const data = this.generateCaseQueriesCollectionData();
20398
20451
  const createEvent$ = this.createEvent(data);
20399
20452
  if (this.queryCreateContext === QueryCreateContext.RESPOND) {
20400
- const completeTask$ = this.workAllocationService.completeTask(this.filteredTask[0].id, this.caseViewTrigger.name);
20401
- this.createEventSubscription = forkJoin([createEvent$, completeTask$]).subscribe({
20402
- next: ([createEventResponse, tasksResponse]) => {
20403
- this.finaliseSubmission();
20404
- },
20405
- error: (error) => this.handleError(error)
20406
- });
20453
+ if (this.filteredTasks?.length > 0) {
20454
+ const completeTask$ = this.workAllocationService.completeTask(this.filteredTasks[0].id, this.caseViewTrigger.name);
20455
+ this.createEventSubscription = forkJoin([createEvent$, completeTask$]).subscribe({
20456
+ next: ([createEventResponse, tasksResponse]) => {
20457
+ this.finaliseSubmission();
20458
+ },
20459
+ error: (error) => this.handleError(error)
20460
+ });
20461
+ }
20462
+ else {
20463
+ console.error('Error: No task to complete found');
20464
+ }
20407
20465
  }
20408
20466
  else {
20409
20467
  this.createEventSubscription = createEvent$.subscribe({
@@ -20640,7 +20698,7 @@ class QueryCheckYourAnswersComponent {
20640
20698
  }], querySubmitted: [{
20641
20699
  type: Output
20642
20700
  }] }); })();
20643
- (() => { (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 }); })();
20701
+ (() => { (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 }); })();
20644
20702
 
20645
20703
  function QueryDetailsComponent_ng_container_0_cut_alert_1_Template(rf, ctx) { if (rf & 1) {
20646
20704
  i0.ɵɵelementStart(0, "cut-alert", 11);
@@ -20930,9 +20988,9 @@ function QueryDetailsComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
20930
20988
  } if (rf & 2) {
20931
20989
  const ctx_r0 = i0.ɵɵnextContext();
20932
20990
  i0.ɵɵadvance();
20933
- i0.ɵɵproperty("ngIf", ctx_r0.hasRespondedToQuery());
20991
+ i0.ɵɵproperty("ngIf", ctx_r0.hasRespondedToQuery() && !ctx_r0.showItem);
20934
20992
  i0.ɵɵadvance(2);
20935
- i0.ɵɵproperty("ngIf", ctx_r0.showLink);
20993
+ i0.ɵɵproperty("ngIf", ctx_r0.showItem);
20936
20994
  i0.ɵɵadvance(2);
20937
20995
  i0.ɵɵattribute("aria-describedby", i0.ɵɵpipeBind1(6, 21, "Details of the query"));
20938
20996
  i0.ɵɵadvance(4);
@@ -20973,11 +21031,11 @@ class QueryDetailsComponent {
20973
21031
  route;
20974
21032
  router;
20975
21033
  query;
20976
- backClicked = new EventEmitter();
20977
21034
  caseId;
21035
+ queryResponseStatus;
21036
+ backClicked = new EventEmitter();
20978
21037
  hasResponded = new EventEmitter();
20979
- totalNumberOfQueryChildren;
20980
- showLink = true;
21038
+ showItem = true;
20981
21039
  message;
20982
21040
  static QUERY_ITEM_RESPOND = '3';
20983
21041
  queryItemId;
@@ -21001,10 +21059,14 @@ class QueryDetailsComponent {
21001
21059
  }
21002
21060
  toggleLinkVisibility() {
21003
21061
  this.queryItemId = this.route.snapshot.params.qid;
21004
- this.showLink = this.queryItemId !== QueryDetailsComponent.QUERY_ITEM_RESPOND;
21062
+ this.showItem = this.queryItemId !== QueryDetailsComponent.QUERY_ITEM_RESPOND;
21005
21063
  }
21006
21064
  hasRespondedToQuery() {
21007
- if (this.totalNumberOfQueryChildren >= 0 && this.isCaseworker() && this.totalNumberOfQueryChildren % 2 !== 0) {
21065
+ if (this.queryResponseStatus === undefined || this.queryResponseStatus === QueryItemResponseStatus.AWAITING) {
21066
+ this.hasResponded.emit(false);
21067
+ return false;
21068
+ }
21069
+ if (this.isCaseworker() && this.queryResponseStatus !== QueryItemResponseStatus.AWAITING) {
21008
21070
  this.message = Constants.TASK_COMPLETION_ERROR;
21009
21071
  this.hasResponded.emit(true);
21010
21072
  return true;
@@ -21013,7 +21075,7 @@ class QueryDetailsComponent {
21013
21075
  return false;
21014
21076
  }
21015
21077
  static ɵfac = function QueryDetailsComponent_Factory(t) { return new (t || QueryDetailsComponent)(i0.ɵɵdirectiveInject(SessionStorageService), i0.ɵɵdirectiveInject(i1$1.ActivatedRoute), i0.ɵɵdirectiveInject(i1$1.Router)); };
21016
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: QueryDetailsComponent, selectors: [["ccd-query-details"]], inputs: { query: "query", caseId: "caseId", totalNumberOfQueryChildren: "totalNumberOfQueryChildren" }, outputs: { backClicked: "backClicked", hasResponded: "hasResponded" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [["followUpMessage", ""], [4, "ngIf"], ["type", "error", 4, "ngIf"], [1, "govuk-table", "query-details-table"], [1, "govuk-table__caption", "govuk-table__caption--l"], [1, "govuk-table__body"], [1, "govuk-table__row"], ["scope", "row", 1, "govuk-table__header"], [1, "govuk-table__cell"], ["class", "govuk-table__row govuk-table__row--isHearingRelated", 4, "ngIf"], ["class", "govuk-table__row", 4, "ngIf"], ["type", "error"], ["href", "javascript:void(0)", 1, "govuk-link", 3, "click"], [1, "govuk-table__row", "govuk-table__row--isHearingRelated"], [3, "attachments", 4, "ngIf"], [3, "attachments"], [4, "ngFor", "ngForOf"], [4, "ngIf", "ngIfElse"]], template: function QueryDetailsComponent_Template(rf, ctx) { if (rf & 1) {
21078
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: QueryDetailsComponent, selectors: [["ccd-query-details"]], inputs: { query: "query", caseId: "caseId", queryResponseStatus: "queryResponseStatus" }, outputs: { backClicked: "backClicked", hasResponded: "hasResponded" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [["followUpMessage", ""], [4, "ngIf"], ["type", "error", 4, "ngIf"], [1, "govuk-table", "query-details-table"], [1, "govuk-table__caption", "govuk-table__caption--l"], [1, "govuk-table__body"], [1, "govuk-table__row"], ["scope", "row", 1, "govuk-table__header"], [1, "govuk-table__cell"], ["class", "govuk-table__row govuk-table__row--isHearingRelated", 4, "ngIf"], ["class", "govuk-table__row", 4, "ngIf"], ["type", "error"], ["href", "javascript:void(0)", 1, "govuk-link", 3, "click"], [1, "govuk-table__row", "govuk-table__row--isHearingRelated"], [3, "attachments", 4, "ngIf"], [3, "attachments"], [4, "ngFor", "ngForOf"], [4, "ngIf", "ngIfElse"]], template: function QueryDetailsComponent_Template(rf, ctx) { if (rf & 1) {
21017
21079
  i0.ɵɵtemplate(0, QueryDetailsComponent_ng_container_0_Template, 47, 42, "ng-container", 1);
21018
21080
  } if (rf & 2) {
21019
21081
  i0.ɵɵproperty("ngIf", ctx.query);
@@ -21021,19 +21083,19 @@ class QueryDetailsComponent {
21021
21083
  }
21022
21084
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(QueryDetailsComponent, [{
21023
21085
  type: Component,
21024
- args: [{ selector: 'ccd-query-details', template: "<ng-container *ngIf=\"query\">\n <cut-alert type=\"error\" *ngIf=\"hasRespondedToQuery()\">\n <ng-container>{{message}}</ng-container>\n </cut-alert>\n\n <br/>\n <p *ngIf=\"showLink\">\n <a class=\"govuk-link\" href=\"javascript:void(0)\" (click)=\"onBack()\">{{ 'Back to query list' | rpxTranslate }}</a>\n </p>\n <div>\n <table class=\"govuk-table query-details-table\" [attr.aria-describedby]=\"'Details of the query' | rpxTranslate\">\n <caption class=\"govuk-table__caption govuk-table__caption--l\">\n <div>{{ 'Query details' | rpxTranslate }}</div>\n </caption>\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Last submitted by' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.lastSubmittedBy }}</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Submission date' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.createdOn | date: 'dd MMM yyyy' }}</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Query subject' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.subject }}</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Query body' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.body }}</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\" [class.govuk-table__header--no-border]=\"query.isHearingRelated\">\n {{ 'Is the query hearing related?' | rpxTranslate }}\n </th>\n <td class=\"govuk-table__cell\" [class.govuk-table__cell--no-border]=\"query.isHearingRelated\">\n {{ 'Is the query hearing related?' | rpxTranslate: null : (query.isHearingRelated) }}</td>\n </tr>\n <tr class=\"govuk-table__row govuk-table__row--isHearingRelated\" *ngIf=\"query.isHearingRelated === 'Yes'\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'What is the date of the hearing?' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.hearingDate | date: 'dd MMM yyyy' }}</td>\n </tr>\n <tr class=\"govuk-table__row\" *ngIf=\"query.attachments.length > 0\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Attachments' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">\n <ccd-query-attachments-read\n *ngIf=\"query.attachments\"\n [attachments]=\"query.attachments\"\n >\n </ccd-query-attachments-read>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <ng-container *ngIf=\"query.children?.length > 0\">\n <ng-container *ngFor=\"let child of query.children; let i = index;\">\n <ng-container *ngIf=\"i % 2 === 0; else followUpMessage\">\n <table class=\"govuk-table query-details-table\" [attr.aria-describedby]=\"'Response of the query' | rpxTranslate\">\n <caption class=\"govuk-table__caption govuk-table__caption--l\">\n <div>{{ 'Response' | rpxTranslate }}</div>\n </caption>\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Last response date' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.createdOn | date: 'dd MMM yyyy' }}</td>\n </tr>\n\n <tr *ngIf=\"isCaseworker()\" class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Caseworker name' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.name }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Response detail' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.body }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\" *ngIf=\"child.attachments.length > 0\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Attachments' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">\n <ccd-query-attachments-read\n *ngIf=\"child.attachments\"\n [attachments]=\"child.attachments\"\n >\n </ccd-query-attachments-read>\n </td>\n </tr>\n </tbody>\n </table>\n </ng-container>\n\n <ng-template #followUpMessage>\n <!-- <div class=\"query_details_caption\">{{ 'Follow-up' | rpxTranslate }}</div> -->\n <table class=\"govuk-table query-details-table\"\n [attr.aria-describedby]=\"'Follow-up of the response' | rpxTranslate\">\n <caption class=\"govuk-table__caption govuk-table__caption--l\">\n <div>{{ 'Follow up query' | rpxTranslate }}</div>\n </caption>\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Last submission date' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.createdOn | date: 'dd MMM yyyy' }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Last submitted by' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.name }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Query detail' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.body }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\" *ngIf=\"child.attachments.length > 0\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Attachments' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">\n <ccd-query-attachments-read\n *ngIf=\"child.attachments\"\n [attachments]=\"child.attachments\"\n >\n </ccd-query-attachments-read>\n </td>\n </tr>\n </tbody>\n </table>\n </ng-template>\n </ng-container>\n </ng-container>\n</ng-container>\n", styles: [".query-details-table .govuk-table__header{width:330px}\n"] }]
21086
+ args: [{ selector: 'ccd-query-details', template: "<ng-container *ngIf=\"query\">\n <cut-alert type=\"error\" *ngIf=\"hasRespondedToQuery() && !showItem\">\n <ng-container>{{message}}</ng-container>\n </cut-alert>\n\n <br/>\n <p *ngIf=\"showItem\">\n <a class=\"govuk-link\" href=\"javascript:void(0)\" (click)=\"onBack()\">{{ 'Back to query list' | rpxTranslate }}</a>\n </p>\n <div>\n <table class=\"govuk-table query-details-table\" [attr.aria-describedby]=\"'Details of the query' | rpxTranslate\">\n <caption class=\"govuk-table__caption govuk-table__caption--l\">\n <div>{{ 'Query details' | rpxTranslate }}</div>\n </caption>\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Last submitted by' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.lastSubmittedBy }}</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Submission date' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.createdOn | date: 'dd MMM yyyy' }}</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Query subject' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.subject }}</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Query body' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.body }}</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\" [class.govuk-table__header--no-border]=\"query.isHearingRelated\">\n {{ 'Is the query hearing related?' | rpxTranslate }}\n </th>\n <td class=\"govuk-table__cell\" [class.govuk-table__cell--no-border]=\"query.isHearingRelated\">\n {{ 'Is the query hearing related?' | rpxTranslate: null : (query.isHearingRelated) }}</td>\n </tr>\n <tr class=\"govuk-table__row govuk-table__row--isHearingRelated\" *ngIf=\"query.isHearingRelated === 'Yes'\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'What is the date of the hearing?' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ query.hearingDate | date: 'dd MMM yyyy' }}</td>\n </tr>\n <tr class=\"govuk-table__row\" *ngIf=\"query.attachments.length > 0\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Attachments' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">\n <ccd-query-attachments-read\n *ngIf=\"query.attachments\"\n [attachments]=\"query.attachments\"\n >\n </ccd-query-attachments-read>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <ng-container *ngIf=\"query.children?.length > 0\">\n <ng-container *ngFor=\"let child of query.children; let i = index;\">\n <ng-container *ngIf=\"i % 2 === 0; else followUpMessage\">\n <table class=\"govuk-table query-details-table\" [attr.aria-describedby]=\"'Response of the query' | rpxTranslate\">\n <caption class=\"govuk-table__caption govuk-table__caption--l\">\n <div>{{ 'Response' | rpxTranslate }}</div>\n </caption>\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Last response date' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.createdOn | date: 'dd MMM yyyy' }}</td>\n </tr>\n\n <tr *ngIf=\"isCaseworker()\" class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Caseworker name' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.name }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Response detail' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.body }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\" *ngIf=\"child.attachments.length > 0\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Attachments' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">\n <ccd-query-attachments-read\n *ngIf=\"child.attachments\"\n [attachments]=\"child.attachments\"\n >\n </ccd-query-attachments-read>\n </td>\n </tr>\n </tbody>\n </table>\n </ng-container>\n\n <ng-template #followUpMessage>\n <!-- <div class=\"query_details_caption\">{{ 'Follow-up' | rpxTranslate }}</div> -->\n <table class=\"govuk-table query-details-table\"\n [attr.aria-describedby]=\"'Follow-up of the response' | rpxTranslate\">\n <caption class=\"govuk-table__caption govuk-table__caption--l\">\n <div>{{ 'Follow up query' | rpxTranslate }}</div>\n </caption>\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Last submission date' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.createdOn | date: 'dd MMM yyyy' }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Last submitted by' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.name }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Query detail' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">{{ child.body }}</td>\n </tr>\n\n <tr class=\"govuk-table__row\" *ngIf=\"child.attachments.length > 0\">\n <th scope=\"row\" class=\"govuk-table__header\">{{ 'Attachments' | rpxTranslate }}</th>\n <td class=\"govuk-table__cell\">\n <ccd-query-attachments-read\n *ngIf=\"child.attachments\"\n [attachments]=\"child.attachments\"\n >\n </ccd-query-attachments-read>\n </td>\n </tr>\n </tbody>\n </table>\n </ng-template>\n </ng-container>\n </ng-container>\n</ng-container>\n", styles: [".query-details-table .govuk-table__header{width:330px}\n"] }]
21025
21087
  }], () => [{ type: SessionStorageService }, { type: i1$1.ActivatedRoute }, { type: i1$1.Router }], { query: [{
21026
21088
  type: Input
21027
- }], backClicked: [{
21028
- type: Output
21029
21089
  }], caseId: [{
21030
21090
  type: Input
21091
+ }], queryResponseStatus: [{
21092
+ type: Input
21093
+ }], backClicked: [{
21094
+ type: Output
21031
21095
  }], hasResponded: [{
21032
21096
  type: Output
21033
- }], totalNumberOfQueryChildren: [{
21034
- type: Input
21035
21097
  }] }); })();
21036
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(QueryDetailsComponent, { className: "QueryDetailsComponent", filePath: "lib/shared/components/palette/query-management/components/query-details/query-details.component.ts", lineNumber: 11 }); })();
21098
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(QueryDetailsComponent, { className: "QueryDetailsComponent", filePath: "lib/shared/components/palette/query-management/components/query-details/query-details.component.ts", lineNumber: 12 }); })();
21037
21099
 
21038
21100
  class QueryEventCompletionComponent {
21039
21101
  eventCompletionParams;
@@ -21696,7 +21758,7 @@ class QueryWriteRespondToQueryComponent {
21696
21758
  caseId;
21697
21759
  queryItemId;
21698
21760
  caseDetails;
21699
- totalNumberOfQueryChildren;
21761
+ queryResponseStatus;
21700
21762
  queryItemDisplay;
21701
21763
  hasRespondedToQuery = false;
21702
21764
  static QUERY_ITEM_RESPOND = '3';
@@ -21724,8 +21786,7 @@ class QueryWriteRespondToQueryComponent {
21724
21786
  console.error('caseQueriesCollections[0] is undefined!', this.caseQueriesCollections);
21725
21787
  return;
21726
21788
  }
21727
- const numberOfQueryChildren = new QueryListData(this.caseQueriesCollections[0]);
21728
- this.totalNumberOfQueryChildren = numberOfQueryChildren?.queries?.[0]?.children?.length || 0;
21789
+ const queryWithChildren = new QueryListData(this.caseQueriesCollections[0]);
21729
21790
  const messageId = this.route.snapshot.params.dataid;
21730
21791
  if (!messageId) {
21731
21792
  console.warn('No messageId found in route params:', this.route.snapshot.params);
@@ -21737,6 +21798,8 @@ class QueryWriteRespondToQueryComponent {
21737
21798
  .filter((message) => message?.value?.id === messageId); // Safe access
21738
21799
  if (filteredMessages.length > 0) {
21739
21800
  const matchingMessage = filteredMessages[0]?.value;
21801
+ const filteredQuery = queryWithChildren?.queries.filter((message) => filteredMessages[0]?.value?.parentId === message?.id);
21802
+ this.queryResponseStatus = filteredQuery[0]?.responseStatus;
21740
21803
  if (matchingMessage) {
21741
21804
  this.queryItemDisplay = new QueryListItem();
21742
21805
  Object.assign(this.queryItemDisplay, matchingMessage);
@@ -21750,7 +21813,7 @@ class QueryWriteRespondToQueryComponent {
21750
21813
  this.hasRespondedToQueryTask.emit(value);
21751
21814
  }
21752
21815
  static ɵfac = function QueryWriteRespondToQueryComponent_Factory(t) { return new (t || QueryWriteRespondToQueryComponent)(i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$1.ActivatedRoute)); };
21753
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: QueryWriteRespondToQueryComponent, selectors: [["ccd-query-write-respond-to-query"]], inputs: { queryItem: "queryItem", formGroup: "formGroup", queryCreateContext: "queryCreateContext", submitted: "submitted", caseQueriesCollections: "caseQueriesCollections", showForm: "showForm" }, outputs: { hasRespondedToQueryTask: "hasRespondedToQueryTask" }, features: [i0.ɵɵNgOnChangesFeature], decls: 13, vars: 10, consts: [[1, "govuk-!-margin-bottom-6"], [1, "govuk-caption-l"], [1, "govuk-heading-l", "govuk-!-margin-bottom-0"], [1, "govuk-!-margin-bottom-4"], [3, "caseDetails"], [3, "hasResponded", "query", "totalNumberOfQueryChildren"], ["class", "query-respond", 4, "ngIf"], [1, "query-respond"], [4, "ngIf"], [1, "govuk-heading-m"], [3, "formGroup"], [1, "govuk-form-group", "body-textarea"], [1, "govuk-label-wrapper"], ["for", "body", 1, "govuk-label", "govuk-label--m", "govuk-!-font-weight-bold"], ["id", "body-error", "class", "govuk-error-message", 4, "ngIf"], ["id", "body", "name", "body", "rows", "5", "aria-describedby", "body-hint body-error", 1, "govuk-textarea", 3, "formControlName"], ["id", "body-error", 1, "govuk-error-message"], [1, "govuk-visually-hidden"]], template: function QueryWriteRespondToQueryComponent_Template(rf, ctx) { if (rf & 1) {
21816
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: QueryWriteRespondToQueryComponent, selectors: [["ccd-query-write-respond-to-query"]], inputs: { queryItem: "queryItem", formGroup: "formGroup", queryCreateContext: "queryCreateContext", submitted: "submitted", caseQueriesCollections: "caseQueriesCollections", showForm: "showForm" }, outputs: { hasRespondedToQueryTask: "hasRespondedToQueryTask" }, features: [i0.ɵɵNgOnChangesFeature], decls: 13, vars: 10, consts: [[1, "govuk-!-margin-bottom-6"], [1, "govuk-caption-l"], [1, "govuk-heading-l", "govuk-!-margin-bottom-0"], [1, "govuk-!-margin-bottom-4"], [3, "caseDetails"], [3, "hasResponded", "query", "queryResponseStatus"], ["class", "query-respond", 4, "ngIf"], [1, "query-respond"], [4, "ngIf"], [1, "govuk-heading-m"], [3, "formGroup"], [1, "govuk-form-group", "body-textarea"], [1, "govuk-label-wrapper"], ["for", "body", 1, "govuk-label", "govuk-label--m", "govuk-!-font-weight-bold"], ["id", "body-error", "class", "govuk-error-message", 4, "ngIf"], ["id", "body", "name", "body", "rows", "5", "aria-describedby", "body-hint body-error", 1, "govuk-textarea", 3, "formControlName"], ["id", "body-error", 1, "govuk-error-message"], [1, "govuk-visually-hidden"]], template: function QueryWriteRespondToQueryComponent_Template(rf, ctx) { if (rf & 1) {
21754
21817
  i0.ɵɵelementStart(0, "div", 0)(1, "div", 0)(2, "div", 1);
21755
21818
  i0.ɵɵtext(3);
21756
21819
  i0.ɵɵpipe(4, "rpxTranslate");
@@ -21774,14 +21837,14 @@ class QueryWriteRespondToQueryComponent {
21774
21837
  i0.ɵɵadvance(3);
21775
21838
  i0.ɵɵproperty("caseDetails", ctx.caseDetails);
21776
21839
  i0.ɵɵadvance(2);
21777
- i0.ɵɵproperty("query", ctx.queryItem)("totalNumberOfQueryChildren", ctx.totalNumberOfQueryChildren);
21840
+ i0.ɵɵproperty("query", ctx.queryItem)("queryResponseStatus", ctx.queryResponseStatus);
21778
21841
  i0.ɵɵadvance();
21779
21842
  i0.ɵɵproperty("ngIf", ctx.showForm);
21780
21843
  } }, styles: [".query-respond[_ngcontent-%COMP%]{width:100%;max-width:720px}"] });
21781
21844
  }
21782
21845
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(QueryWriteRespondToQueryComponent, [{
21783
21846
  type: Component,
21784
- args: [{ selector: 'ccd-query-write-respond-to-query', template: "<div class=\"govuk-!-margin-bottom-6\">\n <div class=\"govuk-!-margin-bottom-6\">\n <div class=\"govuk-caption-l\">{{ 'Respond to a query' | rpxTranslate }}</div>\n <h1 class=\"govuk-heading-l govuk-!-margin-bottom-0\">{{ 'Query details' | rpxTranslate }}</h1>\n </div>\n\n <div class=\"govuk-!-margin-bottom-4\">\n <ccd-query-case-details-header [caseDetails]=\"caseDetails\"></ccd-query-case-details-header>\n </div>\n\n <div>\n <ccd-query-details [query]=\"queryItem\"\n [totalNumberOfQueryChildren]=\"totalNumberOfQueryChildren\"\n (hasResponded)=\"hasResponded($event)\"></ccd-query-details>\n </div>\n</div>\n<div class=\"query-respond\" *ngIf=\"showForm\">\n <div *ngIf=\"!hasRespondedToQuery\">\n <h1 class=\"govuk-heading-m\">\n {{ queryCreateContext === queryCreateContextEnum.RESPOND ? 'Respond to a query' : 'Ask a follow-up question' | rpxTranslate }}\n </h1>\n\n <div [formGroup]=\"formGroup\">\n <div class=\"govuk-form-group body-textarea\"\n [class.govuk-form-group--error]=\"submitted && formGroup.get('body')?.hasError('required')\">\n <div class=\"govuk-label-wrapper\">\n <label class=\"govuk-label govuk-label--m govuk-!-font-weight-bold\" for=\"body\">\n {{ queryCreateContext === queryCreateContextEnum.RESPOND ? 'Response detail' : 'Query Body' | rpxTranslate }}\n </label>\n </div>\n <p id=\"body-error\" class=\"govuk-error-message\"\n *ngIf=\"submitted && formGroup.get('body')?.hasError('required')\">\n <span class=\"govuk-visually-hidden\">{{ 'Error:' | rpxTranslate }} </span>{{ queryCreateContext === queryCreateContextEnum.RESPOND ? raiseQueryErrorMessages.RESPOND_QUERY_BODY : raiseQueryErrorMessages.QUERY_BODY | rpxTranslate }}\n </p>\n <textarea [formControlName]=\"'body'\" class=\"govuk-textarea\"\n [class.govuk-textarea--error]=\"submitted && formGroup.get('body')?.hasError('required')\" id=\"body\"\n name=\"body\" rows=\"5\" aria-describedby=\"body-hint body-error\">\n </textarea>\n </div>\n </div>\n </div>\n</div>\n", styles: [".query-respond{width:100%;max-width:720px}\n"] }]
21847
+ args: [{ selector: 'ccd-query-write-respond-to-query', template: "<div class=\"govuk-!-margin-bottom-6\">\n <div class=\"govuk-!-margin-bottom-6\">\n <div class=\"govuk-caption-l\">{{ 'Respond to a query' | rpxTranslate }}</div>\n <h1 class=\"govuk-heading-l govuk-!-margin-bottom-0\">{{ 'Query details' | rpxTranslate }}</h1>\n </div>\n\n <div class=\"govuk-!-margin-bottom-4\">\n <ccd-query-case-details-header [caseDetails]=\"caseDetails\"></ccd-query-case-details-header>\n </div>\n\n <div>\n <ccd-query-details [query]=\"queryItem\"\n [queryResponseStatus]=\"queryResponseStatus\"\n (hasResponded)=\"hasResponded($event)\"></ccd-query-details>\n </div>\n</div>\n<div class=\"query-respond\" *ngIf=\"showForm\">\n <div *ngIf=\"!hasRespondedToQuery\">\n <h1 class=\"govuk-heading-m\">\n {{ queryCreateContext === queryCreateContextEnum.RESPOND ? 'Respond to a query' : 'Ask a follow-up question' | rpxTranslate }}\n </h1>\n\n <div [formGroup]=\"formGroup\">\n <div class=\"govuk-form-group body-textarea\"\n [class.govuk-form-group--error]=\"submitted && formGroup.get('body')?.hasError('required')\">\n <div class=\"govuk-label-wrapper\">\n <label class=\"govuk-label govuk-label--m govuk-!-font-weight-bold\" for=\"body\">\n {{ queryCreateContext === queryCreateContextEnum.RESPOND ? 'Response detail' : 'Query Body' | rpxTranslate }}\n </label>\n </div>\n <p id=\"body-error\" class=\"govuk-error-message\"\n *ngIf=\"submitted && formGroup.get('body')?.hasError('required')\">\n <span class=\"govuk-visually-hidden\">{{ 'Error:' | rpxTranslate }} </span>{{ queryCreateContext === queryCreateContextEnum.RESPOND ? raiseQueryErrorMessages.RESPOND_QUERY_BODY : raiseQueryErrorMessages.QUERY_BODY | rpxTranslate }}\n </p>\n <textarea [formControlName]=\"'body'\" class=\"govuk-textarea\"\n [class.govuk-textarea--error]=\"submitted && formGroup.get('body')?.hasError('required')\" id=\"body\"\n name=\"body\" rows=\"5\" aria-describedby=\"body-hint body-error\">\n </textarea>\n </div>\n </div>\n </div>\n</div>\n", styles: [".query-respond{width:100%;max-width:720px}\n"] }]
21785
21848
  }], () => [{ type: CaseNotifier }, { type: i1$1.ActivatedRoute }], { queryItem: [{
21786
21849
  type: Input
21787
21850
  }], formGroup: [{