~ order overview done
~ template changes for users not logged in.
This commit is contained in:
parent
1965331149
commit
cc06ec797e
|
@ -6,7 +6,6 @@ import lombok.NonNull;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
@ -34,12 +33,14 @@ public class Order {
|
|||
@NonNull private Payment payment;
|
||||
@NonNull private Address address;
|
||||
|
||||
public String getItemNames() {
|
||||
List<String> titles = new ArrayList<>();
|
||||
for(OrderItem item : items) {
|
||||
titles.add(item.getBook().getTitle());
|
||||
public String getFormattedPrice() {
|
||||
String res = "";
|
||||
res += price / 100;
|
||||
res += ",";
|
||||
if (price % 100 < 10) {
|
||||
res += "0";
|
||||
}
|
||||
|
||||
return String.join(", ", titles);
|
||||
res += price % 100;
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ public class CartBean {
|
|||
}
|
||||
|
||||
public String add(Book book) {
|
||||
if (getUser() != null) {
|
||||
if (getUser() != null && getUser().getId() != 0) {
|
||||
for (ShoppingCartItem item : getItems()) {
|
||||
if (item.getArticle().getId() == book.getId()) {
|
||||
Database.getInstance().shoppingCart().delete(item);
|
||||
|
@ -66,11 +66,6 @@ public class CartBean {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public void setItems(List<ShoppingCartItem> list) {
|
||||
|
||||
}*/
|
||||
|
||||
public String buy() {
|
||||
ArrayList<OrderItem> orderList = new ArrayList<>();
|
||||
for (ShoppingCartItem item : getItems()) {
|
||||
|
@ -80,7 +75,7 @@ public class CartBean {
|
|||
for (ShoppingCartItem item : getItems()) {
|
||||
Database.getInstance().shoppingCart().delete(item);
|
||||
}
|
||||
return "index.jsf";
|
||||
return "thanks.jsf";
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
|
|
|
@ -10,17 +10,43 @@
|
|||
|
||||
<ui:define name="content">
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<ui:repeat value="#{orderBean.orders}" var="order">
|
||||
<div class="m-row">
|
||||
<div class="m-col-t-12">
|
||||
<div class="m-block m-primary">
|
||||
#{order.itemNames}
|
||||
<div class="m-row">
|
||||
<div class="m-col-t-4">
|
||||
<h:outputText value="#{order.date}">
|
||||
<f:convertDateTime pattern="dd.MM.yyyy"/>
|
||||
</h:outputText>
|
||||
<ui:repeat value="#{order.items}" var="item">
|
||||
<br/>
|
||||
</ui:repeat>
|
||||
</div>
|
||||
<div class="m-col-t-4">
|
||||
<ul>
|
||||
<ui:repeat value="#{order.items}" var="item">
|
||||
<li>
|
||||
#{item.book.title} - #{item.book.authorsString}
|
||||
</li>
|
||||
</ui:repeat>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="m-col-t-4">
|
||||
<p class="m-text-right">
|
||||
#{order.payment.type.name}
|
||||
</p>
|
||||
<p class="m-text-right">
|
||||
#{order.formattedPrice} €
|
||||
</p>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ui:repeat>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
<div class="m-row">
|
||||
<ol class="m-col-t-6 m-col-m-none">
|
||||
<li><a href="category.xhtml">Katalog</a></li>
|
||||
<h:panelGroup layout="block" rendered="#{userBean.loggedIn}">
|
||||
<li><a href="cart.jsf">(#{cartBean.itemCount}) Warenkorb</a></li>
|
||||
</h:panelGroup>
|
||||
</ol>
|
||||
<h:panelGroup layout="block" rendered="#{userBean.loggedIn}">
|
||||
<ol class="m-col-t-6 m-col-m-none" start="4">
|
||||
|
@ -48,7 +50,9 @@
|
|||
<li><a href="orders.jsf">Meine Bestellungen</a></li>
|
||||
<li><a href="address.jsf">Adressen</a></li>
|
||||
<li><a href="payments.jsf">Zahlungsmöglichkeiten</a></li>
|
||||
<li><a href="logout.jsf">Abmelden</a></li>
|
||||
<h:form>
|
||||
<li><h:commandLink action="#{userBean.logout}">Abmelden</h:commandLink></li>
|
||||
</h:form>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
|
Loading…
Reference in New Issue