@hmcts/ccd-case-ui-toolkit 7.0.12 → 7.0.13-address-validation-fix

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 (28) hide show
  1. package/esm2020/lib/shared/commons/address-validation-constants.mjs +13 -0
  2. package/esm2020/lib/shared/commons/constants.mjs +2 -1
  3. package/esm2020/lib/shared/components/case-editor/case-edit/case-edit.component.mjs +12 -6
  4. package/esm2020/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.mjs +15 -6
  5. package/esm2020/lib/shared/components/case-viewer/case-event-trigger/case-event-trigger.component.mjs +22 -9
  6. package/esm2020/lib/shared/components/palette/address/write-address-field.component.mjs +57 -20
  7. package/esm2020/lib/shared/components/palette/case-flag/write-case-flag-field.component.mjs +30 -26
  8. package/esm2020/lib/shared/services/addresses/addresses.service.mjs +9 -1
  9. package/fesm2015/hmcts-ccd-case-ui-toolkit.mjs +151 -61
  10. package/fesm2015/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
  11. package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs +144 -59
  12. package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
  13. package/lib/shared/commons/address-validation-constants.d.ts +7 -0
  14. package/lib/shared/commons/address-validation-constants.d.ts.map +1 -0
  15. package/lib/shared/commons/constants.d.ts +1 -0
  16. package/lib/shared/commons/constants.d.ts.map +1 -1
  17. package/lib/shared/components/case-editor/case-edit/case-edit.component.d.ts +3 -2
  18. package/lib/shared/components/case-editor/case-edit/case-edit.component.d.ts.map +1 -1
  19. package/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts +3 -2
  20. package/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts.map +1 -1
  21. package/lib/shared/components/case-viewer/case-event-trigger/case-event-trigger.component.d.ts +5 -2
  22. package/lib/shared/components/case-viewer/case-event-trigger/case-event-trigger.component.d.ts.map +1 -1
  23. package/lib/shared/components/palette/address/write-address-field.component.d.ts +5 -0
  24. package/lib/shared/components/palette/address/write-address-field.component.d.ts.map +1 -1
  25. package/lib/shared/components/palette/case-flag/write-case-flag-field.component.d.ts.map +1 -1
  26. package/lib/shared/services/addresses/addresses.service.d.ts +3 -0
  27. package/lib/shared/services/addresses/addresses.service.d.ts.map +1 -1
  28. package/package.json +1 -1
@@ -8,7 +8,7 @@ import * as i1$1 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, ReactiveFormsModule, FormsModule } from '@angular/forms';
11
- import { throwError, Subject, EMPTY, Observable, of, BehaviorSubject, timer, fromEvent, forkJoin, Subscription, combineLatest } from 'rxjs';
11
+ import { throwError, Subject, EMPTY, BehaviorSubject, Observable, of, timer, fromEvent, forkJoin, Subscription, combineLatest } from 'rxjs';
12
12
  import * as i1$2 from '@angular/common/http';
13
13
  import { HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http';
14
14
  import { catchError, map, switchMap, debounceTime, publish, refCount, delay, distinctUntilChanged, finalize, timeout, mergeMap, retryWhen, tap, delayWhen, publishReplay, take, first, takeUntil, filter } from 'rxjs/operators';
@@ -4529,6 +4529,7 @@ class Constants {
4529
4529
  }
4530
4530
  Constants.MANDATORY = 'MANDATORY';
4531
4531
  Constants.REGEX_WHITESPACES = '^[^ ]+(?:\\s+[^ ]+)*$';
4532
+ 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';
4532
4533
  Constants.ɵfac = function Constants_Factory(t) { return new (t || Constants)(); };
4533
4534
  Constants.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: Constants, factory: Constants.ɵfac });
