@hmcts/ccd-case-ui-toolkit 7.0.4-mv-upgrade → 7.0.4-task-completion-error-message

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 (40) hide show
  1. package/esm2020/lib/shared/commons/constants.mjs +2 -1
  2. package/esm2020/lib/shared/components/case-editor/case-edit/case-edit.component.mjs +67 -27
  3. package/esm2020/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.mjs +4 -1
  4. 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
  5. package/esm2020/lib/shared/components/case-editor/services/event-completion-state-machine.service.mjs +6 -25
  6. package/esm2020/lib/shared/components/case-viewer/case-event-trigger/case-event-trigger.component.mjs +22 -9
  7. package/esm2020/lib/shared/components/palette/datetime-picker/datetime-picker-utils.mjs +3 -3
  8. package/esm2020/lib/shared/components/palette/document/write-document-field.component.mjs +14 -2
  9. package/esm2020/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.mjs +25 -12
  10. package/esm2020/lib/shared/domain/case-view/service-org-response.model.mjs +2 -0
  11. package/esm2020/lib/shared/pipes/complex/ccd-read-fields-filter.pipe.mjs +4 -3
  12. package/esm2020/lib/shared/services/common-data-service/common-data-service.mjs +7 -1
  13. package/esm2020/lib/shared/services/fields/fields.purger.mjs +16 -6
  14. package/esm2020/lib/shared/services/form/form-value.service.mjs +10 -7
  15. package/esm2020/lib/shared/services/utils/retry/retry.service.mjs +1 -2
  16. package/fesm2015/hmcts-ccd-case-ui-toolkit.mjs +165 -94
  17. package/fesm2015/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
  18. package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs +164 -94
  19. package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
  20. package/lib/shared/commons/constants.d.ts +1 -0
  21. package/lib/shared/commons/constants.d.ts.map +1 -1
  22. package/lib/shared/components/case-editor/case-edit/case-edit.component.d.ts +7 -3
  23. package/lib/shared/components/case-editor/case-edit/case-edit.component.d.ts.map +1 -1
  24. package/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts.map +1 -1
  25. 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
  26. package/lib/shared/components/case-editor/services/event-completion-state-machine.service.d.ts.map +1 -1
  27. package/lib/shared/components/case-viewer/case-event-trigger/case-event-trigger.component.d.ts +5 -2
  28. package/lib/shared/components/case-viewer/case-event-trigger/case-event-trigger.component.d.ts.map +1 -1
  29. package/lib/shared/components/palette/document/write-document-field.component.d.ts.map +1 -1
  30. package/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.d.ts +6 -3
  31. package/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.d.ts.map +1 -1
  32. package/lib/shared/domain/case-view/service-org-response.model.d.ts +14 -0
  33. package/lib/shared/domain/case-view/service-org-response.model.d.ts.map +1 -0
  34. package/lib/shared/pipes/complex/ccd-read-fields-filter.pipe.d.ts.map +1 -1
  35. package/lib/shared/services/common-data-service/common-data-service.d.ts +2 -0
  36. package/lib/shared/services/common-data-service/common-data-service.d.ts.map +1 -1
  37. package/lib/shared/services/fields/fields.purger.d.ts.map +1 -1
  38. package/lib/shared/services/form/form-value.service.d.ts +1 -1
  39. package/lib/shared/services/form/form-value.service.d.ts.map +1 -1
  40. 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';
@@ -4325,6 +4325,7 @@ class Constants {
4325
4325
  }
4326
4326
  Constants.MANDATORY = 'MANDATORY';
4327
4327
  Constants.REGEX_WHITESPACES = '^[^ ]+(?:\\s+[^ ]+)*$';
4328
+ Constants.TASK_COMPLETION_ERROR = 'The associated task for this event failed to complete automatically. Please complete the task manually in the Tasks tab on the case';
4328
4329
  Constants.ɵfac = function Constants_Factory(t) { return new (t || Constants)(); };
4329
4330
  Constants.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: Constants, factory: Constants.ɵfac });
