Commit 5b2d2f0c by Tuukka Kivilahti

user side also, not tested yet

1 parent ee9d6ad5
......@@ -61,7 +61,7 @@ public class AccountEvent extends GenericEntity {
private Calendar delivered;
@Column(name = "delivered_count", nullable = false, precision = 24, scale = 4)
private BigDecimal deliveredCount;
private BigDecimal deliveredCount = new BigDecimal(0);
/**
* If this AccountEvent is a product in foodwace, this field is a reference
......
......@@ -6,12 +6,13 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{gameCodeView.initView}" />
<f:event type="preRenderView" listener="#{gameCodeView.initAdminView}" />
</f:metadata>
<ui:param name="thispage" value="page.game.list" />
<ui:param name="thispage" value="page.gamecode.manageCodes" />
<ui:define name="content">
<h:form>
<h:dataTable border="1" id="games" value="#{gameCodeView.games}" var="game">
<h:column>
<f:facet name="header">
......@@ -34,6 +35,7 @@
</h:column>
</h:dataTable>
</h:form>
<h:form>
<h:outputLabel value="name" />
......
<!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:products="http://java.sun.com/jsf/composite/tools/products"
xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:f="http://java.sun.com/jsf/core">
<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:products="http://java.sun.com/jsf/composite/tools/products" xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.game.list" />
<ui:param name="thispage" value="page.gamecode.viewCodes" />
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{gameCodeView.initUserView}" />
</f:metadata>
<ui:define name="content">
No codes :(
<h:form>
<h:outputLabel rendered="#{gameCodeView.noGameCodes}" value="#{i18n['game.noGameCodes']}" />
<h:dataTable rendered="#{not gameCodeView.noGameCodes}" border="1" id="codes" value="#{gameCodeView.gameCodes}" var="code">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['game.name']}" />
</f:facet>
<h:outputText value="#{code.game.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['game.description']}" />
</f:facet>
<h:outputText value="#{code.game.description}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['gamecode.code']}" />
</f:facet>
<h:commandButton rendered="#{not code.accessed}" value="#{i18n['gamecode.open']}" action="#{gameCodeView.openSelectedCode}" />
<h:outputText rendered="#{code.accessed}" value="#{code.code}" />
</h:column>
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
......
......@@ -10,6 +10,7 @@ import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.GameBeanLocal;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Game;
import fi.codecrew.moya.model.GameCode;
import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
......@@ -33,10 +34,11 @@ public class GameCodeView extends GenericCDIView {
GameBeanLocal gameBean;
ListDataModel<Game> gamesDataModel;
ListDataModel<GameCode> gameCodesDataModel;
private Game currentGame;
public void initView() {
public void initAdminView() {
if(gamesDataModel == null) {
this.currentGame = new Game();
this.currentGame.setEvent(eventBean.getCurrentEvent());
......@@ -45,11 +47,22 @@ public class GameCodeView extends GenericCDIView {
}
}
public void initUserView() {
if(gamesDataModel == null) {
this.gameCodesDataModel = new ListDataModel<GameCode>(gameBean.findUserCodes(user));
this.beginConversation();
}
}
public ListDataModel<Game> getGames() {
return gamesDataModel;
}
public ListDataModel<GameCode> getGameCodes() {
return gameCodesDataModel;
}
public Game getCurrentGame() {
return this.currentGame;
......@@ -71,11 +84,27 @@ public class GameCodeView extends GenericCDIView {
}
public String editSelected() {
if(gamesDataModel != null && gamesDataModel.isRowAvailable()) {
currentGame = gamesDataModel.getRowData();
}
return null;
}
public String openSelectedCode() {
if(gameCodesDataModel != null && gameCodesDataModel.isRowAvailable()) {
GameCode code = gameCodesDataModel.getRowData();
gameBean.accessCode(code, user);
}
return null;
}
return "manageCodes";
public boolean isNoGameCodes() {
return (getGameCodes().getRowCount() <= 0);
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!