4534
4535
  (function () {
@@ -6275,6 +6276,7 @@ class AddressesService {
6275
6276
  constructor(http, appConfig) {
6276
6277
  this.http = http;
6277
6278
  this.appConfig = appConfig;
6279
+ this.mandatoryError = new BehaviorSubject(false);
6278
6280
  }
6279
6281
  getAddressesForPostcode(postcode) {
6280
6282
  return this.http
@@ -6283,6 +6285,12 @@ class AddressesService {
6283
6285
  .pipe(map(res => res.results))
6284
6286
  .pipe(map(output => output.map(addresses => this.format(new AddressParser().parse(addresses[AddressType.DPA])))));
6285
6287
  }
6288
+ getMandatoryError() {
6289
+ return this.mandatoryError.asObservable();
6290
+ }
6291
+ setMandatoryError(value) {
6292
+ this.mandatoryError.next(value);
6293
+ }
6286
6294
  format(addressModel) {
6287
6295
  return this.formatAddressLines(this.shiftAddressLinesUp(addressModel));
6288
6296
  }
@@ -8954,7 +8962,7 @@ ValidPageListCaseFieldsService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({
8954
8962
  })();
8955
8963
 
8956
8964
  class CaseEditComponent {
8957
- constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService, workAllocationService) {
8965
+ constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService, workAllocationService, alertService) {
8958
8966
  this.fb = fb;
8959
8967
  this.caseNotifier = caseNotifier;
8960
8968
  this.router = router;
@@ -8970,6 +8978,7 @@ class CaseEditComponent {
8970
8978
  this.loadingService = loadingService;
8971
8979
  this.validPageListCaseFieldsService = validPageListCaseFieldsService;
8972
8980
  this.workAllocationService = workAllocationService;
8981
+ this.alertService = alertService;
8973
8982
  this.cancelled = new EventEmitter();
8974
8983
  this.submitted = new EventEmitter();
8975
8984
  this.isEventCompletionChecksRequired = false;
@@ -9258,6 +9267,7 @@ class CaseEditComponent {
9258
9267
  const loadingSpinnerToken = this.loadingService.register();
9259
9268
  // keep the initial event response to finalise process after task completion
9260
9269
  let eventResponse;
9270
+ this.sessionStorageService.setItem('taskCompletionError', 'false');
9261
9271
  submit(caseEventData).pipe(switchMap((response) => {
9262
9272
  eventResponse = response;
9263
9273
  return this.postCompleteTaskIfRequired();
@@ -9279,10 +9289,13 @@ class CaseEditComponent {
9279
9289
  this.isSubmitting = false;
9280
9290
  }
9281
9291
  else {
9292
+ this.sessionStorageService.setItem('taskCompletionError', 'true');
9282
9293
  // task assignment/completion error - handled within workallocation service
9283
9294
  // could set task to be deleted (or completed later)?
9284
- // note: think error messages only shown if user is caseworker - might reqauire changing
9285
9295
  this.finishEventCompletionLogic(eventResponse);
9296
+ // below allows error to be shown on navigation to confirmation page
9297
+ this.alertService.setPreserveAlerts(true);
9298
+ this.alertService.error({ phrase: Constants.TASK_COMPLETION_ERROR });
9286
9299
  }
9287
9300
  });
9288
9301
  }
@@ -9338,7 +9351,7 @@ class CaseEditComponent {
9338
9351
  }
9339
9352
  CaseEditComponent.ORIGIN_QUERY_PARAM = 'origin';
9340
9353
  CaseEditComponent.ALERT_MESSAGE = 'Page is being refreshed so you will be redirected to the first page of this event.';
9341
- CaseEditComponent.ɵfac = function CaseEditComponent_Factory(t) { return new (t || CaseEditComponent)(i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$1.Router), i0.ɵɵdirectiveInject(i1$1.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)); };
9354
+ CaseEditComponent.ɵfac = function CaseEditComponent_Factory(t) { return new (t || CaseEditComponent)(i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$1.Router), i0.ɵɵdirectiveInject(i1$1.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)); };
9342
9355
  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) {
9343
9356
  if (rf & 1) {
9344
9357
  i0.ɵɵelement(0, "router-outlet");
@@ -9348,7 +9361,7 @@ CaseEditComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaseEditC
9348
9361
  (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseEditComponent, [{
9349
9362
  type: Component,
9350
9363
  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%}.no-bottom-border{border-bottom:none}.case-field-change{width:5%}\n"] }]
9351
- }], function () { return [{ type: i3.FormBuilder }, { type: CaseNotifier }, { type: i1$1.Router }, { type: i1$1.ActivatedRoute }, { type: FieldsUtils }, { type: FieldsPurger }, { type: ConditionalShowRegistrarService }, { type: WizardFactoryService }, { type: SessionStorageService }, { type: WindowService }, { type: FormValueService }, { type: FormErrorService }, { type: LoadingService }, { type: ValidPageListCaseFieldsService }, { type: WorkAllocationService }]; }, { eventTrigger: [{
9364
+ }], function () { return [{ type: i3.FormBuilder }, { type: CaseNotifier }, { type: i1$1.Router }, { type: i1$1.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: [{
9352
9365
  type: Input
9353
9366
  }], submit: [{
9354
9367
  type: Input
@@ -10000,7 +10013,7 @@ function CaseEditPageComponent_ccd_case_event_completion_11_Template(rf, ctx) {
10000
10013
  }
10001
10014
  }
10002
10015
  class CaseEditPageComponent {
10003
- constructor(caseEdit, route, formValueService, formErrorService, cdRef, pageValidationService, dialog, caseFieldService, caseEditDataService, loadingService, validPageListCaseFieldsService) {
10016
+ constructor(caseEdit, route, formValueService, formErrorService, cdRef, pageValidationService, dialog, caseFieldService, caseEditDataService, loadingService, validPageListCaseFieldsService, addressService) {
10004
10017
  this.caseEdit = caseEdit;
10005
10018
  this.route = route;
10006
10019
  this.formValueService = formValueService;
@@ -10012,6 +10025,7 @@ class CaseEditPageComponent {
10012
10025
  this.caseEditDataService = caseEditDataService;
10013
10026
  this.loadingService = loadingService;
10014
10027
  this.validPageListCaseFieldsService = validPageListCaseFieldsService;
10028
+ this.addressService = addressService;
10015
10029
  this.triggerTextStart = CaseEditPageComponent.TRIGGER_TEXT_START;
10016
10030
  this.triggerTextIgnoreWarnings = CaseEditPageComponent.TRIGGER_TEXT_CONTINUE;
10017
10031
  this.formValuesChanged = false;
@@ -10136,7 +10150,14 @@ class CaseEditPageComponent {
10136
10150
  }
10137
10151
  }
10138
10152
  if (fieldElement.hasError('required')) {
10139
- this.caseEditDataService.addFormValidationError({ id, message: `%FIELDLABEL% is required`, label });
10153
+ if (casefield.id === 'AddressLine1') {
10154
+ // EUI-1067 - Display more relevant error message to user and correctly navigate to the field
10155
+ this.addressService.setMandatoryError(true);
10156
+ this.caseEditDataService.addFormValidationError({ id: `${path}_${path}`, message: `An address is required` });
10157
+ }
10158
+ else {
10159
+ this.caseEditDataService.addFormValidationError({ id, message: `%FIELDLABEL% is required`, label });
10160
+ }
10140
10161
  fieldElement.markAsDirty();
10141
10162
  // For the JudicialUser field type, an error needs to be set on the component so that an error message
10142
10163
  // can be displayed at field level
@@ -10211,6 +10232,7 @@ class CaseEditPageComponent {
10211
10232
  }
10212
10233
  }
10213
10234
  if (!this.caseEdit.isSubmitting && !this.currentPageIsNotValid()) {
10235
+ this.addressService.setMandatoryError(false);
10214
10236
  console.log('Case Edit Error', this.caseEdit.error);
10215
10237
  if (this.caseEdit.validPageList.findIndex(page => page.id === this.currentPage.id) === -1) {
10216
10238
  this.caseEdit.validPageList.push(this.currentPage);
@@ -10506,7 +10528,7 @@ CaseEditPageComponent.RESUMED_FORM_SAVE = 'RESUMED_FORM_SAVE';
10506
10528
  CaseEditPageComponent.TRIGGER_TEXT_START = 'Continue';
10507
10529
  CaseEditPageComponent.TRIGGER_TEXT_SAVE = 'Save and continue';
10508
10530
  CaseEditPageComponent.TRIGGER_TEXT_CONTINUE = 'Ignore Warning and Continue';
10509
- CaseEditPageComponent.ɵfac = function CaseEditPageComponent_Factory(t) { return new (t || CaseEditPageComponent)(i0.ɵɵdirectiveInject(CaseEditComponent), i0.ɵɵdirectiveInject(i1$1.ActivatedRoute), i0.ɵɵdirectiveInject(FormValueService), i0.ɵɵdirectiveInject(FormErrorService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(PageValidationService), i0.ɵɵdirectiveInject(i1$3.MatLegacyDialog), i0.ɵɵdirectiveInject(CaseFieldService), i0.ɵɵdirectiveInject(CaseEditDataService), i0.ɵɵdirectiveInject(LoadingService), i0.ɵɵdirectiveInject(ValidPageListCaseFieldsService)); };
10531
+ CaseEditPageComponent.ɵfac = function CaseEditPageComponent_Factory(t) { return new (t || CaseEditPageComponent)(i0.ɵɵdirectiveInject(CaseEditComponent), i0.ɵɵdirectiveInject(i1$1.ActivatedRoute), i0.ɵɵdirectiveInject(FormValueService), i0.ɵɵdirectiveInject(FormErrorService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(PageValidationService), i0.ɵɵdirectiveInject(i1$3.MatLegacyDialog), i0.ɵɵdirectiveInject(CaseFieldService), i0.ɵɵdirectiveInject(CaseEditDataService), i0.ɵɵdirectiveInject(LoadingService), i0.ɵɵdirectiveInject(ValidPageListCaseFieldsService), i0.ɵɵdirectiveInject(AddressesService)); };
10510
10532
  CaseEditPageComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaseEditPageComponent, selectors: [["ccd-case-edit-page"]], decls: 12, vars: 11, consts: [[4, "ngIf"], [4, "ngIf", "ngIfThen", "ngIfElse"], ["titleBlock", ""], ["idBlock", ""], ["class", "govuk-error-summary", "aria-labelledby", "error-summary-title", "role", "alert", "tabindex", "-1", "data-module", "govuk-error-summary", 4, "ngIf"], [3, "error"], [3, "triggerTextContinue", "triggerTextIgnore", "callbackErrorsSubject", "callbackErrorsContext"], [1, "width-50"], ["class", "form", 3, "formGroup", "submit", 4, "ngIf"], [3, "eventCompletionParams", "eventCanBeCompleted", 4, "ngIf"], ["class", "govuk-heading-l", 4, "ngIf"], [1, "govuk-heading-l"], [1, "govuk-caption-l"], [3, "content"], ["class", "heading-h2", 4, "ngIf"], [1, "heading-h2"], ["aria-labelledby", "error-summary-title", "role", "alert", "tabindex", "-1", "data-module", "govuk-error-summary", 1, "govuk-error-summary"], ["id", "error-summary-title", 1, "govuk-error-summary__title"], ["class", "govuk-error-summary__body", 4, "ngFor", "ngForOf"], [1, "govuk-error-summary__body"], [1, "govuk-list", "govuk-error-summary__list"], [1, "validation-error", 3, "click"], [1, "form", 3, "formGroup", "submit"], ["id", "fieldset-case-data"], [2, "display", "none"], ["id", "caseEditForm", 3, "fields", "formGroup", "caseFields", "pageChangeSubject", "valuesChanged", 4, "ngIf"], ["class", "grid-row", 4, "ngIf"], [1, "form-group", "form-group-related"], ["type", "button", 1, "button", "button-secondary", 3, "disabled", "click"], ["type", "submit", 1, "button", 3, "disabled"], [1, "cancel"], ["href", "javascript:void(0)", 3, "click"], ["id", "caseEditForm", 3, "fields", "formGroup", "caseFields", "pageChangeSubject", "valuesChanged"], [1, "grid-row"], [1, "column-two-thirds", "rightBorderSeparator"], ["id", "caseEditForm1", 3, "fields", "formGroup", "caseFields"], [1, "column-one-third"], ["id", "caseEditForm2", 3, "fields", "formGroup", "caseFields"], [3, "eventCompletionParams", "eventCanBeCompleted"]], template: function CaseEditPageComponent_Template(rf, ctx) {
10511
10533
  if (rf & 1) {
10512
10534
  i0.ɵɵtemplate(0, CaseEditPageComponent_ng_container_0_Template, 3, 2, "ng-container", 0);
@@ -10545,7 +10567,7 @@ CaseEditPageComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaseE
10545
10567
  (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseEditPageComponent, [{
10546
10568
  type: Component,
10547
10569
  args: [{ selector: 'ccd-case-edit-page', template: "<ng-container *ngIf=\"currentPage\">\n <h1 *ngIf=\"!currentPage.label\" class=\"govuk-heading-l\">{{eventTrigger.name | rpxTranslate}}</h1>\n <ng-container *ngIf=\"currentPage.label\">\n <span class=\"govuk-caption-l\">{{ eventTrigger.name | rpxTranslate}}</span>\n <h1 class=\"govuk-heading-l\">{{currentPage.label | rpxTranslate}}</h1>\n </ng-container>\n</ng-container>\n\n<!--Case ID or Title -->\n<div *ngIf=\"getCaseTitle(); then titleBlock; else idBlock\"></div>\n<ng-template #titleBlock>\n <ccd-markdown [content]=\"getCaseTitle() | ccdCaseTitle: caseFields : editForm.controls['data']\"></ccd-markdown>\n</ng-template>\n<ng-template #idBlock>\n <h2 *ngIf=\"getCaseId()\" class=\"heading-h2\">#{{ getCaseId() | ccdCaseReference }}</h2>\n</ng-template>\n\n<!-- Error message summary -->\n<div *ngIf=\"validationErrors.length > 0\" class=\"govuk-error-summary\" aria-labelledby=\"error-summary-title\" role=\"alert\" tabindex=\"-1\" data-module=\"govuk-error-summary\">\n <h2 class=\"govuk-error-summary__title\" id=\"error-summary-title\">\n {{'There is a problem' | rpxTranslate}}\n </h2>\n <div *ngFor=\"let validationError of validationErrors\" class=\"govuk-error-summary__body\">\n <ul class=\"govuk-list govuk-error-summary__list\">\n <li>\n <a (click)=\"navigateToErrorElement(validationError.id)\" class=\"validation-error\">\n {{ validationError.message | rpxTranslate: getRpxTranslatePipeArgs(validationError.label | rpxTranslate): null }}\n </a>\n </li>\n </ul>\n </div>\n</div>\n\n<ccd-case-edit-generic-errors [error]=\"caseEdit.error\"></ccd-case-edit-generic-errors>\n\n<ccd-callback-errors\n [triggerTextContinue]=\"triggerTextStart\"\n [triggerTextIgnore]=\"triggerTextIgnoreWarnings\"\n [callbackErrorsSubject]=\"caseEdit.callbackErrorsSubject\"\n (callbackErrorsContext)=\"callbackErrorsNotify($event)\">\n</ccd-callback-errors>\n<div class=\"width-50\">\n <form *ngIf=\"currentPage\" class=\"form\" [formGroup]=\"editForm\" (submit)=\"submit()\">\n <fieldset id=\"fieldset-case-data\">\n <legend style=\"display: none;\"></legend>\n <!-- single column -->\n <ccd-case-edit-form id='caseEditForm' *ngIf=\"!currentPage.isMultiColumn()\" [fields]=\"currentPage.getCol1Fields()\"\n [formGroup]=\"editForm.controls['data']\" [caseFields]=\"caseFields\"\n [pageChangeSubject]=\"pageChangeSubject\"\n (valuesChanged)=\"applyValuesChanged($event)\"></ccd-case-edit-form>\n <!-- two columns -->\n <div *ngIf=\"currentPage.isMultiColumn()\" class=\"grid-row\">\n <div class=\"column-two-thirds rightBorderSeparator\">\n <ccd-case-edit-form id='caseEditForm1' [fields]=\"currentPage.getCol1Fields()\"\n [formGroup]=\"editForm.controls['data']\" [caseFields]=\"caseFields\"></ccd-case-edit-form>\n </div>\n <div class=\"column-one-third\">\n <ccd-case-edit-form id='caseEditForm2' [fields]=\"currentPage.getCol2Fields()\"\n [formGroup]=\"editForm.controls['data']\" [caseFields]=\"caseFields\"></ccd-case-edit-form>\n </div>\n </div>\n </fieldset>\n\n <div class=\"form-group form-group-related\">\n <button class=\"button button-secondary\" type=\"button\" [disabled]=\"!(hasPreviousPage$ | async)\" (click)=\"toPreviousPage()\">\n {{'Previous' | rpxTranslate}}\n </button>\n <button class=\"button\" type=\"submit\" [disabled]=\"submitting()\">{{triggerText | rpxTranslate}}</button>\n </div>\n\n <p class=\"cancel\"><a (click)=\"cancel()\" href=\"javascript:void(0)\">{{getCancelText() | rpxTranslate}}</a></p>\n </form>\n</div>\n\n<ccd-case-event-completion *ngIf=\"caseEdit.isEventCompletionChecksRequired\"\n [eventCompletionParams]=\"caseEdit.eventCompletionParams\"\n (eventCanBeCompleted)=\"onEventCanBeCompleted($event)\">\n</ccd-case-event-completion>\n", styles: [".rightBorderSeparator{border-right-width:4px;border-right-color:#ffcc02;border-right-style:solid}.validation-error{cursor:pointer;text-decoration:underline;color:#d4351c}\n"] }]
10548
- }], function () { return [{ type: CaseEditComponent }, { type: i1$1.ActivatedRoute }, { type: FormValueService }, { type: FormErrorService }, { type: i0.ChangeDetectorRef }, { type: PageValidationService }, { type: i1$3.MatLegacyDialog }, { type: CaseFieldService }, { type: CaseEditDataService }, { type: LoadingService }, { type: ValidPageListCaseFieldsService }]; }, null);
10570
+ }], function () { return [{ type: CaseEditComponent }, { type: i1$1.ActivatedRoute }, { type: FormValueService }, { type: FormErrorService }, { type: i0.ChangeDetectorRef }, { type: PageValidationService }, { type: i1$3.MatLegacyDialog }, { type: CaseFieldService }, { type: CaseEditDataService }, { type: LoadingService }, { type: ValidPageListCaseFieldsService }, { type: AddressesService }]; }, null);
10549
10571
  })();
10550
10572
 
10551
10573
  class CallbackErrorsContext {
@@ -11037,6 +11059,19 @@ class AddressOption {
11037
11059
  }
11038
11060
  }
11039
11061
 
11062
+ class AddressValidationConstants {
11063
+ }
11064
+ // allow alpha-numeric characters and spaces possibly between a connecting - character
11065
+ // this applies validation while allowing partial postcodes
11066
+ AddressValidationConstants.REGEX_POSTCODE = /^([A-Za-z0-9]-*| )+$/;
11067
+ AddressValidationConstants.ɵfac = function AddressValidationConstants_Factory(t) { return new (t || AddressValidationConstants)(); };
11068
+ AddressValidationConstants.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AddressValidationConstants, factory: AddressValidationConstants.ɵfac });
11069
+ (function () {
11070
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AddressValidationConstants, [{
11071
+ type: Injectable
11072
+ }], null, null);
11073
+ })();
11074
+
11040
11075
  const _c0$U = ["writeComplexFieldComponent"];
11041
11076
  function WriteAddressFieldComponent_div_1_div_4_span_5_Template(rf, ctx) {
11042
11077
  if (rf & 1) {
@@ -11046,8 +11081,9 @@ function WriteAddressFieldComponent_div_1_div_4_span_5_Template(rf, ctx) {
11046
11081
  i0.ɵɵelementEnd();
11047
11082
  }
11048
11083
  if (rf & 2) {
11084
+ const ctx_r5 = i0.ɵɵnextContext(3);
11049
11085
  i0.ɵɵadvance(1);
11050
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, "Enter the Postcode"));
11086
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, ctx_r5.errorMessage));
11051
11087
  }
11052
11088
  }
11053
11089
  const _c1$n = function (a0) { return { "form-group-error": a0 }; };
@@ -11082,7 +11118,20 @@ function WriteAddressFieldComponent_div_1_div_4_Template(rf, ctx) {
11082
11118
  i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(9, 11, "Find address"));
11083
11119
  }
11084
11120
  }
11085
- function WriteAddressFieldComponent_div_1_div_5_option_6_Template(rf, ctx) {
11121
+ function WriteAddressFieldComponent_div_1_div_5_span_5_Template(rf, ctx) {
11122
+ if (rf & 1) {
11123
+ i0.ɵɵelementStart(0, "span", 14);
11124
+ i0.ɵɵtext(1);
11125
+ i0.ɵɵpipe(2, "rpxTranslate");
11126
+ i0.ɵɵelementEnd();
11127
+ }
11128
+ if (rf & 2) {
11129
+ const ctx_r8 = i0.ɵɵnextContext(3);
11130
+ i0.ɵɵadvance(1);
11131
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, ctx_r8.errorMessage));
11132
+ }
11133
+ }
11134
+ function WriteAddressFieldComponent_div_1_div_5_option_7_Template(rf, ctx) {
11086
11135
  if (rf & 1) {
11087
11136
  i0.ɵɵelementStart(0, "option", 18);
11088
11137
  i0.ɵɵtext(1);
@@ -11090,31 +11139,35 @@ function WriteAddressFieldComponent_div_1_div_5_option_6_Template(rf, ctx) {
11090
11139
  i0.ɵɵelementEnd();
11091
11140
  }
11092
11141
  if (rf & 2) {
11093
- const addressOption_r9 = ctx.$implicit;
11094
- i0.ɵɵproperty("ngValue", addressOption_r9.value);
11142
+ const addressOption_r10 = ctx.$implicit;
11143
+ i0.ɵɵproperty("ngValue", addressOption_r10.value);
11095
11144
  i0.ɵɵadvance(1);
11096
- i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 2, addressOption_r9.description), " ");
11145
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 2, addressOption_r10.description), " ");
11097
11146
  }
11098
11147
  }
11099
11148
  function WriteAddressFieldComponent_div_1_div_5_Template(rf, ctx) {
11100
11149
  if (rf & 1) {
11101
- const _r11 = i0.ɵɵgetCurrentView();
11150
+ const _r12 = i0.ɵɵgetCurrentView();
11102
11151
  i0.ɵɵelementStart(0, "div", 15)(1, "label", 9)(2, "span", 10);
11103
11152
  i0.ɵɵtext(3);
11104
11153
  i0.ɵɵpipe(4, "rpxTranslate");
11105
11154
  i0.ɵɵelementEnd()();
11106
- i0.ɵɵelementStart(5, "select", 16);
11107
- i0.ɵɵlistener("change", function WriteAddressFieldComponent_div_1_div_5_Template_select_change_5_listener() { i0.ɵɵrestoreView(_r11); const ctx_r10 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r10.addressSelected()); });
11108
- i0.ɵɵtemplate(6, WriteAddressFieldComponent_div_1_div_5_option_6_Template, 3, 4, "option", 17);
11155
+ i0.ɵɵtemplate(5, WriteAddressFieldComponent_div_1_div_5_span_5_Template, 3, 3, "span", 11);
11156
+ i0.ɵɵelementStart(6, "select", 16);
11157
+ i0.ɵɵlistener("change", function WriteAddressFieldComponent_div_1_div_5_Template_select_change_6_listener() { i0.ɵɵrestoreView(_r12); const ctx_r11 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r11.addressSelected()); });
11158
+ i0.ɵɵtemplate(7, WriteAddressFieldComponent_div_1_div_5_option_7_Template, 3, 4, "option", 17);
11109
11159
  i0.ɵɵelementEnd()();
11110
11160
  }
11111
11161
  if (rf & 2) {
11112
11162
  const ctx_r3 = i0.ɵɵnextContext(2);
11163
+ i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(9, _c1$n, ctx_r3.noAddressSelected));
11113
11164
  i0.ɵɵadvance(1);
11114
11165
  i0.ɵɵproperty("for", ctx_r3.createElementId("addressList"));
11115
11166
  i0.ɵɵadvance(2);
11116
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(4, 5, "Select an address"));
11167
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(4, 7, "Select an address"));
11117
11168
  i0.ɵɵadvance(2);
