diff --git a/src/main/java/catering/orderCatalog/CatalogController.java b/src/main/java/catering/orderCatalog/CatalogController.java index 4f76fe2..fc34fb2 100644 --- a/src/main/java/catering/orderCatalog/CatalogController.java +++ b/src/main/java/catering/orderCatalog/CatalogController.java @@ -3,12 +3,19 @@ package catering.orderCatalog; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.ui.Model; @Controller public class CatalogController { + private CustomCatalogEntryRepository catalogEntryRepository; + + public CatalogController(CustomCatalogEntryRepository catalogEntryRepository) { + this.catalogEntryRepository = catalogEntryRepository; + } @GetMapping("/catalog") - public String catalog() { + public String catalog(Model model) { + model.addAttribute("catalogEntries", catalogEntryRepository.getCatalogEntries()); return "catalog"; } @@ -19,7 +26,7 @@ public class CatalogController { @PostMapping("/catalog/remove") public String removeItem() { - return "redirect:/catalog"; + return "catalog_editor"; } } diff --git a/src/main/java/catering/orderCatalog/CustomCatalogEntry.java b/src/main/java/catering/orderCatalog/CustomCatalogEntry.java index f7eff79..10f1dfe 100644 --- a/src/main/java/catering/orderCatalog/CustomCatalogEntry.java +++ b/src/main/java/catering/orderCatalog/CustomCatalogEntry.java @@ -8,13 +8,15 @@ public class CustomCatalogEntry { private EventType eventType; private Map products; private int minimumTimePeriod; // Declared as int for simplification of the prototype. Only whole hours. + private int totalCost; // Should actually accumulate the price of all items. - public CustomCatalogEntry(EventType eventType, Map products, int minimumTimePeriod) { + public CustomCatalogEntry(EventType eventType, Map products, int minimumTimePeriod, int totalCost) { this.id = idCounter; idCounter++; this.eventType = eventType; this.products = products; this.minimumTimePeriod = minimumTimePeriod; + this.totalCost = totalCost; } public int getId() { @@ -29,8 +31,12 @@ public class CustomCatalogEntry { return products; } - public int getMinimumTimePeriod() { - return minimumTimePeriod; + public String getMinimumTimePeriod() { + return minimumTimePeriod + " h"; + } + + public String getTotalCost() { + return totalCost + " €"; } public enum EventType { diff --git a/src/main/java/catering/orderCatalog/CustomCatalogEntryDataInitializer.java b/src/main/java/catering/orderCatalog/CustomCatalogEntryDataInitializer.java index 10de4e4..1b3c16b 100644 --- a/src/main/java/catering/orderCatalog/CustomCatalogEntryDataInitializer.java +++ b/src/main/java/catering/orderCatalog/CustomCatalogEntryDataInitializer.java @@ -23,7 +23,8 @@ public class CustomCatalogEntryDataInitializer implements DataInitializer { catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry( CustomCatalogEntry.EventType.EVENT_CATERING, products, - 3 + 3, + 300 )); products = new HashMap<>(); @@ -35,7 +36,8 @@ public class CustomCatalogEntryDataInitializer implements DataInitializer { catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry( CustomCatalogEntry.EventType.PARTY_SERVICE, products, - 3 + 3, + 500 )); } } diff --git a/src/main/java/catering/orderCatalog/CustomCatalogEntryRepository.java b/src/main/java/catering/orderCatalog/CustomCatalogEntryRepository.java index f7e8f7a..1a8d9f8 100644 --- a/src/main/java/catering/orderCatalog/CustomCatalogEntryRepository.java +++ b/src/main/java/catering/orderCatalog/CustomCatalogEntryRepository.java @@ -25,4 +25,8 @@ public class CustomCatalogEntryRepository { } return false; } + + public Set getCatalogEntries() { + return catalogEntries; + } } diff --git a/src/main/resources/templates/catalog.html b/src/main/resources/templates/catalog.html index f946246..f3339cb 100644 --- a/src/main/resources/templates/catalog.html +++ b/src/main/resources/templates/catalog.html @@ -17,7 +17,7 @@
-

Katalog

+

Katalog

@@ -29,35 +29,18 @@ Basisausstattung Preis ab - + **BILD** - Rent-a-Cook - 3h + + h -
    -
  • 1 Koch
  • -
  • 300kg Mettbrötchen
  • -
  • 300kg vegane Weißwurst
  • +
      +
    - 499,99€ - - - - **BILD** - - Sushi-Abend - 4h - -
      -
    • 2 Köche
    • -
    • 300kg Sushi
    • -
    • 300kg Sushi vegan
    • -
    - - 699,99€ +
@@ -68,6 +51,12 @@ +
+
+ +
+
+
diff --git a/src/main/resources/templates/catalog_editor.html b/src/main/resources/templates/catalog_editor.html index 65530f9..aa320be 100644 --- a/src/main/resources/templates/catalog_editor.html +++ b/src/main/resources/templates/catalog_editor.html @@ -3,7 +3,8 @@ xmlns:sec="http://www.thymeleaf.org/extras/spring-security" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> - Auftragskonfiguration + Basiseventkonfiguration + -

Auftrag konfigurieren

+

Basisevent konfigurieren

Dienstleistung

@@ -69,7 +70,7 @@
- Gesamtpreis: 90 €
+ Gesamtpreis: 90 €