reset criteria on home, show filter on home, new BOM generation, Schema overhaul
This commit is contained in:
@@ -82,7 +82,7 @@ export class DetailsCommercialPropertyListingComponent {
|
||||
this.user = await this.userService.getByMail(this.keycloakUser.email);
|
||||
this.mailinfo.sender = { name: `${this.user.firstname} ${this.user.lastname}`, email: this.user.email, phoneNumber: this.user.phoneNumber, state: this.user.companyLocation };
|
||||
}
|
||||
this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'));
|
||||
this.listing = (await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'))) as CommercialPropertyListing;
|
||||
this.listingUser = await this.userService.getByMail(this.listing.email);
|
||||
this.description = this.sanitizer.bypassSecurityTrustHtml(this.listing.description);
|
||||
import('flowbite').then(flowbite => {
|
||||
|
||||
@@ -53,7 +53,7 @@ export class DetailsUserComponent {
|
||||
const results = await Promise.all([await this.listingsService.getListingsByEmail(this.user.email, 'business'), await this.listingsService.getListingsByEmail(this.user.email, 'commercialProperty')]);
|
||||
// Zuweisen der Ergebnisse zu den Member-Variablen der Klasse
|
||||
this.businessListings = results[0];
|
||||
this.commercialPropListings = results[1];
|
||||
this.commercialPropListings = results[1] as CommercialPropertyListing[];
|
||||
//this.user$ = this.userService.getUserObservable();
|
||||
const token = await this.keycloakService.getToken();
|
||||
this.keycloakUser = map2User(token);
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-4 text-gray-600 text-sm md:text-base text-center">Or search using filters ▼</div>
|
||||
<div class="mt-4 text-gray-600 text-sm md:text-base text-center hover:cursor-pointer" (click)="openModal()">Or search using filters ▼</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,9 +5,12 @@ import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
import onChange from 'on-change';
|
||||
import { BusinessListingCriteria, CommercialPropertyListingCriteria, KeycloakUser, UserListingCriteria } from '../../../../../bizmatch-server/src/models/main.model';
|
||||
import { ModalService } from '../../components/search-modal/modal.service';
|
||||
import { CriteriaChangeService } from '../../services/criteria-change.service';
|
||||
import { ListingsService } from '../../services/listings.service';
|
||||
import { SearchService } from '../../services/search.service';
|
||||
import { SelectOptionsService } from '../../services/select-options.service';
|
||||
import { getCriteriaStateObject, getSessionStorageHandlerWrapper, map2User } from '../../utils/utils';
|
||||
import { getCriteriaStateObject, map2User } from '../../utils/utils';
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
standalone: true,
|
||||
@@ -25,30 +28,54 @@ export class HomeComponent {
|
||||
isMenuOpen = false;
|
||||
user: KeycloakUser;
|
||||
prompt: string;
|
||||
public constructor(private router: Router, private activatedRoute: ActivatedRoute, public selectOptions: SelectOptionsService, public keycloakService: KeycloakService, private listingsService: ListingsService) {
|
||||
this.criteria = onChange(getCriteriaStateObject('business'), getSessionStorageHandlerWrapper(this.activeTabAction));
|
||||
}
|
||||
public constructor(
|
||||
private router: Router,
|
||||
private modalService: ModalService,
|
||||
private searchService: SearchService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
public selectOptions: SelectOptionsService,
|
||||
public keycloakService: KeycloakService,
|
||||
private listingsService: ListingsService,
|
||||
private criteriaChangeService: CriteriaChangeService,
|
||||
) {}
|
||||
async ngOnInit() {
|
||||
const token = await this.keycloakService.getToken();
|
||||
sessionStorage.removeItem('business_criteria');
|
||||
sessionStorage.removeItem('commercialProperty_criteria');
|
||||
sessionStorage.removeItem('broker_criteria');
|
||||
this.criteria = this.createEnhancedProxy(getCriteriaStateObject('business'));
|
||||
this.user = map2User(token);
|
||||
// this.router.events.subscribe(event => {
|
||||
// if (event instanceof NavigationEnd) {
|
||||
// initFlowbite();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
async changeTab(tabname: 'business' | 'commercialProperty' | 'broker') {
|
||||
this.activeTabAction = tabname;
|
||||
// if (this.activeTabAction === 'business' || this.activeTabAction === 'commercialProperty') {
|
||||
// const statesResult = await this.listingsService.getAllStates(this.activeTabAction);
|
||||
// this.states = statesResult.map(s => s.state).map(ls => ({ name: this.selectOptions.getState(ls as string), value: ls }));
|
||||
// } else {
|
||||
// this.states = this.selectOptions.states;
|
||||
// }
|
||||
if ('business' === tabname) {
|
||||
this.criteria = this.createEnhancedProxy(getCriteriaStateObject('business'));
|
||||
} else if ('commercialProperty' === tabname) {
|
||||
this.criteria = this.createEnhancedProxy(getCriteriaStateObject('commercialProperty'));
|
||||
} else if ('broker' === tabname) {
|
||||
this.criteria = this.createEnhancedProxy(getCriteriaStateObject('broker'));
|
||||
} else {
|
||||
this.criteria = undefined;
|
||||
}
|
||||
}
|
||||
private createEnhancedProxy(obj: any) {
|
||||
const component = this;
|
||||
|
||||
const sessionStorageHandler = function (path, value, previous, applyData) {
|
||||
let criteriaType = this.criteriaType;
|
||||
sessionStorage.setItem(`${criteriaType}_criteria`, JSON.stringify(this));
|
||||
};
|
||||
|
||||
return onChange(obj, function (path, value, previous, applyData) {
|
||||
// Call the original sessionStorageHandler
|
||||
sessionStorageHandler.call(this, path, value, previous, applyData);
|
||||
|
||||
// Notify about the criteria change using the component's context
|
||||
component.criteriaChangeService.notifyCriteriaChange();
|
||||
});
|
||||
}
|
||||
search() {
|
||||
const data = { keep: true };
|
||||
this.criteria.prompt = this.prompt;
|
||||
this.router.navigate([`${this.activeTabAction}Listings`]);
|
||||
}
|
||||
|
||||
@@ -63,4 +90,11 @@ export class HomeComponent {
|
||||
toggleMenu() {
|
||||
this.isMenuOpen = !this.isMenuOpen;
|
||||
}
|
||||
async openModal() {
|
||||
const accepted = await this.modalService.showModal(this.criteria);
|
||||
if (accepted) {
|
||||
//this.searchService.search(this.criteria);
|
||||
this.router.navigate([`${this.activeTabAction}Listings`]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ export class AccountComponent {
|
||||
this.user = await this.userService.getByMail(email);
|
||||
} catch (e) {
|
||||
this.user = {
|
||||
id: undefined,
|
||||
email,
|
||||
firstname: keycloakUser.firstName,
|
||||
lastname: keycloakUser.lastName,
|
||||
|
||||
@@ -120,7 +120,7 @@ export class EditCommercialPropertyListingComponent {
|
||||
const token = await this.keycloakService.getToken();
|
||||
const keycloakUser = map2User(token);
|
||||
if (this.mode === 'edit') {
|
||||
this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'));
|
||||
this.listing = (await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'))) as CommercialPropertyListing;
|
||||
} else {
|
||||
this.listing = createDefaultCommercialPropertyListing();
|
||||
const listingUser = await this.userService.getByMail(keycloakUser.email);
|
||||
@@ -134,7 +134,7 @@ export class EditCommercialPropertyListingComponent {
|
||||
}
|
||||
|
||||
async save() {
|
||||
this.listing = await this.listingsService.save(this.listing, this.listing.listingsCategory);
|
||||
this.listing = (await this.listingsService.save(this.listing, this.listing.listingsCategory)) as CommercialPropertyListing;
|
||||
this.router.navigate(['editCommercialPropertyListing', this.listing.id]);
|
||||
this.messageService.addMessage({ severity: 'success', text: 'Listing changes have been persisted', duration: 3000 });
|
||||
}
|
||||
@@ -166,7 +166,7 @@ export class EditCommercialPropertyListingComponent {
|
||||
if (this.croppedImage) {
|
||||
this.imageService.uploadImage(this.croppedImage, 'uploadPropertyPicture', this.listing.imagePath, this.listing.serialId).subscribe(
|
||||
async () => {
|
||||
this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'));
|
||||
this.listing = (await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'))) as CommercialPropertyListing;
|
||||
this.closeModal();
|
||||
},
|
||||
error => {
|
||||
@@ -182,7 +182,7 @@ export class EditCommercialPropertyListingComponent {
|
||||
this.listing.imageOrder = this.listing.imageOrder.filter(item => item !== imageName);
|
||||
await this.imageService.deleteListingImage(this.listing.imagePath, this.listing.serialId, imageName);
|
||||
await this.listingsService.save(this.listing, 'commercialProperty');
|
||||
this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'));
|
||||
this.listing = (await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'))) as CommercialPropertyListing;
|
||||
this.messageService.addMessage({ severity: 'success', text: 'Image has been deleted', duration: 3000 });
|
||||
} else {
|
||||
console.log('deny');
|
||||
|
||||
Reference in New Issue
Block a user