11169
+ i0.ɵɵproperty("ngIf", ctx_r3.noAddressSelected);
11170
+ i0.ɵɵadvance(1);
11118
11171
  i0.ɵɵproperty("id", ctx_r3.createElementId("addressList"))("formControl", ctx_r3.addressList);
11119
11172
  i0.ɵɵadvance(1);
11120
11173
  i0.ɵɵproperty("ngForOf", ctx_r3.addressOptions);
@@ -11122,9 +11175,9 @@ function WriteAddressFieldComponent_div_1_div_5_Template(rf, ctx) {
11122
11175
  }
11123
11176
  function WriteAddressFieldComponent_div_1_a_6_Template(rf, ctx) {
11124
11177
  if (rf & 1) {
11125
- const _r13 = i0.ɵɵgetCurrentView();
11178
+ const _r14 = i0.ɵɵgetCurrentView();
11126
11179
  i0.ɵɵelementStart(0, "a", 19);
11127
- i0.ɵɵlistener("click", function WriteAddressFieldComponent_div_1_a_6_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r13); const ctx_r12 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r12.blankAddress()); });
11180
+ i0.ɵɵlistener("click", function WriteAddressFieldComponent_div_1_a_6_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r14); const ctx_r13 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r13.blankAddress()); });
11128
11181
  i0.ɵɵtext(1);
