diff --git a/src/app/modules/admin/components/manage-session/manage-session.component.ts b/src/app/modules/admin/components/manage-session/manage-session.component.ts index e63b97d0..da7344c7 100644 --- a/src/app/modules/admin/components/manage-session/manage-session.component.ts +++ b/src/app/modules/admin/components/manage-session/manage-session.component.ts @@ -171,7 +171,7 @@ export class ManageSessionComponent implements OnInit { modal.onDidDismiss().then(async (dataReturned) => { this.filteredDatas = [] - if (dataReturned !== null) { + if (dataReturned.data && dataReturned.data.data) { if (dataReturned.data.data.selectedFilters) { for (let key in dataReturned.data.data.selectedFilters) { this.filteredDatas[key] = dataReturned.data.data.selectedFilters[key].slice(0, dataReturned.data.data.selectedFilters[key].length).map(obj => obj.value).join(',').toString() diff --git a/src/app/pages/home-search/home-search.page.html b/src/app/pages/home-search/home-search.page.html index b0c05cd8..f1758332 100644 --- a/src/app/pages/home-search/home-search.page.html +++ b/src/app/pages/home-search/home-search.page.html @@ -24,7 +24,7 @@ *ngFor="let chip of overlayChips; let i = index" (click)="selectChip(chip)" [ngClass]="{'selected-chip': criteriaChip?.label === chip.label}"> - + {{ chip.label }} @@ -33,16 +33,16 @@ - +
- {{criteriaChip?.label}} + {{showSelectedCriteria?.label}}
-

+

diff --git a/src/app/pages/home-search/home-search.page.ts b/src/app/pages/home-search/home-search.page.ts index 9158cb39..5dfbc71f 100644 --- a/src/app/pages/home-search/home-search.page.ts +++ b/src/app/pages/home-search/home-search.page.ts @@ -50,6 +50,7 @@ export class HomeSearchPage implements OnInit { pageSize: any; searchTextSubscription: Subscription; criteriaChipSubscription: Subscription; + showSelectedCriteria: any; constructor(private modalCtrl: ModalController, private router: Router, private toast: ToastService, private sessionService: SessionService, @@ -66,7 +67,7 @@ export class HomeSearchPage implements OnInit { this.searchText = searchText; }); this.criteriaChipSubscription = this.utilService.currentCriteriaChip.subscribe(selectedCriteria => { - this.criteriaChip = JSON.parse(selectedCriteria); + this.criteriaChip = selectedCriteria ? JSON.parse(selectedCriteria) : ""; }); this.user = this.localStorage.getLocalData(localKeys.USER_DETAILS) this.fetchSessionList() @@ -76,6 +77,7 @@ export class HomeSearchPage implements OnInit { } async ionViewWillEnter() { + this.showSelectedCriteria = this.criteriaChip? this.criteriaChip : ""; const obj = {filterType: 'session', org: false}; let data = await this.formService.filterList(obj); this.filterData = await this.utilService.transformToFilterData(data, obj); @@ -84,6 +86,7 @@ export class HomeSearchPage implements OnInit { search(event) { if (event.length >= 3) { this.searchText = event; + this.showSelectedCriteria = this.criteriaChip; this.isOpen = false; this.fetchSessionList() } else { @@ -187,14 +190,16 @@ export class HomeSearchPage implements OnInit { closeCriteriaChip(){ this.criteriaChip = null; + this.showSelectedCriteria = null; this.router.navigate(['/' + CommonRoutes.HOME_SEARCH], { queryParams: {searchString : this.searchText} }); - this.fetchSessionList() } selectChip(chip) { - this.criteriaChip = chip; - this.fetchSessionList() - this.isOpen = false; + if (this.criteriaChip === chip) { + this.criteriaChip = null; + } else { + this.criteriaChip = chip; + } } getUrlQueryData() { @@ -227,6 +232,12 @@ export class HomeSearchPage implements OnInit { } } } + + ionViewWillLeave(){ + this.searchText = ""; + this.criteriaChip = ""; + this.chips = []; + } ngOnDestroy() { this.searchTextSubscription.unsubscribe(); diff --git a/src/app/pages/mentor-search-directory/mentor-search-directory.page.html b/src/app/pages/mentor-search-directory/mentor-search-directory.page.html index 4fcc4caf..1f98b2a2 100644 --- a/src/app/pages/mentor-search-directory/mentor-search-directory.page.html +++ b/src/app/pages/mentor-search-directory/mentor-search-directory.page.html @@ -22,7 +22,7 @@ *ngFor="let chip of overlayChips; let i = index" (click)="selectChip(chip)" [ngClass]="{'selected-chip': selectedChipLabel === chip.label}"> - + {{ chip.label }} @@ -32,16 +32,16 @@ - +
- {{selectedChipLabel}} + {{showSelectedCriteria}}
-

+

diff --git a/src/app/pages/mentor-search-directory/mentor-search-directory.page.ts b/src/app/pages/mentor-search-directory/mentor-search-directory.page.ts index 4ad92968..8476e4f6 100644 --- a/src/app/pages/mentor-search-directory/mentor-search-directory.page.ts +++ b/src/app/pages/mentor-search-directory/mentor-search-directory.page.ts @@ -42,6 +42,7 @@ export class MentorSearchDirectoryPage implements OnInit { totalCount: any; limit: any; chips = []; + showSelectedCriteria: any; constructor( private router: Router, @@ -66,6 +67,7 @@ export class MentorSearchDirectoryPage implements OnInit { onSearch(event){ if (event.length >= 3) { this.searchText = event; + this.showSelectedCriteria = this.selectedChipLabel; this.getMentors(); } else { this.toast.showToast("ENTER_MIN_CHARACTER","danger"); @@ -73,23 +75,25 @@ export class MentorSearchDirectoryPage implements OnInit { } selectChip(chip) { - this.selectedChipLabel = chip.label; - this.selectedChipName = chip.name; - this.isOpen = false; - this.getMentors() + if (this.selectedChipLabel === chip.label) { + this.selectedChipLabel = null; + this.selectedChipName = null; + } else { + this.selectedChipLabel = chip.label; + this.selectedChipName = chip.name; + } } closeCriteriaChip(){ this.selectedChipLabel = ""; this.selectedChipName = ""; - this.getMentors() + this.showSelectedCriteria = ""; } removeChip(chip: string,index: number) { this.chips.splice(index, 1); this.removeFilteredData(chip) this.getUrlQueryData(); - this.getMentors() } async onClickFilter() { @@ -175,8 +179,11 @@ export class MentorSearchDirectoryPage implements OnInit { async getMentors(){ var obj = {page: this.page, pageSize: this.pageSize, searchText: this.searchText.trim(), selectedChip: this.selectedChipName, urlQueryData: this.urlQueryData}; let data = await this.profileService.getMentors(true,obj); - this.data = data.result.data; - this.totalCount = data.result.count; + if(data && data.result){ + this.isOpen = false; + this.data = data.result.data; + this.totalCount = data.result.count; + } } } diff --git a/src/app/pages/tabs/dashboard/dashboard.page.ts b/src/app/pages/tabs/dashboard/dashboard.page.ts index 4cf5f8bd..e78aaca1 100644 --- a/src/app/pages/tabs/dashboard/dashboard.page.ts +++ b/src/app/pages/tabs/dashboard/dashboard.page.ts @@ -41,14 +41,13 @@ export class DashboardPage implements OnInit { private profile: ProfileService, private apiService: HttpService) { } - ngOnInit() { + ngOnInit() { } + + ionViewWillEnter() { this.isMentor = this.profile.isMentor; this.segment = this.isMentor ? "mentor" : "mentee"; this.dataAvailable = true; this.getReports(); - } - - ionViewWillEnter() { this.gotToTop(); } diff --git a/src/app/shared/components/filter-tree/filter-tree.component.ts b/src/app/shared/components/filter-tree/filter-tree.component.ts index 7c9ad2a8..8afde640 100644 --- a/src/app/shared/components/filter-tree/filter-tree.component.ts +++ b/src/app/shared/components/filter-tree/filter-tree.component.ts @@ -11,17 +11,18 @@ export class FilterTreeComponent implements OnInit { @Input() filterData: any; @Output() filtersChanged = new EventEmitter(); - ogArrObj: any; constructor() { } - ngOnInit() { - this.ogArrObj = _.cloneDeep(this.filterData); - } + ngOnInit() { } clearAll() { - this.filterData = _.cloneDeep(this.ogArrObj) + if (this.filterData) { + this.filterData.forEach(filter => + filter.options = filter.options.map(option => ({ ...option, selected: false })) + ); + } this.filtersChanged.emit([]) }