@hmcts/ccd-case-ui-toolkit 7.0.5 → 7.0.6

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 (37) hide show
  1. package/esm2020/lib/shared/components/case-editor/case-edit/case-edit.component.mjs +56 -26
  2. package/esm2020/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.mjs +4 -1
  3. package/esm2020/lib/shared/components/case-editor/case-event-completion/components/case-event-completion-task-reassigned/case-event-completion-task-reassigned.component.mjs +4 -14
  4. package/esm2020/lib/shared/components/case-editor/services/event-completion-state-machine.service.mjs +6 -25
  5. package/esm2020/lib/shared/components/palette/datetime-picker/datetime-picker-utils.mjs +3 -3
  6. package/esm2020/lib/shared/components/palette/document/write-document-field.component.mjs +14 -2
  7. package/esm2020/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.mjs +25 -12
  8. package/esm2020/lib/shared/domain/case-view/service-org-response.model.mjs +2 -0
  9. package/esm2020/lib/shared/domain/http/http-error.model.mjs +2 -8
  10. package/esm2020/lib/shared/pipes/complex/ccd-read-fields-filter.pipe.mjs +4 -3
  11. package/esm2020/lib/shared/services/common-data-service/common-data-service.mjs +7 -1
  12. package/esm2020/lib/shared/services/fields/fields.purger.mjs +16 -6
  13. package/esm2020/lib/shared/services/form/form-value.service.mjs +10 -7
  14. package/esm2020/lib/shared/services/utils/retry/retry.service.mjs +1 -2
  15. package/fesm2015/hmcts-ccd-case-ui-toolkit.mjs +137 -94
  16. package/fesm2015/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
  17. package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs +136 -94
  18. package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
  19. package/lib/shared/components/case-editor/case-edit/case-edit.component.d.ts +5 -2
  20. package/lib/shared/components/case-editor/case-edit/case-edit.component.d.ts.map +1 -1
  21. package/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts.map +1 -1
  22. package/lib/shared/components/case-editor/case-event-completion/components/case-event-completion-task-reassigned/case-event-completion-task-reassigned.component.d.ts.map +1 -1
  23. package/lib/shared/components/case-editor/services/event-completion-state-machine.service.d.ts.map +1 -1
  24. package/lib/shared/components/palette/document/write-document-field.component.d.ts.map +1 -1
  25. package/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.d.ts +6 -3
  26. package/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.d.ts.map +1 -1
  27. package/lib/shared/domain/case-view/service-org-response.model.d.ts +14 -0
  28. package/lib/shared/domain/case-view/service-org-response.model.d.ts.map +1 -0
  29. package/lib/shared/domain/http/http-error.model.d.ts +0 -1
  30. package/lib/shared/domain/http/http-error.model.d.ts.map +1 -1
  31. package/lib/shared/pipes/complex/ccd-read-fields-filter.pipe.d.ts.map +1 -1
  32. package/lib/shared/services/common-data-service/common-data-service.d.ts +2 -0
  33. package/lib/shared/services/common-data-service/common-data-service.d.ts.map +1 -1
  34. package/lib/shared/services/fields/fields.purger.d.ts.map +1 -1
  35. package/lib/shared/services/form/form-value.service.d.ts +1 -1
  36. package/lib/shared/services/form/form-value.service.d.ts.map +1 -1
  37. package/package.json +1 -1
@@ -8,7 +8,7 @@ import * as i1$2 from '@angular/router';
8
8
  import { RouterModule, NavigationStart, NavigationEnd } from '@angular/router';
9
9
  import * as i3 from '@angular/forms';
10
10
  import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormArray, FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
11
- import { throwError, Subject, EMPTY, Observable, of, BehaviorSubject, timer, fromEvent, forkJoin } from 'rxjs';
11
+ import { throwError, Subject, EMPTY, Observable, of, BehaviorSubject, timer, fromEvent, forkJoin, Subscription } from 'rxjs';
12
12
  import * as i1$3 from '@angular/common/http';