11129
11182
  i0.ɵɵpipe(2, "rpxTranslate");
11130
11183
  i0.ɵɵelementEnd();
@@ -11141,7 +11194,7 @@ function WriteAddressFieldComponent_div_1_Template(rf, ctx) {
11141
11194
  i0.ɵɵpipe(3, "ccdFieldLabel");
11142
11195
  i0.ɵɵelementEnd();
11143
11196
  i0.ɵɵtemplate(4, WriteAddressFieldComponent_div_1_div_4_Template, 10, 17, "div", 5);
11144
- i0.ɵɵtemplate(5, WriteAddressFieldComponent_div_1_div_5_Template, 7, 7, "div", 6);
11197
+ i0.ɵɵtemplate(5, WriteAddressFieldComponent_div_1_div_5_Template, 8, 11, "div", 6);
11145
11198
  i0.ɵɵtemplate(6, WriteAddressFieldComponent_div_1_a_6_Template, 3, 3, "a", 7);
11146
11199
  i0.ɵɵelementEnd();
11147
11200
  }
@@ -11162,19 +11215,30 @@ class WriteAddressFieldComponent extends AbstractFieldWriteComponent {
11162
11215
  super();
11163
11216
  this.isCompoundPipe = isCompoundPipe;
11164
11217
  this.addressFormGroup = new FormGroup({});
11218
+ this.errorMessage = WriteAddressFieldComponent.REQUIRED_ERROR_MESSAGE;
11165
11219
  this.missingPostcode = false;
11220
+ this.noAddressSelected = false;
11166
11221
  this.addressesService = addressesService;
11167
11222
  }
