Skip to content

Commit

Permalink
Merge pull request #524 from rahulramakrishnan3/release-3.0.0
Browse files Browse the repository at this point in the history
BUG fix 1477
  • Loading branch information
Cafnanc authored Jul 18, 2024
2 parents b617ace + 2e0d673 commit f43f837
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 29 deletions.
14 changes: 12 additions & 2 deletions src/app/core/services/util/util.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -17,6 +16,10 @@ import { LocalStorageService } from '../localstorage.service';
export class UtilService {
modal: any;
public canIonMenuShow = new Subject<boolean>();
private searchTextSource = new BehaviorSubject<string>('');
private criteriaChipSource = new BehaviorSubject<string>('');
currentSearchText = this.searchTextSource.asObservable();
currentCriteriaChip = this.criteriaChipSource.asObservable();

ionMenuShow(data:boolean) {
this.canIonMenuShow.next(data);
Expand Down Expand Up @@ -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);
}

}
4 changes: 3 additions & 1 deletion src/app/pages/home-search/home-search.page.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<app-page-header [config]="headerConfig">
<div class="d-flex flex-justify-center my-8">
<ion-searchbar class="search-bar" [debounce]="1000" placeholder="{{'HOME_SEARCH_PLACEHOLDER' | translate}}" #event [(ngModel)]="searchText" (keyup.enter)="search(event.value)"
<ion-searchbar class="search-bar" [debounce]="1000" placeholder="{{'HOME_SEARCH_PLACEHOLDER' | translate}}"
#event [value]="searchText"
(keyup.enter)="search(event.value)"
cdkOverlayOrigin #trigger="cdkOverlayOrigin" (click)="isOpen = !isOpen">
</ion-searchbar>
</div>
Expand Down
36 changes: 23 additions & 13 deletions src/app/pages/home-search/home-search.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)=>{
Expand All @@ -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() {
Expand Down Expand Up @@ -222,4 +227,9 @@ export class HomeSearchPage implements OnInit {
}
}
}

ngOnDestroy() {
this.searchTextSubscription.unsubscribe();
this.criteriaChipSubscription.unsubscribe();
}
}
2 changes: 1 addition & 1 deletion src/app/pages/mentor-details/mentor-details.page.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<app-page-header [config]="headerConfig" *ngIf="this.userCantAccess && isloaded"></app-page-header>
<app-page-header [config]="headerConfig" *ngIf="isloaded"></app-page-header>
<app-generic-profile-header *ngIf="!this.userCantAccess && isloaded" [headerData]='detailData.data' [buttonConfig]="buttonConfig" [showRole]="false">
</app-generic-profile-header>
<div *ngIf="!this.userCantAccess && isloaded">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<app-page-header [config]="headerConfig">
<div class="d-flex flex-justify-center">
<ion-searchbar class="top-padding search-style" debounce="1000" placeholder="{{'MENTOR_SEARCH_PLACEHOLDER' | translate}}"
[(ngModel)]="searchText" (ionChange)="onSearch()"
#event
(keyup.enter)="onSearch(event.value)"
cdkOverlayOrigin #trigger="cdkOverlayOrigin" (click)="isOpen = !isOpen"></ion-searchbar>
</div>
</app-page-header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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() {
Expand All @@ -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) {
Expand Down
16 changes: 10 additions & 6 deletions src/app/pages/tabs/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}

0 comments on commit f43f837

Please sign in to comment.