13
13
  import { HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http';
14
14
  import { catchError, map, publish, refCount, debounceTime, delay, distinctUntilChanged, finalize, timeout, mergeMap, retryWhen, tap, delayWhen, publishReplay, take, first, switchMap, takeUntil, filter } from 'rxjs/operators';
@@ -1241,14 +1241,9 @@ class HttpError {
1241
1241
  }
1242
1242
  static from(response) {
1243
1243
  const error = new HttpError();
1244
- if (response?.status === 429) {
1245
- error.error = HttpError.MESSAGE_ERROR_429;
1246
- error.status = response.status;
1247
- error.message = response.message;
1248
- }
1249
1244
  // Check that the HttpErrorResponse contains an "error" object before mapping the error properties
1250
1245
  if (!!(response && response.error)) {
1251
- Object.keys(error).forEach((key) => {
1246
+ Object.keys(error).forEach(key => {
1252
1247
  error[key] = response.error.hasOwnProperty(key) && response.error[key] ? response.error[key] : error[key];
1253
1248
  });
1254
1249
  }
@@ -1265,7 +1260,6 @@ class HttpError {
1265
1260
  HttpError.DEFAULT_ERROR = 'Unknown error';
1266
1261
  HttpError.DEFAULT_MESSAGE = 'Something unexpected happened, our technical staff have been automatically notified';
1267
1262
  HttpError.DEFAULT_STATUS = 500;
1268
- HttpError.MESSAGE_ERROR_429 = 'Your request was rate limited. Please wait a few seconds before retrying your document upload';
1269
1263
 
1270
1264
  /**
1271
1265
  * `Oauth2Service` and `AuthService` cannot be merged as it creates a cyclic dependency on `AuthService` through `HttpErrorService`.
@@ -4959,11 +4953,21 @@ class FieldsPurger {
4959
4953
  * @returns A new array with the mapped values
4960
4954
  */
4961
4955
  mapArrayValuesToNull(array) {
4962
- return array.map(element => {
4963
- return typeof element === 'object'
4964
- ? Object.assign({}, ...Object.keys(element).map(k => ({ [k]: null })))
4965
- : null;
4966
- });
4956
+ if (array && array.length > 0) {
4957
+ return array.map(element => {
4958
+ if (element !== undefined && element !== null) {
4959
+ return typeof element === 'object'
4960
+ ? Object.assign({}, ...Object.keys(element).map(k => ({ [k]: null })))
4961
+ : null;
4962
+ }
4963
+ else {
4964
+ return {};
4965
+ }
4966
+ });
4967
+ }
4968
+ else {
4969
+ return array;
4970
+ }
4967
4971
  }
4968
4972
  }
4969
4973
  FieldsPurger.ɵfac = function FieldsPurger_Factory(t) { return new (t || FieldsPurger)(i0.ɵɵinject(FieldsUtils)); };
@@ -5435,7 +5439,7 @@ class FormValueService {
5435
5439
  * @param clearEmpty Whether or not we should clear out empty, optional, complex objects.
5436
5440
  * @param clearNonCase Whether or not we should clear out non-case fields at the top level.
5437
5441
  */
5438
- removeUnnecessaryFields(data, caseFields, clearEmpty = false, clearNonCase = false, fromPreviousPage = false, currentPageCaseFields = []) {
5442
+ removeUnnecessaryFields(data, caseFields, clearEmpty = false, clearNonCase = false, fromPreviousPage = false, currentPageCaseFields = [], isCalledFromSubmit = false) {
5439
5443
  if (data && caseFields && caseFields.length > 0) {
5440
5444
  // check if there is any data at the top level of the form that's not in the caseFields
5441
5445
  if (clearNonCase) {
@@ -5446,10 +5450,13 @@ class FormValueService {
5446
5450
  // Retain anything that is readonly and not a label.
5447
5451
  continue;
5448
5452
  }
5449
- if (field.hidden === true && field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP' && field.id !== 'caseLinks' && !field.retain_hidden_value) {
5453
+ if (field.hidden === true && field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP' && field.id !== 'caseLinks') {
5450
5454
  // Delete anything that is hidden (that is NOT readonly), and that
5451
5455
  // hasn't had its display_context overridden to make it hidden.
5452
- delete data[field.id];
5456
+ // in event submission check for field's retain_hidden_value defore deletion
5457
+ if ((isCalledFromSubmit && !field.retain_hidden_value) || !isCalledFromSubmit) {
5458
+ delete data[field.id];
5459
+ }
5453
5460
  }
5454
5461
  else if (field.field_type) {
5455
5462
  switch (field.field_type.type) {
@@ -5463,7 +5470,7 @@ class FormValueService {
5463
5470
  }
5464
5471
  break;
5465
5472
  case 'Complex':
5466
- this.removeUnnecessaryFields(data[field.id], field.field_type.complex_fields, clearEmpty);
5473
+ this.removeUnnecessaryFields(data[field.id], field.field_type.complex_fields, clearEmpty, false, false, [], isCalledFromSubmit);
5467
5474
  // Also remove any optional complex objects that are completely empty.
5468
5475
  // EUI-4244: Ritesh's fix, passing true instead of clearEmpty.
5469
5476
  if (FormValueService.clearOptionalEmpty(true, data[field.id], field)) {
@@ -5486,8 +5493,8 @@ class FormValueService {
5486
5493
  if (field.field_type.collection_field_type.type === 'Complex') {
5487
5494
  // Iterate through the elements and remove any unnecessary fields within.
5488
5495
  for (const item of collection) {
5489
- this.removeUnnecessaryFields(item, field.field_type.collection_field_type.complex_fields, clearEmpty);
5490
- this.removeUnnecessaryFields(item.value, field.field_type.collection_field_type.complex_fields, false);
5496
+ this.removeUnnecessaryFields(item, field.field_type.collection_field_type.complex_fields, clearEmpty, false, false, [], isCalledFromSubmit);
5497
+ this.removeUnnecessaryFields(item.value, field.field_type.collection_field_type.complex_fields, false, false, false, [], isCalledFromSubmit);
5491
5498
  }
5492
5499
  }
5493
5500
  }
@@ -6731,7 +6738,6 @@ class ArtificialDelayContext {
6731
6738
  this.artificialDelayOn = true;
6732
6739
  this.selectedDelay = this.selectActualDelayTime();
6733
6740
  }
6734
- ;
6735
6741
  switchArtificialDelays(status) {
6736
6742
  this.artificialDelayOn = status;
6737
6743
  this.selectedDelay = this.selectActualDelayTime();
@@ -8055,18 +8061,9 @@ class EventCompletionStateMachineService {
8055
8061
  state.trigger(EventCompletionStates.Final);
8056
8062
  const taskStr = context.sessionStorageService.getItem('taskToComplete');
8057
8063
  if (taskStr) {
8058
- // Task is in session storage
8059
- const task = JSON.parse(taskStr);
8060
- // Task already assigned to current user, just complete task
8061
- context.workAllocationService.completeTask(task.id).subscribe(response => {
8062
- // Emit event can be completed event
8063
- context.component.eventCanBeCompleted.emit(true);
8064
- }, error => {
8065
- // Emit event cannot be completed event
8066
- context.component.eventCanBeCompleted.emit(false);
8067
- context.alertService.error(error.message);
8068
- return throwError(error);
8069
- });
8064
+ context.sessionStorageService.setItem('assignNeeded', 'false');
8065
+ // just set event can be completed
8066
+ context.component.eventCanBeCompleted.emit(true);
8070
8067
  }
8071
8068
  else {
8072
8069
  // Emit event cannot be completed event
@@ -8085,18 +8082,8 @@ class EventCompletionStateMachineService {
8085
8082
  // Get task details
8086
8083
  const taskStr = context.sessionStorageService.getItem('taskToComplete');
8087
8084
  if (taskStr) {
8088
- // Task is in session storage
8089
- const task = JSON.parse(taskStr);
8090
- // Assign and complete task
8091
- context.workAllocationService.assignAndCompleteTask(task.id).subscribe(response => {
8092
- // Emit event can be completed event
8093
- context.component.eventCanBeCompleted.emit(true);
8094
- }, error => {
8095
- // Emit event cannot be completed event
8096
- context.component.eventCanBeCompleted.emit(false);
8097
- context.alertService.error(error.message);
8098
- return throwError(error);
8099
- });
8085
+ context.sessionStorageService.setItem('assignNeeded', 'true');
8086
+ context.component.eventCanBeCompleted.emit(true);
8100
8087
  }
8101
8088
  else {
8102
8089
  // Emit event cannot be completed event
@@ -8442,7 +8429,7 @@ ValidPageListCaseFieldsService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({
8442
8429
  }], function () { return [{ type: FieldsUtils }]; }, null); })();
8443
8430
 
8444
8431
  class CaseEditComponent {
8445
- constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService) {
8432
+ constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService, workAllocationService) {
8446
8433
  this.fb = fb;
8447
8434
  this.caseNotifier = caseNotifier;
8448
8435
  this.router = router;
@@ -8457,6 +8444,7 @@ class CaseEditComponent {
8457
8444
  this.formErrorService = formErrorService;
8458
8445
  this.loadingService = loadingService;
8459
8446
  this.validPageListCaseFieldsService = validPageListCaseFieldsService;
8447
+ this.workAllocationService = workAllocationService;
8460
8448
  this.cancelled = new EventEmitter();
8461
8449
  this.submitted = new EventEmitter();
8462
8450
  this.isEventCompletionChecksRequired = false;
@@ -8630,7 +8618,7 @@ class CaseEditComponent {
8630
8618
  const pageListCaseFields = this.validPageListCaseFieldsService.validPageListCaseFields(this.validPageList, eventTrigger.case_fields, form.controls['data'].value);
8631
8619
  // Remove unnecessary case fields which are hidden, only if the submission is *not* for Case Flags
8632
8620
  if (!this.isCaseFlagSubmission) {
8633
- this.formValueService.removeUnnecessaryFields(caseEventData.data, pageListCaseFields, true, true);
8621
+ this.formValueService.removeUnnecessaryFields(caseEventData.data, pageListCaseFields, true, true, false, [], true);
8634
8622
  }
8635
8623
  caseEventData.event_token = eventTrigger.event_token;
8636
8624
  caseEventData.ignore_warning = this.ignoreWarning;
@@ -8743,31 +8731,60 @@ class CaseEditComponent {
8743
8731
  }
8744
8732
  caseSubmit({ form, caseEventData, submit }) {
8745
8733
  const loadingSpinnerToken = this.loadingService.register();
8746
- submit(caseEventData)
8747
- .pipe(finalize(() => {
8734
+ // keep the initial event response to finalise process after task completion
8735
+ let eventResponse;
8736
+ submit(caseEventData).pipe(switchMap((response) => {
8737
+ eventResponse = response;
8738
+ return this.postCompleteTaskIfRequired();
8739
+ }), finalize(() => {
8748
8740
  this.loadingService.unregister(loadingSpinnerToken);
8749
8741
  }))
8750
- .subscribe(response => {
8751
- this.caseNotifier.cachedCaseView = null;
8752
- this.sessionStorageService.removeItem('eventUrl');
8753
- const confirmation = this.buildConfirmation(response);
8754
- if (confirmation && (confirmation.getHeader() || confirmation.getBody())) {
8755
- this.confirm(confirmation);
8742
+ .subscribe(() => {
8743
+ this.finishEventCompletionLogic(eventResponse);
8744
+ }, error => {
8745
+ if (!eventResponse) {
8746
+ // event submission error
8747
+ this.error = error;
8748
+ this.callbackErrorsSubject.next(error);
8749
+ /* istanbul ignore else */
8750
+ if (this.error.details) {
8751
+ this.formErrorService
8752
+ .mapFieldErrors(this.error.details.field_errors, form.controls['data'], 'validation');
8753
+ }
8754
+ this.isSubmitting = false;
8756
8755
  }
8757
8756
  else {
8758
- this.emitSubmitted(response);
8759
- }
8760
- }, error => {
8761
- this.error = error;
8762
- this.callbackErrorsSubject.next(error);
8763
- /* istanbul ignore else */
8764
- if (this.error.details) {
8765
- this.formErrorService
8766
- .mapFieldErrors(this.error.details.field_errors, form.controls['data'], 'validation');
8757
+ // task assignment/completion error - handled within workallocation service
8758
+ // could set task to be deleted (or completed later)?
8759
+ // note: think error messages only shown if user is caseworker - might reqauire changing
8760
+ this.finishEventCompletionLogic(eventResponse);
8767
8761
  }
8768
- this.isSubmitting = false;
8769
8762
  });
8770
8763
  }
8764
+ postCompleteTaskIfRequired() {
8765
+ const taskStr = this.sessionStorageService.getItem('taskToComplete');
8766
+ const assignNeeded = this.sessionStorageService.getItem('assignNeeded') === 'true';
8767
+ if (taskStr && assignNeeded) {
8768
+ const task = JSON.parse(taskStr);
8769
+ return this.workAllocationService.assignAndCompleteTask(task.id);
8770
+ }
8771
+ else if (taskStr) {
8772
+ const task = JSON.parse(taskStr);
8773
+ return this.workAllocationService.completeTask(task.id);
8774
+ }
8775
+ return of(true);
8776
+ }
8777
+ finishEventCompletionLogic(eventResponse) {
8778
+ this.caseNotifier.cachedCaseView = null;
8779
+ this.sessionStorageService.removeItem('eventUrl');
8780
+ const confirmation = this.buildConfirmation(eventResponse);
8781
+ if (confirmation && (confirmation.getHeader() || confirmation.getBody())) {
8782
+ this.confirm(confirmation);
8783
+ }
8784
+ else {
8785
+ this.emitSubmitted(eventResponse);
8786
+ }
8787
+ }
8771
8788
  buildConfirmation(response) {
8772
8789
  if (response['after_submit_callback_response']) {
8773
8790
  return new Confirmation(response['id'], response['callback_response_status'], response['after_submit_callback_response']['confirmation_header'], response['after_submit_callback_response']['confirmation_body']);
@@ -8796,14 +8813,14 @@ class CaseEditComponent {
8796
8813
  }
8797
8814
  CaseEditComponent.ORIGIN_QUERY_PARAM = 'origin';
8798
8815
  CaseEditComponent.ALERT_MESSAGE = 'Page is being refreshed so you will be redirected to the first page of this event.';
8799
- CaseEditComponent.ɵfac = function CaseEditComponent_Factory(t) { return new (t || CaseEditComponent)(i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute), i0.ɵɵdirectiveInject(FieldsUtils), i0.ɵɵdirectiveInject(FieldsPurger), i0.ɵɵdirectiveInject(ConditionalShowRegistrarService), i0.ɵɵdirectiveInject(WizardFactoryService), i0.ɵɵdirectiveInject(SessionStorageService), i0.ɵɵdirectiveInject(WindowService), i0.ɵɵdirectiveInject(FormValueService), i0.ɵɵdirectiveInject(FormErrorService), i0.ɵɵdirectiveInject(LoadingService), i0.ɵɵdirectiveInject(ValidPageListCaseFieldsService)); };
8816
+ CaseEditComponent.ɵfac = function CaseEditComponent_Factory(t) { return new (t || CaseEditComponent)(i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute), i0.ɵɵdirectiveInject(FieldsUtils), i0.ɵɵdirectiveInject(FieldsPurger), i0.ɵɵdirectiveInject(ConditionalShowRegistrarService), i0.ɵɵdirectiveInject(WizardFactoryService), i0.ɵɵdirectiveInject(SessionStorageService), i0.ɵɵdirectiveInject(WindowService), i0.ɵɵdirectiveInject(FormValueService), i0.ɵɵdirectiveInject(FormErrorService), i0.ɵɵdirectiveInject(LoadingService), i0.ɵɵdirectiveInject(ValidPageListCaseFieldsService), i0.ɵɵdirectiveInject(WorkAllocationService)); };
8800
8817
  CaseEditComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaseEditComponent, selectors: [["ccd-case-edit"]], inputs: { eventTrigger: "eventTrigger", submit: "submit", validate: "validate", saveDraft: "saveDraft", caseDetails: "caseDetails" }, outputs: { cancelled: "cancelled", submitted: "submitted" }, features: [i0.ɵɵProvidersFeature([GreyBarService])], decls: 1, vars: 0, template: function CaseEditComponent_Template(rf, ctx) { if (rf & 1) {
8801
8818
  i0.ɵɵelement(0, "router-outlet");
8802
8819
  } }, dependencies: [i1$2.RouterOutlet], styles: ["#fieldset-case-data[_ngcontent-%COMP%]{margin-bottom:30px}#fieldset-case-data[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{width:1%;white-space:nowrap;vertical-align:top}.compound-field[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:0}#confirmation-header[_ngcontent-%COMP%]{width:630px;background-color:#17958b;border:solid 1px #979797;color:#fff;text-align:center}#confirmation-body[_ngcontent-%COMP%]{width:630px;background-color:#fff}.valign-top[_ngcontent-%COMP%]{vertical-align:top}.summary-fields[_ngcontent-%COMP%]{margin-bottom:30px}.summary-fields[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .summary-fields[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border-bottom:0px}a.disabled[_ngcontent-%COMP%]{pointer-events:none;cursor:default}.case-field-label[_ngcontent-%COMP%]{width:45%}.case-field-content[_ngcontent-%COMP%]{width:50%}.case-field-change[_ngcontent-%COMP%]{width:5%}"] });
8803
8820
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseEditComponent, [{
8804
8821
  type: Component,
8805
8822
  args: [{ selector: 'ccd-case-edit', providers: [GreyBarService], template: "<router-outlet></router-outlet>\n", styles: ["#fieldset-case-data{margin-bottom:30px}#fieldset-case-data th{width:1%;white-space:nowrap;vertical-align:top}.compound-field td{padding:0}#confirmation-header{width:630px;background-color:#17958b;border:solid 1px #979797;color:#fff;text-align:center}#confirmation-body{width:630px;background-color:#fff}.valign-top{vertical-align:top}.summary-fields{margin-bottom:30px}.summary-fields tbody tr th,.summary-fields tbody tr td{border-bottom:0px}a.disabled{pointer-events:none;cursor:default}.case-field-label{width:45%}.case-field-content{width:50%}.case-field-change{width:5%}\n"] }]
8806
- }], function () { return [{ type: i3.FormBuilder }, { type: CaseNotifier }, { type: i1$2.Router }, { type: i1$2.ActivatedRoute }, { type: FieldsUtils }, { type: FieldsPurger }, { type: ConditionalShowRegistrarService }, { type: WizardFactoryService }, { type: SessionStorageService }, { type: WindowService }, { type: FormValueService }, { type: FormErrorService }, { type: LoadingService }, { type: ValidPageListCaseFieldsService }]; }, { eventTrigger: [{
8823
+ }], function () { return [{ type: i3.FormBuilder }, { type: CaseNotifier }, { type: i1$2.Router }, { type: i1$2.ActivatedRoute }, { type: FieldsUtils }, { type: FieldsPurger }, { type: ConditionalShowRegistrarService }, { type: WizardFactoryService }, { type: SessionStorageService }, { type: WindowService }, { type: FormValueService }, { type: FormErrorService }, { type: LoadingService }, { type: ValidPageListCaseFieldsService }, { type: WorkAllocationService }]; }, { eventTrigger: [{
8807
8824
  type: Input
8808
8825
  }], submit: [{
8809
8826
  type: Input
@@ -9570,6 +9587,7 @@ class CaseEditPageComponent {
9570
9587
  }
9571
9588
  submit() {
9572
9589
  this.caseEditDataService.clearFormValidationErrors();
9590
+ console.log('Page submit event fired!');
9573
9591
  if (this.currentPageIsNotValid()) {
9574
9592
  // The generateErrorMessage method filters out the hidden fields.
9575
9593
  // The error message for LinkedCases journey will never get displayed because the
@@ -9583,6 +9601,7 @@ class CaseEditPageComponent {
9583
9601
  }
9584
9602
  }
9585
9603
  if (!this.caseEdit.isSubmitting && !this.currentPageIsNotValid()) {
9604
+ console.log('Case Edit Error', this.caseEdit.error);
9586
9605
  if (this.caseEdit.validPageList.findIndex(page => page.id === this.currentPage.id) === -1) {
9587
9606
  this.caseEdit.validPageList.push(this.currentPage);
9588
9607
  }
@@ -9772,6 +9791,7 @@ class CaseEditPageComponent {
9772
9791
  this.formErrorService
9773
9792
  .mapFieldErrors(this.caseEdit.error.details.field_errors, this.editForm?.controls?.['data'], 'validation');
9774
9793
  }
9794
+ console.log('handleError ', error);
9775
9795
  }
9776
9796
  resetErrors() {
9777
9797
  this.caseEdit.error = null;
@@ -12703,7 +12723,19 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
12703
12723
  if (0 === error.status || 502 === error.status) {
12704
12724
  return WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE;
12705
12725
  }
12706
- return error.error;
12726
+ let errorMsg = 'Error uploading file';
12727
+ if (error?.error) {
12728
+ const fullError = error.error;
12729
+ const start = fullError.indexOf('{');
12730
+ if (start >= 0) {
12731
+ const json = fullError.substring(start, fullError.length - 1).split('<EOL>').join('');
12732
+ const obj = JSON.parse(json);
12733
+ if (obj?.error) {
12734
+ errorMsg = obj.error;
12735
+ }
12736
+ }
12737
+ }
12738
+ return errorMsg;
12707
12739
  }
12708
12740
  buildDocumentUploadData(selectedFile) {
12709
12741
  const documentUpload = new FormData();
@@ -15791,6 +15823,12 @@ class CommonDataService {
15791
15823
  }
15792
15824
  return of(null);
15793
15825
  }
15826
+ getServiceOrgData(url) {
15827
+ if (url) {
15828
+ return this.http.get(url, { observe: 'body' });
15829
+ }
15830
+ return of(null);
15831
+ }
15794
15832
  }
15795
15833
  CommonDataService.ɵfac = function CommonDataService_Factory(t) { return new (t || CommonDataService)(i0.ɵɵinject(i1$3.HttpClient)); };
15796
15834
  CommonDataService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CommonDataService, factory: CommonDataService.ɵfac });
@@ -16002,6 +16040,7 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
16002
16040
  this.linkedCasesPages = LinkedCasesPages;
16003
16041
  this.linkedCasesEventTriggers = LinkedCasesEventTriggers;
16004
16042
  this.linkedCases = [];
16043
+ this.subscriptions = new Subscription();
16005
16044
  }
16006
16045
  ngOnInit() {
16007
16046
  // This is required to enable Continue button validation
@@ -16010,17 +16049,17 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
16010
16049
  // Clear validation errors
16011
16050
  this.caseEditDataService.clearFormValidationErrors();
16012
16051
  // Get linked case reasons from ref data
16013
- this.getLinkedCaseReasons();
16014
16052
  this.linkedCasesService.editMode = false;
16015
- this.caseEditDataService.caseDetails$.subscribe({
16016
- next: caseDetails => this.initialiseCaseDetails(caseDetails)
16017
- });
16018
- this.caseEditDataService.caseEventTriggerName$.subscribe({
16053
+ this.subscriptions.add(this.caseEditDataService.caseDetails$.subscribe({
16054
+ next: caseDetails => { this.initialiseCaseDetails(caseDetails); }
16055
+ }));
16056
+ this.getOrgService();
16057
+ this.subscriptions.add(this.caseEditDataService.caseEventTriggerName$.subscribe({
16019
16058
  next: name => this.linkedCasesService.isLinkedCasesEventTrigger = (name === LinkedCasesEventTriggers.LINK_CASES)
16020
- });
16021
- this.caseEditDataService.caseEditForm$.subscribe({
16059
+ }));
16060
+ this.subscriptions.add(this.caseEditDataService.caseEditForm$.subscribe({
16022
16061
  next: editForm => this.caseEditForm = editForm
16023
- });
16062
+ }));
16024
16063
  }
16025
16064
  initialiseCaseDetails(caseDetails) {
16026
16065
  if (caseDetails) {
@@ -16056,18 +16095,26 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
16056
16095
  }
16057
16096
  }
16058
16097
  }
16059
- getLinkedCaseReasons() {
16060
- const reasonCodeAPIurl = `${this.appConfig.getRDCommonDataApiUrl()}/lov/categories/CaseLinkingReasonCode`;
16098
+ getLinkedCaseReasons(serviceId) {
16099
+ const reasonCodeAPIurl = `${this.appConfig.getRDCommonDataApiUrl()}/lov/categories/CaseLinkingReasonCode?serviceId=${serviceId}`;
16061
16100
  this.commonDataService.getRefData(reasonCodeAPIurl).subscribe({
16062
16101
  next: reasons => {
16063
16102
  // Sort in ascending order
16064
16103
  const linkCaseReasons = reasons.list_of_values.sort((a, b) => (a.value_en > b.value_en) ? 1 : -1);
16065
- // Move Other option to the end of the list
16066
16104
  this.linkedCasesService.linkCaseReasons = linkCaseReasons?.filter(reason => reason.value_en !== 'Other');
16105
+ // Move Other option to the end of the list
16067
16106
  this.linkedCasesService.linkCaseReasons.push(linkCaseReasons?.find(reason => reason.value_en === 'Other'));
16068
16107
  }
16069
16108
  });
16070
16109
  }
16110
+ getOrgService() {
16111
+ const servicesApiUrl = `refdata/location/orgServices?ccdCaseType=${this.caseDetails?.case_type?.id}`;
16112
+ this.commonDataService.getServiceOrgData(servicesApiUrl).subscribe(result => {
16113
+ result.forEach(ids => {
16114
+ this.getLinkedCaseReasons(ids.service_id);
16115
+ });
16116
+ });
16117
+ }
16071
16118
  proceedToNextPage() {
16072
16119
  if (this.isAtFinalPage()) {
16073
16120
  // Continue button event must be allowed in final page
@@ -16122,6 +16169,9 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
16122
16169
  : LinkedCasesPages.NO_LINKED_CASES;
16123
16170
  });
16124
16171
  }
16172
+ ngOnDestroy() {
16173
+ this.subscriptions.unsubscribe();
16174
+ }
16125
16175
  }
16126
16176
  WriteLinkedCasesFieldComponent.ɵfac = function WriteLinkedCasesFieldComponent_Factory(t) { return new (t || WriteLinkedCasesFieldComponent)(i0.ɵɵdirectiveInject(AbstractAppConfig), i0.ɵɵdirectiveInject(CommonDataService), i0.ɵɵdirectiveInject(CasesService), i0.ɵɵdirectiveInject(LinkedCasesService), i0.ɵɵdirectiveInject(CaseEditDataService)); };
16127
16177
  WriteLinkedCasesFieldComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WriteLinkedCasesFieldComponent, selectors: [["ccd-write-linked-cases-field"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 7, vars: 7, consts: [[1, "form-group", "govuk-!-margin-bottom-2", 3, "formGroup"], [1, "govuk-form-group", 3, "ngSwitch"], [4, "ngSwitchCase"], [3, "linkedCasesStateEmitter"]], template: function WriteLinkedCasesFieldComponent_Template(rf, ctx) { if (rf & 1) {
@@ -20776,10 +20826,10 @@ WriteDateFieldComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Wri
20776
20826
 
20777
20827
  const CUSTOM_MOMENT_FORMATS = {
20778
20828
  parse: {
20779
- dateInput: 'YYYY MM DD HH:mm:ss'
20829
+ dateInput: 'DD-MM-YYYY HH:mm:ss'
20780
20830
  },
20781
20831
  display: {
20782
- dateInput: 'YYYY MM DD HH:mm:ss',
20832
+ dateInput: 'DD-MM-YYYY HH:mm:ss',
20783
20833
  monthYearLabel: 'MMMM YYYY',
20784
20834
  dateA11yLabel: 'EEE/MMM/YYYY',
20785
20835
  monthYearA11yLabel: 'MMMM YYYY',
@@ -21907,8 +21957,9 @@ class ReadFieldsFilterPipe {
21907
21957
  return isNotEmpty;
21908
21958
  }
21909
21959
  static isEmpty(value) {
21910
- return ReadFieldsFilterPipe.EMPTY_VALUES.indexOf(value) !== -1
21911
- || value.length === 0;
21960
+ const fieldValue = value?.hasOwnProperty('list_items') && value?.hasOwnProperty('value') ? value.value : value;
21961
+ return ReadFieldsFilterPipe.EMPTY_VALUES.indexOf(fieldValue) !== -1
21962
+ || fieldValue.length === 0;
21912
21963
  }
21913
21964
  static isCompound(field) {
21914
21965
  return ReadFieldsFilterPipe.NESTED_TYPES[field.field_type.type];
@@ -23704,18 +23755,9 @@ class CaseEventCompletionTaskReassignedComponent {
23704
23755
  // Get task details
23705
23756
  const taskStr = this.sessionStorageService.getItem('taskToComplete');
23706
23757
  if (taskStr) {
23707
- // Task is in session storage
23708
- const task = JSON.parse(taskStr);
23709
- // Assign and complete task
23710
- this.subscription = this.workAllocationService.assignAndCompleteTask(task.id).subscribe(response => {
23711
- // Emit event can be completed event
23712
- this.parentComponent.eventCanBeCompleted.emit(true);
23713
- }, error => {
23714
- // Emit event cannot be completed event
23715
- this.parentComponent.eventCanBeCompleted.emit(false);
23716
- this.alertService.error(error.message);
23717
- return throwError(error);
23718
- });
23758
+ this.sessionStorageService.setItem('assignNeeded', 'true');
23759
+ // set event can be completed to true
23760
+ this.parentComponent.eventCanBeCompleted.emit(true);
23719
23761
  }
23720
23762
  else {
23721
23763
  // Emit event cannot be completed event