Paginator & SQL Querries where clauses & city search
This commit is contained in:
@@ -2,15 +2,15 @@ import { CommonModule, NgOptimizedImage } from '@angular/common';
|
||||
import { ChangeDetectorRef, Component } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import onChange from 'on-change';
|
||||
import { BusinessListing, User } from '../../../../../../bizmatch-server/src/models/db.model';
|
||||
import { ListingType, UserListingCriteria, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { ImageService } from '../../../services/image.service';
|
||||
import { ListingsService } from '../../../services/listings.service';
|
||||
import { SearchService } from '../../../services/search.service';
|
||||
import { SelectOptionsService } from '../../../services/select-options.service';
|
||||
import { UserService } from '../../../services/user.service';
|
||||
import { getCriteriaStateObject, getSessionStorageHandlerWrapper } from '../../../utils/utils';
|
||||
import { getCriteriaStateObject } from '../../../utils/utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-broker-listings',
|
||||
@@ -48,15 +48,23 @@ export class BrokerListingsComponent {
|
||||
private cdRef: ChangeDetectorRef,
|
||||
private imageService: ImageService,
|
||||
private route: ActivatedRoute,
|
||||
private searchService: SearchService,
|
||||
) {
|
||||
this.criteria = onChange(getCriteriaStateObject('broker'), getSessionStorageHandlerWrapper('broker'));
|
||||
this.route.data.subscribe(async () => {
|
||||
if (this.router.getCurrentNavigation().extras.state) {
|
||||
} else {
|
||||
this.first = this.criteria.page * this.criteria.length;
|
||||
this.rows = this.criteria.length;
|
||||
this.criteria = getCriteriaStateObject('broker');
|
||||
// this.route.data.subscribe(async () => {
|
||||
// if (this.router.getCurrentNavigation().extras.state) {
|
||||
// } else {
|
||||
// this.first = this.criteria.page * this.criteria.length;
|
||||
// this.rows = this.criteria.length;
|
||||
// }
|
||||
// this.init();
|
||||
// });
|
||||
this.init();
|
||||
this.searchService.currentCriteria.subscribe(criteria => {
|
||||
if (criteria && criteria.criteriaType === 'broker') {
|
||||
this.criteria = criteria as UserListingCriteria;
|
||||
this.search();
|
||||
}
|
||||
this.init();
|
||||
});
|
||||
}
|
||||
async ngOnInit() {
|
||||
@@ -73,8 +81,8 @@ export class BrokerListingsComponent {
|
||||
}
|
||||
async search() {
|
||||
const usersReponse = await this.userService.search(this.criteria);
|
||||
this.users = usersReponse.data;
|
||||
this.totalRecords = usersReponse.total;
|
||||
this.users = usersReponse.results;
|
||||
this.totalRecords = usersReponse.totalCount;
|
||||
this.cdRef.markForCheck();
|
||||
this.cdRef.detectChanges();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user