@hmcts/ccd-case-ui-toolkit 6.14.4-eui-4157 → 6.14.4-hotfix-110

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.
@@ -8421,13 +8421,223 @@
8421
8421
  }], null, null);
8422
8422
  })();
8423
8423
 
8424
+ var MULTIPLE_TASKS_FOUND = 'More than one task found!';
8425
+ var WorkAllocationService = /** @class */ (function () {
8426
+ function WorkAllocationService(http, appConfig, errorService, alertService, sessionStorageService) {
8427
+ this.http = http;
8428
+ this.appConfig = appConfig;
8429
+ this.errorService = errorService;
8430
+ this.alertService = alertService;
8431
+ this.sessionStorageService = sessionStorageService;
8432
+ // Check to see if work allocation is enabled
8433
+ }
8434
+ /**
8435
+ * Call the API to get tasks matching the search criteria.
8436
+ * @param searchRequest The search parameters that specify which tasks to match.
8437
+ */
8438
+ WorkAllocationService.prototype.searchTasks = function (searchRequest) {
8439
+ var _this = this;
8440
+ // Do not need to check if WA enabled as parent method will do that
8441
+ var url = this.appConfig.getWorkAllocationApiUrl() + "/searchForCompletable";
8442
+ return this.http
8443
+ .post(url, { searchRequest: searchRequest }, null, false)
8444
+ .pipe(operators.map(function (response) { return response; }), operators.catchError(function (error) {
8445
+ _this.errorService.setError(error);
8446
+ // explicitly eat away 401 error and 400 error
8447
+ if (error && error.status && (error.status === 401 || error.status === 400)) {
8448
+ // do nothing
8449
+ console.log('error status 401 or 400', error);
8450
+ }
8451
+ else {
8452
+ return rxjs.throwError(error);
8453
+ }
8454
+ }));
8455
+ };
8456
+ WorkAllocationService.prototype.isWAEnabled = function (jurisdiction, caseType) {
8457
+ this.features = this.appConfig.getWAServiceConfig();
8458
+ var enabled = false;
8459
+ if (!jurisdiction || !caseType) {
8460
+ var caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
8461
+ jurisdiction = caseInfo.jurisdiction;
8462
+ caseType = caseInfo.caseType;
8463
+ }
8464
+ if (!this.features || !this.features.configurations) {
8465
+ return false;
8466
+ }
8467
+ this.features.configurations.forEach(function (serviceConfig) {
8468
+ if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
8469
+ enabled = true;
8470
+ }
8471
+ });
8472
+ return enabled;
8473
+ };
8474
+ /**
8475
+ * Call the API to assign a task.
8476
+ * @param taskId specifies which task should be assigned.
8477
+ * @param userId specifies the user the task should be assigned to.
8478
+ */
8479
+ WorkAllocationService.prototype.assignTask = function (taskId, userId) {
8480
+ var _this = this;
8481
+ if (!this.isWAEnabled()) {
8482
+ return rxjs.of(null);
8483
+ }
8484
+ var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/assign";
8485
+ return this.http
8486
+ .post(url, { userId: userId })
8487
+ .pipe(operators.catchError(function (error) {
8488
+ _this.errorService.setError(error);
8489
+ return rxjs.throwError(error);
8490
+ }));
8491
+ };
8492
+ /**
8493
+ * Call the API to complete a task.
8494
+ * @param taskId specifies which task should be completed.
8495
+ */
8496
+ WorkAllocationService.prototype.completeTask = function (taskId) {
8497
+ var _this = this;
8498
+ if (!this.isWAEnabled()) {
8499
+ return rxjs.of(null);
8500
+ }
8501
+ var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
8502
+ return this.http
8503
+ .post(url, {})
8504
+ .pipe(operators.catchError(function (error) {
8505
+ _this.errorService.setError(error);
8506
+ // this will subscribe to get the user details and decide whether to display an error message
8507
+ _this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
8508
+ _this.handleTaskCompletionError(response);
8509
+ });
8510
+ return rxjs.throwError(error);
8511
+ }));
8512
+ };
8513
+ /**
8514
+ * Call the API to assign and complete a task.
8515
+ * @param taskId specifies which task should be completed.
8516
+ */
8517
+ WorkAllocationService.prototype.assignAndCompleteTask = function (taskId) {
8518
+ var _this = this;
8519
+ if (!this.isWAEnabled()) {
8520
+ return rxjs.of(null);
8521
+ }
8522
+ var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
8523
+ return this.http
8524
+ .post(url, {
8525
+ completion_options: {
8526
+ assign_and_complete: true
8527
+ }
8528
+ })
8529
+ .pipe(operators.catchError(function (error) {
8530
+ _this.errorService.setError(error);
8531
+ // this will subscribe to get the user details and decide whether to display an error message
8532
+ _this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
8533
+ _this.handleTaskCompletionError(response);
8534
+ });
8535
+ return rxjs.throwError(error);
8536
+ }));
8537
+ };
8538
+ /**
8539
+ * Handles the response from the observable to get the user details when task is completed.
8540
+ * @param response is the response given from the observable which contains the user detaild.
8541
+ */
8542
+ WorkAllocationService.prototype.handleTaskCompletionError = function (response) {
8543
+ var userDetails = response;
8544
+ if (this.userIsCaseworker(userDetails.userInfo.roles)) {
8545
+ // when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
8546
+ this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
8547
+ this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
8548
+ }
8549
+ };
8550
+ /**
8551
+ * Returns true if the user's role is equivalent to a caseworker.
8552
+ * @param roles is the list of roles found from the current user.
8553
+ */
8554
+ WorkAllocationService.prototype.userIsCaseworker = function (roles) {
8555
+ var lowerCaseRoles = roles.map(function (role) { return role.toLowerCase(); });
8556
+ // When/if lib & target permanently change to es2016, replace indexOf with includes
8557
+ return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
8558
+ || (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
8559
+ };
8560
+ /**
8561
+ * Look for open tasks for a case and event combination. There are 5 possible scenarios:
8562
+ * 1. No tasks found => Success.
8563
+ * 2. One task found => Mark as done => Success.
8564
+ * 3. One task found => Mark as done throws error => Failure.
8565
+ * 4. More than one task found => Failure.
8566
+ * 5. Search call throws an error => Failure.
8567
+ * @param ccdId The ID of the case to find tasks for.
8568
+ * @param eventId The ID of the event to find tasks for.
8569
+ */
8570
+ WorkAllocationService.prototype.completeAppropriateTask = function (ccdId, eventId, jurisdiction, caseTypeId) {
8571
+ var _this = this;
8572
+ if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
8573
+ return rxjs.of(null);
8574
+ }
8575
+ var taskSearchParameter = {
8576
+ ccdId: ccdId,
8577
+ eventId: eventId,
8578
+ jurisdiction: jurisdiction,
8579
+ caseTypeId: caseTypeId
8580
+ };
8581
+ return this.searchTasks(taskSearchParameter)
8582
+ .pipe(operators.map(function (response) {
8583
+ var tasks = response.tasks;
8584
+ if (tasks && tasks.length > 0) {
8585
+ if (tasks.length === 1) {
8586
+ _this.completeTask(tasks[0].id).subscribe();
8587
+ }
8588
+ else {
8589
+ // This is a problem. Throw an appropriate error.
8590
+ throw new Error(MULTIPLE_TASKS_FOUND);
8591
+ }
8592
+ }
8593
+ return true; // All good. Nothing to see here.
8594
+ }), operators.catchError(function (error) {
8595
+ // Simply rethrow it.
8596
+ return rxjs.throwError(error);
8597
+ }));
8598
+ };
8599
+ /**
8600
+ * Return tasks for case and event.
8601
+ */
8602
+ WorkAllocationService.prototype.getTasksByCaseIdAndEventId = function (eventId, caseId, caseType, jurisdiction) {
8603
+ var defaultPayload = {
8604
+ task_required_for_event: false,
8605
+ tasks: []
8606
+ };
8607
+ if (!this.isWAEnabled()) {
8608
+ return rxjs.of(defaultPayload);
8609
+ }
8610
+ return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/case/tasks/" + caseId + "/event/" + eventId + "/caseType/" + caseType + "/jurisdiction/" + jurisdiction);
8611
+ };
8612
+ /**
8613
+ * Call the API to get a task
8614
+ */
8615
+ WorkAllocationService.prototype.getTask = function (taskId) {
8616
+ if (!this.isWAEnabled()) {
8617
+ return rxjs.of({ task: null });
8618
+ }
8619
+ return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId);
8620
+ };
8621
+ return WorkAllocationService;
8622
+ }());
8623
+ WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
8624
+ WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
8625
+ WorkAllocationService.ɵfac = function WorkAllocationService_Factory(t) { return new (t || WorkAllocationService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(AlertService), i0__namespace.ɵɵinject(SessionStorageService)); };
8626
+ WorkAllocationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
8627
+ (function () {
8628
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(WorkAllocationService, [{
8629
+ type: i0.Injectable
8630
+ }], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null);
8631
+ })();
8632
+
8424
8633
  var CasesService = /** @class */ (function () {
8425
- function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService) {
8634
+ function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, workAllocationService, loadingService, sessionStorageService) {
8426
8635
  this.http = http;
8427
8636
  this.appConfig = appConfig;
8428
8637
  this.orderService = orderService;
8429
8638
  this.errorService = errorService;
8430
8639
  this.wizardPageFieldToCaseFieldMapper = wizardPageFieldToCaseFieldMapper;
8640
+ this.workAllocationService = workAllocationService;
8431
8641
  this.loadingService = loadingService;
8432
8642
  this.sessionStorageService = sessionStorageService;
8433
8643
  this.get = this.getCaseView;
@@ -8662,12 +8872,12 @@
8662
8872
  CasesService.V2_MEDIATYPE_CREATE_EVENT = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-event.v2+json;charset=UTF-8';
8663
8873
  CasesService.V2_MEDIATYPE_CREATE_CASE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-case.v2+json;charset=UTF-8';
8664
8874
  CasesService.PUI_CASE_MANAGER = 'pui-case-manager';
8665
- CasesService.ɵfac = function CasesService_Factory(t) { return new (t || CasesService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(OrderService), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(WizardPageFieldToCaseFieldMapper), i0__namespace.ɵɵinject(LoadingService), i0__namespace.ɵɵinject(SessionStorageService)); };
8875
+ CasesService.ɵfac = function CasesService_Factory(t) { return new (t || CasesService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(OrderService), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(WizardPageFieldToCaseFieldMapper), i0__namespace.ɵɵinject(WorkAllocationService), i0__namespace.ɵɵinject(LoadingService), i0__namespace.ɵɵinject(SessionStorageService)); };
8666
8876
  CasesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: CasesService, factory: CasesService.ɵfac });
