counties, pagination, filter count, show total results
This commit is contained in:
@@ -95,3 +95,6 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if(pageCount>1){
|
||||
<app-paginator [page]="page" [pageCount]="pageCount" (pageChange)="onPageChange($event)"></app-paginator>
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ import { ChangeDetectorRef, Component } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { BusinessListing, User } from '../../../../../../bizmatch-server/src/models/db.model';
|
||||
import { ListingType, UserListingCriteria, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model';
|
||||
import { LISTINGS_PER_PAGE, ListingType, UserListingCriteria, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { PaginatorComponent } from '../../../components/paginator/paginator.component';
|
||||
import { ImageService } from '../../../services/image.service';
|
||||
import { ListingsService } from '../../../services/listings.service';
|
||||
import { SearchService } from '../../../services/search.service';
|
||||
@@ -15,7 +16,7 @@ import { getCriteriaStateObject } from '../../../utils/utils';
|
||||
@Component({
|
||||
selector: 'app-broker-listings',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, RouterModule, NgOptimizedImage],
|
||||
imports: [CommonModule, FormsModule, RouterModule, NgOptimizedImage, PaginatorComponent],
|
||||
templateUrl: './broker-listings.component.html',
|
||||
styleUrls: ['./broker-listings.component.scss', '../../pages.scss'],
|
||||
})
|
||||
@@ -39,6 +40,8 @@ export class BrokerListingsComponent {
|
||||
env = environment;
|
||||
public category: 'business' | 'commercialProperty' | 'professionals_brokers' | undefined;
|
||||
emailToDirName = emailToDirName;
|
||||
page = 1;
|
||||
pageCount = 1;
|
||||
constructor(
|
||||
public selectOptions: SelectOptionsService,
|
||||
private listingsService: ListingsService,
|
||||
@@ -51,14 +54,6 @@ export class BrokerListingsComponent {
|
||||
private searchService: SearchService,
|
||||
) {
|
||||
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') {
|
||||
@@ -74,24 +69,20 @@ export class BrokerListingsComponent {
|
||||
async init() {
|
||||
this.search();
|
||||
}
|
||||
refine() {
|
||||
this.criteria.start = 0;
|
||||
this.criteria.page = 0;
|
||||
this.search();
|
||||
}
|
||||
async search() {
|
||||
const usersReponse = await this.userService.search(this.criteria);
|
||||
this.users = usersReponse.results;
|
||||
this.totalRecords = usersReponse.totalCount;
|
||||
this.pageCount = this.totalRecords % LISTINGS_PER_PAGE === 0 ? this.totalRecords / LISTINGS_PER_PAGE : Math.floor(this.totalRecords / LISTINGS_PER_PAGE) + 1;
|
||||
this.cdRef.markForCheck();
|
||||
this.cdRef.detectChanges();
|
||||
}
|
||||
onPageChange(event: any) {
|
||||
this.criteria.start = event.first;
|
||||
this.criteria.length = event.rows;
|
||||
this.criteria.page = event.page;
|
||||
this.criteria.pageCount = event.pageCount;
|
||||
onPageChange(page: any) {
|
||||
this.criteria.start = (page - 1) * LISTINGS_PER_PAGE;
|
||||
this.criteria.length = LISTINGS_PER_PAGE;
|
||||
this.criteria.page = page;
|
||||
this.search();
|
||||
}
|
||||
|
||||
reset() {}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,9 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if(pageCount>1){
|
||||
<app-paginator [page]="page" [pageCount]="pageCount" (pageChange)="onPageChange($event)"></app-paginator>
|
||||
}
|
||||
|
||||
<!-- <div class="container mx-auto px-4 py-8">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
|
||||
@@ -50,14 +50,6 @@ export class BusinessListingsComponent {
|
||||
private searchService: SearchService,
|
||||
) {
|
||||
this.criteria = getCriteriaStateObject('business');
|
||||
// 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 === 'business') {
|
||||
@@ -66,20 +58,14 @@ export class BusinessListingsComponent {
|
||||
}
|
||||
});
|
||||
}
|
||||
async ngOnInit() {
|
||||
//initFlowbite();
|
||||
}
|
||||
async ngOnInit() {}
|
||||
async init() {
|
||||
this.reset();
|
||||
const statesResult = await this.listingsService.getAllStates('business');
|
||||
this.states = statesResult.map(ls => ({ name: this.selectOptions.getState(ls.state as string), value: ls.state, count: ls.count }));
|
||||
this.search();
|
||||
}
|
||||
// refine() {
|
||||
// this.criteria.start = 0;
|
||||
// this.criteria.page = 0;
|
||||
// this.search();
|
||||
// }
|
||||
|
||||
async search() {
|
||||
//this.listings = await this.listingsService.getListingsByPrompt(this.criteria);
|
||||
const listingReponse = await this.listingsService.getListings(this.criteria, 'business');
|
||||
@@ -90,10 +76,9 @@ export class BusinessListingsComponent {
|
||||
this.cdRef.detectChanges();
|
||||
}
|
||||
onPageChange(page: any) {
|
||||
this.criteria.start = (page - 1) * LISTINGS_PER_PAGE + 1;
|
||||
this.criteria.start = (page - 1) * LISTINGS_PER_PAGE;
|
||||
this.criteria.length = LISTINGS_PER_PAGE;
|
||||
this.criteria.page = page;
|
||||
// this.criteria.pageCount = event.pageCount;
|
||||
this.search();
|
||||
}
|
||||
imageErrorHandler(listing: ListingType) {
|
||||
|
||||
@@ -78,3 +78,6 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if(pageCount>1){
|
||||
<app-paginator [page]="page" [pageCount]="pageCount" (pageChange)="onPageChange($event)"></app-paginator>
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ import { ChangeDetectorRef, Component } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { CommercialPropertyListing } from '../../../../../../bizmatch-server/src/models/db.model';
|
||||
import { CommercialPropertyListingCriteria, ResponseCommercialPropertyListingArray } from '../../../../../../bizmatch-server/src/models/main.model';
|
||||
import { CommercialPropertyListingCriteria, LISTINGS_PER_PAGE, ResponseCommercialPropertyListingArray } from '../../../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { PaginatorComponent } from '../../../components/paginator/paginator.component';
|
||||
import { ImageService } from '../../../services/image.service';
|
||||
import { ListingsService } from '../../../services/listings.service';
|
||||
import { SearchService } from '../../../services/search.service';
|
||||
@@ -14,7 +15,7 @@ import { getCriteriaStateObject } from '../../../utils/utils';
|
||||
@Component({
|
||||
selector: 'app-commercial-property-listings',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, RouterModule],
|
||||
imports: [CommonModule, FormsModule, RouterModule, PaginatorComponent],
|
||||
templateUrl: './commercial-property-listings.component.html',
|
||||
styleUrls: ['./commercial-property-listings.component.scss', '../../pages.scss'],
|
||||
})
|
||||
@@ -35,6 +36,8 @@ export class CommercialPropertyListingsComponent {
|
||||
totalRecords: number = 0;
|
||||
ts = new Date().getTime();
|
||||
env = environment;
|
||||
page = 1;
|
||||
pageCount = 1;
|
||||
constructor(
|
||||
public selectOptions: SelectOptionsService,
|
||||
private listingsService: ListingsService,
|
||||
@@ -46,14 +49,6 @@ export class CommercialPropertyListingsComponent {
|
||||
private searchService: SearchService,
|
||||
) {
|
||||
this.criteria = getCriteriaStateObject('commercialProperty');
|
||||
// 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 === 'commercialProperty') {
|
||||
@@ -77,14 +72,14 @@ export class CommercialPropertyListingsComponent {
|
||||
const listingReponse = await this.listingsService.getListings(this.criteria, 'commercialProperty');
|
||||
this.listings = (<ResponseCommercialPropertyListingArray>listingReponse).results;
|
||||
this.totalRecords = (<ResponseCommercialPropertyListingArray>listingReponse).totalCount;
|
||||
this.pageCount = this.totalRecords % LISTINGS_PER_PAGE === 0 ? this.totalRecords / LISTINGS_PER_PAGE : Math.floor(this.totalRecords / LISTINGS_PER_PAGE) + 1;
|
||||
this.cdRef.markForCheck();
|
||||
this.cdRef.detectChanges();
|
||||
}
|
||||
onPageChange(event: any) {
|
||||
this.criteria.start = event.first;
|
||||
this.criteria.length = event.rows;
|
||||
this.criteria.page = event.page;
|
||||
this.criteria.pageCount = event.pageCount;
|
||||
onPageChange(page: any) {
|
||||
this.criteria.start = (page - 1) * LISTINGS_PER_PAGE;
|
||||
this.criteria.length = LISTINGS_PER_PAGE;
|
||||
this.criteria.page = page;
|
||||
this.search();
|
||||
}
|
||||
reset() {
|
||||
|
||||
Reference in New Issue
Block a user