@hmcts/ccd-case-ui-toolkit 4.12.0 → 4.12.1

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.
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @hmcts/ccd-case-ui-toolkit - Case UI Toolkit
3
- * @version v4.12.0
3
+ * @version v4.12.1
4
4
  * @link undefined
5
5
  * @license MIT
6
6
  */
@@ -23584,16 +23584,33 @@ var CaseFullAccessViewComponent = /** @class */ (function () {
23584
23584
  var matTab;
23585
23585
  var url = this.location.path(true);
23586
23586
  var hashValue = url.substring(url.indexOf('#') + 1);
23587
- // if we have prepended tabs route to one of the prepended tabs
23588
- if (!url.includes('#') && this.prependedTabs && this.prependedTabs.length) {
23587
+ if (!url.includes('#')) {
23589
23588
  var paths = url.split('/');
23590
- var tabName_1 = decodeURIComponent(paths[paths.length - 1]);
23591
- var selectedTab_1 = this.prependedTabs.find(function (caseTab) { return caseTab.id.toLowerCase() === tabName_1.toLowerCase(); });
23592
- var tab = selectedTab_1 ? selectedTab_1.id : 'tasks';
23593
- this.router.navigate(['cases', 'case-details', this.caseDetails.case_id, tab]).then(function () {
23594
- matTab = _this.tabGroup._tabs.find(function (x) { return x.textLabel === selectedTab_1.label; });
23595
- _this.tabGroup.selectedIndex = matTab.position;
23596
- });
23589
+ // lastPath can be /caseId, or the tabs /tasks, /hearings etc.
23590
+ var lastPath_1 = decodeURIComponent(paths[paths.length - 1]);
23591
+ var foundTab_1 = null;
23592
+ var additionalTabs = this.prependedTabs.concat(this.appendedTabs);
23593
+ if (additionalTabs && additionalTabs.length) {
23594
+ foundTab_1 = additionalTabs.find(function (caseTab) { return caseTab.id.toLowerCase() === lastPath_1.toLowerCase(); });
23595
+ }
23596
+ // found tasks or hearing tab
23597
+ if (foundTab_1) {
23598
+ this.router.navigate(['cases', 'case-details', this.caseDetails.case_id, foundTab_1.id]).then(function () {
23599
+ matTab = _this.tabGroup._tabs.find(function (x) { return x.textLabel === foundTab_1.label; });
23600
+ _this.tabGroup.selectedIndex = matTab.position;
23601
+ });
23602
+ // last path is caseId
23603
+ }
23604
+ else {
23605
+ // sort with the order of CCD predefined tabs
23606
+ this.caseDetails.tabs.sort(function (aTab, bTab) { return aTab.order > bTab.order ? 1 : (bTab.order > aTab.order ? -1 : 0); });
23607
+ // preselect the 1st order of CCD predefined tabs
23608
+ var preSelectTab_1 = this.caseDetails.tabs[0];
23609
+ this.router.navigate(['cases', 'case-details', this.caseDetails.case_id]).then(function () {
23610
+ matTab = _this.tabGroup._tabs.find(function (x) { return x.textLabel === preSelectTab_1.label; });
23611
+ _this.tabGroup.selectedIndex = matTab.position;
23612
+ });
23613
+ }
23597
23614
  }
23598
23615
  else {
23599
23616
  var regExp = new RegExp(CaseFullAccessViewComponent_1.UNICODE_SPACE, 'g');