@for (image of listing.imageOrder; track $index) {
diff --git a/bizmatch/src/app/pages/subscription/account/account.component.ts b/bizmatch/src/app/pages/subscription/account/account.component.ts
index a4c4d12..6b962ff 100644
--- a/bizmatch/src/app/pages/subscription/account/account.component.ts
+++ b/bizmatch/src/app/pages/subscription/account/account.component.ts
@@ -1,7 +1,6 @@
import { ChangeDetectorRef, Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { faTrash } from '@fortawesome/free-solid-svg-icons';
-import { AngularCropperjsModule } from 'angular-cropperjs';
import { KeycloakService } from 'keycloak-angular';
import { lastValueFrom } from 'rxjs';
import { User } from '../../../../../../bizmatch-server/src/models/db.model';
@@ -19,7 +18,7 @@ import { TOOLBAR_OPTIONS } from '../../utils/defaults';
@Component({
selector: 'app-account',
standalone: true,
- imports: [SharedModule, AngularCropperjsModule],
+ imports: [SharedModule],
providers: [],
templateUrl: './account.component.html',
styleUrl: './account.component.scss',
diff --git a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts
index ba9058c..dd1ed6e 100644
--- a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts
+++ b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts
@@ -7,8 +7,6 @@ import { createDefaultBusinessListing, map2User, routeListingWithState } from '.
import { DragDropModule } from '@angular/cdk/drag-drop';
import { faTrash } from '@fortawesome/free-solid-svg-icons';
-import { AngularCropperjsModule } from 'angular-cropperjs';
-import { MixedCdkDragDropModule } from 'angular-mixed-cdk-drag-drop';
import { KeycloakService } from 'keycloak-angular';
import { QuillModule } from 'ngx-quill';
@@ -27,7 +25,7 @@ import { TOOLBAR_OPTIONS } from '../../utils/defaults';
@Component({
selector: 'business-listing',
standalone: true,
- imports: [SharedModule, ArrayToStringPipe, AngularCropperjsModule, DragDropModule, MixedCdkDragDropModule, QuillModule, NgxCurrencyDirective, NgSelectModule],
+ imports: [SharedModule, ArrayToStringPipe, DragDropModule, QuillModule, NgxCurrencyDirective, NgSelectModule],
providers: [],
templateUrl: './edit-business-listing.component.html',
styleUrl: './edit-business-listing.component.scss',
diff --git a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.html b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.html
index 50f4eea..c80eed3 100644
--- a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.html
+++ b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.html
@@ -146,10 +146,11 @@
Edit Listing
+ @if (listing){
-
-
+
+
}
+
-->
+
+
+
Property Pictures
+
(Pictures can be uploaded once the listing is posted initially)
+
+
@if (mode==='create'){
-
+
} @else {
-
+
}
+ }
+
+
+
+
Crop Image
+
+
+
+
+
+
+
+
diff --git a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.scss b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.scss
index ea92945..04884f9 100644
--- a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.scss
+++ b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.scss
@@ -55,3 +55,52 @@
cursor: pointer; /* Verwandelt den Cursor in eine Hand, um Interaktivität anzudeuten */
border-radius: 8px; /* Optional: Abrunden der linken unteren Ecke für ästhetische Zwecke */
}
+
+// -------------------------------
+
+.grid-container {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
+ gap: 16px;
+ padding: 16px;
+}
+
+.grid-item {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ aspect-ratio: 16 / 9;
+ background-color: #f0f0f0;
+ border-radius: 8px;
+ transition: box-shadow 200ms cubic-bezier(0, 0, 0.2, 1);
+ box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
+}
+
+.grid-item:active {
+ box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
+}
+
+.image-box {
+ width: 100%;
+ height: 100%;
+ position: relative;
+ overflow: hidden;
+}
+
+.cdk-drag-preview {
+ box-sizing: border-box;
+ border-radius: 4px;
+ box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
+}
+
+.cdk-drag-placeholder {
+ opacity: 0.3;
+}
+
+.cdk-drag-animating {
+ transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
+}
+
+.grid-container.cdk-drop-list-dragging .grid-item:not(.cdk-drag-placeholder) {
+ transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
+}
diff --git a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts
index 1441673..c367362 100644
--- a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts
+++ b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts
@@ -1,21 +1,25 @@
-import { Component } from '@angular/core';
+import { ChangeDetectorRef, Component, ElementRef, ViewChild } from '@angular/core';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { lastValueFrom } from 'rxjs';
import { ListingsService } from '../../../services/listings.service';
import { SelectOptionsService } from '../../../services/select-options.service';
import { createDefaultCommercialPropertyListing, map2User, routeListingWithState } from '../../../utils/utils';
-import { CdkDragDrop, DragDropModule, moveItemInArray } from '@angular/cdk/drag-drop';
+import { DragDropModule } from '@angular/cdk/drag-drop';
+import { ViewportRuler } from '@angular/cdk/scrolling';
import { faTrash } from '@fortawesome/free-solid-svg-icons';
import { NgSelectModule } from '@ng-select/ng-select';
-import { AngularCropperjsModule } from 'angular-cropperjs';
-import { MixedCdkDragDropModule } from 'angular-mixed-cdk-drag-drop';
import { KeycloakService } from 'keycloak-angular';
import { NgxCurrencyDirective } from 'ngx-currency';
+import { ImageCroppedEvent, ImageCropperComponent } from 'ngx-image-cropper';
import { QuillModule } from 'ngx-quill';
import { BusinessListing, CommercialPropertyListing, User } from '../../../../../../bizmatch-server/src/models/db.model';
import { AutoCompleteCompleteEvent, ImageProperty, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model';
import { environment } from '../../../../environments/environment';
+import { ConfirmationComponent } from '../../../components/confirmation/confirmation.component';
+import { ConfirmationService } from '../../../components/confirmation/confirmation.service';
+import { DragDropMixedComponent } from '../../../components/drag-drop-mixed/drag-drop-mixed.component';
+import { MessageService } from '../../../components/message/message.service';
import { ArrayToStringPipe } from '../../../pipes/array-to-string.pipe';
import { GeoService } from '../../../services/geo.service';
import { ImageService } from '../../../services/image.service';
@@ -26,13 +30,15 @@ import { TOOLBAR_OPTIONS } from '../../utils/defaults';
@Component({
selector: 'commercial-property-listing',
standalone: true,
- imports: [SharedModule, ArrayToStringPipe, AngularCropperjsModule, DragDropModule, MixedCdkDragDropModule, QuillModule, NgxCurrencyDirective, NgSelectModule],
+ imports: [SharedModule, ArrayToStringPipe, DragDropModule, QuillModule, NgxCurrencyDirective, NgSelectModule, ImageCropperComponent, ConfirmationComponent, DragDropMixedComponent],
providers: [],
templateUrl: './edit-commercial-property-listing.component.html',
styleUrl: './edit-commercial-property-listing.component.scss',
})
export class EditCommercialPropertyListingComponent {
// @ViewChild(FileUpload) public fileUpload: FileUpload;
+ @ViewChild('fileInput') fileInput!: ElementRef
;
+
listingsCategory = 'commercialProperty';
category: string;
location: string;
@@ -74,6 +80,10 @@ export class EditCommercialPropertyListingComponent {
quillModules = {
toolbar: [['bold', 'italic', 'underline', 'strike'], [{ list: 'ordered' }, { list: 'bullet' }], [{ header: [1, 2, 3, 4, 5, 6, false] }], [{ color: [] }, { background: [] }], ['clean']],
};
+ showModal = false;
+ imageChangedEvent: any = '';
+ croppedImage: Blob | null = null;
+
constructor(
public selectOptions: SelectOptionsService,
private router: Router,
@@ -87,6 +97,10 @@ export class EditCommercialPropertyListingComponent {
private route: ActivatedRoute,
private keycloakService: KeycloakService,
+ private cdr: ChangeDetectorRef,
+ private confirmationService: ConfirmationService,
+ private messageService: MessageService,
+ private viewportRuler: ViewportRuler,
) {
// Abonniere Router-Events, um den aktiven Link zu ermitteln
this.router.events.subscribe(event => {
@@ -130,7 +144,43 @@ export class EditCommercialPropertyListingComponent {
const result = await lastValueFrom(this.geoService.findCitiesStartingWith(event.query, this.listing.state));
this.suggestions = result.map(r => r.city).slice(0, 5);
}
+ openFileDialog() {
+ this.fileInput.nativeElement.click();
+ }
+ fileChangeEvent(event: any): void {
+ this.imageChangedEvent = event;
+ this.showModal = true;
+ }
+
+ imageCropped(event: ImageCroppedEvent) {
+ this.croppedImage = event.blob;
+ }
+
+ closeModal() {
+ this.showModal = false;
+ this.imageChangedEvent = '';
+ this.croppedImage = null;
+ }
+
+ uploadImage() {
+ if (this.croppedImage) {
+ // Convert base64 to blob
+ // Replace with your actual API endpoint
+ this.imageService.uploadImage(this.croppedImage, 'uploadPropertyPicture', this.listing.imagePath, this.listing.serialId).subscribe(
+ async response => {
+ console.log('Upload successful', response);
+ setTimeout(async () => {
+ this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'));
+ });
+ this.closeModal();
+ },
+ error => {
+ console.error('Upload failed', error);
+ },
+ );
+ }
+ }
// select(event: any) {
// const imageUrl = URL.createObjectURL(event.files[0]);
// getImageDimensions(imageUrl).then(dimensions => {
@@ -174,36 +224,22 @@ export class EditCommercialPropertyListingComponent {
// });
// }
- // deleteConfirm(imageName: string) {
- // this.confirmationService.confirm({
- // target: event.target as EventTarget,
- // message: `Do you want to delete this image ${imageName}?`,
- // header: 'Delete Confirmation',
- // icon: 'pi pi-info-circle',
- // acceptButtonStyleClass: 'p-button-danger p-button-text',
- // rejectButtonStyleClass: 'p-button-text p-button-text',
- // acceptIcon: 'none',
- // rejectIcon: 'none',
-
- // accept: async () => {
- // this.listing.imageOrder = this.listing.imageOrder.filter(item => item !== imageName);
- // await Promise.all([this.imageService.deleteListingImage(this.listing.imagePath, this.listing.serialId, imageName), this.listingsService.save(this.listing, 'commercialProperty')]);
- // this.messageService.add({ severity: 'info', summary: 'Confirmed', detail: 'Image deleted' });
- // },
- // reject: () => {
- // // this.messageService.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected' });
- // console.log('deny');
- // },
- // });
- // }
-
- onDrop(event: { previousIndex: number; currentIndex: number }) {
- moveItemInArray(this.listing.imageOrder, event.previousIndex, event.currentIndex);
+ async deleteConfirm(imageName: string) {
+ const confirmed = await this.confirmationService.showConfirmation('Are you sure you want to delete this image?');
+ if (confirmed) {
+ this.listing.imageOrder = this.listing.imageOrder.filter(item => item !== imageName);
+ await Promise.all([this.imageService.deleteListingImage(this.listing.imagePath, this.listing.serialId, imageName), this.listingsService.save(this.listing, 'commercialProperty')]);
+ this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'));
+ this.messageService.showMessage('Image deleted');
+ } else {
+ console.log('deny');
+ }
}
+
changeListingCategory(value: 'business' | 'commercialProperty') {
routeListingWithState(this.router, value, this.listing);
}
- drop(event: CdkDragDrop) {
- moveItemInArray(this.listing.imageOrder, event.previousIndex, event.currentIndex);
+ imageOrderChanged(imageOrder: string[]) {
+ this.listing.imageOrder = imageOrder;
}
}