autocomplete off bei numeric fields, Mail Mask emptied after Mail dispatch, unknown listing controller for EMail Listings

This commit is contained in:
Andreas Knuth 2024-08-12 13:55:23 +02:00
parent 245e76f697
commit 3a6a64cce9
9 changed files with 57 additions and 36 deletions

View File

@ -1,18 +1,26 @@
import { Controller, Inject } from '@nestjs/common';
import { Controller, Get, Inject, Param, Request, UseGuards } from '@nestjs/common';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
import { OptionalJwtAuthGuard } from '../jwt-auth/optional-jwt-auth.guard.js';
import { BusinessListingService } from './business-listing.service.js';
import { CommercialPropertyService } from './commercial-property.service.js';
@Controller('listings/undefined')
export class UnknownListingsController {
constructor(@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {}
constructor(
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
private readonly businessListingsService: BusinessListingService,
private readonly propertyListingsService: CommercialPropertyService,
) {}
// @Get(':id')
// async findById(@Param('id') id: string): Promise<any> {
// const result = await this.listingsService.findById(id, businesses);
// if (result) {
// return result;
// } else {
// return await this.listingsService.findById(id, commercials);
// }
// }
@UseGuards(OptionalJwtAuthGuard)
@Get(':id')
async findById(@Request() req, @Param('id') id: string): Promise<any> {
const result = await this.businessListingsService.findBusinessesById(id, req.user);
if (result) {
return result;
} else {
return await this.propertyListingsService.findCommercialPropertiesById(id, req.user);
}
}
}

View File

@ -21,5 +21,6 @@
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
[options]="{ prefix: '$', thousands: ',', decimal: '.', precision: 0, align: 'left' }"
currencyMask
autocomplete="off"
/>
</div>

View File

@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable, of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { catchError, tap } from 'rxjs/operators';
import { environment } from '../../environments/environment';
@Injectable({
@ -17,14 +17,14 @@ export class ListingCategoryGuard implements CanActivate {
const url = `${this.apiBaseUrl}/bizmatch/listings/undefined/${id}`;
return this.http.get<any>(url).pipe(
map(response => {
tap(response => {
const category = response.listingsCategory;
if (category === 'business') {
return this.router.createUrlTree([`/details-business-listing/${id}`]);
this.router.navigate(['details-business-listing', id]);
} else if (category === 'commercialProperty') {
return this.router.createUrlTree([`/details-commercial-property-listing/${id}`]);
this.router.navigate(['details-commercial-property-listing', id]);
} else {
return this.router.createUrlTree(['/not-found']);
this.router.navigate(['not-found']);
}
}),
catchError(() => {

View File

@ -16,7 +16,7 @@ import { MailService } from '../../../services/mail.service';
import { SelectOptionsService } from '../../../services/select-options.service';
import { UserService } from '../../../services/user.service';
import { SharedModule } from '../../../shared/shared/shared.module';
import { map2User } from '../../../utils/utils';
import { createMailInfo, map2User } from '../../../utils/utils';
@Component({
selector: 'app-details-business-listing',
standalone: true,
@ -81,7 +81,7 @@ export class DetailsBusinessListingComponent {
this.keycloakUser = map2User(token);
if (this.keycloakUser) {
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.state };
this.mailinfo = createMailInfo(this.user);
}
this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'business'));
this.listingUser = await this.userService.getByMail(this.listing.email);
@ -99,6 +99,7 @@ export class DetailsBusinessListingComponent {
this.mailinfo.listing = this.listing;
await this.mailService.mail(this.mailinfo);
this.messageService.addMessage({ severity: 'success', text: 'Your message has been sent to the creator of the listing', duration: 3000 });
this.mailinfo = createMailInfo(this.user);
} catch (error) {
this.messageService.addMessage({
severity: 'danger',

View File

@ -18,7 +18,7 @@ import { MailService } from '../../../services/mail.service';
import { SelectOptionsService } from '../../../services/select-options.service';
import { UserService } from '../../../services/user.service';
import { SharedModule } from '../../../shared/shared/shared.module';
import { map2User } from '../../../utils/utils';
import { createMailInfo, map2User } from '../../../utils/utils';
@Component({
selector: 'app-details-commercial-property-listing',
@ -86,7 +86,7 @@ export class DetailsCommercialPropertyListingComponent {
this.keycloakUser = map2User(token);
if (this.keycloakUser) {
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.state };
this.mailinfo = createMailInfo(this.user);
}
this.listing = (await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'))) as CommercialPropertyListing;
this.listingUser = await this.userService.getByMail(this.listing.email);
@ -123,6 +123,7 @@ export class DetailsCommercialPropertyListingComponent {
this.mailinfo.listing = this.listing;
await this.mailService.mail(this.mailinfo);
this.messageService.addMessage({ severity: 'success', text: 'Your message has been sent to the creator of the listing', duration: 3000 });
this.mailinfo = createMailInfo(this.user);
} catch (error) {
this.messageService.addMessage({
severity: 'danger',

View File

@ -129,15 +129,15 @@
<div class="flex mb-4 space-x-4">
<div class="flex items-center">
<input type="checkbox" id="realEstateIncluded" [(ngModel)]="listing.realEstateIncluded" name="realEstateIncluded" class="mr-2" />
<input type="checkbox" id="realEstateIncluded" [(ngModel)]="listing.realEstateIncluded" (change)="onCheckboxChange('realEstateIncluded')" name="realEstateIncluded" class="mr-2" />
<label for="realEstateIncluded" class="text-sm font-bold text-gray-700">Real Estate Included</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="leasedLocation" [(ngModel)]="listing.leasedLocation" name="leasedLocation" class="mr-2" />
<input type="checkbox" id="leasedLocation" [(ngModel)]="listing.leasedLocation" (change)="onCheckboxChange('leasedLocation')" name="leasedLocation" class="mr-2" />
<label for="leasedLocation" class="text-sm font-bold text-gray-700">Leased Location</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="franchiseResale" [(ngModel)]="listing.franchiseResale" name="franchiseResale" class="mr-2" />
<input type="checkbox" id="franchiseResale" [(ngModel)]="listing.franchiseResale" (change)="onCheckboxChange('franchiseResale')" name="franchiseResale" class="mr-2" />
<label for="franchiseResale" class="text-sm font-bold text-gray-700">Franchise Re-Sale</label>
</div>
</div>

View File

@ -159,4 +159,13 @@ export class EditBusinessListingComponent {
}
target[keys[keys.length - 1]] = value;
}
onCheckboxChange(checkbox: string) {
// Deaktivieren Sie alle Checkboxes
this.listing.realEstateIncluded = false;
this.listing.leasedLocation = false;
this.listing.franchiseResale = false;
// Aktivieren Sie nur die aktuell ausgewählte Checkbox
this.listing[checkbox] = true;
}
}

View File

@ -11,7 +11,7 @@ import { ValidationMessagesService } from '../../../components/validation-messag
import { MailService } from '../../../services/mail.service';
import { UserService } from '../../../services/user.service';
import { SharedModule } from '../../../shared/shared/shared.module';
import { map2User } from '../../../utils/utils';
import { createMailInfo, map2User } from '../../../utils/utils';
@Component({
selector: 'app-email-us',
standalone: true,
@ -39,7 +39,7 @@ export class EmailUsComponent {
this.keycloakUser = map2User(token);
if (this.keycloakUser) {
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.state };
this.mailinfo = createMailInfo(this.user);
}
}
ngOnDestroy() {
@ -50,6 +50,7 @@ export class EmailUsComponent {
this.mailinfo.email = 'support@bizmatch.net';
await this.mailService.mail(this.mailinfo);
this.messageService.addMessage({ severity: 'success', text: 'Your request has been forwarded to the support team of bizmatch.', duration: 3000 });
this.mailinfo = createMailInfo(this.user);
} catch (error) {
this.messageService.addMessage({
severity: 'danger',

View File

@ -1,7 +1,7 @@
import { Router } from '@angular/router';
import { ConsoleFormattedStream, INFO, createLogger as _createLogger, stdSerializers } from 'browser-bunyan';
import { jwtDecode } from 'jwt-decode';
import { BusinessListingCriteria, CommercialPropertyListingCriteria, JwtToken, KeycloakUser, UserListingCriteria } from '../../../../bizmatch-server/src/models/main.model';
import { BusinessListingCriteria, CommercialPropertyListingCriteria, JwtToken, KeycloakUser, MailInfo, UserListingCriteria } from '../../../../bizmatch-server/src/models/main.model';
// export function createDefaultUser(email: string, firstname: string, lastname: string): User {
// return {
@ -154,6 +154,14 @@ export function createEmptyUserListingCriteria(): UserListingCriteria {
radius: null,
};
}
export function createMailInfo(user: User): MailInfo {
return {
sender: { name: `${user.firstname} ${user.lastname}`, email: user.email, phoneNumber: user.phoneNumber, state: user.companyLocation.state, comments: null },
email: null,
url: environment.mailinfoUrl,
listing: null,
};
}
export function createLogger(name: string, level: number = INFO, options: any = {}) {
return _createLogger({
name,
@ -244,6 +252,8 @@ export function getDialogWidth(dimensions): string {
import { initFlowbite } from 'flowbite';
import onChange from 'on-change';
import { Subject, concatMap, delay, of } from 'rxjs';
import { User } from '../../../../bizmatch-server/src/models/db.model';
import { environment } from '../../environments/environment';
const flowbiteQueue = new Subject<() => void>();
@ -387,17 +397,7 @@ export function getCriteriaProxy(path: string, component: any): BusinessListingC
}
}
export function createEnhancedProxy(obj: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria, component: any) {
// const component = this;
const sessionStorageHandler = function (path, value, previous, applyData) {
// let criteriaType = '';
// if ('/businessListings' === window.location.pathname) {
// criteriaType = 'business';
// } else if ('/commercialPropertyListings' === window.location.pathname) {
// criteriaType = 'commercialProperty';
// } else if ('/brokerListings' === window.location.pathname) {
// criteriaType = 'broker';
// }
sessionStorage.setItem(`${obj.criteriaType}`, JSON.stringify(this));
};