4330
4331
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Constants, [{
@@ -4953,11 +4954,21 @@ class FieldsPurger {
4953
4954
  * @returns A new array with the mapped values
4954
4955
  */
4955
4956
  mapArrayValuesToNull(array) {
4956
- return array.map(element => {
4957
- return typeof element === 'object'
4958
- ? Object.assign({}, ...Object.keys(element).map(k => ({ [k]: null })))
4959
- : null;
4960
- });
4957
+ if (array && array.length > 0) {
4958
+ return array.map(element => {
4959
+ if (element !== undefined && element !== null) {
4960
+ return typeof element === 'object'
4961
+ ? Object.assign({}, ...Object.keys(element).map(k => ({ [k]: null })))
4962
+ : null;
4963
+ }
4964
+ else {
4965
+ return {};
4966
+ }
4967
+ });
4968
+ }
4969
+ else {
4970
+ return array;
4971
+ }
4961
4972
  }
4962
4973
  }
4963
4974
  FieldsPurger.ɵfac = function FieldsPurger_Factory(t) { return new (t || FieldsPurger)(i0.ɵɵinject(FieldsUtils)); };
@@ -5429,7 +5440,7 @@ class FormValueService {
5429
5440
  * @param clearEmpty Whether or not we should clear out empty, optional, complex objects.
5430
5441
  * @param clearNonCase Whether or not we should clear out non-case fields at the top level.
5431
5442
  */
5432
- removeUnnecessaryFields(data, caseFields, clearEmpty = false, clearNonCase = false, fromPreviousPage = false, currentPageCaseFields = []) {
5443
+ removeUnnecessaryFields(data, caseFields, clearEmpty = false, clearNonCase = false, fromPreviousPage = false, currentPageCaseFields = [], isCalledFromSubmit = false) {
5433
5444
  if (data && caseFields && caseFields.length > 0) {
5434
5445
  // check if there is any data at the top level of the form that's not in the caseFields
5435
5446
  if (clearNonCase) {
@@ -5440,10 +5451,13 @@ class FormValueService {
5440
5451
  // Retain anything that is readonly and not a label.
5441
5452
  continue;
5442
5453
  }
5443
- if (field.hidden === true && field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP' && field.id !== 'caseLinks' && !field.retain_hidden_value) {
5454
+ if (field.hidden === true && field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP' && field.id !== 'caseLinks') {
5444
5455
  // Delete anything that is hidden (that is NOT readonly), and that
5445
5456
  // hasn't had its display_context overridden to make it hidden.
5446
- delete data[field.id];
5457
+ // in event submission check for field's retain_hidden_value defore deletion
5458
+ if ((isCalledFromSubmit && !field.retain_hidden_value) || !isCalledFromSubmit) {
5459
+ delete data[field.id];
5460
+ }
5447
5461
  }
5448
5462
  else if (field.field_type) {
5449
5463
  switch (field.field_type.type) {
@@ -5457,7 +5471,7 @@ class FormValueService {
5457
5471
  }
5458
5472
  break;
5459
5473
  case 'Complex':
5460
- this.removeUnnecessaryFields(data[field.id], field.field_type.complex_fields, clearEmpty);
5474
+ this.removeUnnecessaryFields(data[field.id], field.field_type.complex_fields, clearEmpty, false, false, [], isCalledFromSubmit);
5461
5475
  // Also remove any optional complex objects that are completely empty.
5462
5476
  // EUI-4244: Ritesh's fix, passing true instead of clearEmpty.
5463
5477
  if (FormValueService.clearOptionalEmpty(true, data[field.id], field)) {
@@ -5480,8 +5494,8 @@ class FormValueService {
5480
5494
  if (field.field_type.collection_field_type.type === 'Complex') {
5481
5495
  // Iterate through the elements and remove any unnecessary fields within.
5482
5496
  for (const item of collection) {
5483
- this.removeUnnecessaryFields(item, field.field_type.collection_field_type.complex_fields, clearEmpty);
5484
- this.removeUnnecessaryFields(item.value, field.field_type.collection_field_type.complex_fields, false);
5497
+ this.removeUnnecessaryFields(item, field.field_type.collection_field_type.complex_fields, clearEmpty, false, false, [], isCalledFromSubmit);
5498
+ this.removeUnnecessaryFields(item.value, field.field_type.collection_field_type.complex_fields, false, false, false, [], isCalledFromSubmit);
5485
5499
  }
5486
5500
  }
5487
5501
  }
@@ -6725,7 +6739,6 @@ class ArtificialDelayContext {
6725
6739
  this.artificialDelayOn = true;
6726
6740
  this.selectedDelay = this.selectActualDelayTime();
6727
6741
  }
6728
- ;
6729
6742
  switchArtificialDelays(status) {
6730
6743
  this.artificialDelayOn = status;
6731
6744
  this.selectedDelay = this.selectActualDelayTime();
@@ -8049,18 +8062,9 @@ class EventCompletionStateMachineService {
8049
8062
  state.trigger(EventCompletionStates.Final);
8050
8063
  const taskStr = context.sessionStorageService.getItem('taskToComplete');
8051
8064
  if (taskStr) {
8052
- // Task is in session storage
8053
- const task = JSON.parse(taskStr);
8054
- // Task already assigned to current user, just complete task
8055
- context.workAllocationService.completeTask(task.id).subscribe(response => {
8056
- // Emit event can be completed event
8057
- context.component.eventCanBeCompleted.emit(true);
8058
- }, error => {
8059
- // Emit event cannot be completed event
8060
- context.component.eventCanBeCompleted.emit(false);
8061
- context.alertService.error(error.message);
8062
- return throwError(error);
8063
- });
8065
+ context.sessionStorageService.setItem('assignNeeded', 'false');
8066
+ // just set event can be completed
8067
+ context.component.eventCanBeCompleted.emit(true);
8064
8068
  }
8065
8069
  else {
8066
8070
  // Emit event cannot be completed event
@@ -8079,18 +8083,8 @@ class EventCompletionStateMachineService {
8079
8083
  // Get task details
8080
8084
  const taskStr = context.sessionStorageService.getItem('taskToComplete');
8081
8085
  if (taskStr) {
8082
- // Task is in session storage
8083
- const task = JSON.parse(taskStr);
8084
- // Assign and complete task
8085
- context.workAllocationService.assignAndCompleteTask(task.id).subscribe(response => {
8086
- // Emit event can be completed event
8087
- context.component.eventCanBeCompleted.emit(true);
8088
- }, error => {
8089
- // Emit event cannot be completed event
8090
- context.component.eventCanBeCompleted.emit(false);
8091
- context.alertService.error(error.message);
8092
- return throwError(error);
8093
- });
8086
+ context.sessionStorageService.setItem('assignNeeded', 'true');
8087
+ context.component.eventCanBeCompleted.emit(true);
8094
8088
  }
8095
8089
  else {
8096
8090
  // Emit event cannot be completed event
@@ -8436,7 +8430,7 @@ ValidPageListCaseFieldsService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({
8436
8430
  }], function () { return [{ type: FieldsUtils }]; }, null); })();
8437
8431
 
8438
8432
  class CaseEditComponent {
8439
- constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService) {
8433
+ constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService, workAllocationService, alertService) {
8440
8434
  this.fb = fb;
8441
8435
  this.caseNotifier = caseNotifier;
8442
8436
  this.router = router;
@@ -8451,6 +8445,8 @@ class CaseEditComponent {
8451
8445
  this.formErrorService = formErrorService;
8452
8446
  this.loadingService = loadingService;
8453
8447
  this.validPageListCaseFieldsService = validPageListCaseFieldsService;
8448
+ this.workAllocationService = workAllocationService;
8449
+ this.alertService = alertService;
8454
8450
  this.cancelled = new EventEmitter();
8455
8451
  this.submitted = new EventEmitter();
8456
8452
  this.isEventCompletionChecksRequired = false;
@@ -8624,7 +8620,7 @@ class CaseEditComponent {
8624
8620
  const pageListCaseFields = this.validPageListCaseFieldsService.validPageListCaseFields(this.validPageList, eventTrigger.case_fields, form.controls['data'].value);
8625
8621
  // Remove unnecessary case fields which are hidden, only if the submission is *not* for Case Flags
8626
8622
  if (!this.isCaseFlagSubmission) {
8627
- this.formValueService.removeUnnecessaryFields(caseEventData.data, pageListCaseFields, true, true);
8623
+ this.formValueService.removeUnnecessaryFields(caseEventData.data, pageListCaseFields, true, true, false, [], true);
8628
8624
  }
8629
8625
  caseEventData.event_token = eventTrigger.event_token;
8630
8626
  caseEventData.ignore_warning = this.ignoreWarning;
@@ -8737,31 +8733,68 @@ class CaseEditComponent {
8737
8733
  }
8738
8734
  caseSubmit({ form, caseEventData, submit }) {
8739
8735
  const loadingSpinnerToken = this.loadingService.register();
8740
- submit(caseEventData)
8741
- .pipe(finalize(() => {
8736
+ // keep the initial event response to finalise process after task completion
8737
+ let eventResponse;
8738
+ submit(caseEventData).pipe(switchMap((response) => {
8739
+ eventResponse = response;
8740
+ return this.postCompleteTaskIfRequired();
8741
+ }), finalize(() => {
8742
+ this.sessionStorageService.removeItem('taskToComplete');
8743
+ this.sessionStorageService.removeItem('assignNeeded');
8742
8744
  this.loadingService.unregister(loadingSpinnerToken);
8743
8745
  }))
8744
- .subscribe(response => {
8745
- this.caseNotifier.cachedCaseView = null;
8746
- this.sessionStorageService.removeItem('eventUrl');
8747
- const confirmation = this.buildConfirmation(response);
8748
- if (confirmation && (confirmation.getHeader() || confirmation.getBody())) {
8749
- this.confirm(confirmation);
8746
+ .subscribe(() => {
8747
+ this.finishEventCompletionLogic(eventResponse);
8748
+ /* NOTE: Uncomment this to test event confirmation page display of error
8749
+ Replicates lines 458-459
8750
+ this.alertService.setPreserveAlerts(true);
8751
+ this.alertService.error({phrase: 'The associated task for this event failed to complete automatically. Please complete the task manually in the Tasks tab on the case'}); */
8752
+ }, error => {
8753
+ if (!eventResponse) {
8754
+ // event submission error
8755
+ this.error = error;
8756
+ this.callbackErrorsSubject.next(error);
8757
+ /* istanbul ignore else */
8758
+ if (this.error.details) {
8759
+ this.formErrorService
8760
+ .mapFieldErrors(this.error.details.field_errors, form.controls['data'], 'validation');
8761
+ }
8762
+ this.isSubmitting = false;
8750
8763
  }
8751
8764
  else {
8752
- this.emitSubmitted(response);
8753
- }
8754
- }, error => {
8755
- this.error = error;
8756
- this.callbackErrorsSubject.next(error);
8757
- /* istanbul ignore else */
8758
- if (this.error.details) {
8759
- this.formErrorService
8760
- .mapFieldErrors(this.error.details.field_errors, form.controls['data'], 'validation');
8765
+ // task assignment/completion error - handled within workallocation service
8766
+ // could set task to be deleted (or completed later)?
8767
+ this.finishEventCompletionLogic(eventResponse);
8768
+ // below allows error to be shown on navigation to confirmation page
8769
+ this.alertService.setPreserveAlerts(true);
8770
+ this.alertService.error({ phrase: Constants.TASK_COMPLETION_ERROR });
8761
8771
  }
8762
- this.isSubmitting = false;
8763
8772
  });
8764
8773
  }
8774
+ postCompleteTaskIfRequired() {
8775
+ const taskStr = this.sessionStorageService.getItem('taskToComplete');
8776
+ const assignNeeded = this.sessionStorageService.getItem('assignNeeded') === 'true';
8777
+ if (taskStr && assignNeeded) {
8778
+ const task = JSON.parse(taskStr);
8779
+ return this.workAllocationService.assignAndCompleteTask(task.id);
8780
+ }
8781
+ else if (taskStr) {
8782
+ const task = JSON.parse(taskStr);
8783
+ return this.workAllocationService.completeTask(task.id);
8784
+ }
8785
+ return of(true);
8786
+ }
8787
+ finishEventCompletionLogic(eventResponse) {
8788
+ this.caseNotifier.cachedCaseView = null;
8789
+ this.sessionStorageService.removeItem('eventUrl');
8790
+ const confirmation = this.buildConfirmation(eventResponse);
8791
+ if (confirmation && (confirmation.getHeader() || confirmation.getBody())) {
8792
+ this.confirm(confirmation);
8793
+ }
8794
+ else {
8795
+ this.emitSubmitted(eventResponse);
8796
+ }
8797
+ }
8765
8798
  buildConfirmation(response) {
8766
8799
  if (response['after_submit_callback_response']) {
8767
8800
  return new Confirmation(response['id'], response['callback_response_status'], response['after_submit_callback_response']['confirmation_header'], response['after_submit_callback_response']['confirmation_body']);
@@ -8790,14 +8823,14 @@ class CaseEditComponent {
8790
8823
  }
8791
8824
  CaseEditComponent.ORIGIN_QUERY_PARAM = 'origin';
8792
8825
  CaseEditComponent.ALERT_MESSAGE = 'Page is being refreshed so you will be redirected to the first page of this event.';
8793
- 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)); };
8826
+ 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), i0.ɵɵdirectiveInject(AlertService)); };
8794
8827
  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) {
8795
8828
  i0.ɵɵelement(0, "router-outlet");
8796
8829
  } }, 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%}"] });
8797
8830
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseEditComponent, [{
8798
8831
  type: Component,
8799
8832
  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"] }]
8800
- }], 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: [{
8833
+ }], 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 }, { type: AlertService }]; }, { eventTrigger: [{
8801
8834
  type: Input
8802
8835
  }], submit: [{
8803
8836
  type: Input
@@ -9564,6 +9597,7 @@ class CaseEditPageComponent {
9564
9597
  }
9565
9598
  submit() {
9566
9599
  this.caseEditDataService.clearFormValidationErrors();
9600
+ console.log('Page submit event fired!');
9567
9601
  if (this.currentPageIsNotValid()) {
9568
9602
  // The generateErrorMessage method filters out the hidden fields.
9569
9603
  // The error message for LinkedCases journey will never get displayed because the
@@ -9577,6 +9611,7 @@ class CaseEditPageComponent {
9577
9611
  }
9578
9612
  }
9579
9613
  if (!this.caseEdit.isSubmitting && !this.currentPageIsNotValid()) {
9614
+ console.log('Case Edit Error', this.caseEdit.error);
9580
9615
  if (this.caseEdit.validPageList.findIndex(page => page.id === this.currentPage.id) === -1) {
9581
9616
  this.caseEdit.validPageList.push(this.currentPage);
9582
9617
  }
@@ -9766,6 +9801,7 @@ class CaseEditPageComponent {
9766
9801
  this.formErrorService
9767
9802
  .mapFieldErrors(this.caseEdit.error.details.field_errors, this.editForm?.controls?.['data'], 'validation');
9768
9803
  }
9804
+ console.log('handleError ', error);
9769
9805
  }
9770
9806
  resetErrors() {
9771
9807
  this.caseEdit.error = null;
@@ -12697,7 +12733,19 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
12697
12733
  if (0 === error.status || 502 === error.status) {
12698
12734
  return WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE;
12699
12735
  }
12700
- return error.error;
12736
+ let errorMsg = 'Error uploading file';
12737
+ if (error?.error) {
12738
+ const fullError = error.error;
12739
+ const start = fullError.indexOf('{');
12740
+ if (start >= 0) {
12741
+ const json = fullError.substring(start, fullError.length - 1).split('<EOL>').join('');
12742
+ const obj = JSON.parse(json);
12743
+ if (obj?.error) {
12744
+ errorMsg = obj.error;
12745
+ }
12746
+ }
12747
+ }
12748
+ return errorMsg;
12701
12749
  }
12702
12750
  buildDocumentUploadData(selectedFile) {
12703
12751
  const documentUpload = new FormData();
@@ -15785,6 +15833,12 @@ class CommonDataService {
15785
15833
  }
15786
15834
  return of(null);
15787
15835
  }
15836
+ getServiceOrgData(url) {
15837
+ if (url) {
15838
+ return this.http.get(url, { observe: 'body' });
15839
+ }
15840
+ return of(null);
15841
+ }
15788
15842
  }
15789
15843
  CommonDataService.ɵfac = function CommonDataService_Factory(t) { return new (t || CommonDataService)(i0.ɵɵinject(i1$3.HttpClient)); };
15790
15844
  CommonDataService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CommonDataService, factory: CommonDataService.ɵfac });
@@ -15996,6 +16050,7 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
15996
16050
  this.linkedCasesPages = LinkedCasesPages;
15997
16051
  this.linkedCasesEventTriggers = LinkedCasesEventTriggers;
15998
16052
  this.linkedCases = [];
16053
+ this.subscriptions = new Subscription();
15999
16054
  }
16000
16055
  ngOnInit() {
16001
16056
  // This is required to enable Continue button validation
@@ -16004,17 +16059,17 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
16004
16059
  // Clear validation errors
16005
16060
  this.caseEditDataService.clearFormValidationErrors();
16006
16061
  // Get linked case reasons from ref data
16007
- this.getLinkedCaseReasons();
16008
16062
  this.linkedCasesService.editMode = false;
16009
- this.caseEditDataService.caseDetails$.subscribe({
16010
- next: caseDetails => this.initialiseCaseDetails(caseDetails)
16011
- });
16012
- this.caseEditDataService.caseEventTriggerName$.subscribe({
16063
+ this.subscriptions.add(this.caseEditDataService.caseDetails$.subscribe({
16064
+ next: caseDetails => { this.initialiseCaseDetails(caseDetails); }
16065
+ }));
16066
+ this.getOrgService();
16067
+ this.subscriptions.add(this.caseEditDataService.caseEventTriggerName$.subscribe({
16013
16068
  next: name => this.linkedCasesService.isLinkedCasesEventTrigger = (name === LinkedCasesEventTriggers.LINK_CASES)
16014
- });
16015
- this.caseEditDataService.caseEditForm$.subscribe({
16069
+ }));
16070
+ this.subscriptions.add(this.caseEditDataService.caseEditForm$.subscribe({
16016
16071
  next: editForm => this.caseEditForm = editForm
16017
- });
16072
+ }));
16018
16073
  }
16019
16074
  initialiseCaseDetails(caseDetails) {
16020
16075
  if (caseDetails) {
@@ -16050,18 +16105,26 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
16050
16105
  }
16051
16106
  }
16052
16107
  }
16053
- getLinkedCaseReasons() {
16054
- const reasonCodeAPIurl = `${this.appConfig.getRDCommonDataApiUrl()}/lov/categories/CaseLinkingReasonCode`;
16108
+ getLinkedCaseReasons(serviceId) {
16109
+ const reasonCodeAPIurl = `${this.appConfig.getRDCommonDataApiUrl()}/lov/categories/CaseLinkingReasonCode?serviceId=${serviceId}`;
16055
16110
  this.commonDataService.getRefData(reasonCodeAPIurl).subscribe({
16056
16111
  next: reasons => {
16057
16112
  // Sort in ascending order
16058
16113
  const linkCaseReasons = reasons.list_of_values.sort((a, b) => (a.value_en > b.value_en) ? 1 : -1);
16059
- // Move Other option to the end of the list
16060
16114
  this.linkedCasesService.linkCaseReasons = linkCaseReasons?.filter(reason => reason.value_en !== 'Other');
16115
+ // Move Other option to the end of the list
16061
16116
  this.linkedCasesService.linkCaseReasons.push(linkCaseReasons?.find(reason => reason.value_en === 'Other'));
16062
16117
  }
16063
16118
  });
16064
16119
  }
16120
+ getOrgService() {
16121
+ const servicesApiUrl = `refdata/location/orgServices?ccdCaseType=${this.caseDetails?.case_type?.id}`;
16122
+ this.commonDataService.getServiceOrgData(servicesApiUrl).subscribe(result => {
16123
+ result.forEach(ids => {
16124
+ this.getLinkedCaseReasons(ids.service_id);
16125
+ });
16126
+ });
16127
+ }
16065
16128
  proceedToNextPage() {
16066
16129
  if (this.isAtFinalPage()) {
16067
16130
  // Continue button event must be allowed in final page
@@ -16116,6 +16179,9 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
16116
16179
  : LinkedCasesPages.NO_LINKED_CASES;
16117
16180
  });
16118
16181
  }
16182
+ ngOnDestroy() {
16183
+ this.subscriptions.unsubscribe();
16184
+ }
16119
16185
  }
16120
16186
  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)); };
16121
16187
  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) {
@@ -20770,10 +20836,10 @@ WriteDateFieldComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Wri
20770
20836
 
20771
20837
  const CUSTOM_MOMENT_FORMATS = {
20772
20838
  parse: {
20773
- dateInput: 'YYYY MM DD HH:mm:ss'
20839
+ dateInput: 'DD-MM-YYYY HH:mm:ss'
20774
20840
  },
20775
20841
  display: {
20776
- dateInput: 'YYYY MM DD HH:mm:ss',
20842
+ dateInput: 'DD-MM-YYYY HH:mm:ss',
20777
20843
  monthYearLabel: 'MMMM YYYY',
20778
20844
  dateA11yLabel: 'EEE/MMM/YYYY',
20779
20845
  monthYearA11yLabel: 'MMMM YYYY',
@@ -21901,8 +21967,9 @@ class ReadFieldsFilterPipe {
21901
21967
  return isNotEmpty;
21902
21968
  }
21903
21969
  static isEmpty(value) {
21904
- return ReadFieldsFilterPipe.EMPTY_VALUES.indexOf(value) !== -1
21905
- || value.length === 0;
21970
+ const fieldValue = value?.hasOwnProperty('list_items') && value?.hasOwnProperty('value') ? value.value : value;
21971
+ return ReadFieldsFilterPipe.EMPTY_VALUES.indexOf(fieldValue) !== -1
21972
+ || fieldValue.length === 0;
21906
21973
  }
21907
21974
  static isCompound(field) {
21908
21975
  return ReadFieldsFilterPipe.NESTED_TYPES[field.field_type.type];
@@ -23698,18 +23765,9 @@ class CaseEventCompletionTaskReassignedComponent {
23698
23765
  // Get task details
23699
23766
  const taskStr = this.sessionStorageService.getItem('taskToComplete');
23700
23767
  if (taskStr) {
23701
- // Task is in session storage
23702
- const task = JSON.parse(taskStr);
23703
- // Assign and complete task
23704
- this.subscription = this.workAllocationService.assignAndCompleteTask(task.id).subscribe(response => {
23705
- // Emit event can be completed event
23706
- this.parentComponent.eventCanBeCompleted.emit(true);
23707
- }, error => {
23708
- // Emit event cannot be completed event
23709
- this.parentComponent.eventCanBeCompleted.emit(false);
23710
- this.alertService.error(error.message);
23711
- return throwError(error);
23712
- });
23768
+ this.sessionStorageService.setItem('assignNeeded', 'true');
23769
+ // set event can be completed to true
23770
+ this.parentComponent.eventCanBeCompleted.emit(true);
23713
23771
  }
23714
23772
  else {
23715
23773
  // Emit event cannot be completed event
@@ -25994,7 +26052,7 @@ function CaseEventTriggerComponent_div_0_Template(rf, ctx) { if (rf & 1) {
25994
26052
  i0.ɵɵproperty("caseDetails", ctx_r0.caseDetails)("submit", ctx_r0.submit())("validate", ctx_r0.validate())("eventTrigger", ctx_r0.eventTrigger);
25995
26053
  } }
25996
26054
  class CaseEventTriggerComponent {
25997
- constructor(ngZone, casesService, caseNotifier, router, alertService, route, caseReferencePipe, activityPollingService) {
26055
+ constructor(ngZone, casesService, caseNotifier, router, alertService, route, caseReferencePipe, activityPollingService, sessionStorageService) {
25998
26056
  this.ngZone = ngZone;
25999
26057
  this.casesService = casesService;
26000
26058
  this.caseNotifier = caseNotifier;
@@ -26003,6 +26061,7 @@ class CaseEventTriggerComponent {
26003
26061
  this.route = route;
26004
26062
  this.caseReferencePipe = caseReferencePipe;
26005
26063
  this.activityPollingService = activityPollingService;
26064
+ this.sessionStorageService = sessionStorageService;
26006
26065
  this.BANNER = DisplayMode.BANNER;
26007
26066
  }
26008
26067
  ngOnInit() {
@@ -26064,21 +26123,30 @@ class CaseEventTriggerComponent {
26064
26123
  }
26065
26124
  submitted(event) {
26066
26125
  const eventStatus = event['status'];
26126
+ const task = this.sessionStorageService.getItem('taskToComplete');
26067
26127
  this.router
26068
26128
  .navigate([this.parentUrl])
26069
26129
  .then(() => {
26070
26130
  const caseReference = this.caseReferencePipe.transform(this.caseDetails.case_id.toString());
26071
26131
  const replacements = { CASEREFERENCE: caseReference, NAME: this.eventTrigger.name };
26072
- if (EventStatusService.isIncomplete(eventStatus)) {
26132
+ this.alertService.setPreserveAlerts(true);
26133
+ if (task) {
26134
+ // if task still present in session storage, we know that the task has not been correctly completed
26135
+ this.alertService.warning({
26136
+ phrase: CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE + '. ' + Constants.TASK_COMPLETION_ERROR,
26137
+ replacements
26138
+ });
26139
+ this.sessionStorageService.removeItem('taskToComplete');
26140
+ }
26141
+ else if (EventStatusService.isIncomplete(eventStatus)) {
26073
26142
  this.alertService.warning({
26074
- phrase: `Case #%CASEREFERENCE% has been updated with event: %NAME%
26075
- but the callback service cannot be completed`,
26143
+ phrase: CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE + CaseEventTriggerComponent.CALLBACK_FAILED_MESSAGE,
26076
26144
  replacements
26077
26145
  });
26078
26146
  }
26079
26147
  else {
26080
26148
  this.alertService.success({
26081
- phrase: 'Case #%CASEREFERENCE% has been updated with event: %NAME%',
26149
+ phrase: CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE,
26082
26150
  replacements,
26083
26151
  preserve: true
26084
26152
  });
@@ -26097,7 +26165,9 @@ class CaseEventTriggerComponent {
26097
26165
  return !!(this.eventTrigger && this.caseDetails);
26098
26166
  }
26099
26167
  }
26100
- CaseEventTriggerComponent.ɵfac = function CaseEventTriggerComponent_Factory(t) { return new (t || CaseEventTriggerComponent)(i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(CasesService), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(AlertService), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute), i0.ɵɵdirectiveInject(CaseReferencePipe), i0.ɵɵdirectiveInject(ActivityPollingService)); };
26168
+ CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE = `Case #%CASEREFERENCE% has been updated with event: %NAME%`;
26169
+ CaseEventTriggerComponent.CALLBACK_FAILED_MESSAGE = ' but the callback service cannot be completed';
26170
+ CaseEventTriggerComponent.ɵfac = function CaseEventTriggerComponent_Factory(t) { return new (t || CaseEventTriggerComponent)(i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(CasesService), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(AlertService), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute), i0.ɵɵdirectiveInject(CaseReferencePipe), i0.ɵɵdirectiveInject(ActivityPollingService), i0.ɵɵdirectiveInject(SessionStorageService)); };
26101
26171
  CaseEventTriggerComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaseEventTriggerComponent, selectors: [["ccd-case-event-trigger"]], decls: 1, vars: 1, consts: [["class", "screen-990", 4, "ngIf"], [1, "screen-990"], [3, "caseId", "displayMode"], [3, "caseDetails", "submit", "validate", "eventTrigger", "cancelled", "submitted"]], template: function CaseEventTriggerComponent_Template(rf, ctx) { if (rf & 1) {
26102
26172
  i0.ɵɵtemplate(0, CaseEventTriggerComponent_div_0_Template, 3, 6, "div", 0);
26103
26173
  } if (rf & 2) {
@@ -26106,7 +26176,7 @@ CaseEventTriggerComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: C
26106
26176
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseEventTriggerComponent, [{
26107
26177
  type: Component,
26108
26178
  args: [{ selector: 'ccd-case-event-trigger', template: "<div *ngIf=\"isDataLoaded()\" class=\"screen-990\">\n <ccd-activity [caseId]=\"caseDetails.case_id\" [displayMode]=\"BANNER\"></ccd-activity>\n <ccd-case-edit [caseDetails]=\"caseDetails\"\n [submit]=\"submit()\"\n [validate]=\"validate()\"\n [eventTrigger]=\"eventTrigger\"\n (cancelled)=\"cancel()\"\n (submitted)=\"submitted($event)\"></ccd-case-edit>\n</div>\n" }]
26109
- }], function () { return [{ type: i0.NgZone }, { type: CasesService }, { type: CaseNotifier }, { type: i1$2.Router }, { type: AlertService }, { type: i1$2.ActivatedRoute }, { type: CaseReferencePipe }, { type: ActivityPollingService }]; }, null); })();
26179
+ }], function () { return [{ type: i0.NgZone }, { type: CasesService }, { type: CaseNotifier }, { type: i1$2.Router }, { type: AlertService }, { type: i1$2.ActivatedRoute }, { type: CaseReferencePipe }, { type: ActivityPollingService }, { type: SessionStorageService }]; }, null); })();
26110
26180
 
26111
26181
  function CaseViewComponent_div_0_Template(rf, ctx) { if (rf & 1) {
26112
26182
  i0.ɵɵelementStart(0, "div");