@hmcts/ccd-case-ui-toolkit 6.14.5-testing → 6.14.6-infinite-tab-loop-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.
@@ -30730,7 +30730,7 @@
30730
30730
  var _r34_1 = i0__namespace.ɵɵgetCurrentView();
30731
30731
  i0__namespace.ɵɵelementContainerStart(0);
30732
30732
  i0__namespace.ɵɵelementStart(1, "mat-tab-group", 23, 24);
30733
- 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); });
30733
+ 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); });
30734
30734
  i0__namespace.ɵɵtemplate(3, CaseFullAccessViewComponent_ng_container_12_mat_tab_3_Template, 1, 2, "mat-tab", 25);
30735
30735
  i0__namespace.ɵɵtemplate(4, CaseFullAccessViewComponent_ng_container_12_mat_tab_4_Template, 2, 2, "mat-tab", 25);
30736
30736
  i0__namespace.ɵɵtemplate(5, CaseFullAccessViewComponent_ng_container_12_mat_tab_5_Template, 1, 2, "mat-tab", 25);
@@ -30768,6 +30768,7 @@
30768
30768
  this.location = location;
30769
30769
  this.crf = crf;
30770
30770
  this.sessionStorageService = sessionStorageService;
30771
+ this.HEARINGS_TAB_LABEL = 'Hearings';
30771
30772
  this.hasPrint = true;
30772
30773
  this.hasEventSelector = true;
30773
30774
  this.prependedTabs = [];
@@ -30779,6 +30780,7 @@
30779
30780
  this.ignoreWarning = false;
30780
30781
  this.selectedTabIndex = 0;
30781
30782
  this.activeCaseFlags = false;
30783
+ this.subs = [];
30782
30784
  this.callbackErrorsSubject = new rxjs.Subject();
30783
30785
  }
30784
30786
  CaseFullAccessViewComponent.prototype.ngOnInit = function () {
@@ -30831,6 +30833,7 @@
30831
30833
  this.unsubscribe(this.callbackErrorsSubject);
30832
30834
  this.unsubscribe(this.errorSubscription);
30833
30835
  this.unsubscribe(this.subscription);
30836
+ this.subs.forEach(function (s) { return s.unsubscribe(); });
30834
30837
  };
30835
30838
  CaseFullAccessViewComponent.prototype.unsubscribe = function (subscription) {
30836
30839
  if (subscription) {
@@ -30839,7 +30842,7 @@
30839
30842
  };
30840
30843
  CaseFullAccessViewComponent.prototype.checkRouteAndSetCaseViewTab = function () {
30841
30844
  var _this = this;
30842
- this.router.events
30845
+ this.subs.push(this.router.events
30843
30846
  .pipe(operators.filter(function (event) { return event instanceof i1$1.NavigationEnd; }))
30844
30847
  .subscribe(function (event) {
30845
30848
  var url = event && event.url;
@@ -30851,8 +30854,9 @@
30851
30854
  _this.tabGroup.selectedIndex = matTab.position;
30852
30855
  }
30853
30856
  }
30854
- });
30857
+ }));
30855
30858
  };
30859
+ ;
30856
30860
  CaseFullAccessViewComponent.prototype.postViewActivity = function () {
30857
30861
  return this.activityPollingService.postViewActivity(this.caseDetails.case_id);
30858
30862
  };
@@ -30975,22 +30979,25 @@
30975
30979
  }
30976
30980
  }
30977
30981
  };
30978
- CaseFullAccessViewComponent.prototype.tabChanged = function (tabChangeEvent) {
30979
- // Update selected tab index
30980
- this.selectedTabIndex = tabChangeEvent.index;
30981
- var tab = tabChangeEvent.tab['_viewContainerRef'];
30982
- var id = tab.element.nativeElement.id;
30983
- // due to some edge case like hidden tab we can't calculate the last index of existing tabs,
30984
- // so have to hard code the hearings id here
30985
- if ((tabChangeEvent.index <= 1 && this.prependedTabs && this.prependedTabs.length) ||
30986
- (this.appendedTabs && this.appendedTabs.length && id === 'hearings')) {
30982
+ // Refactored under EXUI-110 to address infinite tab loop to use tabIndexChanged instead
30983
+ CaseFullAccessViewComponent.prototype.tabChanged = function (tabIndexChanged) {
30984
+ var matTab = this.tabGroup._tabs.find(function (tab) { return tab.isActive; });
30985
+ var tabLabel = matTab.textLabel;
30986
+ // sortedTabs are fragments
30987
+ // appended/prepepended tabs use router navigation
30988
+ if ((tabIndexChanged <= 1 && this.prependedTabs && this.prependedTabs.length) ||
30989
+ (this.appendedTabs && this.appendedTabs.length && tabLabel === this.HEARINGS_TAB_LABEL)) {
30990
+ // Hack to get ID from tab as it's not easily achieved through Angular Material Tabs
30991
+ var tab = matTab['_viewContainerRef'];
30992
+ var id = tab.element.nativeElement.id;
30993
+ // cases/case-details/:caseId/hearings
30994
+ // cases/case-details/:caseId/roles-and-access
30987
30995
  this.router.navigate([id], { relativeTo: this.route });
30988
30996
  }
30989
30997
  else {
30990
- var label_1 = tabChangeEvent.tab.textLabel;
30991
- this.router.navigate(['cases', 'case-details', this.caseDetails.case_id]).then(function () {
30992
- window.location.hash = label_1;
30993
- });
30998
+ // Routing here is based on tab label, not ideal
30999
+ // cases/case-details/:caseId#tabLabel
31000
+ this.router.navigate(['cases', 'case-details', this.caseDetails.case_id], { fragment: tabLabel });
30994
31001
  }
30995
31002
  };
30996
31003
  CaseFullAccessViewComponent.prototype.onLinkClicked = function (triggerOutputEventText) {
@@ -31088,6 +31095,12 @@
31088
31095
  this.callbackErrorsSubject.next(null);
31089
31096
  this.alertService.clear();
31090
31097
  };
31098
+ CaseFullAccessViewComponent.prototype.getUrlFragment = function (url) {
31099
+ return url.split('#')[url.split('#').length - 1];
31100
+ };
31101
+ CaseFullAccessViewComponent.prototype.getTabIndexByTabLabel = function (tabGroup, tabLabel) {
31102
+ return tabGroup._tabs.toArray().findIndex(function (t) { return t.textLabel.toLowerCase() === tabLabel.toLowerCase(); });
31103
+ };
31091
31104
  return CaseFullAccessViewComponent;
31092
31105
  }());
31093
31106
  CaseFullAccessViewComponent.ORIGIN_QUERY_PARAM = 'origin';
@@ -31104,7 +31117,7 @@
31104
31117
  var _t = void 0;
31105
31118
  i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.tabGroup = _t.first);
31106
31119
  }
31107
- }, 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) {
31120
+ }, 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) {
31108
31121
  if (rf & 1) {
31109
31122
  i0__namespace.ɵɵtemplate(0, CaseFullAccessViewComponent_div_0_Template, 10, 0, "div", 0);
31110
31123
  i0__namespace.ɵɵtemplate(1, CaseFullAccessViewComponent_div_1_Template, 6, 2, "div", 0);