Commit 979346f1 by Tuomas Riihimäki

Lock and release placeslots

1 parent 54d109ae
......@@ -126,4 +126,8 @@ public interface PlaceBeanLocal {
List<PlaceSlot> getPlaceslots(EventUser user);
boolean lockSlot(PlaceSlot row);
boolean releaseSlot(PlaceSlot row);
}
......@@ -801,4 +801,26 @@ public class PlaceBean implements PlaceBeanLocal {
return placeSlotFacade.finForUser(user);
}
@Override
public boolean lockSlot(PlaceSlot row) {
row = placeSlotFacade.reload(row);
if (row.getPlace() == null && row.getUsed() == null) {
row.setUsed(new Date());
}else {
return false;
}
return true;
}
@Override
public boolean releaseSlot(PlaceSlot row) {
row = placeSlotFacade.reload(row);
if (row.getPlace() == null && row.getUsed() != null) {
row.setUsed(null);
}else {
return false;
}
return true;
}
}
......@@ -89,6 +89,10 @@
<f:param name="billid" value="#{slot.bill.id}" />
</h:link>
</p:column>
<p:column >
<h:commandButton rendered="#{empty slot.place and empty slot.used}" value="#{i18n['placeslot.lockSlot']}" ajax="false" action="#{placeGroupView.lockSlot}" />
<h:commandButton rendered="#{empty slot.place and not empty slot.used}" value="#{i18n['placeslot.releaseSlot']}" ajax="false" action="#{placeGroupView.releaseSlot}" />
</p:column>
</p:dataTable>
</h:form>
......
......@@ -78,7 +78,7 @@ public class PlacegroupView extends GenericCDIView {
private Map<Integer, String> inviteMails = new HashMap<>();
@EJB
private PlaceBeanLocal placeslotBean;
private ListDataModel<PlaceSlot> placeslots;
public String editGroup() {
......@@ -211,6 +211,20 @@ public class PlacegroupView extends GenericCDIView {
return null;
}
public String lockSlot() {
PlaceSlot row = placeslots.getRowData();
placeslotBean.lockSlot(row);
placeslots = null;
return null;
}
public String releaseSlot() {
PlaceSlot row = placeslots.getRowData();
placeslotBean.releaseSlot(row);
placeslots = null;
return null;
}
public ListDataModel<PlaceGroup> getPlacegroups() {
if (placegroups == null) {
List<PlaceGroup> retlist = new ArrayList<PlaceGroup>();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!