From 5cbbbba0c4ac3dc9b48f883fe8cdffc0d243898d Mon Sep 17 00:00:00 2001 From: Rahul K R Date: Thu, 18 Jul 2024 16:38:39 +0530 Subject: [PATCH 1/2] BUG fix 1477 --- src/app/core/services/util/util.service.ts | 14 ++++++-- .../pages/home-search/home-search.page.html | 4 ++- src/app/pages/home-search/home-search.page.ts | 36 ++++++++++++------- .../mentor-search-directory.page.html | 3 +- .../mentor-search-directory.page.ts | 14 +++++--- src/app/pages/tabs/home/home.page.ts | 16 +++++---- src/assets/i18n/en.json | 3 +- 7 files changed, 62 insertions(+), 28 deletions(-) diff --git a/src/app/core/services/util/util.service.ts b/src/app/core/services/util/util.service.ts index bdd8ab7e..5245635c 100644 --- a/src/app/core/services/util/util.service.ts +++ b/src/app/core/services/util/util.service.ts @@ -6,9 +6,8 @@ import { environment } from 'src/environments/environment'; import { ISocialSharing } from '../../interface/soical-sharing-interface'; import { ModelComponent } from 'src/app/shared/components/model/model.component'; import * as Bowser from "bowser" -import { Subject } from 'rxjs'; +import { BehaviorSubject, Subject } from 'rxjs'; import * as Papa from 'papaparse'; -import { localKeys } from '../../constants/localStorage.keys'; import { LocalStorageService } from '../localstorage.service'; @Injectable({ @@ -17,6 +16,10 @@ import { LocalStorageService } from '../localstorage.service'; export class UtilService { modal: any; public canIonMenuShow = new Subject(); + private searchTextSource = new BehaviorSubject(''); + private criteriaChipSource = new BehaviorSubject(''); + currentSearchText = this.searchTextSource.asObservable(); + currentCriteriaChip = this.criteriaChipSource.asObservable(); ionMenuShow(data:boolean) { this.canIonMenuShow.next(data); @@ -264,5 +267,12 @@ export class UtilService { const data = [...filterData, ...result] return data; } + + subscribeSearchText(searchText: string) { + this.searchTextSource.next(searchText); + } + subscribeCriteriaChip(criteriaChip: string) { + this.criteriaChipSource.next(criteriaChip); + } } diff --git a/src/app/pages/home-search/home-search.page.html b/src/app/pages/home-search/home-search.page.html index a845556a..b0c05cd8 100644 --- a/src/app/pages/home-search/home-search.page.html +++ b/src/app/pages/home-search/home-search.page.html @@ -1,6 +1,8 @@
-
diff --git a/src/app/pages/home-search/home-search.page.ts b/src/app/pages/home-search/home-search.page.ts index 69ea6d26..9158cb39 100644 --- a/src/app/pages/home-search/home-search.page.ts +++ b/src/app/pages/home-search/home-search.page.ts @@ -11,6 +11,7 @@ import { ProfileService } from 'src/app/core/services/profile/profile.service'; import { Location } from '@angular/common'; import { PermissionService } from 'src/app/core/services/permission/permission.service'; import { FormService } from 'src/app/core/services/form/form.service'; +import { Subscription } from 'rxjs'; @Component({ selector: 'app-home-search', @@ -43,30 +44,30 @@ export class HomeSearchPage implements OnInit { criteriaChip: any; chips =[] criteriaChipName: any; - params: any; overlayChips: any; isOpen = false; urlQueryData: string; pageSize: any; + searchTextSubscription: Subscription; + criteriaChipSubscription: Subscription; constructor(private modalCtrl: ModalController, private router: Router, private toast: ToastService, private sessionService: SessionService, private localStorage: LocalStorageService, private profileService: ProfileService, private location: Location, - private activatedRoute: ActivatedRoute, private permissionService: PermissionService, private formService: FormService, - private utilService: UtilService - ) { - this.activatedRoute.queryParamMap.subscribe(async (params) => { - this.params = params; - this.criteriaChip = JSON.parse(params.get('criteriaChip')); - this.searchText = this.params.get('searchString'); - }) - } + private utilService: UtilService, + ) { } async ngOnInit() { + this.searchTextSubscription = this.utilService.currentSearchText.subscribe(searchText => { + this.searchText = searchText; + }); + this.criteriaChipSubscription = this.utilService.currentCriteriaChip.subscribe(selectedCriteria => { + this.criteriaChip = JSON.parse(selectedCriteria); + }); this.user = this.localStorage.getLocalData(localKeys.USER_DETAILS) this.fetchSessionList() this.permissionService.getPlatformConfig().then((config)=>{ @@ -81,9 +82,13 @@ export class HomeSearchPage implements OnInit { } search(event) { - this.searchText = event; - this.isOpen = false; - this.fetchSessionList() + if (event.length >= 3) { + this.searchText = event; + this.isOpen = false; + this.fetchSessionList() + } else { + this.toast.showToast("ENTER_MIN_CHARACTER","danger"); + } } async onClickFilter() { @@ -222,4 +227,9 @@ export class HomeSearchPage implements OnInit { } } } + + ngOnDestroy() { + this.searchTextSubscription.unsubscribe(); + this.criteriaChipSubscription.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 f47d65ce..4fcc4caf 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 @@ -1,7 +1,8 @@
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 71b1dc39..4ad92968 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 @@ -3,7 +3,7 @@ import { MatPaginator } from '@angular/material/paginator'; import { Router } from '@angular/router'; import { ModalController } from '@ionic/angular'; import { paginatorConstants } from 'src/app/core/constants/paginatorConstants'; -import { UtilService } from 'src/app/core/services'; +import { ToastService, UtilService } from 'src/app/core/services'; import { FormService } from 'src/app/core/services/form/form.service'; import { PermissionService } from 'src/app/core/services/permission/permission.service'; import { ProfileService } from 'src/app/core/services/profile/profile.service'; @@ -49,7 +49,8 @@ export class MentorSearchDirectoryPage implements OnInit { private modalCtrl: ModalController, private permissionService: PermissionService, private formService: FormService, - private utilService: UtilService + private utilService: UtilService, + private toast: ToastService ) { } async ngOnInit() { @@ -62,8 +63,13 @@ export class MentorSearchDirectoryPage implements OnInit { this.filterData = await this.utilService.transformToFilterData(data, obj); } - onSearch(){ - this.getMentors() + onSearch(event){ + if (event.length >= 3) { + this.searchText = event; + this.getMentors(); + } else { + this.toast.showToast("ENTER_MIN_CHARACTER","danger"); + } } selectChip(chip) { diff --git a/src/app/pages/tabs/home/home.page.ts b/src/app/pages/tabs/home/home.page.ts index 45b45ea9..91e31444 100644 --- a/src/app/pages/tabs/home/home.page.ts +++ b/src/app/pages/tabs/home/home.page.ts @@ -2,13 +2,12 @@ import { HttpClient } from '@angular/common/http'; import { Component, OnInit, ViewChild } from '@angular/core'; import { JsonFormData } from 'src/app/shared/components/dynamic-form/dynamic-form.component'; import { CommonRoutes } from 'src/global.routes'; -import { ModalController, NavController, Platform, IonContent } from '@ionic/angular'; +import { ModalController, NavController, IonContent } from '@ionic/angular'; import { SKELETON } from 'src/app/core/constants/skeleton.constant'; import { Router } from '@angular/router'; import { localKeys } from 'src/app/core/constants/localStorage.keys'; import { ProfileService } from 'src/app/core/services/profile/profile.service'; import { HttpService, LoaderService, LocalStorageService, ToastService, UserService, UtilService } from 'src/app/core/services'; -import { urlConstants } from 'src/app/core/constants/urlConstants'; import { SessionService } from 'src/app/core/services/session/session.service'; import { TermsAndConditionsPage } from '../../terms-and-conditions/terms-and-conditions.page'; import { App, AppState } from '@capacitor/app'; @@ -63,7 +62,8 @@ export class HomePage implements OnInit { private userService: UserService, private localStorage: LocalStorageService, private toast: ToastService, - private permissionService: PermissionService) { } + private permissionService: PermissionService, + private utilService: UtilService) { } ngOnInit() { this.isMentor = this.profileService.isMentor @@ -146,10 +146,14 @@ export class HomePage implements OnInit { this.router.navigate([`/${CommonRoutes.SESSIONS}`], { queryParams: { type: data } }); } - search(q: string) { + search(event: string) { this.isOpen = false; - if(q){ - this.router.navigate([`/${CommonRoutes.HOME_SEARCH}`], {queryParams: { criteriaChip: JSON.stringify(this.criteriaChip), searchString: q}}); + if(event && event.length >= 3){ + this.utilService.subscribeSearchText(event); + this.utilService.subscribeCriteriaChip(JSON.stringify(this.criteriaChip)) + this.router.navigate([`/${CommonRoutes.HOME_SEARCH}`]); + }else { + this.toast.showToast("ENTER_MIN_CHARACTER","danger"); } this.criteriaChip = null; } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 4a2c69fe..ec74d0e9 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -279,5 +279,6 @@ "NO_SESSION_MESSAGE_DESCRIPTION": "Looks like we couldn’t find what you were looking for, try searching for something else.", "PROFILE_FORM_UNSAVED_DATA": "You have unsaved data, would you like to save it before exiting?", "PROFILE_EXIT_HEADER_LABEL": "Save Data?", - "DONOT_SAVE": "Don't Save" + "DONOT_SAVE": "Don't Save", + "ENTER_MIN_CHARACTER": "Please enter at least three characters to search." } \ No newline at end of file From 2e0d67367ca184e8b8ca85cb117a8cb83024ce69 Mon Sep 17 00:00:00 2001 From: Rahul K R Date: Thu, 18 Jul 2024 17:02:45 +0530 Subject: [PATCH 2/2] bug fix : 1411 --- src/app/pages/mentor-details/mentor-details.page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/pages/mentor-details/mentor-details.page.html b/src/app/pages/mentor-details/mentor-details.page.html index 0ebe44ca..f03dd5d6 100644 --- a/src/app/pages/mentor-details/mentor-details.page.html +++ b/src/app/pages/mentor-details/mentor-details.page.html @@ -1,4 +1,4 @@ - +