Commit 03adad00 by Juho Juopperi

Merge branch 'master' of codecrew.fi:bortal into official

2 parents 864d0e0e 94d334a7
Showing with 162 additions and 30 deletions
...@@ -9,6 +9,7 @@ import java.util.Map.Entry; ...@@ -9,6 +9,7 @@ import java.util.Map.Entry;
import javax.annotation.security.DeclareRoles; import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.EJBException;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -128,4 +129,15 @@ public class AccountEventBean implements AccountEventBeanLocal { ...@@ -128,4 +129,15 @@ public class AccountEventBean implements AccountEventBeanLocal {
} }
@Override
public AccountEvent markDelivered(AccountEvent e, Calendar c) {
accountfacade.reload(e);
if (e.getDelivered() != null)
{
throw new EJBException("AccountEvent " + e + " already marked paid!");
}
e.setDelivered(c);
return e;
}
} }
...@@ -46,6 +46,7 @@ import fi.insomnia.bortal.model.User; ...@@ -46,6 +46,7 @@ import fi.insomnia.bortal.model.User;
UserPermission.S_INVITE_USERS, UserPermission.S_INVITE_USERS,
UserPermission.S_READ_ORGROLES, UserPermission.S_READ_ORGROLES,
UserPermission.S_WRITE_ORGROLES, UserPermission.S_WRITE_ORGROLES,
UserPermission.S_VITUTTAAKO,
MapPermission.S_VIEW, MapPermission.S_VIEW,
MapPermission.S_MANAGE_MAPS, MapPermission.S_MANAGE_MAPS,
......
...@@ -520,4 +520,10 @@ public class UserBean implements UserBeanLocal { ...@@ -520,4 +520,10 @@ public class UserBean implements UserBeanLocal {
return eventUserFacade.searchEventUsers(searchQuery); return eventUserFacade.searchEventUsers(searchQuery);
} }
@Override
public void submitFeedback(String feedback) {
logger.warn("Received feedback {}", feedback);
// TODO
}
} }
\ No newline at end of file
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -25,4 +26,6 @@ public interface AccountEventBeanLocal { ...@@ -25,4 +26,6 @@ public interface AccountEventBeanLocal {
List<Role> getRolesFromAccountEvents(EventUser u); List<Role> getRolesFromAccountEvents(EventUser u);
AccountEvent markDelivered(AccountEvent e, Calendar c);
} }
...@@ -81,4 +81,6 @@ public interface UserBeanLocal { ...@@ -81,4 +81,6 @@ public interface UserBeanLocal {
SearchResult<EventUser> getThisEventsUsers(UserSearchQuery searchQuery); SearchResult<EventUser> getThisEventsUsers(UserSearchQuery searchQuery);
void submitFeedback(String feedback);
} }
...@@ -126,6 +126,14 @@ public class FoodWave extends GenericEntity { ...@@ -126,6 +126,14 @@ public class FoodWave extends GenericEntity {
} }
public boolean isFull() { public boolean isFull() {
if(getMaximumFoods() <= 0) {
return false;
}
if(getReservedCount() >= getMaximumFoods()) {
return true;
}
return false; return false;
} }
...@@ -174,6 +182,12 @@ public class FoodWave extends GenericEntity { ...@@ -174,6 +182,12 @@ public class FoodWave extends GenericEntity {
} }
public Integer getMaximumFoods() { public Integer getMaximumFoods() {
if(maximumFoods == null) {
return 0;
}
return maximumFoods; return maximumFoods;
} }
......
...@@ -17,7 +17,7 @@ public enum UserPermission implements IAppPermission { ...@@ -17,7 +17,7 @@ public enum UserPermission implements IAppPermission {
MANAGE_HTTP_SESSION, // ("Manage http sessions"), MANAGE_HTTP_SESSION, // ("Manage http sessions"),
INVITE_USERS, // ("Invite users"), INVITE_USERS, // ("Invite users"),
READ_ORGROLES, // ("View organization roles"), READ_ORGROLES, // ("View organization roles"),
WRITE_ORGROLES, // ("Modify organization roles"), WRITE_ORGROLES, VITUTTAAKO, // ("Modify organization roles"),
; ;
public static final String S_VIEW_ALL = "USER/VIEW_ALL"; public static final String S_VIEW_ALL = "USER/VIEW_ALL";
...@@ -35,6 +35,7 @@ public enum UserPermission implements IAppPermission { ...@@ -35,6 +35,7 @@ public enum UserPermission implements IAppPermission {
public static final String S_INVITE_USERS = "USER/INVITE_USERS"; public static final String S_INVITE_USERS = "USER/INVITE_USERS";
public static final String S_READ_ORGROLES = "USER/READ_ORGROLES"; public static final String S_READ_ORGROLES = "USER/READ_ORGROLES";
public static final String S_WRITE_ORGROLES = "USER/WRITE_ORGROLES"; public static final String S_WRITE_ORGROLES = "USER/WRITE_ORGROLES";
public static final String S_VITUTTAAKO = "USER/VITUTTAAKO";
private final String fullName; private final String fullName;
private final String key; private final String key;
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
</session-config> </session-config>
<context-param> <context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name> <param-name>javax.faces.PROJECT_STAGE</param-name>
<!-- <param-value>Production</param-value> --> <param-value>Production</param-value>
<param-value>Development</param-value> <!-- <param-value>Development</param-value>-->
</context-param> </context-param>
<context-param> <context-param>
......
<!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:users="http://java.sun.com/jsf/composite/tools/user" xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.eventorg.create" />
<f:metadata>
<f:event type="preRenderView" listener="#{feedbackView.initFeedback}" />
</f:metadata>
<ui:define name="content">
<h1>Avaudu tähän:</h1>
<h:form id="feedback">
<h:inputTextarea value="#{feedbackView.feedback}" cols="50" rows="10"/><br/>
<p:commandButton ajax="false" value="#{i18n['feedback.submit']}" action="#{feedbackView.submitFeedback}" />
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
<ui:define name="content"> <ui:define name="content">
<h:form> <h:form>
<p:dataTable styleClass="bordertable" value="#{foodWaveView.foodWaves}" sortBy="#{foodwave.time}" sortOrder="ascending" var="foodwave" editable="true" rowStyleClass="#{not foodwave.isOrderable() ? foodwave.isDelivered() ? 'hidden' : 'closed' : null}"> <p:dataTable styleClass="bordertable" value="#{foodWaveView.foodWaves}" sortBy="#{foodwave.time}" sortOrder="ascending" var="foodwave" editable="true" rowStyleClass="#{not foodwave.isOrderable() ? foodwave.isDelivered() ? 'hidden' : 'closed' : null}">
<!-- rowStyleClass="#{foodWave.closed ? 'old' : null} -->
<p:ajax event="rowEdit" listener="#{foodWaveView.onEditFoodWave}" /> <p:ajax event="rowEdit" listener="#{foodWaveView.onEditFoodWave}" />
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['foodWave.activeFoodWaves']}" /> <h:outputLabel value="#{i18n['foodWave.activeFoodWaves']}" />
......
...@@ -45,12 +45,17 @@ ...@@ -45,12 +45,17 @@
<h:outputText rendered="#{sessionHandler.loggedIn}" value="#{i18n['template.loggedInAs']} #{sessionHandler.currentUser.nick}" /> <h:outputText rendered="#{sessionHandler.loggedIn}" value="#{i18n['template.loggedInAs']} #{sessionHandler.currentUser.nick}" />
<div> <div>
<tools:loginLogout /> <tools:loginLogout />
</div> </div>
</div> </div>
<ui:fragment rendered="#{menuView.getMenu(0).size() > 1}"> <ui:fragment rendered="#{menuView.getMenu(0).size() > 1}">
<ul id="topmenu"> <ul id="topmenu">
<li jsfc="ui:repeat" var="menuitem" value="#{menuView.getMenu(0)}"><h:link outcome="#{menuitem.outcome}" value="#{i18n[menuitem.navigation.key]}" <li jsfc="ui:repeat" var="menuitem" value="#{menuView.getMenu(0)}"><h:link outcome="#{menuitem.outcome}" value="#{i18n[menuitem.navigation.key]}"
styleClass="#{menuitem.selected?'active':''}" /></li> styleClass="#{menuitem.selected?'active':''}" /></li>
<ui:fragment rendered="#{feedbackView.canFeedback}" >
<li><h:link outcome="/feedback/index" value="#{i18n['feedback.canFeedback']}" /></li>
</ui:fragment>
<li></li>
</ul> </ul>
</ui:fragment> </ui:fragment>
</div> </div>
......
...@@ -15,18 +15,20 @@ ...@@ -15,18 +15,20 @@
<!-- <h:outputScript target="head" library="script" name="shopscript.js" /> --> <!-- <h:outputScript target="head" library="script" name="shopscript.js" /> -->
<h:outputScript library="primefaces" name="jquery/jquery.js" /> <h:outputScript library="primefaces" name="jquery/jquery.js" />
<p:dataTable columnClasses="nowrap,numalign,numalign,nowrap,numalign" styleClass="bordertable" value="#{foodWaveView.foodWaves}" var="foodwave"> <p:dataTable columnClasses="nowrap,numalign,numalign,nowrap,numalign" styleClass="bordertable" value="#{foodWaveView.foodWaves}" var="foodwave" sortBy="#{foodwave.time.time}" rowStyleClass="#{foodwave.isFull() ? 'closed' : null}">
<p:column> <p:column sortBy="#{i18n['foodWave.name']}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel id="name" value="${i18n['foodWave.name']}" /> <h:outputLabel id="name" value="#{i18n['foodWave.name']}" />
</f:facet> </f:facet>
<h:link outcome="#{cc.attrs.outcome}" value="#{foodwave.name}"> <h:link rendered="#{not foodwave.isFull()}" outcome="#{cc.attrs.outcome}" value="#{foodwave.name}">
<f:param name="foodwaveid" value="#{foodwave.id}" /> <f:param name="foodwaveid" value="#{foodwave.id}" />
<f:param name="userid" value="#{userView.user.user.id}" /> <f:param name="userid" value="#{userView.user.user.id}" />
</h:link> </h:link>
<h:outputText rendered="#{foodwave.isFull()}" value="#{foodwave.name}" />
</p:column> </p:column>
<p:column> <p:column sortBy="#{foodwave.template.name}">
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Menu" /> <h:outputText value="Menu" />
</f:facet> </f:facet>
...@@ -34,13 +36,22 @@ ...@@ -34,13 +36,22 @@
<f:param name="foodwaveid" value="#{foodwave.id}" /> <f:param name="foodwaveid" value="#{foodwave.id}" />
</h:outputText> </h:outputText>
</p:column> </p:column>
<p:column> <p:column sortBy="#{foodwave.template.description}">
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['foodWave.description']}" /> <h:outputText value="${i18n['foodWave.description']}" />
</f:facet> </f:facet>
<h:outputText id="description" value="#{foodwave.template.description}" /> <h:outputText id="description" value="#{foodwave.template.description}" />
</p:column> </p:column>
<p:column>
<p:column sortBy="#{foodwave.reservedCount}">
<f:facet name="header">
<h:outputText value="${i18n['foodWave.totalReserved']}" />
</f:facet>
<h:outputText value="#{foodwave.reservedCount}" /> / <h:outputText value="#{foodwave.maximumFoods}" />
</p:column>
<p:column sortBy="#{foodwave.time.time}">
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['foodWave.time']}" /> <h:outputText value="${i18n['foodWave.time']}" />
</f:facet> </f:facet>
......
...@@ -38,7 +38,7 @@ td span span div.rating-cancel { ...@@ -38,7 +38,7 @@ td span span div.rating-cancel {
} }
#login { #login {
width: 400px; width: 385px;
height: 23px; height: 23px;
float: right; float: right;
margin-top: 10px; margin-top: 10px;
......
...@@ -194,10 +194,16 @@ eventorgView.eventname = Name of event ...@@ -194,10 +194,16 @@ eventorgView.eventname = Name of event
eventorganiser.name = Eventorganiser eventorganiser.name = Eventorganiser
feedback.canFeedback = Feedback
feedback.submit = Submit
feedback.thanks = Thanks
food = Food food = Food
foodWave.accountevents = Accountevents foodWave.accountevents = Accountevents
foodWave.activeFoodWaves = Active Foodwaves
foodWave.billLines = Pending Online Payments foodWave.billLines = Pending Online Payments
foodWave.deliveredFoodWaves = Delivered Foodwaves
foodWave.description = Description foodWave.description = Description
foodWave.list = Active Foodwaves foodWave.list = Active Foodwaves
foodWave.name = Foodwave foodWave.name = Foodwave
......
...@@ -192,12 +192,18 @@ eventorgView.eventname = Tapahtuman nimi ...@@ -192,12 +192,18 @@ eventorgView.eventname = Tapahtuman nimi
eventorganiser.name = Tapahtumaj\u00E4rjest\u00E4j\u00E4 eventorganiser.name = Tapahtumaj\u00E4rjest\u00E4j\u00E4
feedback.canFeedback = Vituttaako?
feedback.submit = L\u00E4het\u00E4
feedback.thanks = Kiiiiitooooos! :)
food = Ruoka food = Ruoka
foodWave.accountevents = Maksetut tilaukset foodWave.accountevents = Maksetut tilaukset
foodWave.activeFoodWaves = Aktiiviset Ruokatilaukset
foodWave.billLines = Maksamattomat Verkkomaksut foodWave.billLines = Maksamattomat Verkkomaksut
foodWave.deliveredFoodWaves = Toimitetut Ruokatilaukset
foodWave.description = Kuvaus foodWave.description = Kuvaus
foodWave.list = Aktiviset ruokatilaukset foodWave.list = Ruokatilaukset
foodWave.name = Ruokatilaus foodWave.name = Ruokatilaus
foodWave.orders = Tilausten M\u00E4\u00E4r\u00E4 foodWave.orders = Tilausten M\u00E4\u00E4r\u00E4
foodWave.paid = Maksettuja foodWave.paid = Maksettuja
......
...@@ -67,7 +67,7 @@ public class FoodWaveView extends GenericCDIView { ...@@ -67,7 +67,7 @@ public class FoodWaveView extends GenericCDIView {
private Integer foodWaveId; private Integer foodWaveId;
private ListDataModel<AccountEvent> accountEventLines; private ListDataModel<AccountEvent> accountEventLines;
private ListDataModel<FoodWave> foodWaves; private List<FoodWave> foodWaves;
private static final Logger logger = LoggerFactory.getLogger(FoodWaveView.class); private static final Logger logger = LoggerFactory.getLogger(FoodWaveView.class);
public List<Product> getProducts() { public List<Product> getProducts() {
...@@ -80,11 +80,6 @@ public class FoodWaveView extends GenericCDIView { ...@@ -80,11 +80,6 @@ public class FoodWaveView extends GenericCDIView {
this.foodWaveBean.saveTemplate(template); this.foodWaveBean.saveTemplate(template);
} }
public void onEditFoodWave() {
FoodWave fw = foodWaves.getRowData();
this.foodWaveBean.merge(fw);
}
public void initTemplateList() { public void initTemplateList() {
super.requirePermissions(ShopPermission.SHOP_FOODWAVE); super.requirePermissions(ShopPermission.SHOP_FOODWAVE);
} }
...@@ -92,11 +87,7 @@ public class FoodWaveView extends GenericCDIView { ...@@ -92,11 +87,7 @@ public class FoodWaveView extends GenericCDIView {
public void initFoodwaveManagerList() { public void initFoodwaveManagerList() {
if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES)) if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES))
{ {
if(foodWaves == null) { foodWaves = foodWaveBean.getEventFoodWaves();
super.beginConversation();
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
}
} }
} }
...@@ -119,9 +110,9 @@ public class FoodWaveView extends GenericCDIView { ...@@ -119,9 +110,9 @@ public class FoodWaveView extends GenericCDIView {
if (templateId != null) if (templateId != null)
{ {
template = foodWaveBean.findTemplate(templateId); template = foodWaveBean.findTemplate(templateId);
foodWaves = new ListDataModel<FoodWave>(template.getFoodwaves()); foodWaves = template.getFoodwaves();
} else { } else {
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getOpenFoodWaves()); foodWaves = foodWaveBean.getOpenFoodWaves();
} }
super.beginConversation(); super.beginConversation();
} }
...@@ -244,8 +235,7 @@ public class FoodWaveView extends GenericCDIView { ...@@ -244,8 +235,7 @@ public class FoodWaveView extends GenericCDIView {
public String deliverAccountEvent() { public String deliverAccountEvent() {
if (getAccountEventLines().isRowAvailable()) { if (getAccountEventLines().isRowAvailable()) {
AccountEvent e = getAccountEventLines().getRowData(); AccountEvent e = getAccountEventLines().getRowData();
e.setDelivered(Calendar.getInstance()); e = accountEventBean.markDelivered(e, Calendar.getInstance());
e = accountEventBean.merge(e);
foodWaveId = selectedFoodWave.getId(); foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null; selectedFoodWave = null;
...@@ -344,11 +334,11 @@ public class FoodWaveView extends GenericCDIView { ...@@ -344,11 +334,11 @@ public class FoodWaveView extends GenericCDIView {
this.billLines = billLines; this.billLines = billLines;
} }
public void setFoodWaves(ListDataModel<FoodWave> foodWaves) { public void setFoodWaves(List<FoodWave> foodWaves) {
this.foodWaves = foodWaves; this.foodWaves = foodWaves;
} }
public ListDataModel<FoodWave> getFoodWaves() { public List<FoodWave> getFoodWaves() {
return foodWaves; return foodWaves;
} }
......
package fi.insomnia.bortal.web.helper;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.PermissionBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class FeedbackView extends GenericCDIView {
private static final long serialVersionUID = -6231624059763086722L;
@EJB
private PermissionBeanLocal permissionBean;
private String feedback;
public void initFeedback() {
super.beginConversation();
}
@EJB
private UserBeanLocal userbean;
public boolean isCanFeedback()
{
return permissionBean.hasPermission(UserPermission.VITUTTAAKO);
}
public String submitFeedback()
{
userbean.submitFeedback(getFeedback());
feedback = "";
super.addFaceMessage("feedback.thanks");
return null;
}
public String getFeedback() {
return feedback;
}
public void setFeedback(String feedback) {
this.feedback = feedback;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!