From dfe631edf61034fe7f683ae168f5d91d5dfdaeac Mon Sep 17 00:00:00 2001 From: "Tizian.Breuch" Date: Fri, 28 Nov 2025 11:18:42 +0100 Subject: [PATCH] shipping methods --- src/app/core/models/shipping.model.ts | 3 + .../product-create.component.css | 6 +- .../product-create.component.html | 2 +- .../product-edit/product-edit.component.css | 6 +- .../product-edit/product-edit.component.html | 2 +- .../product-list/product-list.component.css | 12 ++- .../product-list/product-list.component.html | 37 ++++++--- .../product-list/product-list.component.ts | 9 +- .../shipping-method-list.component.html | 82 +++++++++++++------ .../shipping-method-list.component.ts | 13 +-- .../generic-table.component.html | 8 +- .../generic-table/generic-table.component.ts | 2 + .../paginator/paginator.component.html | 4 +- .../components/ui/button/button.component.css | 11 ++- 14 files changed, 135 insertions(+), 62 deletions(-) diff --git a/src/app/core/models/shipping.model.ts b/src/app/core/models/shipping.model.ts index eb97874..0e92f03 100644 --- a/src/app/core/models/shipping.model.ts +++ b/src/app/core/models/shipping.model.ts @@ -6,4 +6,7 @@ export interface ShippingMethod { isActive: boolean; minDeliveryDays: number; maxDeliveryDays: number; + // NEU: Gewichtsgrenzen + minWeight: number; + maxWeight: number; } \ No newline at end of file diff --git a/src/app/features/components/products/product-create/product-create.component.css b/src/app/features/components/products/product-create/product-create.component.css index fd24f7f..185c932 100644 --- a/src/app/features/components/products/product-create/product-create.component.css +++ b/src/app/features/components/products/product-create/product-create.component.css @@ -1,10 +1,8 @@ -.form-header { +.page-header { display: flex; justify-content: space-between; align-items: center; - padding-bottom: 1rem; - margin-bottom: 1.5rem; - border-bottom: 1px solid var(--color-border); + margin-bottom: 1rem; } h3[card-header] { diff --git a/src/app/features/components/products/product-create/product-create.component.html b/src/app/features/components/products/product-create/product-create.component.html index e246ac8..c922eb5 100644 --- a/src/app/features/components/products/product-create/product-create.component.html +++ b/src/app/features/components/products/product-create/product-create.component.html @@ -4,7 +4,7 @@ -
+ diff --git a/src/app/features/components/products/product-edit/product-edit.component.css b/src/app/features/components/products/product-edit/product-edit.component.css index fd24f7f..185c932 100644 --- a/src/app/features/components/products/product-edit/product-edit.component.css +++ b/src/app/features/components/products/product-edit/product-edit.component.css @@ -1,10 +1,8 @@ -.form-header { +.page-header { display: flex; justify-content: space-between; align-items: center; - padding-bottom: 1rem; - margin-bottom: 1.5rem; - border-bottom: 1px solid var(--color-border); + margin-bottom: 1rem; } h3[card-header] { diff --git a/src/app/features/components/products/product-edit/product-edit.component.html b/src/app/features/components/products/product-edit/product-edit.component.html index 2c0510e..130b1d4 100644 --- a/src/app/features/components/products/product-edit/product-edit.component.html +++ b/src/app/features/components/products/product-edit/product-edit.component.html @@ -5,7 +5,7 @@
-
+
-
-

Produktübersicht

- - Neues Produkt - +
+
- +
- + +
- Spalten + + Neues Produkt + + + Spalten
@@ -25,6 +39,7 @@ [data]="filteredProducts" [columns]="visibleTableColumns" (edit)="onEditProduct($event.id)" - (delete)="onDeleteProduct($event.id)"> + (delete)="onDeleteProduct($event.id)" + > -
\ No newline at end of file +
diff --git a/src/app/features/components/products/product-list/product-list.component.ts b/src/app/features/components/products/product-list/product-list.component.ts index 072c3b0..f56a7d7 100644 --- a/src/app/features/components/products/product-list/product-list.component.ts +++ b/src/app/features/components/products/product-list/product-list.component.ts @@ -11,12 +11,11 @@ import { StorageService } from '../../../../core/services/storage.service'; import { GenericTableComponent, ColumnConfig } from '../../../../shared/components/data-display/generic-table/generic-table.component'; import { SearchBarComponent } from '../../../../shared/components/layout/search-bar/search-bar.component'; import { ButtonComponent } from '../../../../shared/components/ui/button/button.component'; -import { IconComponent } from '../../../../shared/components/ui/icon/icon.component'; @Component({ selector: 'app-product-list', standalone: true, - imports: [CommonModule, GenericTableComponent, SearchBarComponent, ButtonComponent, IconComponent], + imports: [CommonModule, GenericTableComponent, SearchBarComponent, ButtonComponent], providers: [DatePipe], templateUrl: './product-list.component.html', styleUrl: './product-list.component.css' @@ -59,6 +58,8 @@ export class ProductListComponent implements OnInit { ]; visibleTableColumns: ColumnConfig[] = []; + public readonly fallbackImage = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNjY2NjY2MiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cmVjdCB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHg9IjMiIHk9IjMiIHJ4PSIyIiByeT0iMiIvPjxjaXJjbGUgY3g9IjkiIGN5PSI5IiByPSIyIi8+PHBhdGggZD0ibTIxIDE1LTUtNWwtNSA1bC0yLTJsLTUgNSIvPjwvc3ZnPg=='; + constructor() { this.loadTableSettings(); } @@ -144,8 +145,8 @@ export class ProductListComponent implements OnInit { } getMainImageUrl(images?: ProductImage[]): string { - if (!images || images.length === 0) return 'https://via.placeholder.com/50'; + if (!images || images.length === 0) return this.fallbackImage; const mainImage = images.find(img => img.isMainImage); - return mainImage?.url || images[0]?.url || 'https://via.placeholder.com/50'; + return mainImage?.url || images[0]?.url || this.fallbackImage; } } \ No newline at end of file diff --git a/src/app/features/components/shipping-methods/shipping-method-list/shipping-method-list.component.html b/src/app/features/components/shipping-methods/shipping-method-list/shipping-method-list.component.html index 7a810f8..af3ca21 100644 --- a/src/app/features/components/shipping-methods/shipping-method-list/shipping-method-list.component.html +++ b/src/app/features/components/shipping-methods/shipping-method-list/shipping-method-list.component.html @@ -22,27 +22,51 @@
- -
- - +
+
+ + +
+ +
+ + +
-
- - + +
+
+ + +
+ +
+ + +
-
+
@@ -55,16 +79,26 @@ Abbrechen +
+

Bestehende Methoden

    -
  • - {{ method.name }} - ({{ method.cost | currency : "EUR" }}) - Lieferzeit: - {{ method.minDeliveryDays }}-{{ method.maxDeliveryDays }} Tage - Aktiv: - {{ method.isActive }} - - +
  • + {{ method.name }} ({{ method.cost | currency : "EUR" }})
    + + + + Lieferzeit: {{ method.minDeliveryDays }}-{{ method.maxDeliveryDays }} Tage | + + Gewicht: {{ method.minWeight }}kg - {{ method.maxWeight }}kg | + Aktiv: {{ method.isActive ? 'Ja' : 'Nein' }} + + +
    + + +
-
+
\ No newline at end of file diff --git a/src/app/features/components/shipping-methods/shipping-method-list/shipping-method-list.component.ts b/src/app/features/components/shipping-methods/shipping-method-list/shipping-method-list.component.ts index 4b4d847..d305ebc 100644 --- a/src/app/features/components/shipping-methods/shipping-method-list/shipping-method-list.component.ts +++ b/src/app/features/components/shipping-methods/shipping-method-list/shipping-method-list.component.ts @@ -26,7 +26,10 @@ export class ShippingMethodListComponent implements OnInit { cost: [0, [Validators.required, Validators.min(0)]], isActive: [true], minDeliveryDays: [1, [Validators.required, Validators.min(0)]], - maxDeliveryDays: [3, [Validators.required, Validators.min(0)]] + maxDeliveryDays: [3, [Validators.required, Validators.min(0)]], + // NEU: Validierung für Gewicht + minWeight: [0, [Validators.required, Validators.min(0)]], + maxWeight: [10, [Validators.required, Validators.min(0)]] }); } @@ -46,15 +49,16 @@ export class ShippingMethodListComponent implements OnInit { cost: 0, isActive: true, minDeliveryDays: 1, - maxDeliveryDays: 3 + maxDeliveryDays: 3, + // NEU: Reset Werte + minWeight: 0, + maxWeight: 10 }); } - // --- KORREKTUR: onSubmit sendet jetzt direkt das Formularwert-Objekt als JSON --- onSubmit(): void { if (this.methodForm.invalid) return; - // Das Formular-Objekt hat bereits die richtige Struktur, die das Backend erwartet. const dataToSend: ShippingMethod = { id: this.selectedMethodId || '00000000-0000-0000-0000-000000000000', ...this.methodForm.value @@ -66,7 +70,6 @@ export class ShippingMethodListComponent implements OnInit { this.shippingMethodService.create(dataToSend).subscribe(() => this.reset()); } } - // --- ENDE KORREKTUR --- onDelete(id: string): void { if (confirm('Versandmethode wirklich löschen?')) { diff --git a/src/app/shared/components/data-display/generic-table/generic-table.component.html b/src/app/shared/components/data-display/generic-table/generic-table.component.html index 4aa2bdb..52e1995 100644 --- a/src/app/shared/components/data-display/generic-table/generic-table.component.html +++ b/src/app/shared/components/data-display/generic-table/generic-table.component.html @@ -35,8 +35,8 @@
- + {{ item.name }}
{{ getProperty(item, col.key) }}
{{ getProperty(item, col.subKey!) }}
@@ -45,8 +45,8 @@ - Bild diff --git a/src/app/shared/components/data-display/generic-table/generic-table.component.ts b/src/app/shared/components/data-display/generic-table/generic-table.component.ts index 98b3ce0..bf5bd6e 100644 --- a/src/app/shared/components/data-display/generic-table/generic-table.component.ts +++ b/src/app/shared/components/data-display/generic-table/generic-table.component.ts @@ -35,6 +35,7 @@ export class GenericTableComponent implements OnChanges, OnInit { public displayedData: any[] = []; public currentPage = 1; + public readonly fallbackImage = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNjY2NjY2MiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cmVjdCB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHg9IjMiIHk9IjMiIHJ4PSIyIiByeT0iMiIvPjxjaXJjbGUgY3g9IjkiIGN5PSI5IiByPSIyIi8+PHBhdGggZD0ibTIxIDE1LTUtNWwtNSA1bC0yLTJsLTUgNSIvPjwvc3ZnPg=='; ngOnInit(): void { this.updatePagination(); } ngOnChanges(changes: SimpleChanges): void { if (changes['data']) { this.currentPage = 1; this.updatePagination(); } } @@ -47,6 +48,7 @@ export class GenericTableComponent implements OnChanges, OnInit { } getProperty(item: any, key: string): any { + if (!key) return ''; return key.split('.').reduce((obj, part) => obj && obj[part], item); } diff --git a/src/app/shared/components/data-display/paginator/paginator.component.html b/src/app/shared/components/data-display/paginator/paginator.component.html index b6d408d..77c61f7 100644 --- a/src/app/shared/components/data-display/paginator/paginator.component.html +++ b/src/app/shared/components/data-display/paginator/paginator.component.html @@ -8,7 +8,7 @@ iconName="chevron_backward" (click)="goToPrevious()" [disabled]="currentPage === 1" - tooltip="Vorherige Seite"> + > + >
diff --git a/src/app/shared/components/ui/button/button.component.css b/src/app/shared/components/ui/button/button.component.css index d29295a..1e6c3c2 100644 --- a/src/app/shared/components/ui/button/button.component.css +++ b/src/app/shared/components/ui/button/button.component.css @@ -135,11 +135,20 @@ transform: translateX(-50%) translateY(-12px); } - .btn.is-loading { cursor: wait; } +.btn-content { + display: flex; +} +.btn-content span { + display: flex; + height: auto; + align-content: center; + flex-wrap: wrap-reverse; +} + .btn-content.is-hidden { visibility: hidden; opacity: 0;