11168
11223
  ngOnInit() {
11169
11224
  if (!this.isComplexWithHiddenFields()) {
11170
- this.postcode = new FormControl('');
11171
- this.addressFormGroup.addControl('postcode', this.postcode);
11225
+ this.postcode = new FormControl('', [Validators.required]);
11226
+ this.formGroup.addControl('postcode', this.postcode);
11172
11227
  this.addressList = new FormControl('');
11173
- this.addressFormGroup.addControl('address', this.addressList);
11228
+ this.formGroup.addControl('address', this.addressList);
11174
11229
  }
11230
+ this.addressesService.getMandatoryError().subscribe((value) => {
11231
+ this.updateErrorsOnContinue(value);
11232
+ });
11175
11233
  }
11176
11234
  findAddress() {
11235
+ this.noAddressSelected = false;
11177
11236
  if (!this.postcode.value) {
11237
+ this.errorMessage = WriteAddressFieldComponent.REQUIRED_ERROR_MESSAGE;
11238
+ this.missingPostcode = true;
11239
+ }
11240
+ else if (!this.postcode.value.trim().match(AddressValidationConstants.REGEX_POSTCODE)) {
11241
+ this.errorMessage = WriteAddressFieldComponent.INVALID_ERROR_MESSAGE;
11178
11242
  this.missingPostcode = true;
11179
11243
  }
11180
11244
  else {
@@ -11203,6 +11267,8 @@ class WriteAddressFieldComponent extends AbstractFieldWriteComponent {
11203
11267
  blankAddress() {
11204
11268
  this.caseField.value = new AddressModel();
11205
11269
  this.setFormValue();
11270
+ this.missingPostcode = false;
11271
+ this.noAddressSelected = false;
11206
11272
  }
11207
11273
  isComplexWithHiddenFields() {
11208
11274
  if (this.caseField.isComplex() && this.caseField.field_type.complex_fields
@@ -11234,6 +11300,7 @@ class WriteAddressFieldComponent extends AbstractFieldWriteComponent {
11234
11300
  addressSelected() {
11235
11301
  this.caseField.value = this.addressList.value;
11236
11302
  this.setFormValue();
11303
+ this.noAddressSelected = false;
11237
11304
  }
11238
11305
  ngOnChanges(changes) {
11239
11306
  super.ngOnChanges(changes);
@@ -11254,7 +11321,14 @@ class WriteAddressFieldComponent extends AbstractFieldWriteComponent {
11254
11321
  this.writeComplexFieldComponent.complexGroup.setValue(this.caseField.value);
11255
11322
  }
11256
11323
  }
11324
+ updateErrorsOnContinue(value) {
11325
+ this.missingPostcode = value && !this.shouldShowDetailFields() && !this.addressOptions;
11326
+ this.noAddressSelected = value && !this.shouldShowDetailFields() && !!this.addressOptions;
11327
+ this.errorMessage = this.noAddressSelected ? 'Select an address' : this.errorMessage;
11328
+ }
11257
11329
  }
11330
+ WriteAddressFieldComponent.REQUIRED_ERROR_MESSAGE = 'Enter a Postcode';
11331
+ WriteAddressFieldComponent.INVALID_ERROR_MESSAGE = 'Enter a valid Postcode';
11258
11332
  WriteAddressFieldComponent.ɵfac = function WriteAddressFieldComponent_Factory(t) { return new (t || WriteAddressFieldComponent)(i0.ɵɵdirectiveInject(AddressesService), i0.ɵɵdirectiveInject(IsCompoundPipe)); };
11259
11333
  WriteAddressFieldComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WriteAddressFieldComponent, selectors: [["ccd-write-address-field"]], viewQuery: function WriteAddressFieldComponent_Query(rf, ctx) {
11260
11334
  if (rf & 1) {
@@ -11266,7 +11340,7 @@ WriteAddressFieldComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type:
11266
11340
  i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.writeComplexFieldComponent = _t.first);
11267
11341
  i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.focusElementDirectives = _t);
11268
11342
  }
11269
- }, inputs: { formGroup: "formGroup" }, features: [i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], decls: 4, vars: 9, consts: [[1, "form-group", 3, "id"], [4, "ngIf"], [3, "hidden", "caseField", "renderLabel", "parent", "formGroup", "ignoreMandatory", "idPrefix"], ["writeComplexFieldComponent", ""], [1, "heading-h2"], ["class", "form-group bottom-30 postcodeLookup", 3, "id", "ngClass", 4, "ngIf"], ["class", "form-group", "id", "selectAddress", 4, "ngIf"], ["class", "manual-link bottom-30", "href", "javascript:void(0)", 3, "click", 4, "ngIf"], [1, "form-group", "bottom-30", "postcodeLookup", 3, "id", "ngClass"], [3, "for"], [1, "form-label"], ["class", "error-message", 4, "ngIf"], ["type", "text", "name", "postcode", 1, "form-control", "postcodeinput", "inline-block", 3, "ngClass", "id", "formControl"], ["type", "button", 1, "button", "button-30", 3, "click"], [1, "error-message"], ["id", "selectAddress", 1, "form-group"], ["name", "address", "focusElement", "", 1, "form-control", "ccd-dropdown", "addressList", 3, "id", "formControl", "change"], [3, "ngValue", 4, "ngFor", "ngForOf"], [3, "ngValue"], ["href", "javascript:void(0)", 1, "manual-link", "bottom-30", 3, "click"]], template: function WriteAddressFieldComponent_Template(rf, ctx) {
11343
+ }, inputs: { formGroup: "formGroup" }, features: [i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], decls: 4, vars: 9, consts: [[1, "form-group", 3, "id"], [4, "ngIf"], [3, "hidden", "caseField", "renderLabel", "parent", "formGroup", "ignoreMandatory", "idPrefix"], ["writeComplexFieldComponent", ""], [1, "heading-h2"], ["class", "form-group bottom-30 postcodeLookup", 3, "id", "ngClass", 4, "ngIf"], ["class", "form-group", "id", "selectAddress", 3, "ngClass", 4, "ngIf"], ["class", "manual-link bottom-30", "href", "javascript:void(0)", 3, "click", 4, "ngIf"], [1, "form-group", "bottom-30", "postcodeLookup", 3, "id", "ngClass"], [3, "for"], [1, "form-label"], ["class", "error-message", 4, "ngIf"], ["type", "text", "name", "postcode", 1, "form-control", "postcodeinput", "inline-block", 3, "ngClass", "id", "formControl"], ["type", "button", 1, "button", "button-30", 3, "click"], [1, "error-message"], ["id", "selectAddress", 1, "form-group", 3, "ngClass"], ["name", "address", "focusElement", "", 1, "form-control", "ccd-dropdown", "addressList", 3, "id", "formControl", "change"], [3, "ngValue", 4, "ngFor", "ngForOf"], [3, "ngValue"], ["href", "javascript:void(0)", 1, "manual-link", "bottom-30", 3, "click"]], template: function WriteAddressFieldComponent_Template(rf, ctx) {
11270
11344
  if (rf & 1) {
11271
11345
  i0.ɵɵelementStart(0, "div", 0);
11272
11346
  i0.ɵɵtemplate(1, WriteAddressFieldComponent_div_1_Template, 7, 6, "div", 1);
@@ -11284,7 +11358,7 @@ WriteAddressFieldComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type:
11284
11358
  (function () {
11285
11359
  (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WriteAddressFieldComponent, [{
11286
11360
  type: Component,
11287
- args: [{ selector: 'ccd-write-address-field', template: "<div class=\"form-group\" [id]=\"id()\">\n <div *ngIf=\"!isComplexWithHiddenFields()\">\n <h2 class=\"heading-h2\">{{caseField | ccdFieldLabel}}</h2>\n\n <div class=\"form-group bottom-30 postcodeLookup\" [id]=\"createElementId('postcodeLookup')\" [ngClass]=\"{'form-group-error': missingPostcode}\" *ngIf=\"!isExpanded\">\n <label [for]=\"createElementId('postcodeInput')\">\n <span class=\"form-label\">{{'Enter a UK postcode' | rpxTranslate}}</span>\n </label>\n <span class=\"error-message\" *ngIf=\"missingPostcode\">{{'Enter the Postcode' | rpxTranslate}}</span>\n <input type=\"text\" [ngClass]=\"{'govuk-input--error': missingPostcode}\"\n [id]=\"createElementId('postcodeInput')\" name=\"postcode\" class=\"form-control postcodeinput inline-block\" [formControl]=\"postcode\">\n <button type=\"button\" class=\"button button-30\" (click)=\"findAddress()\">{{'Find address' | rpxTranslate}}</button>\n </div>\n\n <div class=\"form-group\" *ngIf=\"addressOptions\" id=\"selectAddress\">\n <label [for]=\"createElementId('addressList')\">\n <span class=\"form-label\">{{'Select an address' | rpxTranslate}}</span>\n </label>\n\n <select class=\"form-control ccd-dropdown addressList\" [id]=\"createElementId('addressList')\" name=\"address\" [formControl]=\"addressList\" (change)=\"addressSelected()\" focusElement>\n <option *ngFor=\"let addressOption of addressOptions\" [ngValue]=\"addressOption.value\">\n {{addressOption.description | rpxTranslate}}\n </option>\n </select>\n </div>\n\n <a class=\"manual-link bottom-30\" *ngIf=\"!shouldShowDetailFields()\" (click)=\"blankAddress()\" href=\"javascript:void(0)\">\n {{\"I can't enter a UK postcode\" | rpxTranslate}}\n </a>\n </div>\n\n <ccd-write-complex-type-field\n [hidden]=\"!shouldShowDetailFields()\"\n [caseField]=\"caseField\"\n [renderLabel]=\"false\"\n [parent]=\"parent\"\n [formGroup]=\"formGroup\"\n [ignoreMandatory]=\"true\"\n [idPrefix]=\"buildIdPrefix('detail')\"\n #writeComplexFieldComponent>\n </ccd-write-complex-type-field>\n</div>\n", styles: [".manual-link{cursor:pointer;display:block;text-decoration:underline}\n"] }]
11361
+ args: [{ selector: 'ccd-write-address-field', template: "<div class=\"form-group\" [id]=\"id()\">\n <div *ngIf=\"!isComplexWithHiddenFields()\">\n <h2 class=\"heading-h2\">{{caseField | ccdFieldLabel}}</h2>\n\n <div class=\"form-group bottom-30 postcodeLookup\" [id]=\"createElementId('postcodeLookup')\" [ngClass]=\"{'form-group-error': missingPostcode}\" *ngIf=\"!isExpanded\">\n <label [for]=\"createElementId('postcodeInput')\">\n <span class=\"form-label\">{{'Enter a UK postcode' | rpxTranslate}}</span>\n </label>\n <span class=\"error-message\" *ngIf=\"missingPostcode\">{{errorMessage | rpxTranslate}}</span>\n <input type=\"text\" [ngClass]=\"{'govuk-input--error': missingPostcode}\"\n [id]=\"createElementId('postcodeInput')\" name=\"postcode\" class=\"form-control postcodeinput inline-block\" [formControl]=\"postcode\">\n <button type=\"button\" class=\"button button-30\" (click)=\"findAddress()\">{{'Find address' | rpxTranslate}}</button>\n </div>\n\n <div class=\"form-group\" *ngIf=\"addressOptions\" id=\"selectAddress\" [ngClass]=\"{'form-group-error': noAddressSelected}\">\n <label [for]=\"createElementId('addressList')\">\n <span class=\"form-label\">{{'Select an address' | rpxTranslate}}</span>\n </label>\n <span class=\"error-message\" *ngIf=\"noAddressSelected\">{{errorMessage | rpxTranslate}}</span>\n <select class=\"form-control ccd-dropdown addressList\" [id]=\"createElementId('addressList')\" name=\"address\" [formControl]=\"addressList\" (change)=\"addressSelected()\" focusElement>\n <option *ngFor=\"let addressOption of addressOptions\" [ngValue]=\"addressOption.value\">\n {{addressOption.description | rpxTranslate}}\n </option>\n </select>\n </div>\n\n <a class=\"manual-link bottom-30\" *ngIf=\"!shouldShowDetailFields()\" (click)=\"blankAddress()\" href=\"javascript:void(0)\">\n {{\"I can't enter a UK postcode\" | rpxTranslate}}\n </a>\n </div>\n\n <ccd-write-complex-type-field\n [hidden]=\"!shouldShowDetailFields()\"\n [caseField]=\"caseField\"\n [renderLabel]=\"false\"\n [parent]=\"parent\"\n [formGroup]=\"formGroup\"\n [ignoreMandatory]=\"true\"\n [idPrefix]=\"buildIdPrefix('detail')\"\n #writeComplexFieldComponent>\n </ccd-write-complex-type-field>\n</div>\n", styles: [".manual-link{cursor:pointer;display:block;text-decoration:underline}\n"] }]
11288
11362
  }], function () { return [{ type: AddressesService }, { type: IsCompoundPipe }]; }, { writeComplexFieldComponent: [{
11289
11363
  type: ViewChild,
11290
11364
  args: ['writeComplexFieldComponent', { static: false }]
@@ -12087,7 +12161,7 @@ class WriteCaseFlagFieldComponent extends AbstractFieldWriteComponent {
12087
12161
  // Extract all flags-related data from the CaseEventTrigger object in the snapshot data
12088
12162
  if (this.route.snapshot.data.eventTrigger) {
12089
12163
  // Get the HMCTSServiceId from supplementary data, if it exists (required for retrieving the available flag types in
12090
- // the first instance, only falling back on case type ID or jurisidiction if it's not present)
12164
+ // the first instance, only falling back on case type ID or jurisdiction if it's not present)
12091
12165
  if (this.route.snapshot.data.eventTrigger.supplementary_data
12092
12166
  && this.route.snapshot.data.eventTrigger.supplementary_data.HMCTSServiceId) {
12093
12167
  this.hmctsServiceId = this.route.snapshot.data.eventTrigger.supplementary_data.HMCTSServiceId;
@@ -12442,33 +12516,37 @@ class WriteCaseFlagFieldComponent extends AbstractFieldWriteComponent {
12442
12516
  this.flagCommentsOptional = true;
12443
12517
  }
12444
12518
  populateNewFlagDetailInstance() {
12445
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
12446
- const formValues = (_a = this.caseFlagParentFormGroup) === null || _a === void 0 ? void 0 : _a.value;
12519
+ var _a, _b, _c, _d, _e, _f;
12520
+ const langSearchTerm = (_a = this.caseFlagParentFormGroup) === null || _a === void 0 ? void 0 : _a.value['languageSearchTerm'];
12521
+ const manualLangEntry = (_b = this.caseFlagParentFormGroup) === null || _b === void 0 ? void 0 : _b.value['manualLanguageEntry'];
12522
+ const flagType = (_c = this.caseFlagParentFormGroup) === null || _c === void 0 ? void 0 : _c.value['flagType'];
12523
+ const otherDesc = (_d = this.caseFlagParentFormGroup) === null || _d === void 0 ? void 0 : _d.value['otherDescription'];
12524
+ const formValues = (_e = this.caseFlagParentFormGroup) === null || _e === void 0 ? void 0 : _e.value;
12447
12525
  return {
12448
- name: (_b = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _b === void 0 ? void 0 : _b.name,
12449
- name_cy: (_c = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _c === void 0 ? void 0 : _c.name_cy,
12526
+ name: (_f = this.flagType) === null || _f === void 0 ? void 0 : _f.name,
12527
+ name_cy: flagType === null || flagType === void 0 ? void 0 : flagType.name_cy,
12450
12528
  // Currently, subTypeValue, subTypeValue_cy and subTypeKey are applicable only to language flag types
12451
- subTypeValue: (formValues === null || formValues === void 0 ? void 0 : formValues.languageSearchTerm) && this.rpxTranslationService.language === 'en'
12452
- ? formValues === null || formValues === void 0 ? void 0 : formValues.languageSearchTerm.value
12453
- : (formValues === null || formValues === void 0 ? void 0 : formValues.manualLanguageEntry) && this.rpxTranslationService.language === 'en'
12454
- ? formValues === null || formValues === void 0 ? void 0 : formValues.manualLanguageEntry
12529
+ subTypeValue: langSearchTerm && this.rpxTranslationService.language === 'en'
12530
+ ? langSearchTerm.value
12531
+ : manualLangEntry && this.rpxTranslationService.language === 'en'
12532
+ ? manualLangEntry
12455
12533
  : null,
12456
- subTypeValue_cy: (formValues === null || formValues === void 0 ? void 0 : formValues.languageSearchTerm) && this.rpxTranslationService.language === 'cy'
12457
- ? formValues === null || formValues === void 0 ? void 0 : formValues.languageSearchTerm.value_cy
12458
- : (formValues === null || formValues === void 0 ? void 0 : formValues.manualLanguageEntry) && this.rpxTranslationService.language === 'cy'
12459
- ? formValues === null || formValues === void 0 ? void 0 : formValues.manualLanguageEntry
12534
+ subTypeValue_cy: langSearchTerm && this.rpxTranslationService.language === 'cy'
12535
+ ? langSearchTerm === null || langSearchTerm === void 0 ? void 0 : langSearchTerm.value_cy
12536
+ : manualLangEntry && this.rpxTranslationService.language === 'cy'
12537
+ ? manualLangEntry
12460
12538
  : null,
12461
12539
  // For user-entered (i.e. non-Reference Data) languages, there is no key
12462
- subTypeKey: (formValues === null || formValues === void 0 ? void 0 : formValues.languageSearchTerm)
12463
- ? formValues === null || formValues === void 0 ? void 0 : formValues.languageSearchTerm.key
12540
+ subTypeKey: langSearchTerm
12541
+ ? langSearchTerm.key
12464
12542
  : null,
12465
- otherDescription: ((_d = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _d === void 0 ? void 0 : _d.flagCode) === this.otherFlagTypeCode &&
12466
- (formValues === null || formValues === void 0 ? void 0 : formValues.otherDescription) && this.rpxTranslationService.language === 'en'
12467
- ? formValues === null || formValues === void 0 ? void 0 : formValues.otherDescription
12543
+ otherDescription: (flagType === null || flagType === void 0 ? void 0 : flagType.flagCode) === this.otherFlagTypeCode &&
12544
+ otherDesc && this.rpxTranslationService.language === 'en'
12545
+ ? otherDesc
12468
12546
  : null,
12469
- otherDescription_cy: ((_e = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _e === void 0 ? void 0 : _e.flagCode) === this.otherFlagTypeCode &&
12470
- (formValues === null || formValues === void 0 ? void 0 : formValues.otherDescription) && this.rpxTranslationService.language === 'cy'
12471
- ? formValues === null || formValues === void 0 ? void 0 : formValues.otherDescription
12547
+ otherDescription_cy: (flagType === null || flagType === void 0 ? void 0 : flagType.flagCode) === this.otherFlagTypeCode &&
12548
+ otherDesc && this.rpxTranslationService.language === 'cy'
12549
+ ? otherDesc
12472
12550
  : null,
12473
12551
  flagComment: this.rpxTranslationService.language === 'en'
12474
12552
  ? formValues === null || formValues === void 0 ? void 0 : formValues.flagComments
@@ -12478,18 +12556,18 @@ class WriteCaseFlagFieldComponent extends AbstractFieldWriteComponent {
12478
12556
  : null,
12479
12557
  flagUpdateComment: formValues === null || formValues === void 0 ? void 0 : formValues.statusReason,
12480
12558
  dateTimeCreated: new Date().toISOString(),
12481
- path: ((_f = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _f === void 0 ? void 0 : _f.Path) &&
12482
- ((_g = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _g === void 0 ? void 0 : _g.Path.map(pathValue => Object.assign({ id: null, value: pathValue }))),
12483
- hearingRelevant: ((_h = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _h === void 0 ? void 0 : _h.hearingRelevant) ? 'Yes' : 'No',
12484
- flagCode: (_j = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _j === void 0 ? void 0 : _j.flagCode,
12559
+ path: (flagType === null || flagType === void 0 ? void 0 : flagType.Path) &&
12560
+ (flagType === null || flagType === void 0 ? void 0 : flagType.Path.map(pathValue => Object.assign({ id: null, value: pathValue }))),
12561
+ hearingRelevant: (flagType === null || flagType === void 0 ? void 0 : flagType.hearingRelevant) ? 'Yes' : 'No',
12562
+ flagCode: flagType === null || flagType === void 0 ? void 0 : flagType.flagCode,
12485
12563
  // Status should be set to whatever the default is for this flag type, if flag is being created by an external
12486
12564
  // user, otherwise it should be set to "Active" if Case Flags v2.1 is NOT enabled, or the selected status if it is
12487
12565
  status: this.isDisplayContextParameterExternal
12488
- ? (_k = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _k === void 0 ? void 0 : _k.defaultStatus
12566
+ ? flagType === null || flagType === void 0 ? void 0 : flagType.defaultStatus
12489
12567
  : !this.isDisplayContextParameter2Point1Enabled
12490
12568
  ? CaseFlagStatus.ACTIVE
12491
12569
  : CaseFlagStatus[formValues === null || formValues === void 0 ? void 0 : formValues.selectedStatus],
12492
- availableExternally: ((_l = formValues === null || formValues === void 0 ? void 0 : formValues.flagType) === null || _l === void 0 ? void 0 : _l.externallyAvailable) ? 'Yes' : 'No'
12570
+ availableExternally: (flagType === null || flagType === void 0 ? void 0 : flagType.externallyAvailable) ? 'Yes' : 'No'
12493
12571
  };
12494
12572
  }
12495
12573
  moveToFinalReviewStage() {
@@ -32629,7 +32707,7 @@ function CaseEventTriggerComponent_div_0_Template(rf, ctx) {
32629
32707
  }
32630
32708
  }
32631
32709
  class CaseEventTriggerComponent {
32632
- constructor(ngZone, casesService, caseNotifier, router, alertService, route, caseReferencePipe, activityPollingService) {
32710
+ constructor(ngZone, casesService, caseNotifier, router, alertService, route, caseReferencePipe, activityPollingService, sessionStorageService) {
32633
32711
  this.ngZone = ngZone;
32634
32712
  this.casesService = casesService;
32635
32713
  this.caseNotifier = caseNotifier;
@@ -32638,6 +32716,7 @@ class CaseEventTriggerComponent {
32638
32716
  this.route = route;
32639
32717
  this.caseReferencePipe = caseReferencePipe;
32640
32718
  this.activityPollingService = activityPollingService;
32719
+ this.sessionStorageService = sessionStorageService;
32641
32720
  this.BANNER = DisplayMode.BANNER;
32642
32721
  }
32643
32722
  ngOnInit() {
@@ -32687,21 +32766,30 @@ class CaseEventTriggerComponent {
32687
32766
  }
32688
32767
  submitted(event) {
32689
32768
  const eventStatus = event['status'];
32769
+ const taskCompletionFailed = this.sessionStorageService.getItem('taskCompletionError') === 'true';
32690
32770
  this.router
32691
32771
  .navigate([this.parentUrl])
32692
32772
  .then(() => {
32693
32773
  const caseReference = this.caseReferencePipe.transform(this.caseDetails.case_id.toString());
32694
32774
  const replacements = { CASEREFERENCE: caseReference, NAME: this.eventTrigger.name };
32695
- if (EventStatusService.isIncomplete(eventStatus)) {
32775
+ this.alertService.setPreserveAlerts(true);
32776
+ if (taskCompletionFailed) {
32777
+ // if task still present in session storage, we know that the task has not been correctly completed
32778
+ this.alertService.warning({
32779
+ phrase: CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE + '. ' + Constants.TASK_COMPLETION_ERROR,
32780
+ replacements
32781
+ });
32782
+ this.sessionStorageService.removeItem('taskCompletionError');
32783
+ }
32784
+ else if (EventStatusService.isIncomplete(eventStatus)) {
32696
32785
  this.alertService.warning({
32697
- phrase: `Case #%CASEREFERENCE% has been updated with event: %NAME%
32698
- but the callback service cannot be completed`,
32786
+ phrase: CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE + CaseEventTriggerComponent.CALLBACK_FAILED_MESSAGE,
32699
32787
  replacements
32700
32788
  });
32701
32789
  }
32702
32790
  else {
32703
32791
  this.alertService.success({
32704
- phrase: 'Case #%CASEREFERENCE% has been updated with event: %NAME%',
32792
+ phrase: CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE,
32705
32793
  replacements,
32706
32794
  preserve: true
32707
32795
  });
@@ -32720,7 +32808,9 @@ class CaseEventTriggerComponent {
32720
32808
  return !!(this.eventTrigger && this.caseDetails);
32721
32809
  }
32722
32810
  }
32723
- CaseEventTriggerComponent.ɵfac = function CaseEventTriggerComponent_Factory(t) { return new (t || CaseEventTriggerComponent)(i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(CasesService), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$1.Router), i0.ɵɵdirectiveInject(AlertService), i0.ɵɵdirectiveInject(i1$1.ActivatedRoute), i0.ɵɵdirectiveInject(CaseReferencePipe), i0.ɵɵdirectiveInject(ActivityPollingService)); };
32811
+ CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE = `Case #%CASEREFERENCE% has been updated with event: %NAME%`;
32812
+ CaseEventTriggerComponent.CALLBACK_FAILED_MESSAGE = ' but the callback service cannot be completed';
32813
+ CaseEventTriggerComponent.ɵfac = function CaseEventTriggerComponent_Factory(t) { return new (t || CaseEventTriggerComponent)(i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(CasesService), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$1.Router), i0.ɵɵdirectiveInject(AlertService), i0.ɵɵdirectiveInject(i1$1.ActivatedRoute), i0.ɵɵdirectiveInject(CaseReferencePipe), i0.ɵɵdirectiveInject(ActivityPollingService), i0.ɵɵdirectiveInject(SessionStorageService)); };
32724
32814
  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) {
32725
32815
  if (rf & 1) {
32726
32816
  i0.ɵɵtemplate(0, CaseEventTriggerComponent_div_0_Template, 3, 6, "div", 0);
@@ -32733,7 +32823,7 @@ CaseEventTriggerComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: C
32733
32823
  (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseEventTriggerComponent, [{
32734
32824
  type: Component,
32735
32825
  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" }]
32736
- }], function () { return [{ type: i0.NgZone }, { type: CasesService }, { type: CaseNotifier }, { type: i1$1.Router }, { type: AlertService }, { type: i1$1.ActivatedRoute }, { type: CaseReferencePipe }, { type: ActivityPollingService }]; }, null);
32826
+ }], function () { return [{ type: i0.NgZone }, { type: CasesService }, { type: CaseNotifier }, { type: i1$1.Router }, { type: AlertService }, { type: i1$1.ActivatedRoute }, { type: CaseReferencePipe }, { type: ActivityPollingService }, { type: SessionStorageService }]; }, null);
32737
32827
  })();
32738
32828
 
32739
32829
  function CaseViewComponent_div_0_Template(rf, ctx) {