@hmcts/ccd-case-ui-toolkit 7.4.17 → 7.4.18

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.
@@ -9392,6 +9392,15 @@ class RetryUtil {
9392
9392
  const MEDIA_VIEWER_HANDOFF_RETRY_INTERVAL_MS = 100;
9393
9393
  const MEDIA_VIEWER_HANDOFF_MAX_ATTEMPTS = 100;
9394
9394
  class WindowService {
9395
+ setLocalStorage(key, value) {
9396
+ window.localStorage.setItem(key, value);
9397
+ }
9398
+ getLocalStorage(key) {
9399
+ return window.localStorage.getItem(key);
9400
+ }
9401
+ removeLocalStorage(key) {
9402
+ window.localStorage.removeItem(key);
9403
+ }
9395
9404
  locationAssign(url) {
9396
9405
  window.location.assign(url);
9397
9406
  }
@@ -39240,8 +39249,8 @@ function WorkbasketFiltersComponent_ng_container_39_Template(rf, ctx) { if (rf &
39240
39249
  i0.ɵɵadvance(2);
39241
39250
  i0.ɵɵproperty("ngForOf", ctx_r4.workbasketInputs);
39242
39251
  } }
39243
- const FORM_GROUP_VAL_SES_STORAGE = 'workbasket-filter-form-group-value';
39244
- const SAVED_QUERY_PARAM_SES_STORAGE = 'savedQueryParams';
39252
+ const FORM_GROUP_VAL_LOC_STORAGE = 'workbasket-filter-form-group-value';
39253
+ const SAVED_QUERY_PARAM_LOC_STORAGE = 'savedQueryParams';
39245
39254
  const REGION_LIST_AND_FRC_FILTER = 'regionList';
39246
39255
  class WorkbasketFiltersComponent {
39247
39256
  route;
@@ -39335,7 +39344,7 @@ class WorkbasketFiltersComponent {
39335
39344
  this.alertService.setPreserveAlerts(!this.initialised);
39336
39345
  }
39337
39346
  if (Object.keys(this.formGroup.controls).length === 0) {
39338
- const storedFormGroup = safeJsonParse(this.windowService.getSessionStorage(FORM_GROUP_VAL_SES_STORAGE), null);
39347
+ const storedFormGroup = safeJsonParse(this.windowService.getLocalStorage(FORM_GROUP_VAL_LOC_STORAGE), null);
39339
39348
  this.selected.formGroup = storedFormGroup && Object.keys(storedFormGroup).length > 0 ? storedFormGroup : null;
39340
39349
  }
39341
39350
  else {
@@ -39347,14 +39356,14 @@ class WorkbasketFiltersComponent {
39347
39356
  this.selected.page = 1;
39348
39357
  this.selected.metadataFields = this.getMetadataFields();
39349
39358
  if (init) {
39350
- this.windowService.setSessionStorage(SAVED_QUERY_PARAM_SES_STORAGE, JSON.stringify(queryParams));
39359
+ this.windowService.setLocalStorage(SAVED_QUERY_PARAM_LOC_STORAGE, JSON.stringify(queryParams));
39351
39360
  if (Object.keys(this.formGroup.controls).length > 0) {
39352
39361
  // Find all "special case" JudicialUser FormControl keys and remove the corresponding values from the
39353
39362
  // FormGroup value because these values are not intended to be stored and subsequently passed as query string
39354
39363
  // parameters when calling searchCases API endpoint
39355
39364
  const judicialUserControlValuesToRemove = Object.keys(this.formGroup.controls).filter((key) => key.endsWith('_judicialUserControl'));
39356
39365
  judicialUserControlValuesToRemove.forEach((controlKey) => delete this.formGroup.value[controlKey]);
39357
- this.windowService.setSessionStorage(FORM_GROUP_VAL_SES_STORAGE, JSON.stringify(this.formGroup.value));
39366
+ this.windowService.setLocalStorage(FORM_GROUP_VAL_LOC_STORAGE, JSON.stringify(this.formGroup.value));
39358
39367
  }
39359
39368
  }
39360
39369
  // Announce selected jurisdiction via JurisdictionService
@@ -39368,8 +39377,8 @@ class WorkbasketFiltersComponent {
39368
39377
  this.setFocusToTop();
39369
39378
  }
39370
39379
  reset() {
39371
- this.windowService.removeSessionStorage(FORM_GROUP_VAL_SES_STORAGE);
39372
- this.windowService.removeSessionStorage(SAVED_QUERY_PARAM_SES_STORAGE);
39380
+ this.windowService.removeLocalStorage(FORM_GROUP_VAL_LOC_STORAGE);
39381
+ this.windowService.removeLocalStorage(SAVED_QUERY_PARAM_LOC_STORAGE);
39373
39382
  setTimeout(() => {
39374
39383
  this.resetFieldsWhenNoDefaults();
39375
39384
  this.onReset.emit(true);
@@ -39420,7 +39429,7 @@ class WorkbasketFiltersComponent {
39420
39429
  this.workbasketInputsReady = true;
39421
39430
  this.workbasketInputs = workbasketInputs
39422
39431
  .sort(this.orderService.sortAsc);
39423
- const formValue = this.windowService.getSessionStorage(FORM_GROUP_VAL_SES_STORAGE);
39432
+ const formValue = this.windowService.getLocalStorage(FORM_GROUP_VAL_LOC_STORAGE);
39424
39433
  workbasketInputs.forEach(item => {
39425
39434
  if (item.field.elementPath) {
39426
39435
  item.field.id = `${item.field.id}.${item.field.elementPath}`;
@@ -39460,18 +39469,18 @@ class WorkbasketFiltersComponent {
39460
39469
  * in future to incorporate other dynamic filters.
39461
39470
  */
39462
39471
  updateFormGroupFilters() {
39463
- // Read the form group from session storage
39464
- const formGroupSessionStorage = safeJsonParse(this.windowService.getSessionStorage(FORM_GROUP_VAL_SES_STORAGE), null);
39465
- // Form group session storage is available and contains regionList property
39466
- if (!!formGroupSessionStorage && formGroupSessionStorage.hasOwnProperty(REGION_LIST_AND_FRC_FILTER)) {
39472
+ // Read the form group from local storage
39473
+ const formGroupLS = safeJsonParse(this.windowService.getLocalStorage(FORM_GROUP_VAL_LOC_STORAGE), null);
39474
+ // Form group local storage is available and contains regionList property
39475
+ if (!!formGroupLS && formGroupLS.hasOwnProperty(REGION_LIST_AND_FRC_FILTER)) {
39467
39476
  if (this.formGroup.get(REGION_LIST_AND_FRC_FILTER)) {
39468
- // If regionList value does not match between session storage and form group
39477
+ // If regionList value does not match between local storage and form group
39469
39478
  // then the filter value has been changed and we need to clear the old filter values
39470
- if (formGroupSessionStorage[REGION_LIST_AND_FRC_FILTER] !== this.formGroup.get(REGION_LIST_AND_FRC_FILTER).value) {
39471
- for (const key in formGroupSessionStorage) {
39472
- if (formGroupSessionStorage.hasOwnProperty(key)) {
39473
- const value = formGroupSessionStorage[key];
39474
- // Clear the filter form group control values if it has a value in session storage
39479
+ if (formGroupLS[REGION_LIST_AND_FRC_FILTER] !== this.formGroup.get(REGION_LIST_AND_FRC_FILTER).value) {
39480
+ for (const key in formGroupLS) {
39481
+ if (formGroupLS.hasOwnProperty(key)) {
39482
+ const value = formGroupLS[key];
39483
+ // Clear the filter form group control values if it has a value in local storage
39475
39484
  // The regionList form group control value should be ignored as it always contain the latest value
39476
39485
  if (key !== REGION_LIST_AND_FRC_FILTER && value !== null) {
39477
39486
  this.formGroup.get(key).setValue(null);
@@ -39490,7 +39499,7 @@ class WorkbasketFiltersComponent {
39490
39499
  * Query parameters, when available, take precedence over workbasket defaults.
39491
39500
  */
39492
39501
  initFilters(init) {
39493
- const savedQueryParams = this.windowService.getSessionStorage(SAVED_QUERY_PARAM_SES_STORAGE);
39502
+ const savedQueryParams = this.windowService.getLocalStorage(SAVED_QUERY_PARAM_LOC_STORAGE);
39494
39503
  const routeSnapshot = this.route.snapshot;
39495
39504
  if (savedQueryParams) {
39496
39505
  routeSnapshot.queryParams = JSON.parse(savedQueryParams);
@@ -39551,7 +39560,7 @@ class WorkbasketFiltersComponent {
39551
39560
  this.workbasketInputs = [];
39552
39561
  }
39553
39562
  clearStoredWorkbasketFilterValues() {
39554
- this.windowService.removeSessionStorage(FORM_GROUP_VAL_SES_STORAGE);
39563
+ this.windowService.removeLocalStorage(FORM_GROUP_VAL_LOC_STORAGE);
39555
39564
  }
39556
39565
  resetCaseState() {
39557
39566
  this.defaults.state_id = null;
@@ -45104,10 +45113,10 @@ function SearchFiltersComponent_ng_container_16_Template(rf, ctx) { if (rf & 1)
45104
45113
  i0.ɵɵadvance(2);
45105
45114
  i0.ɵɵproperty("ngForOf", ctx_r3.searchInputs);
45106
45115
  } }
45107
- const JURISDICTION_SES_STORAGE = 'search-jurisdiction';
45108
- const META_FIELDS_SES_STORAGE = 'search-metadata-fields';
45109
- const FORM_GROUP_VALUE_SES_STORAGE = 'search-form-group-value';
45110
- const CASE_TYPE_SES_STORAGE = 'search-caseType';
45116
+ const JURISDICTION_LOC_STORAGE = 'search-jurisdiction';
45117
+ const META_FIELDS_LOC_STORAGE = 'search-metadata-fields';
45118
+ const FORM_GROUP_VALUE_LOC_STORAGE = 'search-form-group-value';
45119
+ const CASE_TYPE_LOC_STORAGE = 'search-caseType';
45111
45120
  class SearchFiltersComponent {
45112
45121
  searchService;
45113
45122
  orderService;
@@ -45136,7 +45145,7 @@ class SearchFiltersComponent {
45136
45145
  this.selected = {};
45137
45146
  }
45138
45147
  ngOnInit() {
45139
- const jurisdiction = this.getValuesFromSessionStorage();
45148
+ const jurisdiction = this.getValuesFromLocalStorage();
45140
45149
  if (this.jurisdictions.length === 1 || jurisdiction) {
45141
45150
  this.selected.jurisdiction = this.jurisdictions[0];
45142
45151
  if (jurisdiction) {
@@ -45163,10 +45172,10 @@ class SearchFiltersComponent {
45163
45172
  });
45164
45173
  }
45165
45174
  reset() {
45166
- this.windowService.removeSessionStorage(FORM_GROUP_VALUE_SES_STORAGE);
45167
- this.windowService.removeSessionStorage(CASE_TYPE_SES_STORAGE);
45168
- this.windowService.removeSessionStorage(JURISDICTION_SES_STORAGE);
45169
- this.windowService.removeSessionStorage(META_FIELDS_SES_STORAGE);
45175
+ this.windowService.removeLocalStorage(FORM_GROUP_VALUE_LOC_STORAGE);
45176
+ this.windowService.removeLocalStorage(CASE_TYPE_LOC_STORAGE);
45177
+ this.windowService.removeLocalStorage(JURISDICTION_LOC_STORAGE);
45178
+ this.windowService.removeLocalStorage(META_FIELDS_LOC_STORAGE);
45170
45179
  this.selected = {};
45171
45180
  if (this.jurisdictions.length === 1) {
45172
45181
  this.selected.jurisdiction = this.jurisdictions[0];
@@ -45178,39 +45187,39 @@ class SearchFiltersComponent {
45178
45187
  this.selected.formGroup = this.formGroup;
45179
45188
  this.selected.page = 1;
45180
45189
  this.selected.metadataFields = this.getMetadataFields();
45181
- this.populateValuesInSessionStorage();
45190
+ this.populateValuesInLocalStorage();
45182
45191
  this.onApply.emit({
45183
45192
  selected: this.selected,
45184
45193
  queryParams: this.getQueryParams()
45185
45194
  });
45186
45195
  this.setFocusToTop();
45187
45196
  }
45188
- populateValuesInSessionStorage() {
45189
- this.windowService.setSessionStorage(FORM_GROUP_VALUE_SES_STORAGE, JSON.stringify(this.selected.formGroup.value));
45190
- this.windowService.setSessionStorage(META_FIELDS_SES_STORAGE, JSON.stringify(this.selected.metadataFields));
45197
+ populateValuesInLocalStorage() {
45198
+ this.windowService.setLocalStorage(FORM_GROUP_VALUE_LOC_STORAGE, JSON.stringify(this.selected.formGroup.value));
45199
+ this.windowService.setLocalStorage(META_FIELDS_LOC_STORAGE, JSON.stringify(this.selected.metadataFields));
45191
45200
  try {
45192
45201
  const compJurisd = compressToUTF16(JSON.stringify(this.selected.jurisdiction));
45193
- this.windowService.setSessionStorage(JURISDICTION_SES_STORAGE, compJurisd);
45202
+ this.windowService.setLocalStorage(JURISDICTION_LOC_STORAGE, compJurisd);
45194
45203
  }
45195
45204
  catch (e) {
45196
- this.windowService.setSessionStorage(JURISDICTION_SES_STORAGE, null);
45205
+ this.windowService.setLocalStorage(JURISDICTION_LOC_STORAGE, null);
45197
45206
  }
45198
45207
  if (this.selected.caseType) {
45199
- this.windowService.setSessionStorage(CASE_TYPE_SES_STORAGE, JSON.stringify(this.selected.caseType));
45208
+ this.windowService.setLocalStorage(CASE_TYPE_LOC_STORAGE, JSON.stringify(this.selected.caseType));
45200
45209
  }
45201
45210
  }
45202
- getValuesFromSessionStorage() {
45203
- const jurisdiction = this.windowService.getSessionStorage(JURISDICTION_SES_STORAGE);
45211
+ getValuesFromLocalStorage() {
45212
+ const jurisdiction = this.windowService.getLocalStorage(JURISDICTION_LOC_STORAGE);
45204
45213
  if (jurisdiction) {
45205
45214
  try {
45206
- const sessionStorageJurisdiction = JSON.parse(decompressFromUTF16(jurisdiction));
45207
- if (sessionStorageJurisdiction) {
45208
- return sessionStorageJurisdiction;
45215
+ const localStorageJurisdiction = JSON.parse(decompressFromUTF16(jurisdiction));
45216
+ if (localStorageJurisdiction) {
45217
+ return localStorageJurisdiction;
45209
45218
  }
45210
45219
  }
45211
45220
  catch (e) {
45212
- this.logger.error('Failed to retrieve jurisdiction from session storage.', { error: e });
45213
- this.windowService.setSessionStorage(JURISDICTION_SES_STORAGE, null);
45221
+ this.logger.error('Failed to retrieve jurisdiction from local storage.', { error: e });
45222
+ this.windowService.setLocalStorage(JURISDICTION_LOC_STORAGE, null);
45214
45223
  }
45215
45224
  }
45216
45225
  return null;
@@ -45248,7 +45257,7 @@ class SearchFiltersComponent {
45248
45257
  this.searchInputs = [];
45249
45258
  this.searchService.getSearchInputs(this.selected.jurisdiction.id, this.selected.caseType.id).pipe(tap(() => this.searchInputsReady = true)).subscribe(searchInputs => {
45250
45259
  this.searchInputs = searchInputs.sort(this.orderService.sortAsc);
45251
- const formValue = this.windowService.getSessionStorage(FORM_GROUP_VALUE_SES_STORAGE);
45260
+ const formValue = this.windowService.getLocalStorage(FORM_GROUP_VALUE_LOC_STORAGE);
45252
45261
  let formValueObject = null;
45253
45262
  if (formValue) {
45254
45263
  formValueObject = JSON.parse(formValue);
@@ -45286,7 +45295,7 @@ class SearchFiltersComponent {
45286
45295
  selectCaseType(caseTypes) {
45287
45296
  if (caseTypes && caseTypes.length > 0) {
45288
45297
  this.selected.caseType = caseTypes[0];
45289
- const caseType = this.windowService.getSessionStorage(CASE_TYPE_SES_STORAGE);
45298
+ const caseType = this.windowService.getLocalStorage(CASE_TYPE_LOC_STORAGE);
45290
45299
  if (caseType) {
45291
45300
  const caseTypeObject = JSON.parse(caseType);
45292
45301
  const result = caseTypes.filter(c => c.id === caseTypeObject.id);