8667
8877
  (function () {
8668
8878
  (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CasesService, [{
8669
8879
  type: i0.Injectable
8670
- }], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }]; }, null);
8880
+ }], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: WorkAllocationService }, { type: LoadingService }, { type: SessionStorageService }]; }, null);
8671
8881
  })();
8672
8882
 
8673
8883
  var EventTriggerService = /** @class */ (function () {
@@ -9321,215 +9531,6 @@
9321
9531
  }], function () { return [{ type: CaseFieldService }]; }, null);
9322
9532
  })();
9323
9533
 
9324
- var MULTIPLE_TASKS_FOUND = 'More than one task found!';
9325
- var WorkAllocationService = /** @class */ (function () {
9326
- function WorkAllocationService(http, appConfig, errorService, alertService, sessionStorageService) {
9327
- this.http = http;
9328
- this.appConfig = appConfig;
9329
- this.errorService = errorService;
9330
- this.alertService = alertService;
9331
- this.sessionStorageService = sessionStorageService;
9332
- // Check to see if work allocation is enabled
9333
- }
9334
- /**
9335
- * Call the API to get tasks matching the search criteria.
9336
- * @param searchRequest The search parameters that specify which tasks to match.
9337
- */
9338
- WorkAllocationService.prototype.searchTasks = function (searchRequest) {
9339
- var _this = this;
9340
- // Do not need to check if WA enabled as parent method will do that
9341
- var url = this.appConfig.getWorkAllocationApiUrl() + "/searchForCompletable";
9342
- return this.http
9343
- .post(url, { searchRequest: searchRequest }, null, false)
9344
- .pipe(operators.map(function (response) { return response; }), operators.catchError(function (error) {
9345
- _this.errorService.setError(error);
9346
- // explicitly eat away 401 error and 400 error
9347
- if (error && error.status && (error.status === 401 || error.status === 400)) {
9348
- // do nothing
9349
- console.log('error status 401 or 400', error);
9350
- }
9351
- else {
9352
- return rxjs.throwError(error);
9353
- }
9354
- }));
9355
- };
9356
- WorkAllocationService.prototype.isWAEnabled = function (jurisdiction, caseType) {
9357
- this.features = this.appConfig.getWAServiceConfig();
9358
- var enabled = false;
9359
- if (!jurisdiction || !caseType) {
9360
- var caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
9361
- jurisdiction = caseInfo.jurisdiction;
9362
- caseType = caseInfo.caseType;
9363
- }
9364
- if (!this.features || !this.features.configurations) {
9365
- return false;
9366
- }
9367
- this.features.configurations.forEach(function (serviceConfig) {
9368
- if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
9369
- enabled = true;
9370
- }
9371
- });
9372
- return enabled;
9373
- };
9374
- /**
9375
- * Call the API to assign a task.
9376
- * @param taskId specifies which task should be assigned.
9377
- * @param userId specifies the user the task should be assigned to.
9378
- */
9379
- WorkAllocationService.prototype.assignTask = function (taskId, userId) {
9380
- var _this = this;
9381
- if (!this.isWAEnabled()) {
9382
- return rxjs.of(null);
9383
- }
9384
- var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/assign";
9385
- return this.http
9386
- .post(url, { userId: userId })
9387
- .pipe(operators.catchError(function (error) {
9388
- _this.errorService.setError(error);
9389
- return rxjs.throwError(error);
9390
- }));
9391
- };
9392
- /**
9393
- * Call the API to complete a task.
9394
- * @param taskId specifies which task should be completed.
9395
- */
9396
- WorkAllocationService.prototype.completeTask = function (taskId) {
9397
- var _this = this;
9398
- if (!this.isWAEnabled()) {
9399
- return rxjs.of(null);
9400
- }
9401
- var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
9402
- return this.http
9403
- .post(url, {})
9404
- .pipe(operators.catchError(function (error) {
9405
- _this.errorService.setError(error);
9406
- // this will subscribe to get the user details and decide whether to display an error message
9407
- _this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
9408
- _this.handleTaskCompletionError(response);
9409
- });
9410
- return rxjs.throwError(error);
9411
- }));
9412
- };
9413
- /**
9414
- * Call the API to assign and complete a task.
9415
- * @param taskId specifies which task should be completed.
9416
- */
9417
- WorkAllocationService.prototype.assignAndCompleteTask = function (taskId) {
9418
- var _this = this;
9419
- if (!this.isWAEnabled()) {
9420
- return rxjs.of(null);
9421
- }
9422
- var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
9423
- return this.http
9424
- .post(url, {
9425
- completion_options: {
9426
- assign_and_complete: true
9427
- }
9428
- })
9429
- .pipe(operators.catchError(function (error) {
9430
- _this.errorService.setError(error);
9431
- // this will subscribe to get the user details and decide whether to display an error message
9432
- _this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
9433
- _this.handleTaskCompletionError(response);
9434
- });
9435
- return rxjs.throwError(error);
9436
- }));
9437
- };
9438
- /**
9439
- * Handles the response from the observable to get the user details when task is completed.
9440
- * @param response is the response given from the observable which contains the user detaild.
9441
- */
9442
- WorkAllocationService.prototype.handleTaskCompletionError = function (response) {
9443
- var userDetails = response;
9444
- if (this.userIsCaseworker(userDetails.userInfo.roles)) {
9445
- // when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
9446
- this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
9447
- this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
9448
- }
9449
- };
9450
- /**
9451
- * Returns true if the user's role is equivalent to a caseworker.
9452
- * @param roles is the list of roles found from the current user.
9453
- */
9454
- WorkAllocationService.prototype.userIsCaseworker = function (roles) {
9455
- var lowerCaseRoles = roles.map(function (role) { return role.toLowerCase(); });
9456
- // When/if lib & target permanently change to es2016, replace indexOf with includes
9457
- return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
9458
- || (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
9459
- };
9460
- /**
9461
- * Look for open tasks for a case and event combination. There are 5 possible scenarios:
9462
- * 1. No tasks found => Success.
9463
- * 2. One task found => Mark as done => Success.
9464
- * 3. One task found => Mark as done throws error => Failure.
9465
- * 4. More than one task found => Failure.
9466
- * 5. Search call throws an error => Failure.
9467
- * @param ccdId The ID of the case to find tasks for.
9468
- * @param eventId The ID of the event to find tasks for.
9469
- */
9470
- WorkAllocationService.prototype.completeAppropriateTask = function (ccdId, eventId, jurisdiction, caseTypeId) {
9471
- var _this = this;
9472
- if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
9473
- return rxjs.of(null);
9474
- }
9475
- var taskSearchParameter = {
9476
- ccdId: ccdId,
9477
- eventId: eventId,
9478
- jurisdiction: jurisdiction,
9479
- caseTypeId: caseTypeId
9480
- };
9481
- return this.searchTasks(taskSearchParameter)
9482
- .pipe(operators.map(function (response) {
9483
- var tasks = response.tasks;
9484
- if (tasks && tasks.length > 0) {
9485
- if (tasks.length === 1) {
9486
- _this.completeTask(tasks[0].id).subscribe();
9487
- }
9488
- else {
9489
- // This is a problem. Throw an appropriate error.
9490
- throw new Error(MULTIPLE_TASKS_FOUND);
9491
- }
9492
- }
9493
- return true; // All good. Nothing to see here.
9494
- }), operators.catchError(function (error) {
9495
- // Simply rethrow it.
9496
- return rxjs.throwError(error);
9497
- }));
9498
- };
9499
- /**
9500
- * Return tasks for case and event.
9501
- */
9502
- WorkAllocationService.prototype.getTasksByCaseIdAndEventId = function (eventId, caseId, caseType, jurisdiction) {
9503
- var defaultPayload = {
9504
- task_required_for_event: false,
9505
- tasks: []
9506
- };
9507
- if (!this.isWAEnabled()) {
9508
- return rxjs.of(defaultPayload);
9509
- }
9510
- return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/case/tasks/" + caseId + "/event/" + eventId + "/caseType/" + caseType + "/jurisdiction/" + jurisdiction);
9511
- };
9512
- /**
9513
- * Call the API to get a task
9514
- */
9515
- WorkAllocationService.prototype.getTask = function (taskId) {
9516
- if (!this.isWAEnabled()) {
9517
- return rxjs.of({ task: null });
9518
- }
9519
- return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId);
9520
- };
9521
- return WorkAllocationService;
9522
- }());
9523
- WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
9524
- WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
9525
- WorkAllocationService.ɵfac = function WorkAllocationService_Factory(t) { return new (t || WorkAllocationService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(AlertService), i0__namespace.ɵɵinject(SessionStorageService)); };
9526
- WorkAllocationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
9527
- (function () {
9528
- (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(WorkAllocationService, [{
9529
- type: i0.Injectable
9530
- }], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null);
9531
- })();
9532
-
9533
9534
  var CaseEditComponent = /** @class */ (function () {
9534
9535
  function CaseEditComponent(fb, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService) {
9535
9536
  this.fb = fb;
@@ -30726,7 +30727,7 @@
30726
30727
  var _r34_1 = i0__namespace.ɵɵgetCurrentView();
30727
30728
  i0__namespace.ɵɵelementContainerStart(0);
30728
30729
  i0__namespace.ɵɵelementStart(1, "mat-tab-group", 23, 24);
30729
- i0__namespace.ɵɵlistener("selectedTabChange", function CaseFullAccessViewComponent_ng_container_12_Template_mat_tab_group_selectedTabChange_1_listener($event) { i0__namespace.ɵɵrestoreView(_r34_1); var ctx_r33 = i0__namespace.ɵɵnextContext(); return ctx_r33.tabChanged($event); });
30730
+ i0__namespace.ɵɵlistener("selectedIndexChange", function CaseFullAccessViewComponent_ng_container_12_Template_mat_tab_group_selectedIndexChange_1_listener($event) { i0__namespace.ɵɵrestoreView(_r34_1); var ctx_r33 = i0__namespace.ɵɵnextContext(); return ctx_r33.tabChanged($event); });
30730
30731
  i0__namespace.ɵɵtemplate(3, CaseFullAccessViewComponent_ng_container_12_mat_tab_3_Template, 1, 2, "mat-tab", 25);
30731
30732
  i0__namespace.ɵɵtemplate(4, CaseFullAccessViewComponent_ng_container_12_mat_tab_4_Template, 2, 2, "mat-tab", 25);
30732
30733
  i0__namespace.ɵɵtemplate(5, CaseFullAccessViewComponent_ng_container_12_mat_tab_5_Template, 1, 2, "mat-tab", 25);
@@ -30764,6 +30765,7 @@
30764
30765
  this.location = location;
30765
30766
  this.crf = crf;
30766
30767
  this.sessionStorageService = sessionStorageService;
30768
+ this.HEARINGS_TAB_LABEL = 'Hearings';
30767
30769
  this.hasPrint = true;
30768
30770
  this.hasEventSelector = true;
30769
30771
  this.prependedTabs = [];
@@ -30775,6 +30777,7 @@
30775
30777
  this.ignoreWarning = false;
30776
30778
  this.selectedTabIndex = 0;
30777
30779
  this.activeCaseFlags = false;
30780
+ this.subs = [];
30778
30781
  this.callbackErrorsSubject = new rxjs.Subject();
30779
30782
  }
30780
30783
  CaseFullAccessViewComponent.prototype.ngOnInit = function () {
@@ -30827,6 +30830,7 @@
30827
30830
  this.unsubscribe(this.callbackErrorsSubject);
30828
30831
  this.unsubscribe(this.errorSubscription);
30829
30832
  this.unsubscribe(this.subscription);
30833
+ this.subs.forEach(function (s) { return s.unsubscribe(); });
30830
30834
  };
30831
30835
  CaseFullAccessViewComponent.prototype.unsubscribe = function (subscription) {
30832
30836
  if (subscription) {
@@ -30835,19 +30839,22 @@
30835
30839
  };
30836
30840
  CaseFullAccessViewComponent.prototype.checkRouteAndSetCaseViewTab = function () {
30837
30841
  var _this = this;
30838
- this.router.events
30842
+ this.subs.push(this.router.events
30839
30843
  .pipe(operators.filter(function (event) { return event instanceof i1$1.NavigationEnd; }))
30840
30844
  .subscribe(function (event) {
30841
30845
  var url = event && event.url;
30842
30846
  if (url) {
30843
- var tabUrl = url ? url.split('#') : null;
30844
- var tab_1 = tabUrl && tabUrl.length > 1 ? tabUrl[tabUrl.length - 1].replaceAll('%20', ' ') : '';
30845
- var matTab = _this.tabGroup._tabs.find(function (x) { return x.textLabel.toLowerCase() === tab_1.toLowerCase(); });
30846
- if (matTab && matTab.position) {
30847
- _this.tabGroup.selectedIndex = matTab.position;
30847
+ if (url.includes('hearings')) {
30848
+ _this.selectedTabIndex = _this.getTabIndexByTabLabel(_this.tabGroup, 'hearings');
30849
+ }
30850
+ else {
30851
+ var urlFragment = _this.getUrlFragment(url);
30852
+ var tabLabel = decodeURIComponent(urlFragment);
30853
+ var tabIndex = _this.getTabIndexByTabLabel(_this.tabGroup, tabLabel);
30854
+ _this.selectedTabIndex = tabIndex;
30848
30855
  }
30849
30856
  }
30850
- });
30857
+ }));
30851
30858
  };
30852
30859
  CaseFullAccessViewComponent.prototype.postViewActivity = function () {
30853
30860
  return this.activityPollingService.postViewActivity(this.caseDetails.case_id);
@@ -30971,22 +30978,19 @@
30971
30978
  }
30972
30979
  }
30973
30980
  };
30974
- CaseFullAccessViewComponent.prototype.tabChanged = function (tabChangeEvent) {
30975
- // Update selected tab index
30976
- this.selectedTabIndex = tabChangeEvent.index;
30977
- var tab = tabChangeEvent.tab['_viewContainerRef'];
30978
- var id = tab.element.nativeElement.id;
30979
- // due to some edge case like hidden tab we can't calculate the last index of existing tabs,
30980
- // so have to hard code the hearings id here
30981
- if ((tabChangeEvent.index <= 1 && this.prependedTabs && this.prependedTabs.length) ||
30982
- (this.appendedTabs && this.appendedTabs.length && id === 'hearings')) {
30983
- this.router.navigate([id], { relativeTo: this.route });
30981
+ CaseFullAccessViewComponent.prototype.tabChanged = function (tabIndexChanged) {
30982
+ // Refactored under EXUI-110 to address infinite tab loop
30983
+ var matTab = this.tabGroup._tabs.find(function (tab) { return tab.isActive; });
30984
+ var tabLabel = matTab.textLabel;
30985
+ // if hearings tab don't use fragment for navigation
30986
+ if ((tabIndexChanged <= 1 && this.prependedTabs && this.prependedTabs.length) ||
30987
+ (this.appendedTabs && this.appendedTabs.length && tabLabel === this.HEARINGS_TAB_LABEL)) {
30988
+ // cases/case-details/:caseId/hearings
30989
+ this.router.navigate([tabLabel.toLowerCase()], { relativeTo: this.route });
30984
30990
  }
30985
30991
  else {
30986
- var label_1 = tabChangeEvent.tab.textLabel;
30987
- this.router.navigate(['cases', 'case-details', this.caseDetails.case_id]).then(function () {
30988
- window.location.hash = label_1;
30989
- });
30992
+ // cases/case-details/:caseId#tabLabel
30993
+ this.router.navigate(['cases', 'case-details', this.caseDetails.case_id], { fragment: tabLabel });
30990
30994
  }
30991
30995
  };
30992
30996
  CaseFullAccessViewComponent.prototype.onLinkClicked = function (triggerOutputEventText) {
@@ -31084,6 +31088,12 @@
31084
31088
  this.callbackErrorsSubject.next(null);
31085
31089
  this.alertService.clear();
31086
31090
  };
31091
+ CaseFullAccessViewComponent.prototype.getUrlFragment = function (url) {
31092
+ return url.split('#')[url.split('#').length - 1];
31093
+ };
31094
+ CaseFullAccessViewComponent.prototype.getTabIndexByTabLabel = function (tabGroup, tabLabel) {
31095
+ return tabGroup._tabs.toArray().findIndex(function (t) { return t.textLabel.toLowerCase() === tabLabel.toLowerCase(); });
31096
+ };
31087
31097
  return CaseFullAccessViewComponent;
31088
31098
  }());
31089
31099
  CaseFullAccessViewComponent.ORIGIN_QUERY_PARAM = 'origin';
@@ -31100,7 +31110,7 @@
31100
31110
  var _t = void 0;
31101
31111
  i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.tabGroup = _t.first);
