Commit bbdc6a79 by Petri Jarvisalo

aloitettu uutta kauppaui:ta

1 parent f0a14147
......@@ -185,7 +185,7 @@ public class MenuNavigation extends GenericEntity implements Comparable<MenuNavi
// used only for initialization function...
public MenuNavigation addPage(Menuitem item, IAppPermission permission) {
int childSort = 100;
if (children == null) {
if (children == null || children.size() == 0) {
children = new ArrayList<MenuNavigation>();
} else {
childSort = children.get(children.size() - 1).getSort() + 10;
......
/* General css, use for non-layout purposes for general elements */
/* userlistview popup */
.userdata_popup {
position: absolute;
border: 1px solid black;
background: white;
border-radius: 3px;
display: none;
width: 300px;
height: 150px;
position: absolute;
border: 1px solid black;
background: white;
border-radius: 3px;
display: none;
width: 300px;
height: 150px;
}
/* general class for hoverable usage */
.hoverable {
}
.hidden {
display: none;
}
#webcamcontainer {
}
#shopItems {}
#shopItems {
}
.ui-panel-title {
text-overflow: clip;
text-overflow: clip;
}
.shopItem {
position: relative;
float: left;
width: 72px;
height: 72px;
float:left;
background: burlywood;
border: 1px solid black;
margin: 2px;
}
.shopItem:hover {
background: #ddd;
a.shopItem {
color: black !important;
}
a.shopItem div {
position: absolute;
height: 72px;
width: 72px;
text-align: center;
/* Firefox */
display: -moz-box;
-moz-box-orient: horizontal;
-moz-box-pack: center;
-moz-box-align: center;
/* Safari and Chrome */
display: -webkit-box;
-webkit-box-orient: horizontal;
-webkit-box-pack: center;
-webkit-box-align: center;
/* W3C */
display: box;
box-orient: horizontal;
box-pack: center;
box-align: center;
clip: rect(0, 72px, 72px, 0);
}
}
a.shopItem:hover {
background: darkgoldenrod;
}
a.shopItem:active {
background: red;
}
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:p="http://primefaces.org/ui" xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products"
xmlns:p="http://primefaces.org/ui"
xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:composition
template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{userView.initView}" />
<f:event type="preRenderView" listener="#{productShopView.initShopView}" />
<f:event type="preRenderView"
listener="#{productShopView.initShopView}" />
</f:metadata>
<ui:define name="title">
......@@ -24,13 +31,13 @@
<h:panelGroup>
<div id="shopItems">
<ui:repeat value="#{productShopView.shoppingcart}" var="cart">
<h:commandLink action="#{productShopView.addOne}">
<f:ajax render="@form" />
<p:panel header="#{cart.product.name}" styleClass="shopItem">
<p:panelGrid>
#{cart.product.price()}
</p:panelGrid>
</p:panel>
<h:commandLink styleClass="shopItem"
action="#{productShopView.addOne}">
<f:ajax render="@form" />
<div>
#{cart.product.name}<br /> #{cart.product.price}
</div>
</h:commandLink>
</ui:repeat>
</div>
......@@ -38,9 +45,50 @@
</h:panelGroup>
<h:panelGroup>
<p:dataTable id="prods" value="#{productShopView.boughtItems}"
var="prods">
<p:column>
<f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true">
</h:link>
</f:facet>
<h:outputText value="#{prods.count}" />
</p:column>
<p:column>
<f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true">
</h:link>
</f:facet>
<h:outputText value="#{prods.getProduct().name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true">
</h:link>
</f:facet>
<h:outputText value="#{prods.getProduct().price}" />
</p:column>
<p:column>
<f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true">
</h:link>
</f:facet>
<h:commandButton action="#{productShopView.removeBought()}" value="Poista"/>
</p:column>
</p:dataTable>
<h:outputLabel value="#{i18n['shop.readBarcode']}" />
<h:inputText id="barcode" value="#{productShopView.barcode}" />
<h:commandButton action="#{productShopView.readBarcode}" onclick="blip(); return true;" value="#{i18n['productShopView.readBarcode']}">
<h:commandButton action="#{productShopView.readBarcode}"
onclick="blip(); return true;"
value="#{i18n['productShopView.readBarcode']}">
<f:ajax render="@form" onevent="barcodeReadEvent" execute="@form" />
</h:commandButton>
......@@ -65,8 +113,8 @@
</h:panelGrid>
<h:outputText value="#{i18n['product.shopInstant']}" />
<h:selectBooleanCheckbox value="#{productShopView.payInstant}">
<f:ajax render="@form" execute="@form" />
......@@ -74,7 +122,8 @@
<h:outputScript library="primefaces" name="jquery/jquery.js" />
<div style="margin-top: 5px;">
<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-top" value="#{cc.attrs.commitValue}" />
<h:commandButton action="#{cc.attrs.commitaction}"
id="commitbutton-top" value="#{cc.attrs.commitValue}" />
</div>
......@@ -86,7 +135,8 @@
</h:outputText>
</div>
<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-botton" value="#{cc.attrs.commitValue}" />
<h:commandButton action="#{cc.attrs.commitaction}"
id="commitbutton-botton" value="#{cc.attrs.commitValue}" />
</h:form>
......
......@@ -64,14 +64,17 @@ public class SessionHandler {
public String getLayout() {
// TODO: layout selection code missing!!
// return "stream1";
template = "template1";
return template;
/*
if (template == null) {
template = eventbean.getPropertyString(LanEventPropertyKey.EVENT_LAYOUT);
}
if (template == null) {
template = "template1";
}
return template;
return template; */
}
// public boolean hasPermission(String target, String permission) {
......
package fi.insomnia.bortal.web.cdiview.shop;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
......@@ -61,6 +63,7 @@ public class ProductShopView extends GenericCDIView {
private BillEditView billEditView;
private boolean hasLimits = false;
private boolean blip = false;
private ListDataModel<ProductShopItem> boughtItems;
public void initBillView() {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)
......@@ -91,34 +94,41 @@ public class ProductShopView extends GenericCDIView {
public String add(Integer count) {
ProductShopItem item = shoppingcart.getRowData();
item.setCount(item.getCount().add(BigDecimal.valueOf(count)));
updateCartLimits(item);
return null;
}
public String addOne()
{
public String addOne() {
return add(1);
}
public String addMinusOne()
{
public String addMinusOne() {
return add(-1);
}
public String addTen()
{
public String addTen() {
return add(10);
}
public String addMinusTen()
{
public String addMinusTen() {
return add(-10);
}
public void updateCartLimits(ProductShopItem item) {
if (boughtItems == null) {
boughtItems = new ListDataModel<ProductShopItem>(
new ArrayList<ProductShopItem>());
}
List<ProductShopItem> listdata = (List<ProductShopItem>) boughtItems
.getWrappedData();
if (item != null && !listdata.contains(item)) {
listdata.add(item);
}
Map<Integer, BigDecimal> prodCounts = new HashMap<Integer, BigDecimal>();
for (ProductShopItem sc : shoppingcart) {
prodCounts.put(sc.getProduct().getId(), sc.getCount());
......@@ -128,11 +138,9 @@ public class ProductShopView extends GenericCDIView {
prodCounts, user);
// Update the updated cart first
if (item != null)
{
if (item != null) {
BigDecimal l = limits.get(item.getProduct().getId());
if (item.updateLimit(l))
{
if (item.updateLimit(l)) {
updateCartLimits(null);
return;
}
......@@ -145,9 +153,29 @@ public class ProductShopView extends GenericCDIView {
}
n.updateLimit(l);
}
}
public String removeBought() {
ProductShopItem row = boughtItems.getRowData();
row.setCount(row.getCount().subtract(BigDecimal.ONE));
updateCartLimits(row);
return null;
}
// public ListDataModel<ProductShopItem> getProducts() {
// List<ProductShopItem> prods = new ArrayList<ProductShopItem>();
// for (ProductShopItem sc : shoppingcart) {
// if (sc.getCount() != null && sc.getCount().compareTo(BigDecimal.ONE) !=
// -1) {
// prods.add(sc);
// }
// }
// return prods;
//
// }
public void updateAllCartLimits() {
updateCartLimits(null);
}
......@@ -201,13 +229,15 @@ public class ProductShopView extends GenericCDIView {
EventUser retuser = null;
for (ProductShopItem shopitem : shoppingcart) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
retuser = productBean.createAccountEvent(shopitem.getProduct(), shopitem.getCount(), user).getUser();
retuser = productBean.createAccountEvent(shopitem.getProduct(),
shopitem.getCount(), user).getUser();
}
}
if (cash != null && cash.compareTo(BigDecimal.ZERO) != 0) {
Product credProd = productBean.findCreditProduct();
retuser = productBean.createAccountEvent(credProd, cash, user).getUser();
retuser = productBean.createAccountEvent(credProd, cash, user)
.getUser();
}
if (user != null) {
user = retuser;
......@@ -316,4 +346,12 @@ public class ProductShopView extends GenericCDIView {
this.blip = blip;
}
public ListDataModel<ProductShopItem> getBoughtItems() {
return boughtItems;
}
public void setBoughtItems(ListDataModel<ProductShopItem> boughtItems) {
this.boughtItems = boughtItems;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!