From 03d557d67b7b2758d4ee31a239c63e6dedb3c847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20F=C3=BCrderer?= Date: Mon, 8 Jun 2020 18:56:35 +0200 Subject: [PATCH] Show a hyphen in supplier column if an article is not offered by anyone Closes #54 --- .../intern/suppliers/SupplierOfferController.java | 12 ++++++++---- .../templates/intern/offeredArticles/index.html | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java index 979f967..98a4c8b 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java @@ -29,8 +29,8 @@ public class SupplierOfferController { List totals = new ArrayList<>(); for (ArticleOffer article : offersRepository.findAll()) { - UImodelOfferedArticle tmp = new UImodelOfferedArticle(); - tmp.addData(article, articleRepository.findArticleIDByRelatedID(article.id)); + UImodelOfferedArticle tmp = new UImodelOfferedArticle(article, + articleRepository.findArticleIDByRelatedID(article.id)); totals.add(tmp); } @@ -50,13 +50,17 @@ public class SupplierOfferController { public int listedArticleId; public boolean offerIsListed; // true --> offered article is listed - public void addData(ArticleOffer article, Optional listedArticleId) { + public UImodelOfferedArticle(ArticleOffer article, Optional listedArticleId) { this.offerId = article.id; this.title = article.title; this.manufacturer = article.manufacturer; this.articleNumber = article.articleNumber; - this.supplierName = article.cheapestSupplier.name; + if (article.cheapestSupplier != null) { + this.supplierName = article.cheapestSupplier.name; + } else { + this.supplierName = "-"; + } this.price = String.format("%.2f", ((float) article.pricePerUnitNet / 100)); this.ads = (article.shouldBeAdvertised) ? "Ja" : "Nein"; diff --git a/prototype/src/main/resources/templates/intern/offeredArticles/index.html b/prototype/src/main/resources/templates/intern/offeredArticles/index.html index df2814f..027627c 100644 --- a/prototype/src/main/resources/templates/intern/offeredArticles/index.html +++ b/prototype/src/main/resources/templates/intern/offeredArticles/index.html @@ -44,7 +44,8 @@ - + - + -- 2.44.0