Show a hyphen in supplier column if an article is not offered by anyone

Closes #54
This commit is contained in:
Lukas Fürderer 2020-06-08 18:56:35 +02:00
parent 6317780dfa
commit 03d557d67b
Signed by: Lukas
GPG Key ID: B0AFA46F94103349
2 changed files with 10 additions and 5 deletions

View File

@ -29,8 +29,8 @@ public class SupplierOfferController {
List<UImodelOfferedArticle> 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<Integer> listedArticleId) {
public UImodelOfferedArticle(ArticleOffer article, Optional<Integer> 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";

View File

@ -44,7 +44,8 @@
<td><span th:text="${article.title}"></span></td>
<td><span th:text="${article.manufacturer}"></span></td>
<td><span th:text="${article.articleNumber}"></span></td>
<td><a th:href="${'/intern/suppliers/#q=' + article.supplierName}" th:text="${article.supplierName}"></a></td>
<td th:if="${article.supplierName} == '-'">-</td>
<td th:unless="${article.supplierName} == '-'"><a th:href="${'/intern/suppliers/#q=' + article.supplierName}" th:text="${article.supplierName}"></a></td>
<td><span th:text="${article.price}"></span></td>
<td><span th:text="${article.ads}"></span></td>
<td>