31102
31112
  }
31103
- }, inputs: { hasPrint: "hasPrint", hasEventSelector: "hasEventSelector", caseDetails: "caseDetails", prependedTabs: "prependedTabs", appendedTabs: "appendedTabs" }, features: [i0__namespace.ɵɵNgOnChangesFeature], decls: 13, vars: 12, consts: [["class", "error-summary", "role", "group", "aria-labelledby", "edit-case-event_error-summary-heading", "tabindex", "-1", 4, "ngIf"], [3, "triggerTextContinue", "triggerTextIgnore", "callbackErrorsSubject", "callbackErrorsContext"], [3, "caseId", "displayMode"], [1, "grid-row"], [1, "column-one-half"], [3, "caseDetails"], ["class", "case-viewer-controls", 4, "ngIf"], ["class", "column-one-half", 4, "ngIf"], ["class", "grid-row", 4, "ngIf"], [1, "column-full"], [4, "ngIf"], ["role", "group", "aria-labelledby", "edit-case-event_error-summary-heading", "tabindex", "-1", 1, "error-summary"], ["id", "edit-case-event_error-summary-heading", 1, "heading-h1", "error-summary-heading"], ["id", "edit-case-event_error-summary-body", 1, "govuk-error-summary__body"], ["href", "get-help", "target", "_blank"], ["id", "edit-case-event_error-summary-heading", 1, "heading-h2", "error-summary-heading"], ["class", "error-summary-list", 4, "ngIf"], [1, "error-summary-list"], [4, "ngFor", "ngForOf"], [1, "case-viewer-controls"], ["id", "case-viewer-control-print", "routerLink", "print", 1, "button", "button-secondary"], [3, "isDisabled", "triggers", "triggerText", "onTriggerChange", "onTriggerSubmit"], [3, "notificationBannerConfig", "linkClicked"], ["animationDuration", "0ms", 3, "disableRipple", "selectedIndex", "selectedTabChange"], ["tabGroup", ""], [3, "id", "label", 4, "ngFor", "ngForOf"], [3, "id", "label"], ["matTabContent", ""], ["aria-describedby", "case viewer table"], ["ccdLabelSubstitutor", "", 3, "caseField", "contextFields", "hidden"], [3, "ngSwitch"], [4, "ngSwitchCase"], ["class", "compound-field", 4, "ngSwitchCase"], ["id", "case-viewer-field-label", 4, "ngIf"], ["scope", "col", 3, "id"], [1, "text-16"], [3, "topLevelFormGroup", "caseField", "caseReference", "markdownUseHrefAsRouterLink"], ["id", "case-viewer-field-label"], [1, "case-viewer-label", "text-16"], [1, "compound-field"]], template: function CaseFullAccessViewComponent_Template(rf, ctx) {
31113
+ }, inputs: { hasPrint: "hasPrint", hasEventSelector: "hasEventSelector", caseDetails: "caseDetails", prependedTabs: "prependedTabs", appendedTabs: "appendedTabs" }, features: [i0__namespace.ɵɵNgOnChangesFeature], decls: 13, vars: 12, consts: [["class", "error-summary", "role", "group", "aria-labelledby", "edit-case-event_error-summary-heading", "tabindex", "-1", 4, "ngIf"], [3, "triggerTextContinue", "triggerTextIgnore", "callbackErrorsSubject", "callbackErrorsContext"], [3, "caseId", "displayMode"], [1, "grid-row"], [1, "column-one-half"], [3, "caseDetails"], ["class", "case-viewer-controls", 4, "ngIf"], ["class", "column-one-half", 4, "ngIf"], ["class", "grid-row", 4, "ngIf"], [1, "column-full"], [4, "ngIf"], ["role", "group", "aria-labelledby", "edit-case-event_error-summary-heading", "tabindex", "-1", 1, "error-summary"], ["id", "edit-case-event_error-summary-heading", 1, "heading-h1", "error-summary-heading"], ["id", "edit-case-event_error-summary-body", 1, "govuk-error-summary__body"], ["href", "get-help", "target", "_blank"], ["id", "edit-case-event_error-summary-heading", 1, "heading-h2", "error-summary-heading"], ["class", "error-summary-list", 4, "ngIf"], [1, "error-summary-list"], [4, "ngFor", "ngForOf"], [1, "case-viewer-controls"], ["id", "case-viewer-control-print", "routerLink", "print", 1, "button", "button-secondary"], [3, "isDisabled", "triggers", "triggerText", "onTriggerChange", "onTriggerSubmit"], [3, "notificationBannerConfig", "linkClicked"], ["animationDuration", "0ms", 3, "disableRipple", "selectedIndex", "selectedIndexChange"], ["tabGroup", ""], [3, "id", "label", 4, "ngFor", "ngForOf"], [3, "id", "label"], ["matTabContent", ""], ["aria-describedby", "case viewer table"], ["ccdLabelSubstitutor", "", 3, "caseField", "contextFields", "hidden"], [3, "ngSwitch"], [4, "ngSwitchCase"], ["class", "compound-field", 4, "ngSwitchCase"], ["id", "case-viewer-field-label", 4, "ngIf"], ["scope", "col", 3, "id"], [1, "text-16"], [3, "topLevelFormGroup", "caseField", "caseReference", "markdownUseHrefAsRouterLink"], ["id", "case-viewer-field-label"], [1, "case-viewer-label", "text-16"], [1, "compound-field"]], template: function CaseFullAccessViewComponent_Template(rf, ctx) {
31104
31114
  if (rf & 1) {
31105
31115
  i0__namespace.ɵɵtemplate(0, CaseFullAccessViewComponent_div_0_Template, 10, 0, "div", 0);
31106
31116
  i0__namespace.ɵɵtemplate(1, CaseFullAccessViewComponent_div_1_Template, 6, 2, "div", 0);