Skip to content

Commit

Permalink
Merge pull request #343 from KnowWhereGraph/tabname_fix
Browse files Browse the repository at this point in the history
Update the tab name when tabs are clicked
  • Loading branch information
ThomasThelen authored Jun 14, 2023
2 parents 18a6916 + f00bff5 commit 019c203
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/facets/facets.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
border-radius: 0 5px 5px 0;
color: #fff;
cursor: pointer;
width: 30%
width: 30%;
}

.facet {
Expand Down
16 changes: 11 additions & 5 deletions src/app/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Component, OnInit, ChangeDetectorRef, ViewChild } from '@angular/core'
import { MatTabChangeEvent } from '@angular/material/tabs'
import { MatDialog, MatDialogConfig } from '@angular/material/dialog'
import { ErrorModalComponent } from '../error-modal/error-modal.component'
import { Location } from '@angular/common'

/**
* A component that represents the main search page. It controls the logic for handling tab switching (ie clicking 'People', 'Places' or 'Hazards).
* A component that represents the main search page. It controls the logic for handling tab switching (ie clicking 'Persons', 'Places' or 'Hazards).
* Based on the tab clicked, it renders the appropriate table component.
*/
@Component({
Expand Down Expand Up @@ -38,7 +39,7 @@ export class SearchComponent implements OnInit {
// Reference to the hazards table
@ViewChild('hazardsTable')
public hazardsTable: any
// Reference people table
// Reference persons table
@ViewChild('peopleTable')
public peopleTable: any
// Reference to the facets component
Expand Down Expand Up @@ -74,16 +75,20 @@ export class SearchComponent implements OnInit {
* @param cd The change detector reference to catch events
* @param route: The activated route for this page
* @param router: The global router
* @param errorModal: A reference to the error modal dialog
* @param location: Angular's 'Location' object for this path
*/
constructor(
private cd: ChangeDetectorRef,
private route: ActivatedRoute,
private router: Router,
private errorModal: MatDialog
private errorModal: MatDialog,
private location: Location
) {
this.totalSize = 0
this.isCounting = true
this.isSearching = true
this.location = location
}

/**
Expand Down Expand Up @@ -140,9 +145,10 @@ export class SearchComponent implements OnInit {
clickedTabName = 'hazard'
break
case 2:
clickedTabName = 'people'
clickedTabName = 'person'
}
//const queryParams = { tab: clickedTabName };
const queryParams = { tab: clickedTabName }
this.location.replaceState(`search?tab=${clickedTabName}`)
}

/**
Expand Down

0 comments on commit 019c203

Please sign in to comment.